mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge pull request #1209 from psgreco/master-wsh-dynafed
Allow deploying regtest networks with p2wsh peg-ins
This commit is contained in:
commit
a47f465847
4 changed files with 16 additions and 4 deletions
|
|
@ -862,6 +862,7 @@ protected:
|
|||
|
||||
const CScript default_script(CScript() << OP_TRUE);
|
||||
consensus.fedpegScript = StrHexToScriptWithDefault(args.GetArg("-fedpegscript", ""), default_script);
|
||||
consensus.start_p2wsh_script = args.GetArg("-con_start_p2wsh_script", consensus.start_p2wsh_script);
|
||||
|
||||
// Calculate pegged Bitcoin asset
|
||||
std::vector<unsigned char> commit = CommitToArguments(consensus, strNetworkID);
|
||||
|
|
@ -1460,6 +1461,7 @@ public:
|
|||
if (args.IsArgSet("-fedpegscript")) {
|
||||
consensus.fedpegScript = StrHexToScriptWithDefault(args.GetArg("-fedpegscript", ""), CScript());
|
||||
}
|
||||
consensus.start_p2wsh_script = args.GetArg("-con_start_p2wsh_script", consensus.start_p2wsh_script);
|
||||
|
||||
consensus.total_valid_epochs = args.GetArg("-total_valid_epochs", consensus.total_valid_epochs);
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
|
|||
argsman.AddArg("-dynamic_epoch_length", "Per-chain parameter that sets how many blocks dynamic federation voting and enforcement are in effect for.", ArgsManager::ALLOW_ANY, OptionsCategory::ELEMENTS);
|
||||
argsman.AddArg("-total_valid_epochs", "Per-chain parameter that sets how long a particular fedpegscript is in effect for.", ArgsManager::ALLOW_ANY, OptionsCategory::ELEMENTS);
|
||||
argsman.AddArg("-evbparams=deployment:start:end:period:threshold", "Use given start/end times for specified version bits deployment (regtest or custom only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::ELEMENTS);
|
||||
argsman.AddArg("-con_start_p2wsh_script", "Create p2wsh addresses when starting in dynafed mode (regtest or custom only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::ELEMENTS);
|
||||
// END ELEMENTS
|
||||
//
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ struct Params {
|
|||
// default 1 to not break legacy chains implicitly.
|
||||
size_t total_valid_epochs = 1;
|
||||
bool elements_mode = false;
|
||||
bool start_p2wsh_script = false;
|
||||
};
|
||||
|
||||
} // namespace Consensus
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ DynaFedParamEntry ComputeNextBlockFullCurrentParameters(const CBlockIndex* pinde
|
|||
epoch_start_height -= epoch_length;
|
||||
}
|
||||
|
||||
if (consensus.genesis_style == "elements" && epoch_start_height == 0 && next_height > 1 && consensus.vDeployments[Consensus::DEPLOYMENT_DYNA_FED].nStartTime == Consensus::BIP9Deployment::ALWAYS_ACTIVE) {
|
||||
// when starting in dynafed mode, the full parameters are stored in block 1 instead of 0
|
||||
epoch_start_height = 1;
|
||||
}
|
||||
// We need to put in place the previous epoch's current which
|
||||
// may be pre-dynafed params
|
||||
const CBlockIndex* p_epoch_start = pindexPrev->GetAncestor(epoch_start_height);
|
||||
|
|
@ -69,11 +73,15 @@ DynaFedParamEntry ComputeNextBlockFullCurrentParameters(const CBlockIndex* pinde
|
|||
uint256 fedpegscript_redeemscript;
|
||||
CSHA256().Write(consensus.fedpegScript.data(), consensus.fedpegScript.size()).Finalize(fedpegscript_redeemscript.begin());
|
||||
CScript fedpeg_p2sw = CScript() << OP_0 << ToByteVector(fedpegscript_redeemscript);
|
||||
uint160 fedpeg_p2sh(Hash160(fedpeg_p2sw));
|
||||
CScript sh_wsh_fedpeg_program = CScript() << OP_HASH160 << ToByteVector(fedpeg_p2sh) << OP_EQUAL;
|
||||
if (consensus.start_p2wsh_script) {
|
||||
winning_proposal = DynaFedParamEntry(p2wsh_signblock_script, consensus.max_block_signature_size, fedpeg_p2sw, consensus.fedpegScript, consensus.first_extension_space);
|
||||
} else {
|
||||
uint160 fedpeg_p2sh(Hash160(fedpeg_p2sw));
|
||||
CScript sh_wsh_fedpeg_program = CScript() << OP_HASH160 << ToByteVector(fedpeg_p2sh) << OP_EQUAL;
|
||||
|
||||
// Put them in winning proposal
|
||||
winning_proposal = DynaFedParamEntry(p2wsh_signblock_script, consensus.max_block_signature_size, sh_wsh_fedpeg_program, consensus.fedpegScript, consensus.first_extension_space);
|
||||
// Put them in winning proposal
|
||||
winning_proposal = DynaFedParamEntry(p2wsh_signblock_script, consensus.max_block_signature_size, sh_wsh_fedpeg_program, consensus.fedpegScript, consensus.first_extension_space);
|
||||
}
|
||||
} else {
|
||||
winning_proposal = p_epoch_start->dynafed_params().m_current;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue