mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
ScriptHasValidPAKProof takes fedpeg as arg
This commit is contained in:
parent
144d486220
commit
fac525bac6
3 changed files with 6 additions and 20 deletions
|
|
@ -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>
|
// Proof follows the OP_RETURN <genesis_block_hash> <destination_scriptpubkey>
|
||||||
// in multiple pushes: <full_pubkey> <proof>
|
// 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));
|
assert(script.IsPegoutScript(genesis_hash));
|
||||||
|
|
||||||
CPAKList paklist;
|
if (paklist.IsReject()) {
|
||||||
if (g_paklist_config) {
|
|
||||||
paklist = *g_paklist_config;
|
|
||||||
} else {
|
|
||||||
paklist = g_paklist_blockchain;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paklist.IsReject() || paklist.IsEmpty()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public:
|
||||||
** given the PAK list. Two pushes after regular pegout script:
|
** given the PAK list. Two pushes after regular pegout script:
|
||||||
** <full_pubkey> <proof>
|
** <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);
|
CPAKList GetActivePAKList(const CBlockIndex* pblockindex, const Consensus::Params& params);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5193,10 +5193,7 @@ UniValue sendtomainchain_pak(const JSONRPCRequest& request)
|
||||||
subtract_fee = request.params[2].get_bool();
|
subtract_fee = request.params[2].get_bool();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPAKList paklist = g_paklist_blockchain;
|
CPAKList paklist = GetActivePAKList(chainActive.Tip(), Params().GetConsensus());
|
||||||
if (g_paklist_config) {
|
|
||||||
paklist = *g_paklist_config;
|
|
||||||
}
|
|
||||||
if (paklist.IsReject()) {
|
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.");
|
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.");
|
||||||
}
|
}
|
||||||
|
|
@ -5334,8 +5331,7 @@ UniValue sendtomainchain_pak(const JSONRPCRequest& request)
|
||||||
CTxDestination address(nulldata);
|
CTxDestination address(nulldata);
|
||||||
assert(GetScriptForDestination(nulldata).IsPegoutScript(genesisBlockHash));
|
assert(GetScriptForDestination(nulldata).IsPegoutScript(genesisBlockHash));
|
||||||
|
|
||||||
txnouttype txntype;
|
if (!ScriptHasValidPAKProof(GetScriptForDestination(nulldata), Params().ParentGenesisBlockHash(), paklist)) {
|
||||||
if (!IsStandard(GetScriptForDestination(nulldata), txntype)) {
|
|
||||||
throw JSONRPCError(RPC_TYPE_ERROR, "Resulting scriptPubKey is non-standard. Ensure pak=reject is not set");
|
throw JSONRPCError(RPC_TYPE_ERROR, "Resulting scriptPubKey is non-standard. Ensure pak=reject is not set");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6477,10 +6473,7 @@ UniValue generatepegoutproof(const JSONRPCRequest& request)
|
||||||
if (!secp256k1_ec_pubkey_parse(secp256k1_ctx, &onlinepubkey_secp, &onlinepubkeybytes[0], onlinepubkeybytes.size()))
|
if (!secp256k1_ec_pubkey_parse(secp256k1_ctx, &onlinepubkey_secp, &onlinepubkeybytes[0], onlinepubkeybytes.size()))
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Invalid online pubkey");
|
throw JSONRPCError(RPC_WALLET_ERROR, "Invalid online pubkey");
|
||||||
|
|
||||||
CPAKList paklist = g_paklist_blockchain;
|
CPAKList paklist = GetActivePAKList(chainActive.Tip(), Params().GetConsensus());
|
||||||
if (g_paklist_config) {
|
|
||||||
paklist = *g_paklist_config;
|
|
||||||
}
|
|
||||||
if (paklist.IsReject()) {
|
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.");
|
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.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue