@@ -52,6 +52,28 @@ static void ParseRecipients(const UniValue& address_amounts, const UniValue& sub
5252 }
5353}
5454
55+ static void InterpretFeeEstimationInstructions (const UniValue& conf_target, const UniValue& estimate_mode, const UniValue& fee_rate, UniValue& options)
56+ {
57+ if (options.exists (" conf_target" ) || options.exists (" estimate_mode" )) {
58+ if (!conf_target.isNull () || !estimate_mode.isNull ()) {
59+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Pass conf_target and estimate_mode either as arguments or in the options object, but not both" );
60+ }
61+ } else {
62+ options.pushKV (" conf_target" , conf_target);
63+ options.pushKV (" estimate_mode" , estimate_mode);
64+ }
65+ if (options.exists (" fee_rate" )) {
66+ if (!fee_rate.isNull ()) {
67+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Pass the fee_rate either as an argument, or in the options object, but not both" );
68+ }
69+ } else {
70+ options.pushKV (" fee_rate" , fee_rate);
71+ }
72+ if (!options[" conf_target" ].isNull () && (options[" estimate_mode" ].isNull () || (options[" estimate_mode" ].get_str () == " unset" ))) {
73+ throw JSONRPCError (RPC_INVALID_PARAMETER, " Specify estimate_mode" );
74+ }
75+ }
76+
5577static void PreventOutdatedOptions (const UniValue& options)
5678{
5779 if (options.exists (" feeRate" )) {
@@ -1149,24 +1171,7 @@ RPCHelpMan send()
11491171 if (!pwallet) return NullUniValue;
11501172
11511173 UniValue options{request.params [4 ].isNull () ? UniValue::VOBJ : request.params [4 ]};
1152- if (options.exists (" conf_target" ) || options.exists (" estimate_mode" )) {
1153- if (!request.params [1 ].isNull () || !request.params [2 ].isNull ()) {
1154- throw JSONRPCError (RPC_INVALID_PARAMETER, " Pass conf_target and estimate_mode either as arguments or in the options object, but not both" );
1155- }
1156- } else {
1157- options.pushKV (" conf_target" , request.params [1 ]);
1158- options.pushKV (" estimate_mode" , request.params [2 ]);
1159- }
1160- if (options.exists (" fee_rate" )) {
1161- if (!request.params [3 ].isNull ()) {
1162- throw JSONRPCError (RPC_INVALID_PARAMETER, " Pass the fee_rate either as an argument, or in the options object, but not both" );
1163- }
1164- } else {
1165- options.pushKV (" fee_rate" , request.params [3 ]);
1166- }
1167- if (!options[" conf_target" ].isNull () && (options[" estimate_mode" ].isNull () || (options[" estimate_mode" ].get_str () == " unset" ))) {
1168- throw JSONRPCError (RPC_INVALID_PARAMETER, " Specify estimate_mode" );
1169- }
1174+ InterpretFeeEstimationInstructions (/* conf_target=*/ request.params [1 ], /* estimate_mode=*/ request.params [2 ], /* fee_rate=*/ request.params [3 ], options);
11701175 PreventOutdatedOptions (options);
11711176
11721177 const bool psbt_opt_in = options.exists (" psbt" ) && options[" psbt" ].get_bool ();
0 commit comments