@@ -356,7 +356,7 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request)
356
356
return ret;
357
357
}
358
358
359
- static void SendMoney (CWallet * const pwallet, const CTxDestination &address, CAmount nValue, bool fSubtractFeeFromAmount , CWalletTx& wtxNew)
359
+ static void SendMoney (CWallet * const pwallet, const CTxDestination &address, CAmount nValue, bool fSubtractFeeFromAmount , CWalletTx& wtxNew, CCoinControl *coin_control = nullptr )
360
360
{
361
361
CAmount curBalance = pwallet->GetBalance ();
362
362
@@ -382,7 +382,7 @@ static void SendMoney(CWallet * const pwallet, const CTxDestination &address, CA
382
382
int nChangePosRet = -1 ;
383
383
CRecipient recipient = {scriptPubKey, nValue, fSubtractFeeFromAmount };
384
384
vecSend.push_back (recipient);
385
- if (!pwallet->CreateTransaction (vecSend, wtxNew, reservekey, nFeeRequired, nChangePosRet, strError)) {
385
+ if (!pwallet->CreateTransaction (vecSend, wtxNew, reservekey, nFeeRequired, nChangePosRet, strError, coin_control )) {
386
386
if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance)
387
387
strError = strprintf (" Error: This transaction requires a transaction fee of at least %s" , FormatMoney (nFeeRequired));
388
388
throw JSONRPCError (RPC_WALLET_ERROR, strError);
@@ -401,9 +401,9 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
401
401
return NullUniValue;
402
402
}
403
403
404
- if (request.fHelp || request.params .size () < 2 || request.params .size () > 5 )
404
+ if (request.fHelp || request.params .size () < 2 || request.params .size () > 8 )
405
405
throw std::runtime_error (
406
- " sendtoaddress \" address\" amount ( \" comment\" \" comment_to\" subtractfeefromamount )\n "
406
+ " sendtoaddress \" address\" amount ( \" comment\" \" comment_to\" subtractfeefromamount replaceable conf_target \" estimate_mode \" )\n "
407
407
" \n Send an amount to a given address.\n "
408
408
+ HelpRequiringPassphrase (pwallet) +
409
409
" \n Arguments:\n "
@@ -416,6 +416,12 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
416
416
" transaction, just kept in your wallet.\n "
417
417
" 5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n "
418
418
" The recipient will receive less bitcoins than you enter in the amount field.\n "
419
+ " 6. replaceable (boolean, optional) Allow this transaction to be replaced by a transaction with higher fees via BIP 125\n "
420
+ " 7. conf_target (numeric, optional) Confirmation target (in blocks)\n "
421
+ " 8. \" estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n "
422
+ " \" UNSET\"\n "
423
+ " \" ECONOMICAL\"\n "
424
+ " \" CONSERVATIVE\"\n "
419
425
" \n Result:\n "
420
426
" \" txid\" (string) The transaction id.\n "
421
427
" \n Examples:\n "
@@ -444,12 +450,29 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
444
450
wtx.mapValue [" to" ] = request.params [3 ].get_str ();
445
451
446
452
bool fSubtractFeeFromAmount = false ;
447
- if (request.params .size () > 4 )
453
+ if (request.params .size () > 4 && !request. params [ 4 ]. isNull ()) {
448
454
fSubtractFeeFromAmount = request.params [4 ].get_bool ();
455
+ }
456
+
457
+ CCoinControl coin_control;
458
+ if (request.params .size () > 5 && !request.params [5 ].isNull ()) {
459
+ coin_control.signalRbf = request.params [5 ].get_bool ();
460
+ }
461
+
462
+ if (request.params .size () > 6 && !request.params [6 ].isNull ()) {
463
+ coin_control.nConfirmTarget = request.params [6 ].get_int ();
464
+ }
465
+
466
+ if (request.params .size () > 7 && !request.params [7 ].isNull ()) {
467
+ if (!FeeModeFromString (request.params [7 ].get_str (), coin_control.m_fee_mode )) {
468
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid estimate_mode parameter" );
469
+ }
470
+ }
471
+
449
472
450
473
EnsureWalletIsUnlocked (pwallet);
451
474
452
- SendMoney (pwallet, address.Get (), nAmount, fSubtractFeeFromAmount , wtx);
475
+ SendMoney (pwallet, address.Get (), nAmount, fSubtractFeeFromAmount , wtx, &coin_control );
453
476
454
477
return wtx.GetHash ().GetHex ();
455
478
}
@@ -888,9 +911,9 @@ UniValue sendmany(const JSONRPCRequest& request)
888
911
return NullUniValue;
889
912
}
890
913
891
- if (request.fHelp || request.params .size () < 2 || request.params .size () > 5 )
914
+ if (request.fHelp || request.params .size () < 2 || request.params .size () > 8 )
892
915
throw std::runtime_error (
893
- " sendmany \" fromaccount\" {\" address\" :amount,...} ( minconf \" comment\" [\" address\" ,...] )\n "
916
+ " sendmany \" fromaccount\" {\" address\" :amount,...} ( minconf \" comment\" [\" address\" ,...] replaceable conf_target \" estimate_mode \" )\n "
894
917
" \n Send multiple times. Amounts are double-precision floating point numbers."
895
918
+ HelpRequiringPassphrase (pwallet) + " \n "
896
919
" \n Arguments:\n "
@@ -910,7 +933,13 @@ UniValue sendmany(const JSONRPCRequest& request)
910
933
" \" address\" (string) Subtract fee from this address\n "
911
934
" ,...\n "
912
935
" ]\n "
913
- " \n Result:\n "
936
+ " 6. replaceable (boolean, optional) Allow this transaction to be replaced by a transaction with higher fees via BIP 125\n "
937
+ " 7. conf_target (numeric, optional) Confirmation target (in blocks)\n "
938
+ " 8. \" estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n "
939
+ " \" UNSET\"\n "
940
+ " \" ECONOMICAL\"\n "
941
+ " \" CONSERVATIVE\"\n "
942
+ " \n Result:\n "
914
943
" \" txid\" (string) The transaction id for the send. Only 1 transaction is created regardless of \n "
915
944
" the number of addresses.\n "
916
945
" \n Examples:\n "
@@ -942,9 +971,24 @@ UniValue sendmany(const JSONRPCRequest& request)
942
971
wtx.mapValue [" comment" ] = request.params [3 ].get_str ();
943
972
944
973
UniValue subtractFeeFromAmount (UniValue::VARR);
945
- if (request.params .size () > 4 )
974
+ if (request.params .size () > 4 && !request. params [ 4 ]. isNull () )
946
975
subtractFeeFromAmount = request.params [4 ].get_array ();
947
976
977
+ CCoinControl coin_control;
978
+ if (request.params .size () > 5 && !request.params [5 ].isNull ()) {
979
+ coin_control.signalRbf = request.params [5 ].get_bool ();
980
+ }
981
+
982
+ if (request.params .size () > 6 && !request.params [6 ].isNull ()) {
983
+ coin_control.nConfirmTarget = request.params [6 ].get_int ();
984
+ }
985
+
986
+ if (request.params .size () > 7 && !request.params [7 ].isNull ()) {
987
+ if (!FeeModeFromString (request.params [7 ].get_str (), coin_control.m_fee_mode )) {
988
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid estimate_mode parameter" );
989
+ }
990
+ }
991
+
948
992
std::set<CBitcoinAddress> setAddress;
949
993
std::vector<CRecipient> vecSend;
950
994
@@ -989,7 +1033,7 @@ UniValue sendmany(const JSONRPCRequest& request)
989
1033
CAmount nFeeRequired = 0 ;
990
1034
int nChangePosRet = -1 ;
991
1035
std::string strFailReason;
992
- bool fCreated = pwallet->CreateTransaction (vecSend, wtx, keyChange, nFeeRequired, nChangePosRet, strFailReason);
1036
+ bool fCreated = pwallet->CreateTransaction (vecSend, wtx, keyChange, nFeeRequired, nChangePosRet, strFailReason, &coin_control );
993
1037
if (!fCreated )
994
1038
throw JSONRPCError (RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
995
1039
CValidationState state;
@@ -2658,6 +2702,11 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
2658
2702
" [vout_index,...]\n "
2659
2703
" \" replaceable\" (boolean, optional) Marks this transaction as BIP125 replaceable.\n "
2660
2704
" Allows this transaction to be replaced by a transaction with higher fees\n "
2705
+ " \" conf_target\" (numeric, optional) Confirmation target (in blocks)\n "
2706
+ " \" estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n "
2707
+ " \" UNSET\"\n "
2708
+ " \" ECONOMICAL\"\n "
2709
+ " \" CONSERVATIVE\"\n "
2661
2710
" }\n "
2662
2711
" for backward compatibility: passing in a true instead of an object will result in {\" includeWatching\" :true}\n "
2663
2712
" \n Result:\n "
@@ -2710,6 +2759,8 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
2710
2759
{" feeRate" , UniValueType ()}, // will be checked below
2711
2760
{" subtractFeeFromOutputs" , UniValueType (UniValue::VARR)},
2712
2761
{" replaceable" , UniValueType (UniValue::VBOOL)},
2762
+ {" conf_target" , UniValueType (UniValue::VNUM)},
2763
+ {" estimate_mode" , UniValueType (UniValue::VSTR)},
2713
2764
},
2714
2765
true , true );
2715
2766
@@ -2746,6 +2797,14 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
2746
2797
if (options.exists (" replaceable" )) {
2747
2798
coinControl.signalRbf = options[" replaceable" ].get_bool ();
2748
2799
}
2800
+ if (options.exists (" conf_target" )) {
2801
+ coinControl.nConfirmTarget = options[" conf_target" ].get_int ();
2802
+ }
2803
+ if (options.exists (" estimate_mode" )) {
2804
+ if (!FeeModeFromString (options[" estimate_mode" ].get_str (), coinControl.m_fee_mode )) {
2805
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid estimate_mode parameter" );
2806
+ }
2807
+ }
2749
2808
}
2750
2809
}
2751
2810
@@ -2823,6 +2882,10 @@ UniValue bumpfee(const JSONRPCRequest& request)
2823
2882
" so the new transaction will not be explicitly bip-125 replaceable (though it may\n "
2824
2883
" still be replaceable in practice, for example if it has unconfirmed ancestors which\n "
2825
2884
" are replaceable).\n "
2885
+ " \" estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n "
2886
+ " \" UNSET\"\n "
2887
+ " \" ECONOMICAL\"\n "
2888
+ " \" CONSERVATIVE\"\n "
2826
2889
" }\n "
2827
2890
" \n Result:\n "
2828
2891
" {\n "
@@ -2845,13 +2908,15 @@ UniValue bumpfee(const JSONRPCRequest& request)
2845
2908
int newConfirmTarget = nTxConfirmTarget;
2846
2909
CAmount totalFee = 0 ;
2847
2910
bool replaceable = true ;
2911
+ FeeEstimateMode fee_mode = FeeEstimateMode::UNSET;
2848
2912
if (request.params .size () > 1 ) {
2849
2913
UniValue options = request.params [1 ];
2850
2914
RPCTypeCheckObj (options,
2851
2915
{
2852
2916
{" confTarget" , UniValueType (UniValue::VNUM)},
2853
2917
{" totalFee" , UniValueType (UniValue::VNUM)},
2854
2918
{" replaceable" , UniValueType (UniValue::VBOOL)},
2919
+ {" estimate_mode" , UniValueType (UniValue::VSTR)},
2855
2920
},
2856
2921
true , true );
2857
2922
@@ -2876,12 +2941,17 @@ UniValue bumpfee(const JSONRPCRequest& request)
2876
2941
if (options.exists (" replaceable" )) {
2877
2942
replaceable = options[" replaceable" ].get_bool ();
2878
2943
}
2944
+ if (options.exists (" estimate_mode" )) {
2945
+ if (!FeeModeFromString (options[" estimate_mode" ].get_str (), fee_mode)) {
2946
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid estimate_mode parameter" );
2947
+ }
2948
+ }
2879
2949
}
2880
2950
2881
2951
LOCK2 (cs_main, pwallet->cs_wallet );
2882
2952
EnsureWalletIsUnlocked (pwallet);
2883
2953
2884
- CFeeBumper feeBump (pwallet, hash, newConfirmTarget, ignoreGlobalPayTxFee, totalFee, replaceable);
2954
+ CFeeBumper feeBump (pwallet, hash, newConfirmTarget, ignoreGlobalPayTxFee, totalFee, replaceable, fee_mode );
2885
2955
BumpFeeResult res = feeBump.getResult ();
2886
2956
if (res != BumpFeeResult::OK)
2887
2957
{
@@ -3023,8 +3093,8 @@ static const CRPCCommand commands[] =
3023
3093
{ " wallet" , " lockunspent" , &lockunspent, true , {" unlock" ," transactions" } },
3024
3094
{ " wallet" , " move" , &movecmd, false , {" fromaccount" ," toaccount" ," amount" ," minconf" ," comment" } },
3025
3095
{ " wallet" , " sendfrom" , &sendfrom, false , {" fromaccount" ," toaddress" ," amount" ," minconf" ," comment" ," comment_to" } },
3026
- { " wallet" , " sendmany" , &sendmany, false , {" fromaccount" ," amounts" ," minconf" ," comment" ," subtractfeefrom" } },
3027
- { " wallet" , " sendtoaddress" , &sendtoaddress, false , {" address" ," amount" ," comment" ," comment_to" ," subtractfeefromamount" } },
3096
+ { " wallet" , " sendmany" , &sendmany, false , {" fromaccount" ," amounts" ," minconf" ," comment" ," subtractfeefrom" , " replaceable " , " conf_target " , " estimate_mode " } },
3097
+ { " wallet" , " sendtoaddress" , &sendtoaddress, false , {" address" ," amount" ," comment" ," comment_to" ," subtractfeefromamount" , " replaceable " , " conf_target " , " estimate_mode " } },
3028
3098
{ " wallet" , " setaccount" , &setaccount, true , {" address" ," account" } },
3029
3099
{ " wallet" , " settxfee" , &settxfee, true , {" amount" } },
3030
3100
{ " wallet" , " signmessage" , &signmessage, true , {" address" ," message" } },
0 commit comments