What changed, and why it matters
This commit fixes a bug in a Bitcoin Core benchmark test, not in the live network code. The benchmark was supposed to create a test transaction with multiple inputs spending outputs from a parent transaction, but due to a typo it kept writing all the input details to the first input slot only. The remaining inputs were left empty/default. The fix writes each input to its correct slot and adds a sanity check. It does not affect real Bitcoin transactions, wallets, or consensus rules.
No security action required. Treat as a normal code-quality/test-fix merge. Reviewers may optionally verify the benchmark now exercises the intended multi-input ephemeral-spend scenario.
Security signals we found
Bug is confined to benchmark code (src/bench/)
No change to consensus, mempool policy, P2P, wallet, or RPC code
No externally reachable attack surface introduced or removed
Fix adds an assertion, improving test correctness
Evidence from the diff
In src/bench/mempool_ephemeral_spends.cpp, the MempoolCheckEphemeralSpends benchmark loop intended to populate tx2.vin[i] with COutPoint(parent_txid, i). A copy-paste error used tx2.vin[0] on both lines, so only the first input was set and the rest retained default-constructed COutPoint values (null hash, n=0). The patch changes the index to i and adds an assert verifying the last input spends the last parent output. This is purely a test/benchmark correctness fix.
Changed components
src/bench/mempool_ephemeral_spends.cppMempoolCheckEphemeralSpends benchmarkInspect captured patch +3 / −2
diff --git a/src/bench/mempool_ephemeral_spends.cpp b/src/bench/mempool_ephemeral_spends.cpp
index f0d8eb0b..1c069287 100644
--- a/src/bench/mempool_ephemeral_spends.cpp
+++ b/src/bench/mempool_ephemeral_spends.cpp
@@ -59,8 +59,8 @@ static void MempoolCheckEphemeralSpends(benchmark::Bench& bench)
CMutableTransaction tx2;
tx2.vin.resize(tx1.vout.size());
for (size_t i = 0; i < tx2.vin.size(); i++) {
- tx2.vin[0].prevout.hash = parent_txid;
- tx2.vin[0].prevout.n = i;
+ tx2.vin[i].prevout.hash = parent_txid;
+ tx2.vin[i].prevout.n = i;
}
tx2.vout.resize(1);
@@ -71,6 +71,7 @@ static void MempoolCheckEphemeralSpends(benchmark::Bench& bench)
const CTransactionRef tx2_r{MakeTransactionRef(tx2)};
AddTx(tx1_r, pool);
+ assert(tx2_r->vin.back().prevout == COutPoint(parent_txid, tx1_r->vout.size() - 1));
uint32_t iteration{0};
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.