Fix #2040: Update Balance immature calculation for MTP-based maturity#2226
Open
kallal79 wants to merge 1 commit into
Open
Fix #2040: Update Balance immature calculation for MTP-based maturity#2226kallal79 wants to merge 1 commit into
kallal79 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes #2040 by updating the
Balanceimmature category calculation to consider Median Time Past (MTP) based maturity for time-locked transactions.Previously,
Balance.immatureonly tracked coinbase outputs that hadn't reached 100 block confirmations, ignoring absolute time-locks (nLockTime). With this change, time-locked transactions (those with absolutenLockTime >= 500,000,000) are also properly classified as immature until the chain tip's MTP exceeds their locktime.Changes made:
lock_time: LockTimeto theFullTxOutstruct incrates/chain/src/chain_data.rs.is_mature_at_mtp()andis_confirmed_and_spendable_at_mtp()onFullTxOutto handle time-based locktime checks against an optionalmtpparameter.CanonicalView::balance()to safely accept anmtp: Option<u32>and delegate to the new MTP maturity checks.Balancedocumentation incrates/chain/src/balance.rsto reflect the updated classification definition.Nonefor MTP in older benchmarks/tests, maintaining compatibility.test_balance_mtp_maturityintest_indexed_tx_graph.rsto explicitly verify time-locked outputs accurately shift fromimmaturetoconfirmedas the MTP increases past the locktime.Notes to the reviewers
Because MTP isn't always available (e.g. missing block timestamps in some local state), the new
balance()parameter usesOption<u32>. IfNoneis provided, time-locked transactions are conservatively classified as immature to avoid falsely showing them as confirmed and spendable.Changelog notice
Balanceimmature tracking to accurately calculate maturity for transactions utilizing absolute MTP-based time-locks (Issue Update Balance immature category calculation to consider MTP-based maturity #2040).Checklists
All Submissions:
New Features:
Bugfixes: