From 25b0d8e33ff2355c86508be7392f792902bb449e Mon Sep 17 00:00:00 2001 From: vertoe Date: Fri, 12 Dec 2014 19:31:24 +0100 Subject: [PATCH 1/2] Fix segfault (checking for prev block of genesis). --- src/main.cpp | 54 +++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 16f6e69c18d49..7ca4ae22f8b92 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2881,39 +2881,41 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo { LOCK2(cs_main, mempool.cs); - if(chainActive.Tip()->GetBlockHash() == block.hashPrevBlock){ - int64_t masternodePaymentAmount = GetMasternodePayment(chainActive.Tip()->nHeight+1, block.vtx[0].GetValueOut()); - bool fIsInitialDownload = IsInitialBlockDownload(); + if (block.GetHash() != Params().HashGenesisBlock()) { + if(chainActive.Tip()->GetBlockHash() == block.hashPrevBlock){ + int64_t masternodePaymentAmount = GetMasternodePayment(chainActive.Tip()->nHeight+1, block.vtx[0].GetValueOut()); + bool fIsInitialDownload = IsInitialBlockDownload(); - // If we don't already have its previous block, skip masternode payment step - if (!fIsInitialDownload && chainActive.Tip() != NULL) - { - bool foundPaymentAmount = false; - bool foundPayee = false; + // If we don't already have its previous block, skip masternode payment step + if (!fIsInitialDownload && chainActive.Tip() != NULL) + { + bool foundPaymentAmount = false; + bool foundPayee = false; - CScript payee; - if(!masternodePayments.GetBlockPayee(chainActive.Tip()->nHeight+1, payee) || payee == CScript()){ - foundPayee = true; //doesn't require a specific payee - } + CScript payee; + if(!masternodePayments.GetBlockPayee(chainActive.Tip()->nHeight+1, payee) || payee == CScript()){ + foundPayee = true; //doesn't require a specific payee + } - for (unsigned int i = 0; i < block.vtx[0].vout.size(); i++) { - if(block.vtx[0].vout[i].nValue == masternodePaymentAmount ) - foundPaymentAmount = true; - if(block.vtx[0].vout[i].scriptPubKey == payee ) - foundPayee = true; - } + for (unsigned int i = 0; i < block.vtx[0].vout.size(); i++) { + if(block.vtx[0].vout[i].nValue == masternodePaymentAmount ) + foundPaymentAmount = true; + if(block.vtx[0].vout[i].scriptPubKey == payee ) + foundPayee = true; + } - if(!foundPaymentAmount || !foundPayee) { - CTxDestination address1; - ExtractDestination(payee, address1); - CBitcoinAddress address2(address1); + if(!foundPaymentAmount || !foundPayee) { + CTxDestination address1; + ExtractDestination(payee, address1); + CBitcoinAddress address2(address1); - LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%d) or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), chainActive.Tip()->nHeight+1); - return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee")); + LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%d) or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), chainActive.Tip()->nHeight+1); + return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee")); + } } + } else { + LogPrintf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", chainActive.Tip()->nHeight+1, block.GetHash().ToString().c_str()); } - } else { - LogPrintf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", chainActive.Tip()->nHeight+1, block.GetHash().ToString().c_str()); } } From 71f3d6eb06537c47e5dd63305c0db189ea8fb45a Mon Sep 17 00:00:00 2001 From: vertoe Date: Fri, 26 Dec 2014 21:23:25 +0100 Subject: [PATCH 2/2] revert 4f95ea2: testnet v4 --- src/chainparams.cpp | 4 ++-- src/checkpoints.cpp | 4 ++-- src/qt/clientmodel.h | 2 +- src/rpcblockchain.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 42b4eac99a3ca..acfce76092b17 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -101,7 +101,7 @@ static CMainParams mainParams; // -// Testnet (v4) +// Testnet (v3) // class CTestNetParams : public CMainParams { public: @@ -131,7 +131,7 @@ class CTestNetParams : public CMainParams { vSeeds.push_back(CDNSSeedData("darkcoin.io", "testnet-seed.darkcoin.io")); vSeeds.push_back(CDNSSeedData("darkcoin.qa", "testnet-seed.darkcoin.qa")); - base58Prefixes[PUBKEY_ADDRESS] = list_of(111); // Testnet v4 addresses + base58Prefixes[PUBKEY_ADDRESS] = list_of(111); // Testnet v3 addresses base58Prefixes[SCRIPT_ADDRESS] = list_of(196); base58Prefixes[SECRET_KEY] = list_of(239); base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF); diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 735dbdf77b680..923365df31e34 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -68,8 +68,8 @@ namespace Checkpoints static const CCheckpointData dataTestnet = { &mapCheckpointsTestnet, 1405699509, - 20, - 300 + 201, + 500 }; static MapCheckpoints mapCheckpointsRegtest = diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index 0fd35fa2aad33..dd077d9be2777 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -55,7 +55,7 @@ class ClientModel : public QObject double getVerificationProgress() const; QDateTime getLastBlockDate() const; - //! Return network (main, testnet4, regtest) + //! Return network (main, testnet3, regtest) QString getNetworkName() const; //! Return true if core is doing initial block download bool inInitialBlockDownload() const; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index c4e2b218b560f..0038da6ad6c61 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -441,7 +441,7 @@ Value getblockchaininfo(const Array& params, bool fHelp) "Returns an object containing various state info regarding block chain processing.\n" "\nResult:\n" "{\n" - " \"chain\": \"xxxx\", (string) current chain (main, testnet4, regtest)\n" + " \"chain\": \"xxxx\", (string) current chain (main, testnet3, regtest)\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" " \"bestblockhash\": \"...\", (string) the hash of the currently best block\n" " \"difficulty\": xxxxxx, (numeric) the current difficulty\n"