text: // Copyright (c) 2010 Satoshi Nakamoto
  // Copyright (c) 2009-2016 The Bitcoin Core developers
  // Copyright (c) 2017 The Raven Core developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #include "chainparams.h"
  #include "consensus/merkle.h"
  
  #include "tinyformat.h"
  #include "util.h"
  #include "utilstrencodings.h"
  #include "arith_uint256.h"
  
  #include <assert.h>
  
  #include "chainparamsseeds.h"
  
  //TODO: Take these out
  extern double algoHashTotal[16];
  extern int algoHashHits[16];
  
  
  static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
  {
      CMutableTransaction txNew;
      txNew.nVersion = 1;
      txNew.vin.resize(1);
      txNew.vout.resize(1);
      txNew.vin[0].scriptSig = CScript() << CScriptNum(0) << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
      txNew.vout[0].nValue = genesisReward;
      txNew.vout[0].scriptPubKey = genesisOutputScript;
  
      CBlock genesis;
      genesis.nTime    = nTime;
      genesis.nBits    = nBits;
      genesis.nNonce   = nNonce;
      genesis.nVersion = nVersion;
      genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
      genesis.hashPrevBlock.SetNull();
      genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
      return genesis;
  }
  
  /**
   * Build the genesis block. Note that the output of its generation
   * transaction cannot be spent since it did not originally exist in the
   * database.
   *
   * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
   *   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
   *     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
   *     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
   *   vMerkleTree: 4a5e1e
   */
  static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
  {
      const char* pszTimestamp = "The Times 03/Jan/2018 Bitcoin is name of the game for new generation of firms";
      const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
      return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
  }
  
  void CChainParams::UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
  {
      consensus.vDeployments[d].nStartTime = nStartTime;
      consensus.vDeployments[d].nTimeout = nTimeout;
  }
  
  void CChainParams::TurnOffSegwit() {
  	consensus.nSegwitEnabled = false;
  }
  
  void CChainParams::TurnOffCSV() {
  	consensus.nCSVEnabled = false;
  }
  
  void CChainParams::TurnOffBIP34() {
  	consensus.nBIP34Enabled = false;
  }
  
  void CChainParams::TurnOffBIP65() {
  	consensus.nBIP65Enabled = false;
  }
  
  void CChainParams::TurnOffBIP66() {
  	consensus.nBIP66Enabled = false;
  }
  
  bool CChainParams::BIP34() {
  	return consensus.nBIP34Enabled;
  }
  
  bool CChainParams::BIP65() {
  	return consensus.nBIP34Enabled;
  }
  
  bool CChainParams::BIP66() {
  	return consensus.nBIP34Enabled;
  }
  
  bool CChainParams::CSVEnabled() const{
  	return consensus.nCSVEnabled;
  }
  
  
  /**
   * Main network
   */
  /**
   * What makes a good checkpoint block?
   * + Is surrounded by blocks with reasonable timestamps
   *   (no blocks before with a timestamp after, none after with
   *    timestamp before)
   * + Contains no strange transactions
   */
  
  class CMainParams : public CChainParams {
  public:
      CMainParams() {
          strNetworkID = "main";
          consensus.nSubsidyHalvingInterval = 2100000;  //~ 4 yrs at 1 min block time
          consensus.nBIP34Enabled = true;
          consensus.nBIP65Enabled = true; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
          consensus.nBIP66Enabled = true;
          consensus.nSegwitEnabled = true;
          consensus.nCSVEnabled = true;
          consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
          consensus.nPowTargetTimespan = 2016 * 60; // 1.4 days
          consensus.nPowTargetSpacing = 1 * 60;
  		consensus.fPowAllowMinDifficultyBlocks = false;
          consensus.fPowNoRetargeting = false;
          consensus.nRuleChangeActivationThreshold = 1814; // Approx 90% of 2016
          consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
          consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].bit = 6;  //Assets (RIP2)
          consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nStartTime = 1540944000; // Oct 31, 2018
          consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nTimeout = 1572480000; // Oct 31, 2019
  
          // The best chain should have at least this much work.
          consensus.nMinimumChainWork = uint256S("0x00");
  
          // By default assume that the signatures in ancestors of this block are valid.
          consensus.defaultAssumeValid = uint256S("0x00");
  
  
          // The best chain should have at least this much work.
  
          //TODO: This needs to be changed when we re-start the chain
          //consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000000000000c000c00");
  
          //TODO - Set this to genesis block
          // By default assume that the signatures in ancestors of this block are valid.
          //consensus.defaultAssumeValid = uint256S("0x0000000000000000003b9ce759c2a087d52abc4266f8f4ebd6d768b89defa50a"); //477890
  
          /**
           * The message start string is designed to be unlikely to occur in normal data.
           * The characters are rarely used upper ASCII, not valid as UTF-8, and produce
           * a large 32-bit integer with any alignment.
           */
          pchMessageStart[0] = 0x52;
          pchMessageStart[1] = 0x41;
          pchMessageStart[2] = 0x56;
          pchMessageStart[3] = 0x4e;
          nDefaultPort = 8767;
          nPruneAfterHeight = 100000;
  
          genesis = CreateGenesisBlock(1514999494, 25023712, 0x1e00ffff, 4, 5000 * COIN);
  
          consensus.hashGenesisBlock = genesis.GetHash();
  
          assert(consensus.hashGenesisBlock == uint256S("0000006b444bc2f2ffe627be9d9e7e7a0730000870ef6eb6da46c8eae389df90"));
          assert(genesis.hashMerkleRoot == uint256S("28ff00a867739a352523808d301f504bc4547699398d70faf2266a8bae5f3516"));
  
          vSeeds.emplace_back("seed-raven.bitactivate.com", false);
          vSeeds.emplace_back("seed-raven.ravencoin.com", false);
          vSeeds.emplace_back("seed-raven.ravencoin.org", false);
  
          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,60);
          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,122);
          base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,128);
          base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
          base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
  
          vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
  
          fDefaultConsistencyChecks = false;
          fRequireStandard = true;
          fMineBlocksOnDemand = false;
          fMiningRequiresPeers = true;
  
          checkpointData = (CCheckpointData) {
              {
  
              }
          };
  
          chainTxData = ChainTxData{
              // Update as we know more about the contents of the Raven chain
              // Stats as of 000000000000a72545994ce72b25042ea63707fca169ca4deb7f9dab4f1b1798 window size 43200
              1543817453, // * UNIX timestamp of last known number of transactions
              2033711,    // * total number of transactions between genesis and that timestamp
                          //   (the tx=... number in the SetBestChain debug.log lines)
              0.1         // * estimated number of transactions per second after that timestamp
          };
  
          /** RVN Start **/
          // Burn Amounts
          nIssueAssetBurnAmount = 500 * COIN;
          nReissueAssetBurnAmount = 100 * COIN;
          nIssueSubAssetBurnAmount = 100 * COIN;
          nIssueUniqueAssetBurnAmount = 5 * COIN;
  
          // Burn Addresses
          strIssueAssetBurnAddress = "RXissueAssetXXXXXXXXXXXXXXXXXhhZGt";
          strReissueAssetBurnAddress = "RXReissueAssetXXXXXXXXXXXXXXVEFAWu";
          strIssueSubAssetBurnAddress = "RXissueSubAssetXXXXXXXXXXXXXWcwhwL";
          strIssueUniqueAssetBurnAddress = "RXissueUniqueAssetXXXXXXXXXXWEAe58";
  
          //Global Burn Address
          strGlobalBurnAddress = "RXBurnXXXXXXXXXXXXXXXXXXXXXXWUo9FV";
  
          // DGW Activation
          nDGWActivationBlock = 338778;
  
          nMaxReorganizationDepth = 60; // 60 at 1 minute block timespan is +/- 60 minutes.
          nMinReorganizationPeers = 4;
          nMinReorganizationAge = 60 * 60 * 12; // 12 hours
          /** RVN End **/
      }
  };
  
  /**
   * Testnet (v6)
   */
  class CTestNetParams : public CChainParams {
  public:
      CTestNetParams() {
          strNetworkID = "test";
          consensus.nSubsidyHalvingInterval = 2100000;  //~ 4 yrs at 1 min block time
          consensus.nBIP34Enabled = true;
          consensus.nBIP65Enabled = true; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
          consensus.nBIP66Enabled = true;
          consensus.nSegwitEnabled = true;
          consensus.nCSVEnabled = true;
  
          consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
          consensus.nPowTargetTimespan = 2016 * 60; // 1.4 days
          consensus.nPowTargetSpacing = 1 * 60;
          consensus.fPowAllowMinDifficultyBlocks = true;
          consensus.fPowNoRetargeting = false;
          consensus.nRuleChangeActivationThreshold = 1310; // Approx 65% for testchains
          consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
          consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].bit = 5;
          consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nStartTime = 1533924000; // GMT: Friday, August 10, 2018 6:00:00 PM
          consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nTimeout = 1538351999; // GMT: Sunday, September 30, 2018 11:59:59 PM
  
  
          // The best chain should have at least this much work.
          consensus.nMinimumChainWork = uint256S("0x00");
  
          // By default assume that the signatures in ancestors of this block are valid.
          consensus.defaultAssumeValid = uint256S("0x00");
  
  
          pchMessageStart[0] = 0x52;
          pchMessageStart[1] = 0x56;
          pchMessageStart[2] = 0x4E;
          pchMessageStart[3] = 0x54;
          nDefaultPort = 18770;
          nPruneAfterHeight = 1000;
  
          uint32_t nGenesisTime = 1537466400;  // Thursday, September 20, 2018 12:00:00 PM GMT-06:00
  
          // This is used inorder to mine the genesis block. Once found, we can use the nonce and block hash found to create a valid genesis block
  //        /////////////////////////////////////////////////////////////////
  
  
  //        arith_uint256 test;
  //        bool fNegative;
  //        bool fOverflow;
  //        test.SetCompact(0x1e00ffff, &fNegative, &fOverflow);
  //        std::cout << "Test threshold: " << test.GetHex() << "\n\n";
  //
  //        int genesisNonce = 0;
  //        uint256 TempHashHolding = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");
  //        uint256 BestBlockHash = uint256S("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
  //        for (int i=0;i<40000000;i++) {
  //            genesis = CreateGenesisBlock(nGenesisTime, i, 0x1e00ffff, 2, 5000 * COIN);
  //            //genesis.hashPrevBlock = TempHashHolding;
  //            consensus.hashGenesisBlock = genesis.GetHash();
  //
  //            arith_uint256 BestBlockHashArith = UintToArith256(BestBlockHash);
  //            if (UintToArith256(consensus.hashGenesisBlock) < BestBlockHashArith) {
  //                BestBlockHash = consensus.hashGenesisBlock;
  //                std::cout << BestBlockHash.GetHex() << " Nonce: " << i << "\n";
  //                std::cout << "   PrevBlockHash: " << genesis.hashPrevBlock.GetHex() << "\n";
  //            }
  //
  //            TempHashHolding = consensus.hashGenesisBlock;
  //
  //            if (BestBlockHashArith < test) {
  //                genesisNonce = i - 1;
  //                break;
  //            }
  //            //std::cout << consensus.hashGenesisBlock.GetHex() << "\n";
  //        }
  //        std::cout << "\n";
  //        std::cout << "\n";
  //        std::cout << "\n";
  //
  //        std::cout << "hashGenesisBlock to 0x" << BestBlockHash.GetHex() << std::endl;
  //        std::cout << "Genesis Nonce to " << genesisNonce << std::endl;
  //        std::cout << "Genesis Merkle " << genesis.hashMerkleRoot.GetHex() << std::endl;
  //
  //        std::cout << "\n";
  //        std::cout << "\n";
  //        int totalHits = 0;
  //        double totalTime = 0.0;
  //
  //        for(int x = 0; x < 16; x++) {
  //            totalHits += algoHashHits[x];
  //            totalTime += algoHashTotal[x];
  //            std::cout << "hash algo " << x << " hits " << algoHashHits[x] << " total " << algoHashTotal[x] << " avg " << algoHashTotal[x]/algoHashHits[x] << std::endl;
  //        }
  //
  //        std::cout << "Totals: hash algo " <<  " hits " << totalHits << " total " << totalTime << " avg " << totalTime/totalHits << std::endl;
  //
  //        genesis.hashPrevBlock = TempHashHolding;
  //
  //        return;
  
  //        /////////////////////////////////////////////////////////////////
  
          genesis = CreateGenesisBlock(nGenesisTime, 15615880, 0x1e00ffff, 2, 5000 * COIN);
          consensus.hashGenesisBlock = genesis.GetHash();
  
          //Test MerkleRoot and GenesisBlock
          assert(consensus.hashGenesisBlock == uint256S("0x000000ecfc5e6324a079542221d00e10362bdc894d56500c414060eea8a3ad5a"));
          assert(genesis.hashMerkleRoot == uint256S("28ff00a867739a352523808d301f504bc4547699398d70faf2266a8bae5f3516"));
  
          vFixedSeeds.clear();
          vSeeds.clear();
  
          vSeeds.emplace_back("seed-testnet-raven.bitactivate.com", false);
          vSeeds.emplace_back("seed-testnet-raven.ravencoin.com", false);
          vSeeds.emplace_back("seed-testnet-raven.ravencoin.org", false);
  
          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
          base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
          base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
          base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
  
          vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
  
          fDefaultConsistencyChecks = false;
          fRequireStandard = false;
          fMineBlocksOnDemand = false;
          fMiningRequiresPeers = true;
  
          checkpointData = (CCheckpointData) {
              {
              }
          };
  
          chainTxData = ChainTxData{
              // Update as we know more about the contents of the Raven chain
              // Stats as of 00000023b66f46d74890287a7b1157dd780c7c5fdda2b561eb96684d2b39d62e window size 43200
              1543633332, // * UNIX timestamp of last known number of transactions
              146666,     // * total number of transactions between genesis and that timestamp
                          //   (the tx=... number in the SetBestChain debug.log lines)
              0.02        // * estimated number of transactions per second after that timestamp
          };
  
          /** RVN Start **/
          // Burn Amounts
          nIssueAssetBurnAmount = 500 * COIN;
          nReissueAssetBurnAmount = 100 * COIN;
          nIssueSubAssetBurnAmount = 100 * COIN;
          nIssueUniqueAssetBurnAmount = 5 * COIN;
  
          // Burn Addresses
          strIssueAssetBurnAddress = "n1issueAssetXXXXXXXXXXXXXXXXWdnemQ";
          strReissueAssetBurnAddress = "n1ReissueAssetXXXXXXXXXXXXXXWG9NLd";
          strIssueSubAssetBurnAddress = "n1issueSubAssetXXXXXXXXXXXXXbNiH6v";
          strIssueUniqueAssetBurnAddress = "n1issueUniqueAssetXXXXXXXXXXS4695i";
  
          // Global Burn Address
          strGlobalBurnAddress = "n1BurnXXXXXXXXXXXXXXXXXXXXXXU1qejP";
  
          // DGW Activation
          nDGWActivationBlock = 200;
  
          nMaxReorganizationDepth = 60; // 60 at 1 minute block timespan is +/- 60 minutes.
          nMinReorganizationPeers = 4;
          nMinReorganizationAge = 60 * 60 * 12; // 12 hours
          /** RVN End **/
  
      }
  };
  
  /**
   * Regression test
   */
  class CRegTestParams : public CChainParams {
  public:
      CRegTestParams() {
          strNetworkID = "regtest";
          consensus.nBIP34Enabled = true;
          consensus.nBIP65Enabled = true; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
          consensus.nBIP66Enabled = true;
          consensus.nSegwitEnabled = true;
          consensus.nCSVEnabled = true;
          consensus.nSubsidyHalvingInterval = 150;
          consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
          consensus.nPowTargetTimespan = 2016 * 60; // 1.4 days
          consensus.nPowTargetSpacing = 1 * 60;
          consensus.fPowAllowMinDifficultyBlocks = true;
          consensus.fPowNoRetargeting = true;
          consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
          consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
          consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 999999999999ULL;
          consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].bit = 6;
          consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nStartTime = 0;
          consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nTimeout = 999999999999ULL;
  
          // The best chain should have at least this much work.
          consensus.nMinimumChainWork = uint256S("0x00");
  
          // By default assume that the signatures in ancestors of this block are valid.
          consensus.defaultAssumeValid = uint256S("0x00");
  
          pchMessageStart[0] = 0x43;
          pchMessageStart[1] = 0x52;
          pchMessageStart[2] = 0x4F;
          pchMessageStart[3] = 0x57;
          nDefaultPort = 18444;
          nPruneAfterHeight = 1000;
  
  // This is used inorder to mine the genesis block. Once found, we can use the nonce and block hash found to create a valid genesis block
  //        /////////////////////////////////////////////////////////////////
  //
  //
  //        arith_uint256 test;
  //        bool fNegative;
  //        bool fOverflow;
  //        test.SetCompact(0x207fffff, &fNegative, &fOverflow);
  //        std::cout << "Test threshold: " << test.GetHex() << "\n\n";
  //
  //        int genesisNonce = 0;
  //        uint256 TempHashHolding = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");
  //        uint256 BestBlockHash = uint256S("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
  //        for (int i=0;i<40000000;i++) {
  //            genesis = CreateGenesisBlock(1533751200, i, 0x207fffff, 2, 5000 * COIN);
  //            //genesis.hashPrevBlock = TempHashHolding;
  //            consensus.hashGenesisBlock = genesis.GetHash();
  //
  //            arith_uint256 BestBlockHashArith = UintToArith256(BestBlockHash);
  //            if (UintToArith256(consensus.hashGenesisBlock) < BestBlockHashArith) {
  //                BestBlockHash = consensus.hashGenesisBlock;
  //                std::cout << BestBlockHash.GetHex() << " Nonce: " << i << "\n";
  //                std::cout << "   PrevBlockHash: " << genesis.hashPrevBlock.GetHex() << "\n";
  //            }
  //
  //            TempHashHolding = consensus.hashGenesisBlock;
  //
  //            if (BestBlockHashArith < test) {
  //                genesisNonce = i - 1;
  //                break;
  //            }
  //            //std::cout << consensus.hashGenesisBlock.GetHex() << "\n";
  //        }
  //        std::cout << "\n";
  //        std::cout << "\n";
  //        std::cout << "\n";
  //
  //        std::cout << "hashGenesisBlock to 0x" << BestBlockHash.GetHex() << std::endl;
  //        std::cout << "Genesis Nonce to " << genesisNonce << std::endl;
  //        std::cout << "Genesis Merkle " << genesis.hashMerkleRoot.GetHex() << std::endl;
  //
  //        std::cout << "\n";
  //        std::cout << "\n";
  //        int totalHits = 0;
  //        double totalTime = 0.0;
  //
  //        for(int x = 0; x < 16; x++) {
  //            totalHits += algoHashHits[x];
  //            totalTime += algoHashTotal[x];
  //            std::cout << "hash algo " << x << " hits " << algoHashHits[x] << " total " << algoHashTotal[x] << " avg " << algoHashTotal[x]/algoHashHits[x] << std::endl;
  //        }
  //
  //        std::cout << "Totals: hash algo " <<  " hits " << totalHits << " total " << totalTime << " avg " << totalTime/totalHits << std::endl;
  //
  //        genesis.hashPrevBlock = TempHashHolding;
  //
  //        return;
  
  //        /////////////////////////////////////////////////////////////////
  
  
          genesis = CreateGenesisBlock(1524179366, 1, 0x207fffff, 4, 5000 * COIN);
          consensus.hashGenesisBlock = genesis.GetHash();
  
          assert(consensus.hashGenesisBlock == uint256S("0x0b2c703dc93bb63a36c4e33b85be4855ddbca2ac951a7a0a29b8de0408200a3c "));
          assert(genesis.hashMerkleRoot == uint256S("0x28ff00a867739a352523808d301f504bc4547699398d70faf2266a8bae5f3516"));
  
          vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
          vSeeds.clear();      //!< Regtest mode doesn't have any DNS seeds.
  
          fDefaultConsistencyChecks = true;
          fRequireStandard = false;
          fMineBlocksOnDemand = true;
  
          checkpointData = (CCheckpointData) {
              {
              }
          };
  
          chainTxData = ChainTxData{
              0,
              0,
              0
          };
  
          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
          base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,239);
          base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
          base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
  
  
          /** RVN Start **/
          // Burn Amounts
          nIssueAssetBurnAmount = 500 * COIN;
          nReissueAssetBurnAmount = 100 * COIN;
          nIssueSubAssetBurnAmount = 100 * COIN;
          nIssueUniqueAssetBurnAmount = 5 * COIN;
  
          // Burn Addresses
          strIssueAssetBurnAddress = "n1issueAssetXXXXXXXXXXXXXXXXWdnemQ";
          strReissueAssetBurnAddress = "n1ReissueAssetXXXXXXXXXXXXXXWG9NLd";
          strIssueSubAssetBurnAddress = "n1issueSubAssetXXXXXXXXXXXXXbNiH6v";
          strIssueUniqueAssetBurnAddress = "n1issueUniqueAssetXXXXXXXXXXS4695i";
  
          // Global Burn Address
          strGlobalBurnAddress = "n1BurnXXXXXXXXXXXXXXXXXXXXXXU1qejP";
  
          // DGW Activation
          nDGWActivationBlock = 200;
  
          nMaxReorganizationDepth = 60; // 60 at 1 minute block timespan is +/- 60 minutes.
          nMinReorganizationPeers = 4;
          nMinReorganizationAge = 60 * 60 * 12; // 12 hours
          /** RVN End **/
      }
  };
  
  static std::unique_ptr<CChainParams> globalChainParams;
  
  const CChainParams &Params() {
      assert(globalChainParams);
      return *globalChainParams;
  }
  
  std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain)
  {
      if (chain == CBaseChainParams::MAIN)
          return std::unique_ptr<CChainParams>(new CMainParams());
      else if (chain == CBaseChainParams::TESTNET)
          return std::unique_ptr<CChainParams>(new CTestNetParams());
      else if (chain == CBaseChainParams::REGTEST)
          return std::unique_ptr<CChainParams>(new CRegTestParams());
      throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
  }
  
  void SelectParams(const std::string& network)
  {
      SelectBaseParams(network);
      globalChainParams = CreateChainParams(network);
  }
  
  void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
  {
      globalChainParams->UpdateVersionBitsParameters(d, nStartTime, nTimeout);
  }
  
  void TurnOffSegwit(){
  	globalChainParams->TurnOffSegwit();
  }
  
  void TurnOffCSV() {
  	globalChainParams->TurnOffCSV();
  }
  
  void TurnOffBIP34() {
  	globalChainParams->TurnOffBIP34();
  }
  
  void TurnOffBIP65() {
  	globalChainParams->TurnOffBIP65();
  }
  
  void TurnOffBIP66() {
  	globalChainParams->TurnOffBIP66();
  }
  