diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2024-06-19 14:27:35 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2024-06-21 18:13:22 -0300 |
commit | 72b226882fe2348a9a66aee1d8d21b4e2d275e68 (patch) | |
tree | 89b670577a3b1e5516331cb0e13b758d9d410096 /src/wallet | |
parent | 2d21060af831fa8f8f1791b4464961d5f28a88cb (diff) |
wallet: notify when preset + automatic inputs exceed max weight
This also avoids signing all inputs prior to erroring out.
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/spend.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 4cbcfdb60f..2fce051f54 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -799,6 +799,13 @@ util::Result<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& av op_selection_result->RecalculateWaste(coin_selection_params.min_viable_change, coin_selection_params.m_cost_of_change, coin_selection_params.m_change_fee); + + // Verify we haven't exceeded the maximum allowed weight + int max_inputs_weight = MAX_STANDARD_TX_WEIGHT - (coin_selection_params.tx_noinputs_size * WITNESS_SCALE_FACTOR); + if (op_selection_result->GetWeight() > max_inputs_weight) { + return util::Error{_("The combination of the pre-selected inputs and the wallet automatic inputs selection exceeds the transaction maximum weight. " + "Please try sending a smaller amount or manually consolidating your wallet's UTXOs")}; + } } return op_selection_result; } |