mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
subsidy: add chainparams and init
This commit is contained in:
parent
f3b63f4b8c
commit
94cde59dc3
3 changed files with 104 additions and 1 deletions
|
|
@ -7,12 +7,13 @@
|
|||
|
||||
#include <chainparamsseeds.h>
|
||||
#include <consensus/merkle.h>
|
||||
#include <crypto/sha256.h>
|
||||
#include <deploymentinfo.h>
|
||||
#include <hash.h> // for signet block challenge hash
|
||||
#include <issuance.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/system.h>
|
||||
#include <crypto/sha256.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
|
@ -232,6 +233,8 @@ public:
|
|||
multi_data_permitted = false;
|
||||
accept_discount_ct = false;
|
||||
create_discount_ct = false;
|
||||
pegin_subsidy = PeginSubsidy();
|
||||
pegin_minimum = PeginMinimum();
|
||||
consensus.has_parent_chain = false;
|
||||
g_signed_blocks = false;
|
||||
g_con_elementsmode = false;
|
||||
|
|
@ -379,6 +382,8 @@ public:
|
|||
multi_data_permitted = false;
|
||||
accept_discount_ct = false;
|
||||
create_discount_ct = false;
|
||||
pegin_subsidy = PeginSubsidy();
|
||||
pegin_minimum = PeginMinimum();
|
||||
consensus.has_parent_chain = false;
|
||||
g_signed_blocks = false;
|
||||
g_con_elementsmode = false;
|
||||
|
|
@ -544,6 +549,8 @@ public:
|
|||
multi_data_permitted = false;
|
||||
accept_discount_ct = false;
|
||||
create_discount_ct = false;
|
||||
pegin_subsidy = PeginSubsidy();
|
||||
pegin_minimum = PeginMinimum();
|
||||
consensus.has_parent_chain = false;
|
||||
g_signed_blocks = false; // lol
|
||||
g_con_elementsmode = false;
|
||||
|
|
@ -648,6 +655,8 @@ public:
|
|||
multi_data_permitted = false;
|
||||
accept_discount_ct = false;
|
||||
create_discount_ct = false;
|
||||
pegin_subsidy = PeginSubsidy();
|
||||
pegin_minimum = PeginMinimum();
|
||||
consensus.has_parent_chain = false;
|
||||
g_signed_blocks = false;
|
||||
g_con_elementsmode = false;
|
||||
|
|
@ -792,6 +801,39 @@ void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
|
|||
}
|
||||
}
|
||||
|
||||
// ELEMENTS
|
||||
PeginSubsidy ParsePeginSubsidy(const ArgsManager& args) {
|
||||
PeginSubsidy pegin_subsidy;
|
||||
|
||||
pegin_subsidy.height = args.GetIntArg("-peginsubsidyheight", std::numeric_limits<int>::max());
|
||||
if (pegin_subsidy.height < 0) {
|
||||
throw std::runtime_error(strprintf("Invalid block height (%d) for -peginsubsidyheight. Must be positive.", pegin_subsidy.height));
|
||||
}
|
||||
if (std::optional<CAmount> amount = ParseMoney(args.GetArg("-peginsubsidythreshold", "0"))) {
|
||||
pegin_subsidy.threshold = amount.value();
|
||||
} else {
|
||||
throw std::runtime_error("Invalid -peginsubsidythreshold");
|
||||
}
|
||||
|
||||
return pegin_subsidy;
|
||||
};
|
||||
|
||||
PeginMinimum ParsePeginMinimum(const ArgsManager& args) {
|
||||
PeginMinimum pegin_minimum;
|
||||
|
||||
pegin_minimum.height = args.GetIntArg("-peginminheight", std::numeric_limits<int>::max());
|
||||
if (pegin_minimum.height < 0) {
|
||||
throw std::runtime_error(strprintf("Invalid block height (%d) for -peginminheight. Must be positive.", pegin_minimum.height));
|
||||
}
|
||||
if (std::optional<CAmount> amount = ParseMoney(args.GetArg("-peginminamount", "0"))) {
|
||||
pegin_minimum.amount = amount.value();
|
||||
} else {
|
||||
throw std::runtime_error("Invalid -peginminamount");
|
||||
}
|
||||
|
||||
return pegin_minimum;
|
||||
};
|
||||
|
||||
/**
|
||||
* Custom params for testing.
|
||||
*/
|
||||
|
|
@ -932,6 +974,11 @@ protected:
|
|||
consensus.start_p2wsh_script = args.GetIntArg("-con_start_p2wsh_script", consensus.start_p2wsh_script);
|
||||
create_discount_ct = args.GetBoolArg("-creatediscountct", create_discount_ct);
|
||||
accept_discount_ct = args.GetBoolArg("-acceptdiscountct", accept_discount_ct) || create_discount_ct;
|
||||
pegin_subsidy = ParsePeginSubsidy(args);
|
||||
pegin_minimum = ParsePeginMinimum(args);
|
||||
if (pegin_subsidy.threshold < pegin_minimum.amount) {
|
||||
throw std::runtime_error(strprintf("Pegin subsidy threshold (%s) must be greater than or equal to pegin minimum amount (%s)", FormatMoney(pegin_subsidy.threshold), FormatMoney(pegin_minimum.amount)));
|
||||
}
|
||||
|
||||
// Calculate pegged Bitcoin asset
|
||||
std::vector<unsigned char> commit = CommitToArguments(consensus, strNetworkID);
|
||||
|
|
@ -1178,6 +1225,11 @@ public:
|
|||
multi_data_permitted = true;
|
||||
create_discount_ct = args.GetBoolArg("-creatediscountct", false);
|
||||
accept_discount_ct = args.GetBoolArg("-acceptdiscountct", true) || create_discount_ct;
|
||||
pegin_subsidy = ParsePeginSubsidy(args);
|
||||
pegin_minimum = ParsePeginMinimum(args);
|
||||
if (pegin_subsidy.threshold < pegin_minimum.amount) {
|
||||
throw std::runtime_error(strprintf("Pegin subsidy threshold (%s) must be greater than or equal to pegin minimum amount (%s)", FormatMoney(pegin_subsidy.threshold), FormatMoney(pegin_minimum.amount)));
|
||||
}
|
||||
|
||||
parentGenesisBlockHash = uint256S("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
|
||||
const bool parent_genesis_is_null = parentGenesisBlockHash == uint256();
|
||||
|
|
@ -1538,6 +1590,11 @@ public:
|
|||
multi_data_permitted = args.GetBoolArg("-multi_data_permitted", multi_data_permitted);
|
||||
create_discount_ct = args.GetBoolArg("-creatediscountct", create_discount_ct);
|
||||
accept_discount_ct = args.GetBoolArg("-acceptdiscountct", accept_discount_ct) || create_discount_ct;
|
||||
pegin_subsidy = ParsePeginSubsidy(args);
|
||||
pegin_minimum = ParsePeginMinimum(args);
|
||||
if (pegin_subsidy.threshold < pegin_minimum.amount) {
|
||||
throw std::runtime_error(strprintf("Pegin subsidy threshold (%s) must be greater than or equal to pegin minimum amount (%s)", FormatMoney(pegin_subsidy.threshold), FormatMoney(pegin_minimum.amount)));
|
||||
}
|
||||
|
||||
if (args.IsArgSet("-parentgenesisblockhash")) {
|
||||
parentGenesisBlockHash = uint256S(args.GetArg("-parentgenesisblockhash", ""));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue