mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
Add withdraw-claimed tracking to mempool and enforce it
This commit is contained in:
parent
16063366d9
commit
79d422acfa
4 changed files with 56 additions and 5 deletions
18
src/main.cpp
18
src/main.cpp
|
|
@ -1228,6 +1228,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
|||
{
|
||||
CCoinsView dummy;
|
||||
CCoinsViewCache view(&dummy);
|
||||
std::set<std::pair<uint256, COutPoint> > setWithdrawsSpent;
|
||||
|
||||
CAmount nValueIn = 0;
|
||||
LockPoints lp;
|
||||
|
|
@ -1261,6 +1262,18 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
|||
if (!view.HaveInputs(tx))
|
||||
return state.Invalid(false, REJECT_DUPLICATE, "bad-txns-inputs-spent");
|
||||
|
||||
BOOST_FOREACH(const CTxIn &txin, tx.vin)
|
||||
{
|
||||
CCoins coins;
|
||||
assert(view.GetCoins(txin.prevout.hash, coins));
|
||||
if (coins.vout[txin.prevout.n].scriptPubKey.IsWithdrawLock() && txin.scriptSig.IsWithdrawProof()) {
|
||||
pair<uint256, COutPoint> outpoint = make_pair(coins.vout[txin.prevout.n].scriptPubKey.GetWithdrawLockGenesisHash(), txin.scriptSig.GetWithdrawSpent());
|
||||
if (view.IsWithdrawSpent(outpoint))
|
||||
return state.Invalid(false, REJECT_CONFLICT, "withdraw-already-claimed");
|
||||
setWithdrawsSpent.insert(outpoint);
|
||||
}
|
||||
}
|
||||
|
||||
// Bring the best block into scope
|
||||
view.GetBestBlock();
|
||||
|
||||
|
|
@ -1309,7 +1322,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
|||
}
|
||||
}
|
||||
|
||||
CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), pool.HasNoInputsOf(tx), inChainInputValue, fSpendsCoinbase, nSigOpsCost, lp);
|
||||
CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), pool.HasNoInputsOf(tx), inChainInputValue, fSpendsCoinbase, nSigOpsCost, lp, setWithdrawsSpent);
|
||||
unsigned int nSize = entry.GetTxSize();
|
||||
|
||||
// Check that the transaction doesn't have an excessive number of
|
||||
|
|
@ -1533,6 +1546,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
|||
return false;
|
||||
}
|
||||
|
||||
assert(setWithdrawsSpent2 == setWithdrawsSpent);
|
||||
setWithdrawsSpent2.clear();
|
||||
|
||||
// Check again against just the consensus-critical mandatory script
|
||||
|
|
@ -1550,6 +1564,8 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
|||
__func__, hash.ToString(), FormatStateMessage(state));
|
||||
}
|
||||
|
||||
assert(setWithdrawsSpent2 == setWithdrawsSpent);
|
||||
|
||||
// Remove conflicting transactions from the mempool
|
||||
BOOST_FOREACH(const CTxMemPool::txiter it, allConflicting)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue