2020#include " chainparamsseeds.h"
2121
2222// Safer for users if they load incorrect parameters via arguments.
23- static std::vector<unsigned char > CommitToArguments (const Consensus::Params& params, const std::string& networkID, const CScript& signblockscript )
23+ static std::vector<unsigned char > CommitToArguments (const Consensus::Params& params, const std::string& networkID)
2424{
2525 CSHA256 sha2;
2626 unsigned char commitment[32 ];
2727 sha2.Write ((const unsigned char *)networkID.c_str (), networkID.length ());
2828 sha2.Write ((const unsigned char *)HexStr (params.fedpegScript ).c_str (), HexStr (params.fedpegScript ).length ());
29- sha2.Write ((const unsigned char *)HexStr (signblockscript ).c_str (), HexStr (signblockscript ).length ());
29+ sha2.Write ((const unsigned char *)HexStr (params. signblockScript ).c_str (), HexStr (params. signblockScript ).length ());
3030 sha2.Finalize (commitment);
3131 return std::vector<unsigned char >(commitment, commitment + 32 );
3232}
@@ -43,7 +43,7 @@ static CScript StrHexToScriptWithDefault(std::string strScript, const CScript de
4343 return returnScript;
4444}
4545
46- static CBlock CreateGenesisBlock (const Consensus::Params& params, const std::string& networkID, const CScript& genesisOutputScript, uint32_t nTime, const CScript& scriptChallenge, int32_t nVersion, const CAmount& genesisReward, const uint32_t rewardShards, const CAsset& asset )
46+ static CBlock CreateGenesisBlock (const Consensus::Params& params, const std::string& networkID, const CScript& genesisOutputScript, uint32_t nTime, int32_t nVersion, const CAmount& genesisReward, const uint32_t rewardShards, const CAsset& genesisAsset )
4747{
4848 // Shards must be evenly divisible
4949 assert (MAX_MONEY % rewardShards == 0 );
@@ -52,16 +52,16 @@ static CBlock CreateGenesisBlock(const Consensus::Params& params, const std::str
5252 txNew.vin .resize (1 );
5353 txNew.vout .resize (rewardShards);
5454 // Any consensus-related values that are command-line set can be added here for anti-footgun
55- txNew.vin [0 ].scriptSig = CScript (CommitToArguments (params, networkID, scriptChallenge ));
55+ txNew.vin [0 ].scriptSig = CScript (CommitToArguments (params, networkID));
5656 for (unsigned int i = 0 ; i < rewardShards; i++) {
5757 txNew.vout [i].nValue = genesisReward/rewardShards;
58- txNew.vout [i].nAsset = asset ;
58+ txNew.vout [i].nAsset = genesisAsset ;
5959 txNew.vout [i].scriptPubKey = genesisOutputScript;
6060 }
6161
6262 CBlock genesis;
6363 genesis.nTime = nTime;
64- genesis.proof = CProof (scriptChallenge, CScript ());
64+ genesis.proof = CProof (CScript ());
6565 genesis.nVersion = nVersion;
6666 genesis.vtx .push_back (MakeTransactionRef (std::move (txNew)));
6767 genesis.hashPrevBlock .SetNull ();
@@ -85,7 +85,7 @@ class CElementsParams : public CChainParams {
8585 CScript defaultSignblockScript;
8686 // Default blocksign script for elements
8787 defaultSignblockScript = CScript () << OP_2 << ParseHex (" 03206b45265ae687dfdc602b8faa7dd749d7865b0e51f986e12c532229f0c998be" ) << ParseHex (" 02cc276552e180061f64dc16e2a02e7f9ecbcc744dea84eddbe991721824df825c" ) << ParseHex (" 0204c6be425356d9200a3303d95f2c39078cc9473ca49619da1e0ec233f27516ca" ) << OP_3 << OP_CHECKMULTISIG ;
88- CScript genesisChallengeScript = StrHexToScriptWithDefault (GetArg (" -signblockscript" , " " ), defaultSignblockScript);
88+ consensus. signblockScript = StrHexToScriptWithDefault (GetArg (" -signblockscript" , " " ), defaultSignblockScript);
8989 CScript defaultFedpegScript;
9090 defaultFedpegScript = CScript () << OP_2 << ParseHex (" 02d51090b27ca8f1cc04984614bd749d8bab6f2a3681318d3fd0dd43b2a39dd774" ) << ParseHex (" 03a75bd7ac458b19f98047c76a6ffa442e592148c5d23a1ec82d379d5d558f4fd8" ) << ParseHex (" 034c55bede1bce8e486080f8ebb7a0e8f106b49efb295a8314da0e1b1723738c66" ) << OP_3 << OP_CHECKMULTISIG ;
9191 consensus.fedpegScript = StrHexToScriptWithDefault (GetArg (" -fedpegscript" , " " ), defaultFedpegScript);
@@ -145,13 +145,13 @@ class CElementsParams : public CChainParams {
145145 parentGenesisBlockHash = uint256S (" 000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" );
146146
147147 // Generate pegged Bitcoin asset
148- std::vector<unsigned char > commit = CommitToArguments (consensus, strNetworkID, genesisChallengeScript );
148+ std::vector<unsigned char > commit = CommitToArguments (consensus, strNetworkID);
149149 uint256 entropy;
150150 GenerateAssetEntropy (entropy, COutPoint (uint256 (commit), 0 ), parentGenesisBlockHash);
151151 CalculateAsset (consensus.pegged_asset , entropy);
152152
153153 CScript scriptDestination (CScript () << std::vector<unsigned char >(parentGenesisBlockHash.begin (), parentGenesisBlockHash.end ()) << OP_WITHDRAWPROOFVERIFY );
154- genesis = CreateGenesisBlock (consensus, strNetworkID, scriptDestination, 1231006505 , genesisChallengeScript, 1 , MAX_MONEY , 100 , consensus.pegged_asset );
154+ genesis = CreateGenesisBlock (consensus, strNetworkID, scriptDestination, 1231006505 , 1 , MAX_MONEY , 100 , consensus.pegged_asset );
155155 consensus.hashGenesisBlock = genesis.GetHash ();
156156
157157 scriptCoinbaseDestination = CScript () << ParseHex (" 0229536c4c83789f59c30b93eb40d4abbd99b8dcc99ba8bd748f29e33c1d279e3c" ) << OP_CHECKSIG ;
@@ -212,7 +212,7 @@ class CRegTestParams : public CChainParams {
212212public:
213213 CRegTestParams () {
214214 const CScript defaultRegtestScript (CScript () << OP_TRUE );
215- CScript genesisChallengeScript = StrHexToScriptWithDefault (GetArg (" -signblockscript" , " " ), defaultRegtestScript);
215+ consensus. signblockScript = StrHexToScriptWithDefault (GetArg (" -signblockscript" , " " ), defaultRegtestScript);
216216 consensus.fedpegScript = StrHexToScriptWithDefault (GetArg (" -fedpegscript" , " " ), defaultRegtestScript);
217217
218218 strNetworkID = CHAINPARAMS_REGTEST ;
@@ -255,12 +255,12 @@ class CRegTestParams : public CChainParams {
255255 parentGenesisBlockHash = uint256S (" 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206" );
256256
257257 // Generate pegged Bitcoin asset
258- std::vector<unsigned char > commit = CommitToArguments (consensus, strNetworkID, genesisChallengeScript );
258+ std::vector<unsigned char > commit = CommitToArguments (consensus, strNetworkID);
259259 uint256 entropy;
260260 GenerateAssetEntropy (entropy, COutPoint (uint256 (commit), 0 ), parentGenesisBlockHash);
261261 CalculateAsset (consensus.pegged_asset , entropy);
262262
263- genesis = CreateGenesisBlock (consensus, strNetworkID, defaultRegtestScript, 1296688602 , genesisChallengeScript, 1 , MAX_MONEY , 100 , consensus.pegged_asset );
263+ genesis = CreateGenesisBlock (consensus, strNetworkID, defaultRegtestScript, 1296688602 , 1 , MAX_MONEY , 100 , consensus.pegged_asset );
264264 consensus.hashGenesisBlock = genesis.GetHash ();
265265
266266
@@ -321,6 +321,10 @@ class CCustomParams : public CChainParams {
321321 // By default assume that the signatures in ancestors of this block are valid.
322322 consensus.defaultAssumeValid = uint256S (GetArg (" -con_defaultassumevalid" , " 0x00" ));
323323
324+ const CScript defaultRegtestScript (CScript () << OP_TRUE );
325+ consensus.signblockScript = StrHexToScriptWithDefault (GetArg (" -signblockscript" , " " ), defaultRegtestScript);
326+ consensus.fedpegScript = StrHexToScriptWithDefault (GetArg (" -fedpegscript" , " " ), defaultRegtestScript);
327+
324328 nDefaultPort = GetArg (" -ndefaultport" , 18444 );
325329 nPruneAfterHeight = GetArg (" -npruneafterheight" , 1000 );
326330 fDefaultConsistencyChecks = GetBoolArg (" -fdefaultconsistencychecks" , true );
0 commit comments