add NetworkIDString() to chainparams
- returns the BIP70 network string - use that new function in the core and GUI code and remove unused code and functions
This commit is contained in:
parent
3f39b9d455
commit
f5ae6c9826
8 changed files with 14 additions and 33 deletions
|
@ -99,6 +99,7 @@ class CMainParams : public CChainParams {
|
||||||
public:
|
public:
|
||||||
CMainParams() {
|
CMainParams() {
|
||||||
networkID = CChainParams::MAIN;
|
networkID = CChainParams::MAIN;
|
||||||
|
strNetworkID = "main";
|
||||||
// The message start string is designed to be unlikely to occur in normal data.
|
// 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
|
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
|
||||||
// a large 4-byte int at any alignment.
|
// a large 4-byte int at any alignment.
|
||||||
|
@ -189,6 +190,7 @@ class CTestNetParams : public CMainParams {
|
||||||
public:
|
public:
|
||||||
CTestNetParams() {
|
CTestNetParams() {
|
||||||
networkID = CChainParams::TESTNET;
|
networkID = CChainParams::TESTNET;
|
||||||
|
strNetworkID = "test";
|
||||||
// The message start string is designed to be unlikely to occur in normal data.
|
// 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
|
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
|
||||||
// a large 4-byte int at any alignment.
|
// a large 4-byte int at any alignment.
|
||||||
|
@ -240,6 +242,7 @@ class CRegTestParams : public CTestNetParams {
|
||||||
public:
|
public:
|
||||||
CRegTestParams() {
|
CRegTestParams() {
|
||||||
networkID = CChainParams::REGTEST;
|
networkID = CChainParams::REGTEST;
|
||||||
|
strNetworkID = "regtest";
|
||||||
pchMessageStart[0] = 0xfa;
|
pchMessageStart[0] = 0xfa;
|
||||||
pchMessageStart[1] = 0xbf;
|
pchMessageStart[1] = 0xbf;
|
||||||
pchMessageStart[2] = 0xb5;
|
pchMessageStart[2] = 0xb5;
|
||||||
|
|
|
@ -79,6 +79,8 @@ public:
|
||||||
* until nGenProcLimit blocks are generated */
|
* until nGenProcLimit blocks are generated */
|
||||||
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
|
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
|
||||||
Network NetworkID() const { return networkID; }
|
Network NetworkID() const { return networkID; }
|
||||||
|
/* Return the BIP70 network string (main, test or regtest) */
|
||||||
|
std::string NetworkIDString() const { return strNetworkID; }
|
||||||
const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
|
const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
|
||||||
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
|
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
|
||||||
const vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
|
const vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
|
||||||
|
@ -102,6 +104,7 @@ protected:
|
||||||
vector<CDNSSeedData> vSeeds;
|
vector<CDNSSeedData> vSeeds;
|
||||||
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
||||||
Network networkID;
|
Network networkID;
|
||||||
|
std::string strNetworkID;
|
||||||
CBlock genesis;
|
CBlock genesis;
|
||||||
vector<CAddress> vFixedSeeds;
|
vector<CAddress> vFixedSeeds;
|
||||||
bool fRequireRPCPassword;
|
bool fRequireRPCPassword;
|
||||||
|
|
|
@ -142,14 +142,6 @@ void ClientModel::updateAlert(const QString &hash, int status)
|
||||||
emit alertsChanged(getStatusBarWarnings());
|
emit alertsChanged(getStatusBarWarnings());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ClientModel::getNetworkName() const
|
|
||||||
{
|
|
||||||
QString netname(QString::fromStdString(Params().DataDir()));
|
|
||||||
if(netname.isEmpty())
|
|
||||||
netname = "main";
|
|
||||||
return netname;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ClientModel::inInitialBlockDownload() const
|
bool ClientModel::inInitialBlockDownload() const
|
||||||
{
|
{
|
||||||
return IsInitialBlockDownload();
|
return IsInitialBlockDownload();
|
||||||
|
|
|
@ -56,8 +56,6 @@ public:
|
||||||
double getVerificationProgress() const;
|
double getVerificationProgress() const;
|
||||||
QDateTime getLastBlockDate() const;
|
QDateTime getLastBlockDate() const;
|
||||||
|
|
||||||
//! Return network (main, testnet3, regtest)
|
|
||||||
QString getNetworkName() const;
|
|
||||||
//! Return true if core is doing initial block download
|
//! Return true if core is doing initial block download
|
||||||
bool inInitialBlockDownload() const;
|
bool inInitialBlockDownload() const;
|
||||||
//! Return true if core is importing blocks
|
//! Return true if core is importing blocks
|
||||||
|
|
|
@ -490,17 +490,6 @@ bool PaymentServer::readPaymentRequest(const QString& filename, PaymentRequestPl
|
||||||
return request.parse(data);
|
return request.parse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PaymentServer::mapNetworkIdToName(CChainParams::Network networkId)
|
|
||||||
{
|
|
||||||
if (networkId == CChainParams::MAIN)
|
|
||||||
return "main";
|
|
||||||
if (networkId == CChainParams::TESTNET)
|
|
||||||
return "test";
|
|
||||||
if (networkId == CChainParams::REGTEST)
|
|
||||||
return "regtest";
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient)
|
bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient)
|
||||||
{
|
{
|
||||||
if (!optionsModel)
|
if (!optionsModel)
|
||||||
|
@ -510,7 +499,7 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoins
|
||||||
const payments::PaymentDetails& details = request.getDetails();
|
const payments::PaymentDetails& details = request.getDetails();
|
||||||
|
|
||||||
// Payment request network matches client network?
|
// Payment request network matches client network?
|
||||||
if (details.network() != mapNetworkIdToName(Params().NetworkID()))
|
if (details.network() != Params().NetworkIDString())
|
||||||
{
|
{
|
||||||
emit message(tr("Payment request rejected"), tr("Payment request network doesn't match client network."),
|
emit message(tr("Payment request rejected"), tr("Payment request network doesn't match client network."),
|
||||||
CClientUIInterface::MSG_ERROR);
|
CClientUIInterface::MSG_ERROR);
|
||||||
|
|
|
@ -118,7 +118,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool readPaymentRequest(const QString& filename, PaymentRequestPlus& request);
|
static bool readPaymentRequest(const QString& filename, PaymentRequestPlus& request);
|
||||||
std::string mapNetworkIdToName(CChainParams::Network networkId);
|
|
||||||
bool processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient);
|
bool processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient);
|
||||||
void fetchRequest(const QUrl& url);
|
void fetchRequest(const QUrl& url);
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,7 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||||
ui->buildDate->setText(model->formatBuildDate());
|
ui->buildDate->setText(model->formatBuildDate());
|
||||||
ui->startupTime->setText(model->formatClientStartupTime());
|
ui->startupTime->setText(model->formatClientStartupTime());
|
||||||
|
|
||||||
ui->networkName->setText(model->getNetworkName());
|
ui->networkName->setText(QString::fromStdString(Params().NetworkIDString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -451,10 +451,7 @@ Value getblockchaininfo(const Array& params, bool fHelp)
|
||||||
);
|
);
|
||||||
|
|
||||||
Object obj;
|
Object obj;
|
||||||
std::string chain = Params().DataDir();
|
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
||||||
if(chain.empty())
|
|
||||||
chain = "main";
|
|
||||||
obj.push_back(Pair("chain", chain));
|
|
||||||
obj.push_back(Pair("blocks", (int)chainActive.Height()));
|
obj.push_back(Pair("blocks", (int)chainActive.Height()));
|
||||||
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
|
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
|
||||||
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
||||||
|
|
Loading…
Reference in a new issue