Skip to content

Commit 266134a

Browse files
committed
[Validation] Reject txes if double spending nullifier in mempool
1 parent c74e86e commit 266134a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/validation.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
339339
if (!IsStandardTx(tx, nextBlockHeight, reason))
340340
return state.DoS(0, false, REJECT_NONSTANDARD, reason);
341341
// is it already in the memory pool?
342-
uint256 hash = tx.GetHash();
342+
const uint256& hash = tx.GetHash();
343343
if (pool.exists(hash)) {
344344
return state.Invalid(false, REJECT_ALREADY_KNOWN, "txn-already-in-mempool");
345345
}
@@ -358,7 +358,13 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
358358
}
359359
}
360360

361-
// TODO check sapling nullifiers
361+
// Check sapling nullifiers
362+
if (tx.IsShieldedTx()) {
363+
for (const auto& sd : tx.sapData->vShieldedSpend) {
364+
if (pool.nullifierExists(sd.nullifier))
365+
return state.Invalid(false, REJECT_INVALID, "bad-txns-nullifier-double-spent");
366+
}
367+
}
362368

363369
{
364370
CCoinsView dummy;

0 commit comments

Comments
 (0)