@@ -356,7 +356,7 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request)
356356 return ret;
357357}
358358
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 )
360360{
361361 CAmount curBalance = pwallet->GetBalance ();
362362
@@ -382,7 +382,7 @@ static void SendMoney(CWallet * const pwallet, const CTxDestination &address, CA
382382 int nChangePosRet = -1 ;
383383 CRecipient recipient = {scriptPubKey, nValue, fSubtractFeeFromAmount };
384384 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 )) {
386386 if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance)
387387 strError = strprintf (" Error: This transaction requires a transaction fee of at least %s" , FormatMoney (nFeeRequired));
388388 throw JSONRPCError (RPC_WALLET_ERROR, strError);
@@ -401,9 +401,9 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
401401 return NullUniValue;
402402 }
403403
404- if (request.fHelp || request.params .size () < 2 || request.params .size () > 5 )
404+ if (request.fHelp || request.params .size () < 2 || request.params .size () > 8 )
405405 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 "
407407 " \n Send an amount to a given address.\n "
408408 + HelpRequiringPassphrase (pwallet) +
409409 " \n Arguments:\n "
@@ -416,6 +416,12 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
416416 " transaction, just kept in your wallet.\n "
417417 " 5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n "
418418 " 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 "
419425 " \n Result:\n "
420426 " \" txid\" (string) The transaction id.\n "
421427 " \n Examples:\n "
@@ -444,12 +450,29 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
444450 wtx.mapValue [" to" ] = request.params [3 ].get_str ();
445451
446452 bool fSubtractFeeFromAmount = false ;
447- if (request.params .size () > 4 )
453+ if (request.params .size () > 4 && !request. params [ 4 ]. isNull ()) {
448454 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+
449472
450473 EnsureWalletIsUnlocked (pwallet);
451474
452- SendMoney (pwallet, address.Get (), nAmount, fSubtractFeeFromAmount , wtx);
475+ SendMoney (pwallet, address.Get (), nAmount, fSubtractFeeFromAmount , wtx, &coin_control );
453476
454477 return wtx.GetHash ().GetHex ();
455478}
@@ -888,9 +911,9 @@ UniValue sendmany(const JSONRPCRequest& request)
888911 return NullUniValue;
889912 }
890913
891- if (request.fHelp || request.params .size () < 2 || request.params .size () > 5 )
914+ if (request.fHelp || request.params .size () < 2 || request.params .size () > 8 )
892915 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 "
894917 " \n Send multiple times. Amounts are double-precision floating point numbers."
895918 + HelpRequiringPassphrase (pwallet) + " \n "
896919 " \n Arguments:\n "
@@ -910,7 +933,13 @@ UniValue sendmany(const JSONRPCRequest& request)
910933 " \" address\" (string) Subtract fee from this address\n "
911934 " ,...\n "
912935 " ]\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 "
914943 " \" txid\" (string) The transaction id for the send. Only 1 transaction is created regardless of \n "
915944 " the number of addresses.\n "
916945 " \n Examples:\n "
@@ -942,9 +971,24 @@ UniValue sendmany(const JSONRPCRequest& request)
942971 wtx.mapValue [" comment" ] = request.params [3 ].get_str ();
943972
944973 UniValue subtractFeeFromAmount (UniValue::VARR);
945- if (request.params .size () > 4 )
974+ if (request.params .size () > 4 && !request. params [ 4 ]. isNull () )
946975 subtractFeeFromAmount = request.params [4 ].get_array ();
947976
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+
948992 std::set<CBitcoinAddress> setAddress;
949993 std::vector<CRecipient> vecSend;
950994
@@ -989,7 +1033,7 @@ UniValue sendmany(const JSONRPCRequest& request)
9891033 CAmount nFeeRequired = 0 ;
9901034 int nChangePosRet = -1 ;
9911035 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 );
9931037 if (!fCreated )
9941038 throw JSONRPCError (RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
9951039 CValidationState state;
@@ -2658,6 +2702,11 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
26582702 " [vout_index,...]\n "
26592703 " \" replaceable\" (boolean, optional) Marks this transaction as BIP125 replaceable.\n "
26602704 " 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 "
26612710 " }\n "
26622711 " for backward compatibility: passing in a true instead of an object will result in {\" includeWatching\" :true}\n "
26632712 " \n Result:\n "
@@ -2710,6 +2759,8 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
27102759 {" feeRate" , UniValueType ()}, // will be checked below
27112760 {" subtractFeeFromOutputs" , UniValueType (UniValue::VARR)},
27122761 {" replaceable" , UniValueType (UniValue::VBOOL)},
2762+ {" conf_target" , UniValueType (UniValue::VNUM)},
2763+ {" estimate_mode" , UniValueType (UniValue::VSTR)},
27132764 },
27142765 true , true );
27152766
@@ -2746,6 +2797,14 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
27462797 if (options.exists (" replaceable" )) {
27472798 coinControl.signalRbf = options[" replaceable" ].get_bool ();
27482799 }
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+ }
27492808 }
27502809 }
27512810
@@ -2823,6 +2882,10 @@ UniValue bumpfee(const JSONRPCRequest& request)
28232882 " so the new transaction will not be explicitly bip-125 replaceable (though it may\n "
28242883 " still be replaceable in practice, for example if it has unconfirmed ancestors which\n "
28252884 " 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 "
28262889 " }\n "
28272890 " \n Result:\n "
28282891 " {\n "
@@ -2845,13 +2908,15 @@ UniValue bumpfee(const JSONRPCRequest& request)
28452908 int newConfirmTarget = nTxConfirmTarget;
28462909 CAmount totalFee = 0 ;
28472910 bool replaceable = true ;
2911+ FeeEstimateMode fee_mode = FeeEstimateMode::UNSET;
28482912 if (request.params .size () > 1 ) {
28492913 UniValue options = request.params [1 ];
28502914 RPCTypeCheckObj (options,
28512915 {
28522916 {" confTarget" , UniValueType (UniValue::VNUM)},
28532917 {" totalFee" , UniValueType (UniValue::VNUM)},
28542918 {" replaceable" , UniValueType (UniValue::VBOOL)},
2919+ {" estimate_mode" , UniValueType (UniValue::VSTR)},
28552920 },
28562921 true , true );
28572922
@@ -2876,12 +2941,17 @@ UniValue bumpfee(const JSONRPCRequest& request)
28762941 if (options.exists (" replaceable" )) {
28772942 replaceable = options[" replaceable" ].get_bool ();
28782943 }
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+ }
28792949 }
28802950
28812951 LOCK2 (cs_main, pwallet->cs_wallet );
28822952 EnsureWalletIsUnlocked (pwallet);
28832953
2884- CFeeBumper feeBump (pwallet, hash, newConfirmTarget, ignoreGlobalPayTxFee, totalFee, replaceable);
2954+ CFeeBumper feeBump (pwallet, hash, newConfirmTarget, ignoreGlobalPayTxFee, totalFee, replaceable, fee_mode );
28852955 BumpFeeResult res = feeBump.getResult ();
28862956 if (res != BumpFeeResult::OK)
28872957 {
@@ -3023,8 +3093,8 @@ static const CRPCCommand commands[] =
30233093 { " wallet" , " lockunspent" , &lockunspent, true , {" unlock" ," transactions" } },
30243094 { " wallet" , " move" , &movecmd, false , {" fromaccount" ," toaccount" ," amount" ," minconf" ," comment" } },
30253095 { " 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 " } },
30283098 { " wallet" , " setaccount" , &setaccount, true , {" address" ," account" } },
30293099 { " wallet" , " settxfee" , &settxfee, true , {" amount" } },
30303100 { " wallet" , " signmessage" , &signmessage, true , {" address" ," message" } },
0 commit comments