Skip to content

Commit

Permalink
refactor: remove out param from ParseRecipients
Browse files Browse the repository at this point in the history
Have `ParseRecipients` return a vector of `CRecipients` and rename to `CreateRecipients`.
  • Loading branch information
josibake committed Jan 19, 2024
1 parent f7384b9 commit 47353a6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/wallet/rpc/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@


namespace wallet {
static void ParseRecipients(const UniValue& address_amounts, const UniValue& subtract_fee_outputs, std::vector<CRecipient>& recipients)
std::vector<CRecipient> CreateRecipients(const UniValue& address_amounts, const UniValue& subtract_fee_outputs)
{
std::vector<CRecipient> recipients;
std::set<CTxDestination> destinations;
int i = 0;
for (const std::string& address: address_amounts.getKeys()) {
Expand All @@ -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)
Expand Down Expand Up @@ -301,8 +303,7 @@ RPCHelpMan sendtoaddress()
subtractFeeFromAmount.push_back(address);
}

std::vector<CRecipient> recipients;
ParseRecipients(address_amounts, subtractFeeFromAmount, recipients);
std::vector<CRecipient> 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);
Expand Down Expand Up @@ -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<CRecipient> recipients;
ParseRecipients(sendTo, subtractFeeFromAmount, recipients);
std::vector<CRecipient> 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);
Expand Down

0 comments on commit 47353a6

Please sign in to comment.