1818#include < boost/assign/list_of.hpp>
1919
2020// Safer for users if they load incorrect parameters via arguments.
21- static std::vector<unsigned char > CommitToArguments (const Consensus::Params& params, const std::string& networkID, const CScript& signblockscript )
21+ static std::vector<unsigned char > CommitToArguments (const Consensus::Params& params, const std::string& networkID)
2222{
2323 CSHA256 sha2;
2424 unsigned char commitment[32 ];
2525 sha2.Write ((const unsigned char *)networkID.c_str (), networkID.length ());
2626 sha2.Write ((const unsigned char *)HexStr (params.fedpegScript ).c_str (), HexStr (params.fedpegScript ).length ());
27- sha2.Write ((const unsigned char *)HexStr (signblockscript ).c_str (), HexStr (signblockscript ).length ());
27+ sha2.Write ((const unsigned char *)HexStr (params. signblockScript ).c_str (), HexStr (params. signblockScript ).length ());
2828 sha2.Finalize (commitment);
2929 return std::vector<unsigned char >(commitment, commitment + 32 );
3030}
@@ -41,19 +41,19 @@ static CScript StrHexToScriptWithDefault(std::string strScript, const CScript de
4141 return returnScript;
4242}
4343
44- static CBlock CreateGenesisBlock (const Consensus::Params& params, const std::string& networkID, uint32_t nTime, const CScript& scriptChallenge, int32_t nVersion)
44+ static CBlock CreateGenesisBlock (const Consensus::Params& params, const std::string& networkID, uint32_t nTime, int32_t nVersion)
4545{
4646 CMutableTransaction txNew;
4747 txNew.nVersion = 1 ;
4848 txNew.vin .resize (1 );
4949 // Any consensus-related values that are command-line set can be added here for anti-footgun
50- txNew.vin [0 ].scriptSig = CScript (CommitToArguments (params, networkID, scriptChallenge ));
50+ txNew.vin [0 ].scriptSig = CScript (CommitToArguments (params, networkID));
5151 txNew.vout .clear ();
5252 txNew.vout .push_back (CTxOut (CAsset (), 0 , CScript () << OP_RETURN));
5353
5454 CBlock genesis;
5555 genesis.nTime = nTime;
56- genesis.proof = CProof (scriptChallenge, CScript ());
56+ genesis.proof = CProof (CScript ());
5757 genesis.nVersion = nVersion;
5858 genesis.vtx .push_back (MakeTransactionRef (std::move (txNew)));
5959 genesis.hashPrevBlock .SetNull ();
@@ -132,6 +132,10 @@ class CCustomParams : public CChainParams {
132132 // bitcoin regtest is the parent chain by default
133133 parentGenesisBlockHash = uint256S (GetArg (" -parentgenesisblockhash" , " 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206" ));
134134
135+ const CScript default_script (CScript () << OP_TRUE);
136+ consensus.signblockScript = StrHexToScriptWithDefault (GetArg (" -signblockscript" , " " ), default_script);
137+ consensus.fedpegScript = StrHexToScriptWithDefault (GetArg (" -fedpegscript" , " " ), default_script);
138+
135139 nDefaultPort = GetArg (" -ndefaultport" , 7042 );
136140 nPruneAfterHeight = GetArg (" -npruneafterheight" , 1000 );
137141 fMiningRequiresPeers = GetBoolArg (" -fminingrequirespeers" , false );
@@ -146,10 +150,6 @@ class CCustomParams : public CChainParams {
146150 {
147151 this ->UpdateFromArgs ();
148152
149- const CScript defaultRegtestScript (CScript () << OP_TRUE);
150- CScript genesisChallengeScript = StrHexToScriptWithDefault (GetArg (" -signblockscript" , " " ), defaultRegtestScript);
151- consensus.fedpegScript = StrHexToScriptWithDefault (GetArg (" -fedpegscript" , " " ), defaultRegtestScript);
152-
153153 consensus.vDeployments [Consensus::DEPLOYMENT_TESTDUMMY].bit = 28 ;
154154 consensus.vDeployments [Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0 ;
155155 consensus.vDeployments [Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 999999999999ULL ;
@@ -166,12 +166,12 @@ class CCustomParams : public CChainParams {
166166 pchMessageStart[3 ] = 0xda ;
167167
168168 // Generate pegged Bitcoin asset
169- std::vector<unsigned char > commit = CommitToArguments (consensus, strNetworkID, genesisChallengeScript );
169+ std::vector<unsigned char > commit = CommitToArguments (consensus, strNetworkID);
170170 uint256 entropy;
171171 GenerateAssetEntropy (entropy, COutPoint (uint256 (commit), 0 ), parentGenesisBlockHash);
172172 CalculateAsset (consensus.pegged_asset , entropy);
173173
174- genesis = CreateGenesisBlock (consensus, strNetworkID, 1296688602 , genesisChallengeScript, 1 );
174+ genesis = CreateGenesisBlock (consensus, strNetworkID, 1296688602 , 1 );
175175 AppendInitialIssuance (genesis, COutPoint (uint256 (commit), 0 ), parentGenesisBlockHash, 100 , 21000000000000 , 0 , 0 , CScript () << OP_TRUE);
176176 consensus.hashGenesisBlock = genesis.GetHash ();
177177
@@ -257,4 +257,3 @@ void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_
257257{
258258 globalChainParams->UpdateBIP9Parameters (d, nStartTime, nTimeout);
259259}
260-
0 commit comments