mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 13:59:06 +01:00
cd9c6994c2
* Initial devnet * Move genesis block adding into its own method * Introduce -allowprivatenet to lift limitation on RFC1918 addresses Normally, RFC1918 (192.168.x.x/10.x.x.x/...) addresses are not allowed to be relayed. Also, masternodes won't start when the address is considered invalid. This is needed to test local devnet or regtest based networks. * Lift the requirement of minimum MN age for regtest/devnet * Implement named devnets This allows the creation of multiple independent devnets. Each one is identified by a name which is hardened into a "devnet genesis" block, which is automatically positioned at height 1. Validation rules will ensure that a node from devnet=test1 never be able to accept blocks from devnet=test2. This is done by checking the expected devnet genesis block. The genesis block of the devnet is the same as the one from regtest. This starts the devnet with a very low difficulty, allowing us to fill up needed balances for masternodes very fast. Also, the devnet name is put into the sub-version of the VERSION message. If a node connects to the wrong network, it will immediately be disconnected. * Allow to select multiple addresses from the same group in devnet/regtest The selection code normally only allows to select addresses from the same group (e.g. 192.168.x.x) once. This results in connecting to only a single node in devnet/regtest. * Show the devnet name in the title bar and on the loading screen * Add AllowMultipleAddressesFromGroup to chainparams and use it in net.cpp * Remove unused/unneeded scripts from devnet geneses creation 1. OP_RETURN not needed in input script of devnet genesis 2. genesisOutputScript was unused * Fix copy/paste error in -allowprivatenet description * Improve -devnet parameter error handling - Only allow one of -devnet, -regtest or -testnet - Only allow -devnet=name to be specified once * Use different datadir for each devnet * Fix `devnet-devnet` issue * Fix devnet splashscreen (should use testnet img) * Avoid passing devNetName around (most of the time) * Remove nMaxTipAge from CDevNetParams Not present anymore after rebase on develop
148 lines
3.7 KiB
C++
148 lines
3.7 KiB
C++
// Copyright (c) 2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include "chainparamsbase.h"
|
|
|
|
#include "tinyformat.h"
|
|
#include "util.h"
|
|
|
|
#include <assert.h>
|
|
|
|
const std::string CBaseChainParams::MAIN = "main";
|
|
const std::string CBaseChainParams::TESTNET = "test";
|
|
const std::string CBaseChainParams::DEVNET = "dev";
|
|
const std::string CBaseChainParams::REGTEST = "regtest";
|
|
|
|
void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp)
|
|
{
|
|
strUsage += HelpMessageGroup(_("Chain selection options:"));
|
|
strUsage += HelpMessageOpt("-testnet", _("Use the test chain"));
|
|
if (debugHelp) {
|
|
strUsage += HelpMessageOpt("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
|
|
"This is intended for regression testing tools and app development.");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Main network
|
|
*/
|
|
class CBaseMainParams : public CBaseChainParams
|
|
{
|
|
public:
|
|
CBaseMainParams()
|
|
{
|
|
nRPCPort = 9998;
|
|
}
|
|
};
|
|
static CBaseMainParams mainParams;
|
|
|
|
/**
|
|
* Testnet (v3)
|
|
*/
|
|
class CBaseTestNetParams : public CBaseChainParams
|
|
{
|
|
public:
|
|
CBaseTestNetParams()
|
|
{
|
|
nRPCPort = 19998;
|
|
strDataDir = "testnet3";
|
|
}
|
|
};
|
|
static CBaseTestNetParams testNetParams;
|
|
|
|
/**
|
|
* Devnet
|
|
*/
|
|
class CBaseDevNetParams : public CBaseChainParams
|
|
{
|
|
public:
|
|
CBaseDevNetParams(const std::string &dataDir)
|
|
{
|
|
nRPCPort = 19998;
|
|
strDataDir = dataDir;
|
|
}
|
|
};
|
|
static CBaseDevNetParams *devNetParams;
|
|
|
|
/*
|
|
* Regression test
|
|
*/
|
|
class CBaseRegTestParams : public CBaseChainParams
|
|
{
|
|
public:
|
|
CBaseRegTestParams()
|
|
{
|
|
nRPCPort = 18332;
|
|
strDataDir = "regtest";
|
|
}
|
|
};
|
|
static CBaseRegTestParams regTestParams;
|
|
|
|
static CBaseChainParams* pCurrentBaseParams = 0;
|
|
|
|
const CBaseChainParams& BaseParams()
|
|
{
|
|
assert(pCurrentBaseParams);
|
|
return *pCurrentBaseParams;
|
|
}
|
|
|
|
CBaseChainParams& BaseParams(const std::string& chain)
|
|
{
|
|
if (chain == CBaseChainParams::MAIN)
|
|
return mainParams;
|
|
else if (chain == CBaseChainParams::TESTNET)
|
|
return testNetParams;
|
|
else if (chain == CBaseChainParams::DEVNET) {
|
|
assert(devNetParams);
|
|
return *devNetParams;
|
|
} else if (chain == CBaseChainParams::REGTEST)
|
|
return regTestParams;
|
|
else
|
|
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
|
}
|
|
|
|
void SelectBaseParams(const std::string& chain)
|
|
{
|
|
if (chain == CBaseChainParams::DEVNET) {
|
|
std::string devNetName = GetDevNetName();
|
|
assert(!devNetName.empty());
|
|
devNetParams = new CBaseDevNetParams(devNetName);
|
|
}
|
|
|
|
pCurrentBaseParams = &BaseParams(chain);
|
|
}
|
|
|
|
std::string ChainNameFromCommandLine()
|
|
{
|
|
bool fRegTest = GetBoolArg("-regtest", false);
|
|
bool fDevNet = mapArgs.count("-devnet") != 0;
|
|
bool fTestNet = GetBoolArg("-testnet", false);
|
|
|
|
int nameParamsCount = (fRegTest ? 1 : 0) + (fDevNet ? 1 : 0) + (fTestNet ? 1 : 0);
|
|
if (nameParamsCount > 1)
|
|
throw std::runtime_error("Only one of -regtest, -testnet or -devnet can be used.");
|
|
|
|
if (fDevNet)
|
|
return CBaseChainParams::DEVNET;
|
|
if (fRegTest)
|
|
return CBaseChainParams::REGTEST;
|
|
if (fTestNet)
|
|
return CBaseChainParams::TESTNET;
|
|
return CBaseChainParams::MAIN;
|
|
}
|
|
|
|
std::string GetDevNetName()
|
|
{
|
|
// This function should never be called for non-devnets
|
|
assert(mapArgs.count("-devnet"));
|
|
std::string devNetName = GetArg("-devnet", "");
|
|
return "devnet" + (devNetName.empty() ? "" : "-" + devNetName);
|
|
}
|
|
|
|
bool AreBaseParamsConfigured()
|
|
{
|
|
return pCurrentBaseParams != NULL;
|
|
}
|