diff --git a/src/primitives/pak.cpp b/src/primitives/pak.cpp index afe16c6fa7..bb2f6c0eb9 100644 --- a/src/primitives/pak.cpp +++ b/src/primitives/pak.cpp @@ -199,21 +199,20 @@ CPAKList GetActivePAKList(const CBlockIndex* pblockindex, const Consensus::Param return CreatePAKListFromExtensionSpace(ComputeNextBlockFullCurrentParameters(pblockindex, params).m_extension_space); } -bool IsPAKValidOutput(const CTxOut& txout, const CPAKList& paklist) +bool IsPAKValidOutput(const CTxOut& txout, const CPAKList& paklist, const uint256& parent_gen_hash, const CAsset& peg_asset) { - const CChainParams& params = Params(); - if (txout.scriptPubKey.IsPegoutScript(params.ParentGenesisBlockHash()) && - txout.nAsset.IsExplicit() && txout.nAsset.GetAsset() == params.GetConsensus().pegged_asset && - (!ScriptHasValidPAKProof(txout.scriptPubKey, params.ParentGenesisBlockHash(), paklist))) { + if (txout.scriptPubKey.IsPegoutScript(parent_gen_hash) && + txout.nAsset.IsExplicit() && txout.nAsset.GetAsset() == peg_asset && + (!ScriptHasValidPAKProof(txout.scriptPubKey, parent_gen_hash, paklist))) { return false; } return true; } -bool IsPAKValidTx(const CTransaction& tx, const CPAKList& paklist) +bool IsPAKValidTx(const CTransaction& tx, const CPAKList& paklist, const uint256& parent_gen_hash, const CAsset& peg_asset) { for (const auto& txout : tx.vout) { - if (!IsPAKValidOutput(txout, paklist)) { + if (!IsPAKValidOutput(txout, paklist, parent_gen_hash, peg_asset)) { return false; } } diff --git a/src/primitives/pak.h b/src/primitives/pak.h index 2a24a86be0..1026bb0675 100644 --- a/src/primitives/pak.h +++ b/src/primitives/pak.h @@ -65,8 +65,8 @@ CPAKList CreatePAKListFromExtensionSpace(const std::vector& vtx, unsigne std::vector tx_to_remove; for (const auto& entry : mapTx) { const CTransaction& tx = entry.GetTx(); - if (chainparams.GetEnforcePak() && !IsPAKValidTx(tx, enforced_paklist)) { + if (chainparams.GetEnforcePak() && !IsPAKValidTx(tx, enforced_paklist, chainparams.ParentGenesisBlockHash(), chainparams.GetConsensus().pegged_asset)) { tx_to_remove.push_back(MakeTransactionRef(tx)); continue; } diff --git a/src/validation.cpp b/src/validation.cpp index 06a18fdc3a..01671f9a1d 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -611,7 +611,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool // And now do PAK checks. Filtered by next blocks' enforced list if (chainparams.GetEnforcePak()) { - if (!IsPAKValidTx(tx, GetActivePAKList(chainActive.Tip(), chainparams.GetConsensus()))) { + if (!IsPAKValidTx(tx, GetActivePAKList(chainActive.Tip(), chainparams.GetConsensus()), chainparams.ParentGenesisBlockHash(), chainparams.GetConsensus().pegged_asset)) { return state.DoS(0, false, REJECT_NONSTANDARD, "invalid-pegout-proof"); } } @@ -2135,7 +2135,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl // GetActivePAKList computes for the following block, so use previous index CPAKList paklist = GetActivePAKList(pindex->pprev, chainparams.GetConsensus()); for (const auto& tx : block.vtx) { - if (!IsPAKValidTx(*tx, paklist)) { + if (!IsPAKValidTx(*tx, paklist, chainparams.ParentGenesisBlockHash(), chainparams.GetConsensus().pegged_asset)) { return state.DoS(100, error("ConnectBlock(): Bad PAK transaction"), REJECT_INVALID, "bad-pak-tx"); } }