wallet: Throw an error in sendall if the tx size cannot be calculated

Github-Pull: #33268
Rebased-From: c40dc822d7
This commit is contained in:
Ava Chow 2025-08-28 15:13:36 -07:00 committed by fanquake
parent d2be9a22d8
commit b85dc7ed3a
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1
1 changed files with 3 additions and 1 deletions

View File

@ -1521,7 +1521,6 @@ RPCHelpMan sendall()
CoinFilterParams coins_params;
coins_params.min_amount = 0;
for (const COutput& output : AvailableCoins(*pwallet, &coin_control, fee_rate, coins_params).All()) {
CHECK_NONFATAL(output.input_bytes > 0);
if (send_max && fee_rate.GetFee(output.input_bytes) > output.txout.nValue) {
continue;
}
@ -1544,6 +1543,9 @@ RPCHelpMan sendall()
// estimate final size of tx
const TxSize tx_size{CalculateMaximumSignedTxSize(CTransaction(rawTx), pwallet.get())};
if (tx_size.vsize == -1) {
throw JSONRPCError(RPC_WALLET_ERROR, "Unable to determine the size of the transaction, the wallet contains unsolvable descriptors");
}
const CAmount fee_from_size{fee_rate.GetFee(tx_size.vsize)};
const std::optional<CAmount> total_bump_fees{pwallet->chain().calculateCombinedBumpFee(outpoints_spent, fee_rate)};
CAmount effective_value = total_input_value - fee_from_size - total_bump_fees.value_or(0);