diff options
author | glozow <gloriajzhao@gmail.com> | 2021-12-17 14:06:16 +0000 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2022-01-17 12:17:50 +0000 |
commit | 83d4fb71260f268abd41d083fb3458476aed83ce (patch) | |
tree | 14c718c311681de8a09e235ec74b280caa630685 /src/validation.cpp | |
parent | 38146a4bd2e55973dbc7c4716b1815e204adbf84 (diff) | |
download | bitcoin-83d4fb71260f268abd41d083fb3458476aed83ce.tar.xz |
[packages] return DIFFERENT_WITNESS for same-txid-different-witness tx
The previous interface required callers to guess that the tx had been
swapped and look up the tx again by txid to find a `MEMPOOL_ENTRY`
result. This is a confusing interface.
Instead, explicitly tell the caller that this transaction was
`DIFFERENT_WITNESS` in the result linked to the mempool entry's wtxid.
This gives the caller all the information they need in 1 lookup, and
they can query the mempool for the other transaction if needed.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index a98ffe006d..616873057c 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1274,9 +1274,10 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package, // transaction for the mempool one. Note that we are ignoring the validity of the // package transaction passed in. // TODO: allow witness replacement in packages. - auto iter = m_pool.GetIter(wtxid); + auto iter = m_pool.GetIter(txid); assert(iter != std::nullopt); - results.emplace(txid, MempoolAcceptResult::MempoolTx(iter.value()->GetTxSize(), iter.value()->GetFee())); + // Provide the wtxid of the mempool tx so that the caller can look it up in the mempool. + results.emplace(wtxid, MempoolAcceptResult::MempoolTxDifferentWitness(iter.value()->GetTx().GetWitnessHash())); } else { // Transaction does not already exist in the mempool. txns_new.push_back(tx); |