Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoindevkit#1830: Fix off-by-one error checking coinbase matu…
…rity in optional UTxOs 03b7eca fix(wallet): off-by-one error checking coinbase maturity in optional UTxOs (nymius) Pull request description: ### Description As I was developing the changes in bitcoindevkit#1798 I discover issue bitcoindevkit#1810. So I introduced the fixes in that PR but later I split them in two to ease the review by suggestion of @oleonardolima . The `preselect_utxos` method has an off-by-one error that is making the selection of optional UTxOs too restrictive, by requiring the coinbase outputs to surpass or equal coinbase maturity time at the current height of the selection, and not in the block in which the transaction may be included in the blockchain. The changes in this commit fix it by considering the maturity of the coinbase output at the spending height and not the transaction creation height, this means, a +1 at the considered height at the moment of building the transaction. Fixes bitcoindevkit#1810. ### Notes to the reviewers Tests for issue bitcoindevkit#1810 have not been explicitly added, as there already was a `text_spend_coinbase` test which was corrected to ensure coinbase maturation is considered in alignment with the new logic. Changes are not breaking but I'm modifying slightly the documentation for the public method `TxBuilder::current_height` to adjust to the fixed code. Does this merit an entry in the CHANGELOG? ### Changelog notice `Wallet` now considers a utxo originated from a coinbase transaction (`coinbase utxo`) as available for selection if it will mature in the next block after the height provided to the selection, the current height by default. The previous behavior allowed selecting a `coinbase utxo` only when the height at the moment of selection was equal to maturity height or greater. ### Checklists * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing * [x] I've updated existing tests to match the fix * [x] I've updated docs to match the fix logic * [x] This pull request DOES NOT break the existing API * [x] I'm linking the issue being fixed by this PR ACKs for top commit: LagginTimes: ACK 03b7eca evanlinjin: ACK 03b7eca Tree-SHA512: f270b73963bd6f141c8a3e759bc9b9bf75de7c52f37fff93f0a6b8b996b449d98c58e5eeb2b56f0ee236222f0807da5c8201ade7462813743e0c4d255313e2b5
- Loading branch information