1717#include < boost/assign/list_of.hpp>
1818
1919// Safer for users if they load incorrect parameters via arguments.
20- static std::vector<unsigned char > CommitToArguments (const Consensus::Params& params, const std::string& networkID, const CScript& signblockscript )
20+ static std::vector<unsigned char > CommitToArguments (const Consensus::Params& params, const std::string& networkID)
2121{
2222 CSHA256 sha2;
2323 unsigned char commitment[32 ];
2424 sha2.Write ((const unsigned char *)networkID.c_str (), networkID.length ());
2525 sha2.Write ((const unsigned char *)HexStr (params.fedpegScript ).c_str (), HexStr (params.fedpegScript ).length ());
26- sha2.Write ((const unsigned char *)HexStr (signblockscript).c_str (), HexStr (signblockscript).length ());
26+ sha2.Write ((const unsigned char *)HexStr (params. signblockscript ).c_str (), HexStr (params. signblockscript ).length ());
2727 sha2.Finalize (commitment);
2828 return std::vector<unsigned char >(commitment, commitment + 32 );
2929}
@@ -40,19 +40,19 @@ static CScript StrHexToScriptWithDefault(std::string strScript, const CScript de
4040 return returnScript;
4141}
4242
43- static CBlock CreateGenesisBlock (const Consensus::Params& params, const std::string& networkID, uint32_t nTime, const CScript& scriptChallenge, int32_t nVersion)
43+ static CBlock CreateGenesisBlock (const Consensus::Params& params, const std::string& networkID, uint32_t nTime, int32_t nVersion)
4444{
4545 CMutableTransaction txNew;
4646 txNew.nVersion = 1 ;
4747 txNew.vin .resize (1 );
4848 // Any consensus-related values that are command-line set can be added here for anti-footgun
49- txNew.vin [0 ].scriptSig = CScript (CommitToArguments (params, networkID, scriptChallenge ));
49+ txNew.vin [0 ].scriptSig = CScript (CommitToArguments (params, networkID));
5050 txNew.vout .clear ();
5151 txNew.vout .push_back (CTxOut (CAsset (), 0 , CScript () << OP_RETURN));
5252
5353 CBlock genesis;
5454 genesis.nTime = nTime;
55- genesis.proof = CProof (scriptChallenge , CScript ());
55+ genesis.proof = CProof (params. signblockscript , CScript ());
5656 genesis.nVersion = nVersion;
5757 genesis.vtx .push_back (MakeTransactionRef (std::move (txNew)));
5858 genesis.hashPrevBlock .SetNull ();
@@ -134,6 +134,10 @@ class CCustomParams : public CChainParams {
134134 parentGenesisBlockHash = uint256S (GetArg (" -parentgenesisblockhash" , " 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206" ));
135135 initialFreeCoins = GetArg (" -initialfreecoins" , 0 );
136136
137+ const CScript default_script (CScript () << OP_TRUE);
138+ consensus.signblockscript = StrHexToScriptWithDefault (GetArg (" -signblockscript" , " " ), default_script);
139+ consensus.fedpegScript = StrHexToScriptWithDefault (GetArg (" -fedpegscript" , " " ), default_script);
140+
137141 nDefaultPort = GetArg (" -ndefaultport" , 7042 );
138142 nPruneAfterHeight = GetArg (" -npruneafterheight" , 1000 );
139143 fMiningRequiresPeers = GetBoolArg (" -fminingrequirespeers" , false );
@@ -168,10 +172,6 @@ class CCustomParams : public CChainParams {
168172 {
169173 this ->UpdateFromArgs ();
170174
171- const CScript defaultRegtestScript (CScript () << OP_TRUE);
172- CScript genesisChallengeScript = StrHexToScriptWithDefault (GetArg (" -signblockscript" , " " ), defaultRegtestScript);
173- consensus.fedpegScript = StrHexToScriptWithDefault (GetArg (" -fedpegscript" , " " ), defaultRegtestScript);
174-
175175 if (!anyonecanspend_aremine) {
176176 assert (" Anyonecanspendismine was marked as false, but they are in the genesis block"
177177 && initialFreeCoins == 0 );
@@ -193,12 +193,12 @@ class CCustomParams : public CChainParams {
193193 pchMessageStart[3 ] = 0xda ;
194194
195195 // Generate pegged Bitcoin asset
196- std::vector<unsigned char > commit = CommitToArguments (consensus, strNetworkID, genesisChallengeScript );
196+ std::vector<unsigned char > commit = CommitToArguments (consensus, strNetworkID);
197197 uint256 entropy;
198198 GenerateAssetEntropy (entropy, COutPoint (uint256 (commit), 0 ), parentGenesisBlockHash);
199199 CalculateAsset (consensus.pegged_asset , entropy);
200200
201- genesis = CreateGenesisBlock (consensus, strNetworkID, 1296688602 , genesisChallengeScript, 1 );
201+ genesis = CreateGenesisBlock (consensus, strNetworkID, 1296688602 , 1 );
202202 if (initialFreeCoins != 0 ) {
203203 AppendInitialIssuance (genesis, COutPoint (uint256 (commit), 0 ), parentGenesisBlockHash, 1 , initialFreeCoins, 0 , 0 , CScript () << OP_TRUE);
204204 }
@@ -276,4 +276,3 @@ void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_
276276{
277277 globalChainParams->UpdateBIP9Parameters (d, nStartTime, nTimeout);
278278}
279-
0 commit comments