From 2eeeaf0e6491ef9111541441ab4fb9950038abf5 Mon Sep 17 00:00:00 2001 From: JohnnyLawDGB Date: Sun, 12 Apr 2026 07:03:37 -0500 Subject: [PATCH] fix: resolve DD amounts from mempool for chained transfers (Bug #35) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/digidollar/validation.cpp | 36 +++++++++++++++++++++++++++++++++++ src/digidollar/validation.h | 7 +++++-- src/validation.cpp | 3 ++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/digidollar/validation.cpp b/src/digidollar/validation.cpp index 2c7f6ebd49..85bac7f956 100644 --- a/src/digidollar/validation.cpp +++ b/src/digidollar/validation.cpp @@ -15,6 +15,7 @@ using DigiDollar::GetScriptMetadata; #include #include #include // For decentralized DD amount lookup via g_txindex +#include // For mempool DD amount lookup (Bug #35) #include