From 802a0551911c070c1106eeed4b57a9de8d9cb2ff Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Fri, 31 May 2019 12:47:37 -0400 Subject: [PATCH] ScriptHasValidPAKProof takes fedpeg as arg --- src/primitives/pak.cpp | 11 ++--------- src/primitives/pak.h | 2 +- src/wallet/rpcwallet.cpp | 13 +++---------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/primitives/pak.cpp b/src/primitives/pak.cpp index 997fd0cd70..add8268f2b 100644 --- a/src/primitives/pak.cpp +++ b/src/primitives/pak.cpp @@ -92,18 +92,11 @@ void CPAKList::ToBytes(std::vector >& offline_keys, s // Proof follows the OP_RETURN // in multiple pushes: -bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash) +bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash, const CPAKList& paklist) { assert(script.IsPegoutScript(genesis_hash)); - CPAKList paklist; - if (g_paklist_config) { - paklist = *g_paklist_config; - } else { - paklist = g_paklist_blockchain; - } - - if (paklist.IsReject() || paklist.IsEmpty()) { + if (paklist.IsReject()) { return false; } diff --git a/src/primitives/pak.h b/src/primitives/pak.h index 35add8ee26..c9611fb5aa 100644 --- a/src/primitives/pak.h +++ b/src/primitives/pak.h @@ -59,7 +59,7 @@ public: ** given the PAK list. Two pushes after regular pegout script: ** **/ -bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash); +bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash, const CPAKList& paklist); CPAKList GetActivePAKList(const CBlockIndex* pblockindex, const Consensus::Params& params); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d7177cb30b..37dc4eda71 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5198,10 +5198,7 @@ UniValue sendtomainchain_pak(const JSONRPCRequest& request) subtract_fee = request.params[2].get_bool(); } - CPAKList paklist = g_paklist_blockchain; - if (g_paklist_config) { - paklist = *g_paklist_config; - } + CPAKList paklist = GetActivePAKList(chainActive.Tip(), Params().GetConsensus()); if (paklist.IsReject()) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pegout freeze is under effect to aid a pak transition to a new list. Please consult the network operator."); } @@ -5339,8 +5336,7 @@ UniValue sendtomainchain_pak(const JSONRPCRequest& request) CTxDestination address(nulldata); assert(GetScriptForDestination(nulldata).IsPegoutScript(genesisBlockHash)); - txnouttype txntype; - if (!IsStandard(GetScriptForDestination(nulldata), txntype)) { + if (!ScriptHasValidPAKProof(GetScriptForDestination(nulldata), Params().ParentGenesisBlockHash(), paklist)) { throw JSONRPCError(RPC_TYPE_ERROR, "Resulting scriptPubKey is non-standard. Ensure pak=reject is not set"); } @@ -6482,10 +6478,7 @@ UniValue generatepegoutproof(const JSONRPCRequest& request) if (!secp256k1_ec_pubkey_parse(secp256k1_ctx, &onlinepubkey_secp, &onlinepubkeybytes[0], onlinepubkeybytes.size())) throw JSONRPCError(RPC_WALLET_ERROR, "Invalid online pubkey"); - CPAKList paklist = g_paklist_blockchain; - if (g_paklist_config) { - paklist = *g_paklist_config; - } + CPAKList paklist = GetActivePAKList(chainActive.Tip(), Params().GetConsensus()); if (paklist.IsReject()) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pegout freeze is under effect to aid a pak transition to a new list. Please consult the network operator."); }