Skip to content

Commit 4f4cd35

Browse files
committed
rpc: decouple sendtoaddress 'subtractfeefromamount' boolean parsing
The 'subtractfeefromamount' arg is only boolean for sendtoaddress(). Other commands should never provide it as a boolean.
1 parent a5fa907 commit 4f4cd35

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/wallet/rpc/spend.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ std::set<int> InterpretSubtractFeeFromOutputInstructions(const UniValue& sffo_in
6868
{
6969
std::set<int> sffo_set;
7070
if (sffo_instructions.isNull()) return sffo_set;
71-
if (sffo_instructions.isBool()) {
72-
if (sffo_instructions.get_bool()) sffo_set.insert(0);
73-
return sffo_set;
74-
}
71+
7572
for (const auto& sffo : sffo_instructions.getValues()) {
7673
if (sffo.isStr()) {
7774
for (size_t i = 0; i < destinations.size(); ++i) {
@@ -310,10 +307,13 @@ RPCHelpMan sendtoaddress()
310307
UniValue address_amounts(UniValue::VOBJ);
311308
const std::string address = request.params[0].get_str();
312309
address_amounts.pushKV(address, request.params[1]);
313-
std::vector<CRecipient> recipients = CreateRecipients(
314-
ParseOutputs(address_amounts),
315-
InterpretSubtractFeeFromOutputInstructions(request.params[4], address_amounts.getKeys())
316-
);
310+
311+
std::set<int> sffo_set;
312+
if (!request.params[4].isNull() && request.params[4].get_bool()) {
313+
sffo_set.insert(0);
314+
}
315+
316+
std::vector<CRecipient> recipients{CreateRecipients(ParseOutputs(address_amounts), sffo_set)};
317317
const bool verbose{request.params[10].isNull() ? false : request.params[10].get_bool()};
318318

319319
return SendMoney(*pwallet, coin_control, recipients, mapValue, verbose);

0 commit comments

Comments
 (0)