diff --git a/src/base58.cpp b/src/base58.cpp index 6df2dabc6..ee8b40541 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -255,6 +255,23 @@ CTxDestination DecodeDestination(const std::string &str, const CChainParams &par } } // namespace +namespace +{ +class CBitcoinAddressVisitor : public boost::static_visitor +{ +private: + CBitcoinAddress* addr; + +public: + CBitcoinAddressVisitor(CBitcoinAddress* addrIn) : addr(addrIn) {} + + bool operator()(const CKeyID& id) const { return addr->Set(id); } + bool operator()(const CScriptID& id) const { return addr->Set(id); } + bool operator()(const CNoDestination& no) const { return false; } +}; + +} // anon namespace + bool CBitcoinAddress::Set(const CKeyID& id) { SetData(Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS), &id, 20); diff --git a/src/main.cpp b/src/main.cpp index 3586dba4d..b8d8134da 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3404,7 +3404,7 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const REJECT_OBSOLETE, "bad-version"); // Check proof of work matches claimed amount - if (fCheckPOW && !CheckProofOfWork(block.GetPoWHash(), block.nBits, consensusParams)) + if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, consensusParams)) return state.DoS(50, error("CheckBlockHeader(): proof of work failed"), REJECT_INVALID, "high-hash"); return true; diff --git a/src/miner.cpp b/src/miner.cpp index 20bfd7382..3a117fc70 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -71,8 +71,7 @@ int64_t UpdateTime(CBlock* pblock, const Consensus::Params& consensusParams, con // Updating time can change work required on testnet: if (consensusParams.fPowAllowMinDifficultyBlocks) - pblock->nBits = GetNextTargetRequired(pindexPrev, pblock, consensusParams, pblock->IsProofOfStake()); - + pblock->nBits = GetNextTargetRequired(pindexPrev, pblock, consensusParams, pblock->IsProofOfStake()); return nNewTime - nOldTime; } @@ -434,7 +433,7 @@ void static BitcoinMiner(const CChainParams& chainparams) // unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); CBlockIndex* pindexPrev = chainActive.Tip(); - int64_t *nFees; + int64_t* nFees = 0; std::unique_ptr pblocktemplate(CreateNewBlock(chainparams, coinbaseScript->reserveScript, nFees, false)); if (!pblocktemplate.get()) { diff --git a/src/pow.cpp b/src/pow.cpp index 297352316..97c9a3592 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -30,20 +30,22 @@ static arith_uint256 GetTargetLimit(int64_t nTime, const Consensus::Params& para unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params, bool fProofOfStake) { - unsigned int nTargetLimit = UintToArith256(params.powLimit).GetCompact(); - - // Genesis block - if (pindexLast == NULL) - return nTargetLimit; + // Genesis block + if (pindexLast == NULL) + return UintToArith256(params.powLimit).GetCompact(); + else { + unsigned int nTargetLimit = GetTargetLimit(pindexLast->GetBlockTime(), params, fProofOfStake).GetCompact(); const CBlockIndex* pindexPrev = GetLastBlockIndex(pindexLast, fProofOfStake); + if (pindexPrev->pprev == NULL) return nTargetLimit; // first block const CBlockIndex* pindexPrevPrev = GetLastBlockIndex(pindexPrev->pprev, fProofOfStake); if (pindexPrevPrev->pprev == NULL) return nTargetLimit; // second block - return CalculateNextTargetRequired(pindexPrev, pindexPrevPrev->GetBlockTime(), params, fProofOfStake); + return CalculateNextTargetRequired(pindexPrev, pindexPrevPrev->GetBlockTime(), params, fProofOfStake); + } } unsigned int CalculateNextTargetRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params, bool fProofOfStake) @@ -56,8 +58,8 @@ unsigned int CalculateNextTargetRequired(const CBlockIndex* pindexLast, int64_t return pindexLast->nBits; } - int64_t nActualSpacing = pindexLast->GetBlockTime() - nFirstBlockTime; int64_t nTargetSpacing = params.IsProtocolV2(pindexLast->GetBlockTime()) ? params.nTargetSpacing : params.nTargetSpacingV1; + int64_t nActualSpacing = pindexLast->GetBlockTime() - nFirstBlockTime; // Limit adjustment step if (pindexLast->GetBlockTime() > params.nProtocolV1RetargetingFixedTime && nActualSpacing < 0) diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 09560a269..57244f533 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -13,9 +13,9 @@ uint256 CBlockHeader::GetHash() const { - if (nVersion > 6) - return SerializeHash(*this); - return GetPoWHash(); + if (nVersion > 6) + return SerializeHash(*this); + return GetPoWHash(); } uint256 CBlockHeader::GetPoWHash() const @@ -34,8 +34,8 @@ std::string CBlock::ToString() const hashPrevBlock.ToString(), hashMerkleRoot.ToString(), nTime, nBits, nNonce, - vtx.size(), - HexStr(vchBlockSig.begin(), vchBlockSig.end())); + vtx.size(), + HexStr(vchBlockSig.begin(), vchBlockSig.end())); for (unsigned int i = 0; i < vtx.size(); i++) { s << " " << vtx[i].ToString() << "\n"; diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 9ed79654a..7e64d1c97 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -960,14 +960,6 @@ void BitcoinGUI::showEvent(QShowEvent *event) optionsAction->setEnabled(true); } -void BitcoinGUI::showEvent(QShowEvent *event) -{ - // enable the debug window when the main window shows up - openRPCConsoleAction->setEnabled(true); - aboutAction->setEnabled(true); - optionsAction->setEnabled(true); -} - #ifdef ENABLE_WALLET void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label) {