asyncOp sendmany: moved inputs total amount check inside load_utxo before the dust validation.

This commit is contained in:
furszy 2020-11-01 14:27:09 -03:00
parent ca9fc49fc4
commit b4e6353f29
No known key found for this signature in database
GPG Key ID: 5DD23CCC686AA623
1 changed files with 10 additions and 10 deletions

View File

@ -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_) {