The bumpfee() RPC was returning misleading or incorrect error codes
(for example RPC_INVALID_ADDRESS_OR_KEY when the transaction was not
BIP125 replacable). This commit fixes those error codes:
- RPC_INVALID_ADDRESS_OR_KEY if an invalid address was provided:
- Invalid change address given
- RPC_INVALID_PARAMETER if a single (non-address/key) parameter is incorrect
- confTarget and totalFee options should not both be set.
- Invalid confTarget
- Insufficient totalFee (cannot be less than required fee)
- RPC_WALLET_ERROR for any other error
- Transaction has descendants in the wallet
- Transaction has descendants in the mempool
- Transaction has been mined, or is conflicted with a mined transaction
- Transaction is not BIP 125 replaceable
- Transaction has already been bumped
- Transaction contains inputs that don't belong to the wallet
- Transaction has multiple change outputs
- Transaction does not have a change output
- Fee is higher than maxTxFee
- New fee rate is less than the minimum fee rate
- Change output is too small.
This commit also updates the test cases to explicitly test the error code.
throwJSONRPCError(RPC_MISC_ERROR,"Transaction has descendants in the mempool");
throwJSONRPCError(RPC_INVALID_PARAMETER,"Transaction has descendants in the mempool");
}
}
}
}
if(wtx.GetDepthInMainChain()!=0){
if(wtx.GetDepthInMainChain()!=0){
throwJSONRPCError(RPC_INVALID_ADDRESS_OR_KEY,"Transaction has been mined, or is conflicted with a mined transaction");
throwJSONRPCError(RPC_WALLET_ERROR,"Transaction has been mined, or is conflicted with a mined transaction");
}
}
if(!SignalsOptInRBF(wtx)){
if(!SignalsOptInRBF(wtx)){
throwJSONRPCError(RPC_INVALID_ADDRESS_OR_KEY,"Transaction is not BIP 125 replaceable");
throwJSONRPCError(RPC_WALLET_ERROR,"Transaction is not BIP 125 replaceable");
}
}
if(wtx.mapValue.count("replaced_by_txid")){
if(wtx.mapValue.count("replaced_by_txid")){
throwJSONRPCError(RPC_INVALID_REQUEST,strprintf("Cannot bump transaction %s which was already bumped by transaction %s",hash.ToString(),wtx.mapValue.at("replaced_by_txid")));
throwJSONRPCError(RPC_WALLET_ERROR,strprintf("Cannot bump transaction %s which was already bumped by transaction %s",hash.ToString(),wtx.mapValue.at("replaced_by_txid")));
}
}
// check that original tx consists entirely of our inputs
// check that original tx consists entirely of our inputs
// if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee)
// if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee)
if(!pwallet->IsAllFromMe(wtx,ISMINE_SPENDABLE)){
if(!pwallet->IsAllFromMe(wtx,ISMINE_SPENDABLE)){
throwJSONRPCError(RPC_INVALID_ADDRESS_OR_KEY,"Transaction contains inputs that don't belong to this wallet");
throwJSONRPCError(RPC_WALLET_ERROR,"Transaction contains inputs that don't belong to this wallet");