You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 wallet");
2865
+
throwJSONRPCError(RPC_INVALID_PARAMETER, "Transaction has descendants in the wallet");
2866
2866
}
2867
2867
2868
2868
{
2869
2869
LOCK(mempool.cs);
2870
2870
auto it = mempool.mapTx.find(hash);
2871
2871
if (it != mempool.mapTx.end() && it->GetCountWithDescendants() > 1) {
2872
-
throwJSONRPCError(RPC_MISC_ERROR, "Transaction has descendants in the mempool");
2872
+
throwJSONRPCError(RPC_INVALID_PARAMETER, "Transaction has descendants in the mempool");
2873
2873
}
2874
2874
}
2875
2875
2876
2876
if (wtx.GetDepthInMainChain() != 0) {
2877
-
throwJSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction has been mined, or is conflicted with a mined transaction");
2877
+
throwJSONRPCError(RPC_WALLET_ERROR, "Transaction has been mined, or is conflicted with a mined transaction");
2878
2878
}
2879
2879
2880
2880
if (!SignalsOptInRBF(wtx)) {
2881
-
throwJSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction is not BIP 125 replaceable");
2881
+
throwJSONRPCError(RPC_WALLET_ERROR, "Transaction is not BIP 125 replaceable");
2882
2882
}
2883
2883
2884
2884
if (wtx.mapValue.count("replaced_by_txid")) {
2885
-
throwJSONRPCError(RPC_INVALID_REQUEST, strprintf("Cannot bump transaction %s which was already bumped by transaction %s", hash.ToString(), wtx.mapValue.at("replaced_by_txid")));
2885
+
throwJSONRPCError(RPC_WALLET_ERROR, strprintf("Cannot bump transaction %s which was already bumped by transaction %s", hash.ToString(), wtx.mapValue.at("replaced_by_txid")));
2886
2886
}
2887
2887
2888
2888
// check that original tx consists entirely of our inputs
2889
2889
// 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)
2890
2890
if (!pwallet->IsAllFromMe(wtx, ISMINE_SPENDABLE)) {
2891
-
throwJSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction contains inputs that don't belong to this wallet");
2891
+
throwJSONRPCError(RPC_WALLET_ERROR, "Transaction contains inputs that don't belong to this wallet");
if (nNewFeeRate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) {
3009
-
throwJSONRPCError(RPC_MISC_ERROR, strprintf("New fee rate (%s) is less than the minimum fee rate (%s) to get into the mempool. totalFee value should to be at least %s or settxfee value should be at least %s to add transaction.", FormatMoney(nNewFeeRate.GetFeePerK()), FormatMoney(minMempoolFeeRate.GetFeePerK()), FormatMoney(minMempoolFeeRate.GetFee(maxNewTxSize)), FormatMoney(minMempoolFeeRate.GetFeePerK())));
3009
+
throwJSONRPCError(RPC_WALLET_ERROR, strprintf("New fee rate (%s) is less than the minimum fee rate (%s) to get into the mempool. totalFee value should to be at least %s or settxfee value should be at least %s to add transaction.", FormatMoney(nNewFeeRate.GetFeePerK()), FormatMoney(minMempoolFeeRate.GetFeePerK()), FormatMoney(minMempoolFeeRate.GetFee(maxNewTxSize)), FormatMoney(minMempoolFeeRate.GetFeePerK())));
0 commit comments