aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-06-26 12:16:16 -0400
committerAva Chow <github@achow101.com>2024-06-26 12:16:16 -0400
commit1d00601b9b559b305e75830121dd30e207ef0d08 (patch)
tree14768084d14b1eefa826d9d570096a833ed66016 /src
parentd3d2bbf576d07f729dbb5eafce4ae6d4cc7dd763 (diff)
parent72b226882fe2348a9a66aee1d8d21b4e2d275e68 (diff)
downloadbitcoin-1d00601b9b559b305e75830121dd30e207ef0d08.tar.xz
Merge bitcoin/bitcoin#30309: wallet: notify when preset + automatic inputs exceed max weight
72b226882fe2348a9a66aee1d8d21b4e2d275e68 wallet: notify when preset + automatic inputs exceed max weight (furszy) Pull request description: Small change. Found it while finishing my review on #29523. This does not interfere with it. Basically, we are erroring out early when the automatic coin selection process exceeds the maximum weight, but we are not doing so when the user-preselected inputs combined with the wallet-selected inputs exceed the maximum weight. This change avoids signing all inputs before erroring out and introduces test coverage for `fundrawtransaction`. ACKs for top commit: achow101: ACK 72b226882fe2348a9a66aee1d8d21b4e2d275e68 tdb3: re ACK for 72b226882fe2348a9a66aee1d8d21b4e2d275e68 rkrux: tACK [72b2268](https://github.com/bitcoin/bitcoin/pull/30309/commits/72b226882fe2348a9a66aee1d8d21b4e2d275e68) ismaelsadeeq: utACK 72b226882fe2348a9a66aee1d8d21b4e2d275e68 Tree-SHA512: d77be19231023383a9c79a5d66b642dcbc6ebfc31a363e0b9f063c44898720a7859ec211cdbc0914ac7a3bfdf15e52fb8fc20d97f171431f70492c0f159dbc36
Diffstat (limited to 'src')
-rw-r--r--src/wallet/spend.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index b9b4666208..c16b8a9d4f 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;
}