mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
wallet: Assert that enough was selected to cover the fees
When the fee is not subtracted from the outputs, the amount that has been reserved for the fee (change_and_fee - change_amount) must be enough to cover the fee that is needed. It would be a bug to not do so, so use an assert to make this obvious if such a situation were to occur.
This commit is contained in:
parent
2de222c401
commit
d9262324e8
1 changed files with 4 additions and 0 deletions
|
@ -778,6 +778,10 @@ bool CWallet::CreateTransactionInternal(
|
|||
fee_needed = coin_selection_params.m_effective_feerate.GetFee(nBytes);
|
||||
}
|
||||
|
||||
// The only time that fee_needed should be less than the amount available for fees (in change_and_fee - change_amount) is when
|
||||
// we are subtracting the fee from the outputs. If this occurs at any other time, it is a bug.
|
||||
assert(coin_selection_params.m_subtract_fee_outputs || fee_needed <= change_and_fee - change_amount);
|
||||
|
||||
// Update nFeeRet in case fee_needed changed due to dropping the change output
|
||||
if (fee_needed <= change_and_fee - change_amount) {
|
||||
nFeeRet = change_and_fee - change_amount;
|
||||
|
|
Loading…
Add table
Reference in a new issue