fix: chained DD transfers fail — mempool DD input amount resolution (Bug #35)#400
Merged
JaredTate merged 1 commit intoDigiByte-Core:feature/digidollar-v1from Apr 14, 2026
Conversation
…yte-Core#35) The DD conservation validator could not determine input DD amounts when the creating transaction was still in the mempool (unconfirmed). All three existing lookup strategies fail for mempool txs: 1. txindex — only indexes confirmed blocks 2. block-db — tx not in any block yet 3. scriptPubKey metadata — P2TR scripts don't encode DD amounts This caused back-to-back DD transfers to fail with "transfer-dd-conservation-violation" because the second transfer's input (the first transfer's change output) had its DD amount silently dropped from the conservation sum. Add mempool transaction lookup as strategy 0 (before txindex). Mempool txs have already passed full validation so their OP_RETURN is trustworthy. Pass the mempool pointer via ValidationContext from MemPoolAccept::PreChecks, where it is naturally available. Applied to both the transfer conservation check and the redemption DD input extraction paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks @JohnnyLawDGB — nice clean fix. Reviewed the diff and traced the code paths. The bug is confirmed real: all three DD amount lookup strategies ( The fix is correct and well-scoped:
CI failures are unrelated (pre-existing MuSig2 test compilation issue in LGTM — approved for merge. |
6105963
into
DigiByte-Core:feature/digidollar-v1
0 of 2 checks passed
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.
Summary
transfer-dd-conservation-violationbecause the validator can't determine DD amounts from inputs whose creating transaction is still in the mempoolvalidation.cpp:1280-1305fail for unconfirmed parent txs:txindexonly indexes confirmed blocks, block-db lookup can't find mempool txs, and P2TR scripts don't encode DD amounts. The input's DD amount is silently dropped from the conservation sum.CTxMemPool::get()retrieves the unconfirmed parent tx, thenExtractDDAmountFromTxRef()parses its OP_RETURN — same trustworthy path used for confirmed txs. The mempool pointer is passed viaValidationContextfromMemPoolAccept::PreCheckswhere it's naturally available.Reproduction
Changes
src/digidollar/validation.hconst CTxMemPool* mempooltoValidationContext, forward-declareCTxMemPoolsrc/digidollar/validation.cppExtractDDAmountFromMempool()helper; insert mempool lookup as strategy 0 in both transfer conservation check and redemption DD input extractionsrc/validation.cpp&m_poolwhen constructingValidationContextinMemPoolAccept::PreChecksSafety
CTxMemPool::get()takes its own lock (LOCK(cs)) — no external lock ordering concernsnullptrfor mempool (unchanged behavior)falsequickly and falls through to txindex/block-dbTest plan
🤖 Generated with Claude Code