@@ -2859,6 +2859,38 @@ UniValue bumpfee(const JSONRPCRequest& request)
2859
2859
uint256 hash;
2860
2860
hash.SetHex (request.params [0 ].get_str ());
2861
2861
2862
+ // optional parameters
2863
+ bool specifiedConfirmTarget = false ;
2864
+ int newConfirmTarget = nTxConfirmTarget;
2865
+ CAmount totalFee = 0 ;
2866
+ bool replaceable = true ;
2867
+ if (request.params .size () > 1 ) {
2868
+ UniValue options = request.params [1 ];
2869
+ RPCTypeCheckObj (options,
2870
+ {
2871
+ {" confTarget" , UniValueType (UniValue::VNUM)},
2872
+ {" totalFee" , UniValueType (UniValue::VNUM)},
2873
+ {" replaceable" , UniValueType (UniValue::VBOOL)},
2874
+ },
2875
+ true , true );
2876
+
2877
+ if (options.exists (" confTarget" ) && options.exists (" totalFee" )) {
2878
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " confTarget and totalFee options should not both be set. Please provide either a confirmation target for fee estimation or an explicit total fee for the transaction." );
2879
+ } else if (options.exists (" confTarget" )) {
2880
+ specifiedConfirmTarget = true ;
2881
+ newConfirmTarget = options[" confTarget" ].get_int ();
2882
+ if (newConfirmTarget <= 0 ) { // upper-bound will be checked by estimatefee/smartfee
2883
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid confTarget (cannot be <= 0)" );
2884
+ }
2885
+ } else if (options.exists (" totalFee" )) {
2886
+ totalFee = options[" totalFee" ].get_int64 ();
2887
+ }
2888
+
2889
+ if (options.exists (" replaceable" )) {
2890
+ replaceable = options[" replaceable" ].get_bool ();
2891
+ }
2892
+ }
2893
+
2862
2894
// retrieve the original tx from the wallet
2863
2895
LOCK2 (cs_main, pwallet->cs_wallet );
2864
2896
EnsureWalletIsUnlocked (pwallet);
@@ -2916,44 +2948,6 @@ UniValue bumpfee(const JSONRPCRequest& request)
2916
2948
int64_t txSize = GetVirtualTransactionSize (*(wtx.tx ));
2917
2949
const int64_t maxNewTxSize = CalculateMaximumSignedTxSize (*wtx.tx , *pwallet);
2918
2950
2919
- // optional parameters
2920
- bool specifiedConfirmTarget = false ;
2921
- int newConfirmTarget = nTxConfirmTarget;
2922
- CAmount totalFee = 0 ;
2923
- bool replaceable = true ;
2924
- if (request.params .size () > 1 ) {
2925
- UniValue options = request.params [1 ];
2926
- RPCTypeCheckObj (options,
2927
- {
2928
- {" confTarget" , UniValueType (UniValue::VNUM)},
2929
- {" totalFee" , UniValueType (UniValue::VNUM)},
2930
- {" replaceable" , UniValueType (UniValue::VBOOL)},
2931
- },
2932
- true , true );
2933
-
2934
- if (options.exists (" confTarget" ) && options.exists (" totalFee" )) {
2935
- throw JSONRPCError (RPC_INVALID_PARAMETER, " confTarget and totalFee options should not both be set. Please provide either a confirmation target for fee estimation or an explicit total fee for the transaction." );
2936
- } else if (options.exists (" confTarget" )) {
2937
- specifiedConfirmTarget = true ;
2938
- newConfirmTarget = options[" confTarget" ].get_int ();
2939
- if (newConfirmTarget <= 0 ) { // upper-bound will be checked by estimatefee/smartfee
2940
- throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid confTarget (cannot be <= 0)" );
2941
- }
2942
- } else if (options.exists (" totalFee" )) {
2943
- totalFee = options[" totalFee" ].get_int64 ();
2944
- CAmount requiredFee = CWallet::GetRequiredFee (maxNewTxSize);
2945
- if (totalFee < requiredFee ) {
2946
- throw JSONRPCError (RPC_INVALID_PARAMETER,
2947
- strprintf (" Insufficient totalFee (cannot be less than required fee %s)" ,
2948
- FormatMoney (requiredFee)));
2949
- }
2950
- }
2951
-
2952
- if (options.exists (" replaceable" )) {
2953
- replaceable = options[" replaceable" ].get_bool ();
2954
- }
2955
- }
2956
-
2957
2951
// calculate the old fee and fee-rate
2958
2952
CAmount nOldFee = wtx.GetDebit (ISMINE_SPENDABLE) - wtx.tx ->GetValueOut ();
2959
2953
CFeeRate nOldFeeRate (nOldFee, txSize);
@@ -2973,6 +2967,11 @@ UniValue bumpfee(const JSONRPCRequest& request)
2973
2967
throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" Insufficient totalFee, must be at least %s (oldFee %s + incrementalFee %s)" ,
2974
2968
FormatMoney (minTotalFee), FormatMoney (nOldFeeRate.GetFee (maxNewTxSize)), FormatMoney (::incrementalRelayFee.GetFee (maxNewTxSize))));
2975
2969
}
2970
+ CAmount requiredFee = CWallet::GetRequiredFee (maxNewTxSize);
2971
+ if (totalFee < requiredFee ) {
2972
+ throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" Insufficient totalFee (cannot be less than required fee %s)" ,
2973
+ FormatMoney (requiredFee)));
2974
+ }
2976
2975
nNewFee = totalFee;
2977
2976
nNewFeeRate = CFeeRate (totalFee, maxNewTxSize);
2978
2977
} else {
0 commit comments