Skip to content

Commit 09a0dcb

Browse files
committed
wallet: Try estimating input size with external data if wallet fails
Instead of choosing whether to use the wallet or external data when estimating the size of an input, first use the wallet, then try external data if that failed.
1 parent fd98ced commit 09a0dcb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/wallet/spend.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,19 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
447447
return std::nullopt;
448448
}
449449
txout = ptr_wtx->tx->vout.at(outpoint.n);
450-
input_bytes = CalculateMaximumSignedInputSize(txout, &wallet, &coin_control);
451450
} else {
452451
// The input is external. We did not find the tx in mapWallet.
453452
if (!coin_control.GetExternalOutput(outpoint, txout)) {
454453
return std::nullopt;
455454
}
455+
}
456+
457+
input_bytes = CalculateMaximumSignedInputSize(txout, &wallet, &coin_control);
458+
459+
if (input_bytes == -1) {
456460
input_bytes = CalculateMaximumSignedInputSize(txout, outpoint, &coin_control.m_external_provider, &coin_control);
457461
}
462+
458463
// If available, override calculated size with coin control specified size
459464
if (coin_control.HasInputWeight(outpoint)) {
460465
input_bytes = GetVirtualTransactionSize(coin_control.GetInputWeight(outpoint), 0, 0);

0 commit comments

Comments
 (0)