@@ -2733,6 +2733,7 @@ UniValue bumpfee(const JSONRPCRequest& request)
2733
2733
" \" txid\" : \" value\" , (string) The id of the new transaction\n "
2734
2734
" \" origfee\" : n, (numeric) Fee of the replaced transaction\n "
2735
2735
" \" fee\" : n, (numeric) Fee of the new transaction\n "
2736
+ " \" errors\" : [ str... ] (json array of strings) Errors encountered during processing (may be empty)\n "
2736
2737
" }\n "
2737
2738
" \n Examples:\n "
2738
2739
" \n Bump the fee, get the new transaction\' s txid\n " +
@@ -2945,23 +2946,32 @@ UniValue bumpfee(const JSONRPCRequest& request)
2945
2946
CWalletTx wtxBumped (pwalletMain, MakeTransactionRef (std::move (tx)));
2946
2947
wtxBumped.mapValue [" replaces_txid" ] = hash.ToString ();
2947
2948
CValidationState state;
2948
- if (!pwalletMain->CommitTransaction (wtxBumped, reservekey, g_connman.get (), state) || !state.IsValid ()) {
2949
+ if (!pwalletMain->CommitTransaction (wtxBumped, reservekey, g_connman.get (), state)) {
2950
+ // NOTE: CommitTransaction never returns false, so this should never happen.
2949
2951
throw JSONRPCError (RPC_WALLET_ERROR, strprintf (" Error: The transaction was rejected! Reason given: %s" , state.GetRejectReason ()));
2950
2952
}
2951
2953
2954
+ UniValue vErrors (UniValue::VARR);
2955
+ if (state.IsInvalid ()) {
2956
+ // This can happen if the mempool rejected the transaction. Report
2957
+ // what happened in the "errors" response.
2958
+ vErrors.push_back (strprintf (" Error: The transaction was rejected: %s" , FormatStateMessage (state)));
2959
+ }
2960
+
2952
2961
// mark the original tx as bumped
2953
2962
if (!pwalletMain->MarkReplaced (wtx.GetHash (), wtxBumped.GetHash ())) {
2954
2963
// TODO: see if JSON-RPC has a standard way of returning a response
2955
2964
// along with an exception. It would be good to return information about
2956
2965
// wtxBumped to the caller even if marking the original transaction
2957
2966
// replaced does not succeed for some reason.
2958
- throw JSONRPCError (RPC_WALLET_ERROR, " Error: Created new bumpfee transaction but could not mark the original transaction as replaced." );
2967
+ vErrors. push_back ( " Error: Created new bumpfee transaction but could not mark the original transaction as replaced." );
2959
2968
}
2960
2969
2961
2970
UniValue result (UniValue::VOBJ);
2962
2971
result.push_back (Pair (" txid" , wtxBumped.GetHash ().GetHex ()));
2963
2972
result.push_back (Pair (" origfee" , ValueFromAmount (nOldFee)));
2964
2973
result.push_back (Pair (" fee" , ValueFromAmount (nNewFee)));
2974
+ result.push_back (Pair (" errors" , vErrors));
2965
2975
2966
2976
return result;
2967
2977
}
0 commit comments