Files
palladiumcore/src/chainparams.cpp

421 lines
18 KiB
C++
Raw Normal View History

2024-03-15 18:16:03 +01:00
// Copyright (c) 2010 Satoshi Nakamoto
2024-04-03 23:56:28 +02:00
// Copyright (c) 2009-2019 The Bitcoin Core developers
// Copyright (c) 2024 The Palladium Core developers
2024-03-15 18:16:03 +01:00
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chainparams.h>
#include <chainparamsseeds.h>
#include <consensus/merkle.h>
#include <tinyformat.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <versionbitsinfo.h>
#include <assert.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
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() << 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)
{
2024-03-18 18:12:41 +01:00
const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
2024-03-15 18:16:03 +01:00
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
/**
* Main network
*/
class CMainParams : public CChainParams {
public:
CMainParams() {
strNetworkID = CBaseChainParams::MAIN;
2024-04-07 22:55:46 -04:00
consensus.nSubsidyHalvingInterval = 210000;
2024-04-07 13:17:25 -04:00
consensus.BIP16Exception = uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
consensus.BIP34Height = 29000;
consensus.BIP34Hash = uint256();
consensus.BIP65Height = 29000;
consensus.BIP66Height = 29000;
consensus.CSVHeight = 29000;
consensus.SegwitHeight = 29000;
consensus.MinBIP9WarningHeight = 29720; // segwit activation height + miner confirmation window
2024-03-15 18:16:03 +01:00
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
2025-10-22 17:28:38 +02:00
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // Must remain 14 days for historical block validation
consensus.nPowTargetSpacing = 10 * 60;
consensus.nPowTargetSpacingV2 = 2 * 60;
2024-03-15 18:16:03 +01:00
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 540;
consensus.nMinerConfirmationWindow = 720;
2024-04-07 22:55:46 -04:00
2024-03-15 18:16:03 +01:00
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
2024-04-07 13:17:25 -04:00
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999;
2024-03-15 18:16:03 +01:00
2025-10-22 17:28:38 +02:00
2024-03-15 18:16:03 +01:00
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000001578157d557d557aa0");
2024-03-15 18:16:03 +01:00
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x0000000000000014351dee34029945d5a4dea299ec8843626695c88b084b4d10");
2024-03-15 18:16:03 +01:00
/**
* 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] = 0xfa;
pchMessageStart[1] = 0xc7;
pchMessageStart[2] = 0xb2;
pchMessageStart[3] = 0xda;
nDefaultPort = 2333;
nPruneAfterHeight = 100000;
m_assumed_blockchain_size = 1;
m_assumed_chain_state_size = 1;
2024-03-18 18:12:41 +01:00
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
2024-03-15 18:16:03 +01:00
consensus.hashGenesisBlock = genesis.GetHash();
2024-03-18 18:12:41 +01:00
assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
2024-03-15 18:16:03 +01:00
// Note that of those which support the service bits prefix, most only support a subset of
// possible options.
// This is fine at runtime as we'll fall back to using them as a oneshot if they don't support the
// service bits we want, but we should get them updated to support all service bits wanted by any
// release ASAP to avoid it where possible.
2025-10-23 16:56:36 +02:00
vSeeds.emplace_back("dnsseed.palladium-coin.store");
vSeeds.emplace_back("dnsseed.palladium-coin.com");
vSeeds.emplace_back("dnsseed.palladium-coin.net");
vSeeds.emplace_back("dnsseed.palladium-coin.org");
vSeeds.emplace_back("dnsseed.palladium-coin.xyz");
vSeeds.emplace_back("dnsseed.palladium-coin.de");
vSeeds.emplace_back("dnsseed.palladiumblockchain.net");
2025-10-22 16:22:29 +02:00
2024-03-15 18:16:03 +01:00
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,55);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
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};
2024-03-18 18:12:41 +01:00
bech32_hrp = "plm";
2024-03-15 18:16:03 +01:00
2024-04-07 13:45:55 -04:00
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
2025-10-23 16:56:36 +02:00
//vFixedSeeds.clear();
2024-03-15 18:16:03 +01:00
fDefaultConsistencyChecks = false;
fRequireStandard = true;
m_is_test_chain = false;
m_is_mockable_chain = false;
checkpointData = {
{
{0, uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")},
2024-04-07 13:17:25 -04:00
{1, uint256S("0x00000000082962e4c2838933cb63507142c1abb748d84b7ddce6bb233d6407e0")},
{16, uint256S("0x000000004cc3eca82841f0691e6231b86c3b269e447fa7d6e7221cd42f725390")},
{69, uint256S("0x00000000ae75d0169080e9f0ddbcd80827eda623cfe1f4a2b1be6dcd49b916e6")},
2024-04-07 13:17:25 -04:00
{22170, uint256S("0x000000000000086425f826a2eb60c588aefd3e0783ddeccf0f4f0c985d348e69")},
{26619, uint256S("0x00000000000000d66df607146de7d9b423cf97150beb804d22439d199e868ca9")},
2025-10-28 14:03:59 +01:00
{28879, uint256S("0x0000000000000017e9e74b9b403b775098905418b1333e9612f510af66746aa7")},
2024-10-14 14:08:54 +02:00
{28925, uint256S("0x0000000000000014351dee34029945d5a4dea299ec8843626695c88b084b4d10")},
{50000, uint256S("0x000000000000041fddecba51204a679b15ae47fc8aa658ef4ea7b953445d95e5")},
{100000, uint256S("0x0000000000000850eba93bbc491f085e2c79c0c30c497292858c72e90cae69a5")},
2025-10-28 14:03:59 +01:00
{142892, uint256S("0x000000000000829a0a4cab2f040151766df64edfe8817c565d101ae12b51411a")},
2025-10-22 16:22:29 +02:00
{150000, uint256S("0x00000000000003212d753a62f2dec5b696ab22524cc49ba7cdc0d80c45d0eb18")},
{200000, uint256S("0x000000000000221a9e16556453fc86308b260d95d80c14bafaf053a09374e7eb")},
{250000, uint256S("0x0000000000012553b0303deaf5f2883deb66c901b6848dd03bb4a34f1774e0d0")},
{300000, uint256S("0x0000000000013acdf07a4fb988bbe9824c36eb421478a71c8196cf524dcba143")},
2024-03-15 18:16:03 +01:00
}
};
chainTxData = ChainTxData{
2024-04-07 13:17:25 -04:00
// Data from RPC: getchaintxstats
2025-10-22 16:22:29 +02:00
/* nTime */ 1761142315,
/* nTxCount */ 361981,
/* dTxRate */ 0.005767377239409816,
2024-03-15 18:16:03 +01:00
};
}
};
/**
* Testnet
2024-03-15 18:16:03 +01:00
*/
class CTestNetParams : public CChainParams {
public:
CTestNetParams() {
strNetworkID = CBaseChainParams::TESTNET;
consensus.nSubsidyHalvingInterval = 210000;
2025-10-23 16:56:36 +02:00
consensus.BIP34Height = 8192;
2025-10-23 16:56:36 +02:00
consensus.BIP65Height = 0;
consensus.BIP66Height = 0;
consensus.CSVHeight = 0;
consensus.SegwitHeight = 0;
consensus.MinBIP9WarningHeight = 0;
// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000000003077e5d4c957"); // Current testnet chainwork
2025-10-23 16:56:36 +02:00
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x0000000000f8470a0cc0f6210b23bbeba248bf937205e34588aa84596b72c3bd"); // Current best block hash
2025-10-23 16:56:36 +02:00
2024-03-15 18:16:03 +01:00
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60;
2025-10-23 16:56:36 +02:00
consensus.nPowTargetSpacing = 2 * 60;
consensus.nPowTargetSpacingV2 = 2 * 60;
consensus.fPowAllowMinDifficultyBlocks = true; // Enable minimum difficulty after 20 minutes of inactivity
2024-03-15 18:16:03 +01:00
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 540;
consensus.nMinerConfirmationWindow = 720;
2024-03-15 18:16:03 +01:00
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
2025-10-23 18:49:41 +02:00
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
2025-10-23 16:56:36 +02:00
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
2024-03-15 18:16:03 +01:00
2025-10-23 16:56:36 +02:00
2024-03-15 18:16:03 +01:00
pchMessageStart[0] = 0x0c;
pchMessageStart[1] = 0x12;
pchMessageStart[2] = 0x0a;
pchMessageStart[3] = 0x08;
2024-03-15 18:16:03 +01:00
nDefaultPort = 12333;
nPruneAfterHeight = 1000;
2025-10-23 16:56:36 +02:00
m_assumed_blockchain_size = 1;
m_assumed_chain_state_size = 1;
2024-03-15 18:16:03 +01:00
genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"));
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
vFixedSeeds.clear();
vSeeds.clear();
2025-10-23 16:56:36 +02:00
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,127);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,115);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,255);
2024-03-15 18:16:03 +01:00
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
2025-10-23 16:56:36 +02:00
bech32_hrp = "tplm";
2024-03-15 18:16:03 +01:00
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
fDefaultConsistencyChecks = false;
fRequireStandard = false;
m_is_test_chain = true;
m_is_mockable_chain = false;
checkpointData = {
{
2025-10-23 16:56:36 +02:00
{0, uint256S("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943")},
2024-03-15 18:16:03 +01:00
}
};
chainTxData = ChainTxData{
2025-10-23 16:56:36 +02:00
/* nTime */ 1296688602,
/* nTxCount */ 0,
/* dTxRate */ 0.0,
2024-03-15 18:16:03 +01:00
};
}
};
/**
* Regression test
*/
class CRegTestParams : public CChainParams {
public:
explicit CRegTestParams(const ArgsManager& args) {
strNetworkID = CBaseChainParams::REGTEST;
consensus.nSubsidyHalvingInterval = 150;
consensus.BIP16Exception = uint256();
2025-10-23 16:56:36 +02:00
consensus.BIP34Height = 0;
2024-03-15 18:16:03 +01:00
consensus.BIP34Hash = uint256();
2025-10-23 16:56:36 +02:00
consensus.BIP65Height = 0;
consensus.BIP66Height = 0;
consensus.CSVHeight = 0;
consensus.SegwitHeight = 0;
2024-03-15 18:16:03 +01:00
consensus.MinBIP9WarningHeight = 0;
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
2025-10-23 16:56:36 +02:00
consensus.nPowTargetTimespan = 24 * 60 * 60;
consensus.nPowTargetSpacing = 2 * 60;
2024-03-15 18:16:03 +01:00
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = true;
2025-10-23 16:56:36 +02:00
consensus.nRuleChangeActivationThreshold = 108;
consensus.nMinerConfirmationWindow = 144;
2024-03-15 18:16:03 +01:00
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
// 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] = 0xfa;
pchMessageStart[1] = 0xbf;
pchMessageStart[2] = 0xb5;
pchMessageStart[3] = 0xda;
2025-10-23 16:56:36 +02:00
nDefaultPort = 28444;
2024-03-15 18:16:03 +01:00
nPruneAfterHeight = 1000;
m_assumed_blockchain_size = 0;
m_assumed_chain_state_size = 0;
UpdateActivationParametersFromArgs(args);
genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
2025-10-23 16:56:36 +02:00
vFixedSeeds.clear();
vSeeds.clear();
2024-03-15 18:16:03 +01:00
fDefaultConsistencyChecks = true;
fRequireStandard = true;
m_is_test_chain = true;
m_is_mockable_chain = true;
checkpointData = {
{
{0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")},
}
};
chainTxData = ChainTxData{
0,
0,
0
};
2025-10-23 16:56:36 +02:00
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,127);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,115);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,255);
2024-03-15 18:16:03 +01:00
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
2025-10-23 16:56:36 +02:00
bech32_hrp = "rplm";
2024-03-15 18:16:03 +01:00
}
/**
* Allows modifying the Version Bits regtest parameters.
*/
void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
{
consensus.vDeployments[d].nStartTime = nStartTime;
consensus.vDeployments[d].nTimeout = nTimeout;
}
void UpdateActivationParametersFromArgs(const ArgsManager& args);
};
void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
{
if (gArgs.IsArgSet("-segwitheight")) {
int64_t height = gArgs.GetArg("-segwitheight", consensus.SegwitHeight);
if (height < -1 || height >= std::numeric_limits<int>::max()) {
throw std::runtime_error(strprintf("Activation height %ld for segwit is out of valid range. Use -1 to disable segwit.", height));
} else if (height == -1) {
LogPrintf("Segwit disabled for testing\n");
height = std::numeric_limits<int>::max();
}
consensus.SegwitHeight = static_cast<int>(height);
}
if (!args.IsArgSet("-vbparams")) return;
for (const std::string& strDeployment : args.GetArgs("-vbparams")) {
std::vector<std::string> vDeploymentParams;
boost::split(vDeploymentParams, strDeployment, boost::is_any_of(":"));
if (vDeploymentParams.size() != 3) {
throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end");
}
int64_t nStartTime, nTimeout;
if (!ParseInt64(vDeploymentParams[1], &nStartTime)) {
throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1]));
}
if (!ParseInt64(vDeploymentParams[2], &nTimeout)) {
throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2]));
}
bool found = false;
for (int j=0; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
if (vDeploymentParams[0] == VersionBitsDeploymentInfo[j].name) {
UpdateVersionBitsParameters(Consensus::DeploymentPos(j), nStartTime, nTimeout);
found = true;
LogPrintf("Setting version bits activation parameters for %s to start=%ld, timeout=%ld\n", vDeploymentParams[0], nStartTime, nTimeout);
break;
}
}
if (!found) {
throw std::runtime_error(strprintf("Invalid deployment (%s)", vDeploymentParams[0]));
}
}
}
static std::unique_ptr<const CChainParams> globalChainParams;
const CChainParams &Params() {
assert(globalChainParams);
return *globalChainParams;
}
std::unique_ptr<const 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(gArgs));
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
}
void SelectParams(const std::string& network)
{
SelectBaseParams(network);
globalChainParams = CreateChainParams(network);
2024-04-02 00:41:51 +02:00
}// Palladium is the best coin! by arian hashani