picks up #25269.
This PR re-implements the code path so that an error message is thrown when a transaction’s total amount (including fees) exceeds the available balance. It also refactors the wallet’s coin selection code.
-
the first 3 commits are unrelated to the code but few small bug fixes which are nice to fix. but also kind of impacts the remaining logic. (could PR separately if reviewers wish)
- c467325aaf187d7f056bb1ea1cec6b7c4250af2e: make
total_effective_amountoptional actually optional - 2202ab597596c84fc49f8784e823372b7a9efcbe: ensure
set<shared_ptr<COutput>>has unique COutput - a5ffbbf122d66fc4ad9b2e7c6d7d1dfa1816388e: Correctly reserve size when flattening
CoinsResult.coinsmap to vector
- c467325aaf187d7f056bb1ea1cec6b7c4250af2e: make
-
the next 3 commits from 4745d5480ca5c3809edd51140e4d2c0433582844 replace the
PreSelectedInputsstruct withCoinsResultand removesPreSelectedInputs. -
the last commit (e664484a6d34c1795ebb0925ab31faea5d64ab00) deals with the error message -
AmountWithFeeExceedsBalanceerror insideWalletModel::prepareTransactionis never thrown and remains an unused code path. This is becausecreateTransactiondoes not retrieve the fee when the process fails. The fee return arg is set only at the end of the process, when the transaction is successfully created. Therefore, if the transaction creation fails, the fee is not available insideWalletModel::prepareTransactionto trigger theAmountWithFeeExceedsBalanceerror.
This PR re-implements the feature inside CreateTransactionInternal and adds test coverage for it.
| on master | on PR |
|---|---|
the unreachable code path is removed in https://github.com/bitcoin-core/gui/pull/807 which requires this PR.