mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
After a reorg, boot all peg-ins and peg-outs from mempool
This commit is contained in:
parent
9a3b9b9cfd
commit
a7dc478ba2
2 changed files with 22 additions and 0 deletions
|
|
@ -521,6 +521,24 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
|
||||||
if (!validLP) {
|
if (!validLP) {
|
||||||
mapTx.modify(it, update_lock_points(lp));
|
mapTx.modify(it, update_lock_points(lp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On re-org, remove *all* peg-in and PAK-based peg-outs due to possible
|
||||||
|
// invalidity from dynafed transitions
|
||||||
|
// TODO: Only boot out now-invalid transactions. Re-orgs are very rare in
|
||||||
|
// federated systems but can occasionally happen due to consensus algorithm.
|
||||||
|
|
||||||
|
// Little hack to quickly check if any outputs are PAK ones
|
||||||
|
// by sending in empty(reject) list.
|
||||||
|
if (!IsPAKValidTx(tx, CPAKList())) {
|
||||||
|
txToRemove.insert(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const auto& input : tx.vin) {
|
||||||
|
if (input.m_is_pegin) {
|
||||||
|
txToRemove.insert(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setEntries setAllRemoves;
|
setEntries setAllRemoves;
|
||||||
for (txiter it : txToRemove) {
|
for (txiter it : txToRemove) {
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,10 @@ class FedPegTest(BitcoinTestFramework):
|
||||||
if sidechain.gettransaction(pegtxid1)["confirmations"] != 0:
|
if sidechain.gettransaction(pegtxid1)["confirmations"] != 0:
|
||||||
raise Exception("Peg-in didn't unconfirm after invalidateblock call.")
|
raise Exception("Peg-in didn't unconfirm after invalidateblock call.")
|
||||||
|
|
||||||
|
# Re-org causes peg-ins to get booted(wallet will resubmit in 10 minutes)
|
||||||
|
assert_equal(sidechain.getrawmempool(), [])
|
||||||
|
sidechain.sendrawtransaction(tx1["hex"])
|
||||||
|
|
||||||
# Create duplicate claim, put it in block along with current one in mempool
|
# Create duplicate claim, put it in block along with current one in mempool
|
||||||
# to test duplicate-in-block claims between two txs that are in the same block.
|
# to test duplicate-in-block claims between two txs that are in the same block.
|
||||||
raw_pegin = sidechain.createrawpegin(raw, proof)["hex"]
|
raw_pegin = sidechain.createrawpegin(raw, proof)["hex"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue