|
17 | 17 | #include <util.h> |
18 | 18 | #include <utilmoneystr.h> |
19 | 19 | #include <utiltime.h> |
| 20 | +#include <chainparams.h> // removeForBlock paklist transition |
20 | 21 |
|
21 | 22 | CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& _tx, const CAmount& _nFee, |
22 | 23 | int64_t _nTime, unsigned int _entryHeight, |
@@ -569,7 +570,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx) |
569 | 570 | /** |
570 | 571 | * Called when a block is connected. Removes from mempool and updates the miner fee estimator. |
571 | 572 | */ |
572 | | -void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight, const std::set<std::pair<uint256, COutPoint>>& setPeginsSpent) |
| 573 | +void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight, const std::set<std::pair<uint256, COutPoint>>& setPeginsSpent, bool pak_transition) |
573 | 574 | { |
574 | 575 | LOCK(cs); |
575 | 576 | std::vector<const CTxMemPoolEntry*> entries; |
@@ -611,7 +612,25 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne |
611 | 612 | ClearPrioritisation(tx_id); |
612 | 613 | } |
613 | 614 | } |
614 | | - |
| 615 | + // Eject any newly-invalid peg-outs based on changing block commitment |
| 616 | + const CChainParams& chainparams = Params(); |
| 617 | + if (pak_transition && !gArgs.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard())) { |
| 618 | + for (const auto& entry : mapTx) { |
| 619 | + for (const auto& out : entry.GetTx().vout) { |
| 620 | + if (out.scriptPubKey.IsPegoutScript(Params().ParentGenesisBlockHash()) && |
| 621 | + !ScriptHasValidPAKProof(out.scriptPubKey, Params().ParentGenesisBlockHash())) { |
| 622 | + txiter it = mapTx.find(entry.GetTx().GetHash()); |
| 623 | + const CTransaction& tx = it->GetTx(); |
| 624 | + setEntries stage; |
| 625 | + stage.insert(it); |
| 626 | + RemoveStaged(stage, true, MemPoolRemovalReason::BLOCK); |
| 627 | + removeRecursive(tx, MemPoolRemovalReason::BLOCK); |
| 628 | + ClearPrioritisation(tx.GetHash()); |
| 629 | + break; |
| 630 | + } |
| 631 | + } |
| 632 | + } |
| 633 | + } |
615 | 634 | lastRollingFeeUpdate = GetTime(); |
616 | 635 | blockSinceLastRollingFeeBump = true; |
617 | 636 | } |
|
0 commit comments