From b4e6353f296a03ab6e5f1f44c307808652acb2b9 Mon Sep 17 00:00:00 2001 From: furszy Date: Sun, 1 Nov 2020 14:27:09 -0300 Subject: [PATCH] asyncOp sendmany: moved inputs total amount check inside load_utxo before the dust validation. --- src/wallet/asyncrpcoperation_sendmany.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index cd67797fd..17eccb2d4 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -270,12 +270,6 @@ bool AsyncRPCOperation_sendmany::main_impl() { assert(!isfromtaddr_ || txValues.z_inputs_total == 0); assert(!isfromzaddr_ || txValues.t_inputs_total == 0); - - if (isfromtaddr_ && (txValues.t_inputs_total < txValues.targetAmount)) { - throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, - strprintf("Insufficient transparent funds, have %s, need %s", - FormatMoney(txValues.t_inputs_total), FormatMoney(txValues.targetAmount))); - } if (isfromzaddr_ && (txValues.z_inputs_total < txValues.targetAmount)) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, @@ -891,16 +885,22 @@ bool AsyncRPCOperation_sendmany::load_inputs(TxValues& txValues) { } } + t_inputs_ = selectedTInputs; + txValues.t_inputs_total = selectedUTXOAmount; + + if (txValues.t_inputs_total < txValues.targetAmount) { + throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, + strprintf("Insufficient transparent funds, have %s, need %s", + FormatMoney(txValues.t_inputs_total), FormatMoney(txValues.targetAmount))); + } + // If there is transparent change, is it valid or is it dust? if (dustChange < dustThreshold && dustChange != 0) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strprintf("Insufficient transparent funds, have %s, need %s more to avoid creating invalid change output %s (dust threshold is %s)", - FormatMoney(selectedUTXOAmount), FormatMoney(dustThreshold - dustChange), FormatMoney(dustChange), FormatMoney(dustThreshold))); + FormatMoney(txValues.t_inputs_total), FormatMoney(dustThreshold - dustChange), FormatMoney(dustChange), FormatMoney(dustThreshold))); } - t_inputs_ = selectedTInputs; - txValues.t_inputs_total = selectedUTXOAmount; - // update the transaction with these inputs if (isUsingBuilder_) { for (const auto& out : t_inputs_) {