diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index 5a13b5ac8e..eb3e607320 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -24,8 +24,9 @@ namespace wallet { -static void ParseRecipients(const UniValue& address_amounts, const UniValue& subtract_fee_outputs, std::vector& recipients) +std::vector CreateRecipients(const UniValue& address_amounts, const UniValue& subtract_fee_outputs) { + std::vector recipients; std::set destinations; int i = 0; for (const std::string& address: address_amounts.getKeys()) { @@ -52,6 +53,7 @@ static void ParseRecipients(const UniValue& address_amounts, const UniValue& sub CRecipient recipient = {dest, amount, subtract_fee}; recipients.push_back(recipient); } + return recipients; } static void InterpretFeeEstimationInstructions(const UniValue& conf_target, const UniValue& estimate_mode, const UniValue& fee_rate, UniValue& options) @@ -301,8 +303,7 @@ RPCHelpMan sendtoaddress() subtractFeeFromAmount.push_back(address); } - std::vector recipients; - ParseRecipients(address_amounts, subtractFeeFromAmount, recipients); + std::vector recipients = CreateRecipients(address_amounts, subtractFeeFromAmount); const bool verbose{request.params[10].isNull() ? false : request.params[10].get_bool()}; return SendMoney(*pwallet, coin_control, recipients, mapValue, verbose); @@ -397,8 +398,7 @@ RPCHelpMan sendmany() SetFeeEstimateMode(*pwallet, coin_control, /*conf_target=*/request.params[6], /*estimate_mode=*/request.params[7], /*fee_rate=*/request.params[8], /*override_min_fee=*/false); - std::vector recipients; - ParseRecipients(sendTo, subtractFeeFromAmount, recipients); + std::vector recipients = CreateRecipients(sendTo, subtractFeeFromAmount); const bool verbose{request.params[9].isNull() ? false : request.params[9].get_bool()}; return SendMoney(*pwallet, coin_control, recipients, std::move(mapValue), verbose);