Add new arguments

This commit is contained in:
Steven Roose 2019-03-19 20:02:02 +00:00
parent fde9fe1010
commit 484d83c371
No known key found for this signature in database
GPG key ID: 7FC91380BB4CE800
6 changed files with 69 additions and 1 deletions

View file

@ -7,6 +7,7 @@
#include <chainparamsseeds.h>
#include <consensus/merkle.h>
#include <issuance.h>
#include <primitives/transaction.h>
#include <tinyformat.h>
#include <util.h>
@ -144,11 +145,14 @@ public:
consensus.genesis_subsidy = 50*COIN;
consensus.connect_genesis_outputs = false;
consensus.subsidy_asset = CAsset();
anyonecanspend_aremine = false;
enforce_pak = false;
multi_data_permitted = false;
consensus.has_parent_chain = false;
g_signed_blocks = false;
g_con_elementswitness = false;
g_con_blockheightinheader = false;
/**
* The message start string is designed to be unlikely to occur in normal data.
@ -267,10 +271,14 @@ public:
consensus.genesis_subsidy = 50*COIN;
consensus.connect_genesis_outputs = false;
consensus.subsidy_asset = CAsset();
anyonecanspend_aremine = false;
enforce_pak = false;
multi_data_permitted = false;
consensus.has_parent_chain = false;
g_signed_blocks = false;
g_con_elementswitness = false;
g_con_blockheightinheader = false;
pchMessageStart[0] = 0x0b;
pchMessageStart[1] = 0x11;
@ -364,10 +372,14 @@ public:
consensus.genesis_subsidy = 50*COIN;
consensus.connect_genesis_outputs = false;
consensus.subsidy_asset = CAsset();
anyonecanspend_aremine = false;
enforce_pak = false;
multi_data_permitted = false;
consensus.has_parent_chain = false;
g_signed_blocks = false;
g_con_elementswitness = false;
g_con_blockheightinheader = false;
pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
@ -573,6 +585,27 @@ class CCustomParams : public CRegTestParams {
base58Prefixes[BLINDED_ADDRESS] = std::vector<unsigned char>(1, args.GetArg("-blindedprefix", 4));
// Calculate pegged Bitcoin asset
std::vector<unsigned char> commit = CommitToArguments(consensus, strNetworkID);
uint256 entropy;
GenerateAssetEntropy(entropy, COutPoint(uint256(commit), 0), parentGenesisBlockHash);
// Elements serialization uses derivation, bitcoin serialization uses 0x00
if (g_con_elementswitness) {
CalculateAsset(consensus.pegged_asset, entropy);
} else {
assert(consensus.pegged_asset == CAsset());
}
consensus.parent_pegged_asset.SetHex(args.GetArg("-con_parent_pegged_asset", "0x00"));
initial_reissuance_tokens = args.GetArg("-initialreissuancetokens", 0);
// Subsidy asset, like policyAsset, defaults to the pegged_asset
consensus.subsidy_asset = consensus.pegged_asset;
if (gArgs.IsArgSet("-subsidyasset")) {
consensus.subsidy_asset = CAsset(uint256S(gArgs.GetArg("-subsidyasset", "0x00")));
}
// END ELEMENTS fields
// CSV always active by default, unlike regtest

View file

@ -107,6 +107,7 @@ protected:
std::string strNetworkID;
CBlock genesis;
CAmount initialFreeCoins;
CAmount initial_reissuance_tokens;
std::vector<SeedSpec6> vFixedSeeds;
bool fDefaultConsistencyChecks;
bool fRequireStandard;

View file

@ -6,6 +6,7 @@
#ifndef BITCOIN_CONSENSUS_PARAMS_H
#define BITCOIN_CONSENSUS_PARAMS_H
#include <asset.h>
#include <uint256.h>
#include <limits>
#include <map>
@ -83,6 +84,7 @@ struct Params {
// ELEMENTS CHAIN PARAMS
CScript mandatory_coinbase_destination;
CAmount genesis_subsidy;
CAsset subsidy_asset;
bool connect_genesis_outputs;
bool has_parent_chain;
uint256 parentChainPowLimit;
@ -90,6 +92,8 @@ struct Params {
CScript parent_chain_signblockscript;
bool ParentChainHasPow() const { return parent_chain_signblockscript == CScript();}
CScript fedpegScript;
CAsset pegged_asset;
CAsset parent_pegged_asset;
// g_con_blockheightinheader global hack instead of proper arg due to circular dep
std::string genesis_style;
CScript signblockscript;

View file

@ -65,6 +65,7 @@
#include <primitives/pak.h> // CPAKList
#include <assetsdir.h> // InitGlobalAssetDir
#include <pegins.h>
#if ENABLE_ZMQ
#include <zmq/zmqnotificationinterface.h>
@ -512,6 +513,7 @@ void SetupServerArgs()
gArgs.AddArg("-blech32_hrp", strprintf("The human-readable part of the chain's blech32 encoding. Used in confidential addresses.(default: %s)", defaultChainParams->Blech32HRP()), false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-assetdir", "Entries of pet names of assets, in this format:asset=<hex>:<label>. There can be any number of entries.", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-defaultpeggedassetname", "Default name of the pegged asset. (default: bitcoin)", false, OptionsCategory::ELEMENTS);
gArgs.AddArg("-blindedaddresses", "Give blind addresses by default via getnewaddress and getrawchangeaddress. (default: -con_elementswitness value)", false, OptionsCategory::ELEMENTS);
#if HAVE_DECL_DAEMON
gArgs.AddArg("-daemon", "Run in the background as a daemon and accept commands", false, OptionsCategory::OPTIONS);
@ -539,6 +541,12 @@ void SetupServerArgs()
gArgs.AddArg("-parentscriptprefix", strprintf("The byte prefix, in decimal, of the parent chain's base58 script address. (default: %d)", 196), false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-parent_bech32_hrp", strprintf("The human-readable part of the parent chain's bech32 encoding. (default: %s)", "bc"), false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-parent_blech32_hrp", strprintf("The human-readable part of the parent chain's blech32 encoding. (default: %s)", "bc"), false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-con_parent_pegged_asset=<hex>", "Asset ID (hex) for pegged asset for when parent chain has CA. (default: 0x00)", false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-feeasset=<hex>", strprintf("Asset ID (hex) for mempool/relay fees (default: %s)", defaultChainParams->GetConsensus().pegged_asset.GetHex()), false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-subsidyasset=<hex>", strprintf("Asset ID (hex) for the block subsidy (default: %s)", defaultChainParams->GetConsensus().pegged_asset.GetHex()), false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-initialreissuancetokens=<n>", "The amount of reissuance tokens created in the genesis block. (default: 0)", false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-ct_bits", strprintf("The default number of hiding bits in a rangeproof. Will be exceeded to cover amounts exceeding the maximum hiding value. (default: %d)", 36), false, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-ct_exponent", strprintf("The hiding exponent. (default: %s)", 0), false, OptionsCategory::CHAINPARAMS);
// Add the hidden options
gArgs.AddHiddenArgs(hidden_args);
@ -1294,6 +1302,9 @@ bool AppInitMain()
RegisterZMQRPCCommands(tableRPC);
#endif
// ELEMENTS:
policyAsset = CAsset(uint256S(gArgs.GetArg("-feeasset", chainparams.GetConsensus().pegged_asset.GetHex())));
/* Start the RPC server already. It will be started in "warmup" mode
* and not really process calls already (but it will signify connections
* that the server is there and will be ready later). Warmup mode will
@ -1832,7 +1843,21 @@ bool AppInitMain()
}
}
// ********************************************************* Step 14: finished
// ********************************************************* Step 14: Check fedpeg
// ELEMENTS:
if (chainparams.GetConsensus().has_parent_chain) {
// Will assert if not properly formatted
const CScript& fedpeg_script = chainparams.GetConsensus().fedpegScript;
unsigned int dummy_required;
std::vector<std::vector<unsigned char>> dummy_keys;
if (!MatchLiquidWatchman(fedpeg_script) &&
fedpeg_script != CScript() << OP_TRUE &&
!MatchMultisig(fedpeg_script, dummy_required, dummy_keys)) {
return InitError(_("ERROR: Fedpegscript is not one of the accepted templates: OP_TRUE, CHECKMULTISIG, and Liquidv1"));
}
}
// ********************************************************* Step 15: finished
SetRPCWarmupFinished();

View file

@ -16,6 +16,8 @@
#include <utilstrencodings.h>
#include <chainparams.h> // Peg-out enforcement
// ELEMENTS:
CAsset policyAsset;
CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
{

View file

@ -16,6 +16,9 @@
class CCoinsViewCache;
class CTxOut;
// ELEMENTS:
extern CAsset policyAsset;
/** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/
static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = MAX_BLOCK_WEIGHT - 4000;
/** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/