Merge pull request #5788 from daira/orchard-nullifier-check
Orchard nullifier and anchor consistency checks
This commit is contained in:
commit
a4cc6ad3d0
20
src/main.cpp
20
src/main.cpp
|
@ -1823,7 +1823,13 @@ bool AcceptToMemoryPool(
|
||||||
if (pool.exists(hash))
|
if (pool.exists(hash))
|
||||||
return state.Invalid(false, REJECT_ALREADY_KNOWN, "txn-already-in-mempool");
|
return state.Invalid(false, REJECT_ALREADY_KNOWN, "txn-already-in-mempool");
|
||||||
|
|
||||||
// Check for conflicts with in-memory transactions
|
// Check for conflicts with in-memory transactions.
|
||||||
|
// This is redundant with the call to HaveInputs (for non-coinbase transactions)
|
||||||
|
// below, but we do it here for consistency with Bitcoin and because this check
|
||||||
|
// doesn't require loading the coins view.
|
||||||
|
// We don't do the corresponding check for nullifiers, because that would also
|
||||||
|
// be redundant, and we have no need to avoid semantic conflicts with Bitcoin
|
||||||
|
// backports in the case of the shielded protocol.
|
||||||
for (unsigned int i = 0; i < tx.vin.size(); i++)
|
for (unsigned int i = 0; i < tx.vin.size(); i++)
|
||||||
{
|
{
|
||||||
COutPoint outpoint = tx.vin[i].prevout;
|
COutPoint outpoint = tx.vin[i].prevout;
|
||||||
|
@ -1833,18 +1839,6 @@ bool AcceptToMemoryPool(
|
||||||
return state.Invalid(false, REJECT_CONFLICT, "txn-mempool-conflict");
|
return state.Invalid(false, REJECT_CONFLICT, "txn-mempool-conflict");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const JSDescription &joinsplit : tx.vJoinSplit) {
|
|
||||||
for (const uint256 &nf : joinsplit.nullifiers) {
|
|
||||||
if (pool.nullifierExists(nf, SPROUT)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const SpendDescription &spendDescription : tx.vShieldedSpend) {
|
|
||||||
if (pool.nullifierExists(spendDescription.nullifier, SAPLING)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
CCoinsView dummy;
|
CCoinsView dummy;
|
||||||
|
|
|
@ -652,6 +652,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||||
|
|
||||||
checkNullifiers(SPROUT);
|
checkNullifiers(SPROUT);
|
||||||
checkNullifiers(SAPLING);
|
checkNullifiers(SAPLING);
|
||||||
|
checkNullifiers(ORCHARD);
|
||||||
|
|
||||||
assert(totalTxSize == checkTotal);
|
assert(totalTxSize == checkTotal);
|
||||||
assert(innerUsage == cachedInnerUsage);
|
assert(innerUsage == cachedInnerUsage);
|
||||||
|
|
Loading…
Reference in New Issue