Skip to content

Commit b85dc7e

Browse files
achow101fanquake
authored andcommitted
wallet: Throw an error in sendall if the tx size cannot be calculated
Github-Pull: #33268 Rebased-From: c40dc82
1 parent d2be9a2 commit b85dc7e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/wallet/rpc/spend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,6 @@ RPCHelpMan sendall()
15211521
CoinFilterParams coins_params;
15221522
coins_params.min_amount = 0;
15231523
for (const COutput& output : AvailableCoins(*pwallet, &coin_control, fee_rate, coins_params).All()) {
1524-
CHECK_NONFATAL(output.input_bytes > 0);
15251524
if (send_max && fee_rate.GetFee(output.input_bytes) > output.txout.nValue) {
15261525
continue;
15271526
}
@@ -1544,6 +1543,9 @@ RPCHelpMan sendall()
15441543

15451544
// estimate final size of tx
15461545
const TxSize tx_size{CalculateMaximumSignedTxSize(CTransaction(rawTx), pwallet.get())};
1546+
if (tx_size.vsize == -1) {
1547+
throw JSONRPCError(RPC_WALLET_ERROR, "Unable to determine the size of the transaction, the wallet contains unsolvable descriptors");
1548+
}
15471549
const CAmount fee_from_size{fee_rate.GetFee(tx_size.vsize)};
15481550
const std::optional<CAmount> total_bump_fees{pwallet->chain().calculateCombinedBumpFee(outpoints_spent, fee_rate)};
15491551
CAmount effective_value = total_input_value - fee_from_size - total_bump_fees.value_or(0);

0 commit comments

Comments
 (0)