text: // Copyright (c) 2010 Satoshi Nakamoto
  // Copyright (c) 2009-2012 The Bitcoin developers
  // Distributed under the MIT/X11 software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #include "assert.h"
  
  #include "chainparams.h"
  #include "main.h"
  #include "util.h"
  
  #include <boost/assign/list_of.hpp>
  
  using namespace boost::assign;
  
  struct SeedSpec6 {
      uint8_t addr[16];
      uint16_t port;
  };
  
  #include "chainparamsseeds.h"
  
  //
  // Main network
  //
  
  // Convert the pnSeeds array into usable address objects.
  static void convertSeeds(std::vector<CAddress> &vSeedsOut, const unsigned int *data, unsigned int count, int port)
  {
       // It'll only connect to one or two seed nodes because once it connects,
       // it'll get a pile of addresses with newer timestamps.
       // Seed nodes are given a random 'last seen time' of between one and two
       // weeks ago.
       const int64_t nOneWeek = 7*24*60*60;
      for (unsigned int k = 0; k < count; ++k)
      {
          struct in_addr ip;
          unsigned int i = data[k], t;
  
          // -- convert to big endian
          t =   (i & 0x000000ff) << 24u
              | (i & 0x0000ff00) << 8u
              | (i & 0x00ff0000) >> 8u
              | (i & 0xff000000) >> 24u;
  
          memcpy(&ip, &t, sizeof(ip));
  
          CAddress addr(CService(ip, port));
          addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek;
          vSeedsOut.push_back(addr);
      }
  }
  
  class CMainParams : public CChainParams {
  public:
      CMainParams() {
          // 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 4-byte int at any alignment.
          pchMessageStart[0] = 0xf5;
          pchMessageStart[1] = 0xef;
          pchMessageStart[2] = 0xa4;
          pchMessageStart[3] = 0xc8;
          vAlertPubKey = ParseHex("043d8e0f7214bd3c40b7d11707deb16c547b6dd9a36c3b59e45cb9255ef15d2fdfc260d79658677aa9f7af4ca549cf300b427ce4d1efa1ea474e5bf9642e016c97");
          nDefaultPort = 32821;
          nRPCPort = 32822;
          bnProofOfWorkLimit = CBigNum(~uint256(0) >> 24);
  
          const char* pszTimestamp = "Bitcoin Could Break Out and Rise With Altcoins Next Week";
          std::vector<CTxIn> vin;
          vin.resize(1);
          vin[0].scriptSig = CScript() << 0 << CBigNum(42) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
          std::vector<CTxOut> vout;
          vout.resize(1);
          vout[0].SetEmpty();
          CTransaction txNew(1, 1531241978, vin, vout, 0);
          genesis.vtx.push_back(txNew);
          genesis.hashPrevBlock = 0;
          genesis.hashMerkleRoot = genesis.BuildMerkleTree();
          genesis.nVersion = 1;
          genesis.nTime    = 1636252304;
          genesis.nBits    = 0x1f00ffff;
          genesis.nNonce   = 69157;
  
          hashGenesisBlock = genesis.GetHash();
          assert(hashGenesisBlock == uint256("0x0000e5c58ff5bfa765dd4cfa93eebad86067987e3adbd9003990975d9ac0b1bb"));
          assert(genesis.hashMerkleRoot == uint256("0xcbccda0e71b67626716f733bd008a4f067e830b96d01788e34154ae5a4bd8f8e"));
  
          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,25);
          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,85);
          base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,153);
          base58Prefixes[STEALTH_ADDRESS] = std::vector<unsigned char>(1,40);
          base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
          base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();
  
          vSeeds.push_back(CDNSSeedData("seed1.buntucryptocurrency.com", "seed1.buntucryptocurrency.com"));
  
          convertSeeds(vFixedSeeds, pnSeed, ARRAYLEN(pnSeed), nDefaultPort);
  
          nPoolMaxTransactions = 3;
          strDarksendPoolDummyAddress = "BTBa6KMQCYVP2kLvE2frRY2vGfsr5omUeN";
          nLastPOWBlock = 600;
          nPOSStartBlock = 1;
      }
  
      virtual const CBlock& GenesisBlock() const { return genesis; }
      virtual Network NetworkID() const { return CChainParams::MAIN; }
  
      virtual const vector<CAddress>& FixedSeeds() const {
          return vFixedSeeds;
      }
  protected:
      CBlock genesis;
      vector<CAddress> vFixedSeeds;
  };
  static CMainParams mainParams;
  
  
  //
  // Testnet
  //
  
  class CTestNetParams : public CMainParams {
  public:
      CTestNetParams() {
          // 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 4-byte int at any alignment.
          pchMessageStart[0] = 0x5l;
          pchMessageStart[1] = 0xa8;
          pchMessageStart[2] = 0xd4;
          pchMessageStart[3] = 0xdc;
          bnProofOfWorkLimit = CBigNum(~uint256(0) >> 16);
          vAlertPubKey = ParseHex("04c74c50a0a5a32dfc1a003f3d9ffac805ea12c7d6f7134e7a92b9a8d0acdffd90e0bd2a05a932d853133ac0fb98bdc16d08f6cffa870e7fbec5b040ca9e922583");
          nDefaultPort = 32823;
          nRPCPort = 32824;
          strDataDir = "testnet";
  
          const char* pszTimestamp = "House Sends Infrastructure Bill With Crypto Tax Provision to US President";
          std::vector<CTxIn> vin;
          vin.resize(1);
          vin[0].scriptSig = CScript() << 0 << CBigNum(42) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
          std::vector<CTxOut> vout;
          vout.resize(1);
          vout[0].SetEmpty();
          CTransaction txNew(1, 1508981174, vin, vout, 0);
          genesis.vtx.push_back(txNew);
          genesis.hashPrevBlock = 0;
          genesis.hashMerkleRoot = genesis.BuildMerkleTree();
          genesis.nVersion = 1;
          genesis.nTime    = 1636252436;
          genesis.nBits    = 0x1f00ffff;
          genesis.nNonce   = 73763;
  
          hashGenesisBlock = genesis.GetHash();
          assert(hashGenesisBlock == uint256("0x0000cd1e93a69c11082be55a9ac3974c9d5b03897de26d5ebce14ac4d4b8abf9"));
          assert(genesis.hashMerkleRoot == uint256("0x0edbe18566120a04ebe9ecaeea338ff336ded9d8cfb41f8bf290cdd508bee121"));
  
          vFixedSeeds.clear();
          vSeeds.clear();
  
          base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,85);
          base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
          base58Prefixes[SECRET_KEY]     = std::vector<unsigned char>(1,239);
          base58Prefixes[STEALTH_ADDRESS] = std::vector<unsigned char>(1,40);
          base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
          base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
  
          convertSeeds(vFixedSeeds, pnTestnetSeed, ARRAYLEN(pnTestnetSeed), nDefaultPort);
  
          nLastPOWBlock = 20000;
      }
      virtual Network NetworkID() const { return CChainParams::TESTNET; }
  };
  static CTestNetParams testNetParams;
  
  
  static CChainParams *pCurrentParams = &mainParams;
  
  const CChainParams &Params() {
      return *pCurrentParams;
  }
  
  void SelectParams(CChainParams::Network network) {
      switch (network) {
          case CChainParams::MAIN:
              pCurrentParams = &mainParams;
              break;
          case CChainParams::TESTNET:
              pCurrentParams = &testNetParams;
              break;
          default:
              assert(false && "Unimplemented network");
              return;
      }
  }
  
  bool SelectParamsFromCommandLine() {
  
      bool fTestNet = GetBoolArg("-testnet", false);
  
      if (fTestNet) {
          SelectParams(CChainParams::TESTNET);
      } else {
          SelectParams(CChainParams::MAIN);
      }
      return true;
  }
  