// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Copyright (c) 2017 The AllSafe developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "libzerocoin/Params.h" #include "chainparams.h" #include "random.h" #include "util.h" #include "utilstrencodings.h" #include #include using namespace std; using namespace boost::assign; struct SeedSpec6 { uint8_t addr[16]; uint16_t port; }; #include "chainparamsseeds.h" /** * Main network */ //! Convert the pnSeeds6 array into usable address objects. static void convertSeed6(std::vector& vSeedsOut, const SeedSpec6* data, unsigned int count) { // 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 i = 0; i < count; i++) { struct in6_addr ip; memcpy(&ip, data[i].addr, sizeof(ip)); CAddress addr(CService(ip, data[i].port)); addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek; vSeedsOut.push_back(addr); } } // 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 static Checkpoints::MapCheckpoints mapCheckpoints = boost::assign::map_list_of (0, uint256("0x000008ef7624feb09776d000c2cfcf670caa04e029ba16b88fbde2a0bdfd047b")); static const Checkpoints::CCheckpointData data = { &mapCheckpoints, 1545874509, // * UNIX timestamp of last checkpoint block 0, // * total number of transactions between genesis and last checkpoint // (the tx=... number in the SetBestChain debug.log lines) 2000 // * estimated number of transactions per day after checkpoint }; static Checkpoints::MapCheckpoints mapCheckpointsTestnet = boost::assign::map_list_of(0, uint256("0x001")); static const Checkpoints::CCheckpointData dataTestnet = { &mapCheckpointsTestnet, 1740710, 0, 250}; static Checkpoints::MapCheckpoints mapCheckpointsRegtest = boost::assign::map_list_of(0, uint256("0x001")); static const Checkpoints::CCheckpointData dataRegtest = { &mapCheckpointsRegtest, 1454124731, 0, 100}; libzerocoin::ZerocoinParams* CChainParams::Zerocoin_Params() const { assert(this); static CBigNum bnTrustedModulus(zerocoinModulus); static libzerocoin::ZerocoinParams ZCParams = libzerocoin::ZerocoinParams(bnTrustedModulus); return &ZCParams; } class CMainParams : public CChainParams { public: CMainParams() { networkID = CBaseChainParams::MAIN; strNetworkID = "main"; pchMessageStart[0] = 0x08; pchMessageStart[1] = 0x20; pchMessageStart[2] = 0x18; pchMessageStart[3] = 0x31; vAlertPubKey = ParseHex("049dac032d04477b5ff9df6fa17185732af9439ccded831664ea5dc0aeff7d2126103416acedd6d380a3010f14046bbb94ab64d4b2cfa2ab5dadec21c144041514"); nDefaultPort = 7127; bnProofOfWorkLimit = ~uint256(0) >> 20; //20 AllSafe starting difficulty is 1 / 2^12 nSubsidyHalvingInterval = 999999999; nMaxReorganizationDepth = 100; nEnforceBlockUpgradeMajority = 750; nRejectBlockOutdatedMajority = 950; nToCheckBlockUpgradeMajority = 1000; nMinerThreads = 0; nTargetTimespan = 1 * 60; nTargetSpacingSlowLaunch = 1 * 60; nTargetSpacing = 1 * 60; nMaturity = 15; nMasternodeCountDrift = 20; nMaxMoneyOut = 15000000 * COIN; nLastPOWBlock = 200; nModifierUpdateBlock = 999999999; nZerocoinStartHeight = 999999999; nAccumulatorStartHeight = 1; nZerocoinStartTime = 1745874509; nBlockEnforceSerialRange = 1; //Enforce serial range starting this block nBlockRecalculateAccumulators = ~1; //Trigger a recalculation of accumulators nBlockFirstFraudulent = ~1; //First block that bad serials emerged nBlockLastGoodCheckpoint = ~1; //Last valid accumulator checkpoint const char* pszTimestamp = "AllSafe Version 2 Established Dec 2018 - Merry Christmas & Happy New Year"; CMutableTransaction txNew; txNew.vin.resize(1); txNew.vout.resize(1); txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); txNew.vout[0].nValue = 1 * COIN; txNew.vout[0].scriptPubKey = CScript() << ParseHex("04fda9440cc8a4a0ba774135eeb1039ba7420d72142d99a54858573a726cf86bfba8cc0e554d5b5d6ea650c3badf832f54521d3ec2648e30bf1784a66c5fb92266") << OP_CHECKSIG; genesis.vtx.push_back(txNew); genesis.hashPrevBlock = 0; genesis.hashMerkleRoot = genesis.BuildMerkleTree(); genesis.nVersion = 1; genesis.nTime = 1545874509; genesis.nBits = 0x1e0ffff0; genesis.nNonce = 262373; hashGenesisBlock = genesis.GetHash(); assert(hashGenesisBlock == uint256("0x000008ef7624feb09776d000c2cfcf670caa04e029ba16b88fbde2a0bdfd047b")); assert(genesis.hashMerkleRoot == uint256("0x5d7df006b8fa32dbd25c7ecfebff4278159c4ada47c32592699dc13a36802d9d")); vSeeds.push_back(CDNSSeedData("185.241.54.17", "185.241.54.17")); vSeeds.push_back(CDNSSeedData("185.241.54.37", "185.241.54.37")); vSeeds.push_back(CDNSSeedData("185.241.54.45", "185.241.54.45")); base58Prefixes[PUBKEY_ADDRESS] = std::vector(1, 125); // s base58Prefixes[SCRIPT_ADDRESS] = std::vector(1, 83); // a base58Prefixes[SECRET_KEY] = std::vector(1, 95); // f base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x02)(0x2D)(0x25)(0x73).convert_to_container >(); base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x02)(0x21)(0x31)(0x2B).convert_to_container >(); base58Prefixes[EXT_COIN_TYPE] = boost::assign::list_of(0x80)(0x00)(0x1d)(0xfc).convert_to_container >(); convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main)); fRequireRPCPassword = true; fMiningRequiresPeers = true; fAllowMinDifficultyBlocks = false; fDefaultConsistencyChecks = false; fRequireStandard = true; fMineBlocksOnDemand = false; fSkipProofOfWorkCheck = false; fTestnetToBeDeprecatedFieldRPC = false; fHeadersFirstSyncingActive = false; nPoolMaxTransactions = 3; strSporkKey = "048600B38F5EAA95A3A70B3E7FAE76B2392A1C5F6926B361A5B531FD2C0270598616CA2B9540B6125B93B4D7C0CFFB1BABD7E3C57490E929280A312F216618D340"; strObfuscationPoolDummyAddress = "sfSAthmZqvsay3mduUi29Dfb6qPeoUPDJN"; nStartMasternodePayments = 1545874509; /** Zerocoin */ zerocoinModulus = "0xc95577b6dce0049b0a20c779af38079355abadde1a1d80c353f6cb697a7ae5a087bad39caa5798478551d0f9d91e6267716506f32412de1d19d17588765eb9502b85c6a18abdb05791cfd8b734e960281193705eeece210920cc922b3af3ceb178bf12c22eb565d5767fbf19545639be8953c2c38ffad41f3371e4aac750ac2d7bd614b3faabb453081d5d88fdbb803657a980bc93707e4b14233a2358c97763bf28f7c933206071477e8b371f229bc9ce7d6ef0ed7163aa5dfe13bc15f7816348b328fa2c1e69d5c88f7b94cee7829d56d1842d77d7bb8692e9fc7b7db059836500de8d57eb43c345feb58671503b932829112941367996b03871300f25efb5"; nMaxZerocoinSpendsPerTransaction = 7; // Assume about 20kb each nMinZerocoinMintFee = 1 * ZCENT; //high fee required for zerocoin mints nMintRequiredConfirmations = 20; //the maximum amount of confirmations until accumulated in 19 nRequiredAccumulation = 1; nDefaultSecurityLevel = 100; //full security level for accumulators nZerocoinHeaderVersion = 4; //Block headers must be this version once zerocoin is active nBudget_Fee_Confirmations = 6; // Number of confirmations for the finalization fee } const Checkpoints::CCheckpointData& Checkpoints() const { return data; } }; static CMainParams mainParams; /** * Testnet (v3) */ class CTestNetParams : public CMainParams { public: CTestNetParams() { networkID = CBaseChainParams::TESTNET; strNetworkID = "test"; pchMessageStart[0] = 0x43; pchMessageStart[1] = 0x76; pchMessageStart[2] = 0x65; pchMessageStart[3] = 0xba; vAlertPubKey = ParseHex("042292b1f401860eea99e1a8a103effbd7e1c013a59a1a3a0c91c9d1997a0bc6f338567278c11344802838c107055bf7c1641eaed61e879245c255a4f5be5746fc"); nDefaultPort = 51434; nEnforceBlockUpgradeMajority = 51; nRejectBlockOutdatedMajority = 75; nToCheckBlockUpgradeMajority = 100; nMinerThreads = 0; nTargetTimespan = 1 * 60; // AllSafe: 1 day nTargetSpacing = 1 * 60; // AllSafe: 1 minute nLastPOWBlock = 200; nMaturity = 15; nMasternodeCountDrift = 4; nModifierUpdateBlock = 51197; //approx Mon, 17 Apr 2017 04:00:00 GMT nMaxMoneyOut = 43199500 * COIN; nZerocoinStartHeight = 201576; nZerocoinStartTime = 1524711188; nBlockEnforceSerialRange = 1; //Enforce serial range starting this block nBlockRecalculateAccumulators = 9908000; //Trigger a recalculation of accumulators nBlockFirstFraudulent = 9891737; //First block that bad serials emerged nBlockLastGoodCheckpoint = 9891730; //Last valid accumulator checkpoint //! Modify the testnet genesis block so the timestamp is valid for a later start. genesis.nTime = 1515616140; genesis.nNonce = 79855; hashGenesisBlock = genesis.GetHash(); //assert(hashGenesisBlock == uint256("0x000007cff63ef602a51bf074e384b3516f0dd202f14d52f7c8c9b1af9423ab2e")); vFixedSeeds.clear(); vSeeds.clear(); // vSeeds.push_back(CDNSSeedData("45.76.61.28", "207.148.0.129")); // Single node address // vSeeds.push_back(CDNSSeedData("209.250.240.94", "45.77.239.30")); // Single node address // vSeeds.push_back(CDNSSeedData("45.77.176.204", "45.76.226.204")); // Single node address base58Prefixes[PUBKEY_ADDRESS] = std::vector(1, 139); // Testnet allsafe addresses start with 'x' or 'y' base58Prefixes[SCRIPT_ADDRESS] = std::vector(1, 19); // Testnet allsafe script addresses start with '8' or '9' base58Prefixes[SECRET_KEY] = std::vector(1, 239); // Testnet private keys start with '9' or 'c' (Bitcoin defaults) // Testnet allsafe BIP32 pubkeys start with 'DRKV' base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x3a)(0x80)(0x61)(0xa0).convert_to_container >(); // Testnet allsafe BIP32 prvkeys start with 'DRKP' base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x3a)(0x80)(0x58)(0x37).convert_to_container >(); // Testnet allsafe BIP44 coin type is '1' (All coin's testnet default) base58Prefixes[EXT_COIN_TYPE] = boost::assign::list_of(0x80)(0x00)(0x00)(0x01).convert_to_container >(); convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test)); fRequireRPCPassword = true; fMiningRequiresPeers = true; fAllowMinDifficultyBlocks = true; fDefaultConsistencyChecks = false; fRequireStandard = false; fMineBlocksOnDemand = false; fTestnetToBeDeprecatedFieldRPC = true; nPoolMaxTransactions = 2; strSporkKey = "04188441e39d99aa69068ee07d26980f459b84465bbd765c6ee15d1aec5b76b5aebb01b24be184a1d3a12af61276549d96cc9499d909f8afc183132837d18d643d"; strObfuscationPoolDummyAddress = "xp87cG8UEQgzs1Bk67Yk884C7pnQfAeo7q"; nStartMasternodePayments = 1420837558; //Fri, 09 Jan 2015 21:05:58 GMT nBudget_Fee_Confirmations = 3; // Number of confirmations for the finalization fee. We have to make this very short // here because we only have a 8 block finalization window on testnet } const Checkpoints::CCheckpointData& Checkpoints() const { return dataTestnet; } }; static CTestNetParams testNetParams; /** * Regression test */ class CRegTestParams : public CTestNetParams { public: CRegTestParams() { networkID = CBaseChainParams::REGTEST; strNetworkID = "regtest"; strNetworkID = "regtest"; pchMessageStart[0] = 0x69; pchMessageStart[1] = 0xcf; pchMessageStart[2] = 0x7e; pchMessageStart[3] = 0xac; nSubsidyHalvingInterval = 150; nEnforceBlockUpgradeMajority = 750; nRejectBlockOutdatedMajority = 950; nToCheckBlockUpgradeMajority = 1000; nMinerThreads = 1; nTargetTimespan = 24 * 60 * 60; // AllSafe: 1 day nTargetSpacing = 1 * 60; // AllSafe: 1 minutes bnProofOfWorkLimit = ~uint256(0) >> 1; genesis.nTime = 1515524400; genesis.nBits = 0x1e0ffff0; genesis.nNonce = 732084; hashGenesisBlock = genesis.GetHash(); nDefaultPort = 51436; //assert(hashGenesisBlock == uint256("0x000008415bdca132b70cf161ecc548e5d0150fd6634a381ee2e99bb8bb77dbb3")); vFixedSeeds.clear(); //! Testnet mode doesn't have any fixed seeds. vSeeds.clear(); //! Testnet mode doesn't have any DNS seeds. fRequireRPCPassword = false; fMiningRequiresPeers = false; fAllowMinDifficultyBlocks = true; fDefaultConsistencyChecks = true; fRequireStandard = false; fMineBlocksOnDemand = true; fTestnetToBeDeprecatedFieldRPC = false; } const Checkpoints::CCheckpointData& Checkpoints() const { return dataRegtest; } }; static CRegTestParams regTestParams; /** * Unit test */ class CUnitTestParams : public CMainParams, public CModifiableParams { public: CUnitTestParams() { networkID = CBaseChainParams::UNITTEST; strNetworkID = "unittest"; nDefaultPort = 51478; vFixedSeeds.clear(); //! Unit test mode doesn't have any fixed seeds. vSeeds.clear(); //! Unit test mode doesn't have any DNS seeds. fRequireRPCPassword = false; fMiningRequiresPeers = false; fDefaultConsistencyChecks = true; fAllowMinDifficultyBlocks = false; fMineBlocksOnDemand = true; } const Checkpoints::CCheckpointData& Checkpoints() const { // UnitTest share the same checkpoints as MAIN return data; } //! Published setters to allow changing values in unit test cases virtual void setSubsidyHalvingInterval(int anSubsidyHalvingInterval) { nSubsidyHalvingInterval = anSubsidyHalvingInterval; } virtual void setEnforceBlockUpgradeMajority(int anEnforceBlockUpgradeMajority) { nEnforceBlockUpgradeMajority = anEnforceBlockUpgradeMajority; } virtual void setRejectBlockOutdatedMajority(int anRejectBlockOutdatedMajority) { nRejectBlockOutdatedMajority = anRejectBlockOutdatedMajority; } virtual void setToCheckBlockUpgradeMajority(int anToCheckBlockUpgradeMajority) { nToCheckBlockUpgradeMajority = anToCheckBlockUpgradeMajority; } virtual void setDefaultConsistencyChecks(bool afDefaultConsistencyChecks) { fDefaultConsistencyChecks = afDefaultConsistencyChecks; } virtual void setAllowMinDifficultyBlocks(bool afAllowMinDifficultyBlocks) { fAllowMinDifficultyBlocks = afAllowMinDifficultyBlocks; } virtual void setSkipProofOfWorkCheck(bool afSkipProofOfWorkCheck) { fSkipProofOfWorkCheck = afSkipProofOfWorkCheck; } }; static CChainParams* pCurrentParams = 0; const CChainParams& Params() { assert(pCurrentParams); return *pCurrentParams; } CChainParams& Params(CBaseChainParams::Network network) { switch (network) { case CBaseChainParams::MAIN: return mainParams; case CBaseChainParams::TESTNET: return testNetParams; case CBaseChainParams::REGTEST: return regTestParams; default: assert(false && "Unimplemented network"); return mainParams; } } void SelectParams(CBaseChainParams::Network network) { SelectBaseParams(network); pCurrentParams = &Params(network); } bool SelectParamsFromCommandLine() { CBaseChainParams::Network network = NetworkIdFromCommandLine(); if (network == CBaseChainParams::MAX_NETWORK_TYPES) return false; SelectParams(network); return true; }