]> Untitled Git - bdk/commit
fix(wallet): off-by-one error checking coinbase maturity in optional UTxOs
authornymius <155548262+nymius@users.noreply.github.com>
Wed, 12 Feb 2025 19:44:15 +0000 (16:44 -0300)
committernymius <155548262+nymius@users.noreply.github.com>
Wed, 12 Feb 2025 19:44:15 +0000 (16:44 -0300)
commit03b7ecaea1176f55c6792d8798ead72b23082af7
tree6221d7446c797f0c0a6937e611c163959ac76f69
parent7067da1522c5c2ae4e457846cfe5bd6aefafbe9e
fix(wallet): off-by-one error checking coinbase maturity in optional UTxOs

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.
crates/wallet/src/wallet/mod.rs
crates/wallet/src/wallet/tx_builder.rs
crates/wallet/tests/wallet.rs