Skip to content

Commit

Permalink
ScriptHasValidPAKProof takes fedpeg as arg
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Sep 3, 2019
1 parent 89174e9 commit 802a055
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
11 changes: 2 additions & 9 deletions src/primitives/pak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,11 @@ void CPAKList::ToBytes(std::vector<std::vector<unsigned char> >& offline_keys, s

// Proof follows the OP_RETURN <genesis_block_hash> <destination_scriptpubkey>
// in multiple pushes: <full_pubkey> <proof>
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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/primitives/pak.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CPAKList
** given the PAK list. Two pushes after regular pegout script:
** <full_pubkey> <proof>
**/
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);

Expand Down
13 changes: 3 additions & 10 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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.");
}
Expand Down

0 comments on commit 802a055

Please sign in to comment.