diff --git a/src/bloom.cpp b/src/bloom.cpp index fbf03133885f..2723c32e9a47 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -42,17 +42,6 @@ CBloomFilter::CBloomFilter(const unsigned int nElements, const double nFPRate, c { } -// Private constructor used by CRollingBloomFilter -CBloomFilter::CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweakIn) : - vData((unsigned int)(-1 / LN2SQUARED * nElements * log(nFPRate)) / 8), - isFull(false), - isEmpty(true), - nHashFuncs((unsigned int)(vData.size() * 8 / nElements * LN2)), - nTweak(nTweakIn), - nFlags(BLOOM_UPDATE_NONE) -{ -} - inline unsigned int CBloomFilter::Hash(unsigned int nHashNum, const std::vector& vDataToHash) const { // 0xFBA4C795 chosen as it guarantees a reasonable bit difference between nHashNum values. diff --git a/src/bloom.h b/src/bloom.h index ecb3c75599ca..e808a265fe7f 100644 --- a/src/bloom.h +++ b/src/bloom.h @@ -55,10 +55,6 @@ class CBloomFilter unsigned int Hash(unsigned int nHashNum, const std::vector& vDataToHash) const; - // Private constructor for CRollingBloomFilter, no restrictions on size - CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweak); - friend class CRollingBloomFilter; - // Check matches for arbitrary script data elements bool CheckScript(const CScript& script) const; // Check additional matches for special transactions diff --git a/src/logging.cpp b/src/logging.cpp index db0a4c043bbc..7bb1807ac01d 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -303,7 +303,7 @@ void BCLog::Logger::ShrinkDebugFile() size_t log_size = 0; try { log_size = fs::file_size(m_file_path); - } catch (boost::filesystem::filesystem_error &) {} + } catch (const fs::filesystem_error&) {} // If debug.log file is more than 10% bigger the RECENT_DEBUG_HISTORY_SIZE // trim it down by saving only the last RECENT_DEBUG_HISTORY_SIZE bytes diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 9db82bc8ea59..48a757f541a7 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1137,18 +1137,6 @@ static UniValue echo(const JSONRPCRequest& request) return request.params; } -static UniValue getinfo_deprecated(const JSONRPCRequest& request) -{ - throw JSONRPCError(RPC_METHOD_NOT_FOUND, - "getinfo\n" - "\nThis call was removed in version 0.16.0. Use the appropriate fields from:\n" - "- getblockchaininfo: blocks, difficulty, chain\n" - "- getnetworkinfo: version, protocolversion, timeoffset, connections, proxy, relayfee, warnings\n" - "- getwalletinfo: balance, coinjoin_balance, keypoololdest, keypoolsize, paytxfee, unlocked_until, walletversion\n" - "\ndash-cli has the option -getinfo to collect and format these in the old format." - ); -} - static const CRPCCommand commands[] = { // category name actor (function) argNames // --------------------- ------------------------ ----------------------- ---------- @@ -1176,7 +1164,6 @@ static const CRPCCommand commands[] = { "hidden", "setmocktime", &setmocktime, {"timestamp"}}, { "hidden", "echo", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, { "hidden", "echojson", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, - { "hidden", "getinfo", &getinfo_deprecated, {}}, { "hidden", "mnauth", &mnauth, {"nodeId", "proTxHash", "publicKey"}}, }; diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 7f9d4ee7f065..3d8f7d54f1a6 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -874,15 +874,15 @@ UniValue dumpwallet(const JSONRPCRequest& request) EnsureWalletIsUnlocked(pwallet); - boost::filesystem::path filepath = request.params[0].get_str(); - filepath = boost::filesystem::absolute(filepath); + fs::path filepath = request.params[0].get_str(); + filepath = fs::absolute(filepath); /* Prevent arbitrary files from being overwritten. There have been reports * that users have overwritten wallet files this way: * https://github.com/bitcoin/bitcoin/issues/9934 * It may also avoid other security issues. */ - if (boost::filesystem::exists(filepath)) { + if (fs::exists(filepath)) { throw JSONRPCError(RPC_INVALID_PARAMETER, filepath.string() + " already exists. If you are sure this is what you want, move it out of the way first"); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f44f20f36a90..6e4e0cf83805 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1785,7 +1785,7 @@ static void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, cons { if (wtx.GetDepthInMainChain() < 1) entry.pushKV("category", "orphan"); - else if (wtx.GetBlocksToMaturity() > 0) + else if (wtx.IsImmatureCoinBase()) entry.pushKV("category", "immature"); else entry.pushKV("category", "generate"); @@ -2098,7 +2098,7 @@ static UniValue listaccounts(const JSONRPCRequest& request) std::list listReceived; std::list listSent; int nDepth = wtx.GetDepthInMainChain(); - if (wtx.GetBlocksToMaturity() > 0 || nDepth < 0) + if (wtx.IsImmatureCoinBase() || nDepth < 0) continue; wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly); mapAccountBalances[strSentAccount] -= nFee; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6da5cadea928..8601fb1c8ac5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2347,7 +2347,7 @@ CAmount CWalletTx::GetDebit(const isminefilter& filter) const CAmount CWalletTx::GetCredit(const isminefilter& filter) const { // Must wait until coinbase is safely deep enough in the chain before valuing it - if (IsCoinBase() && GetBlocksToMaturity() > 0) + if (IsImmatureCoinBase()) return 0; CAmount credit = 0; @@ -2379,8 +2379,7 @@ CAmount CWalletTx::GetCredit(const isminefilter& filter) const CAmount CWalletTx::GetImmatureCredit(bool fUseCache) const { - if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) - { + if (IsImmatureCoinBase() && IsInMainChain()) { if (fUseCache && fImmatureCreditCached) return nImmatureCreditCached; nImmatureCreditCached = pwallet->GetCredit(*tx, ISMINE_SPENDABLE); @@ -2397,7 +2396,7 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache, const isminefilter& filter return 0; // Must wait until coinbase is safely deep enough in the chain before valuing it - if (IsCoinBase() && GetBlocksToMaturity() > 0) + if (IsImmatureCoinBase()) return 0; CAmount* cache = nullptr; @@ -2438,8 +2437,7 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache, const isminefilter& filter CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool fUseCache) const { - if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) - { + if (IsImmatureCoinBase() && IsInMainChain()) { if (fUseCache && fImmatureWatchCreditCached) return nImmatureWatchCreditCached; nImmatureWatchCreditCached = pwallet->GetCredit(*tx, ISMINE_WATCH_ONLY); @@ -2848,7 +2846,7 @@ CAmount CWallet::GetLegacyBalance(const isminefilter& filter, int minDepth, cons for (const auto& entry : mapWallet) { const CWalletTx& wtx = entry.second; const int depth = wtx.GetDepthInMainChain(); - if (depth < 0 || !CheckFinalTx(*wtx.tx) || wtx.GetBlocksToMaturity() > 0) { + if (depth < 0 || !CheckFinalTx(*wtx.tx) || wtx.IsImmatureCoinBase()) { continue; } @@ -2908,7 +2906,7 @@ void CWallet::AvailableCoins(std::vector &vCoins, bool fOnlySafe, const if (!CheckFinalTx(*pcoin->tx)) continue; - if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) + if (pcoin->IsImmatureCoinBase()) continue; int nDepth = pcoin->GetDepthInMainChain(); @@ -4455,7 +4453,7 @@ std::map CWallet::GetAddressBalances() if (!pcoin->IsTrusted()) continue; - if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) + if (pcoin->IsImmatureCoinBase()) continue; int nDepth = pcoin->GetDepthInMainChain(); @@ -5549,6 +5547,11 @@ int CMerkleTx::GetBlocksToMaturity() const return std::max(0, (COINBASE_MATURITY+1) - chain_depth); } +bool CMerkleTx::IsImmatureCoinBase() const +{ + // note GetBlocksToMaturity is 0 for non-coinbase tx + return GetBlocksToMaturity() > 0; +} bool CWalletTx::AcceptToMemoryPool(const CAmount& nAbsurdFee, CValidationState& state) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d85743f80c73..fafadc3a0e76 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -256,6 +256,12 @@ class CMerkleTx bool IsInMainChain() const { return GetDepthInMainChain() > 0; } bool IsLockedByInstantSend() const; bool IsChainLocked() const; + + /** + * @return number of blocks to maturity for this transaction: + * 0 : is not a coinbase transaction, or is a mature coinbase transaction + * >0 : is a coinbase transaction which matures in this many blocks + */ int GetBlocksToMaturity() const; bool hashUnset() const { return (hashBlock.IsNull() || hashBlock == ABANDON_HASH); } bool isAbandoned() const { return (hashBlock == ABANDON_HASH); } @@ -263,6 +269,7 @@ class CMerkleTx const uint256& GetHash() const { return tx->GetHash(); } bool IsCoinBase() const { return tx->IsCoinBase(); } + bool IsImmatureCoinBase() const; }; //Get the marginal bytes of spending the specified output diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index d57cae8e3190..d2c9826f8ae7 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -580,7 +580,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, return false; } } - else if (strType != "bestblock" && strType != "bestblock_nomerkle"){ + else if (strType != "bestblock" && strType != "bestblock_nomerkle" && + strType != "minversion"){ wss.m_unknown_records++; } } catch (...) diff --git a/test/functional/feature_blocksdir.py b/test/functional/feature_blocksdir.py index bb67c6ae2221..408b676e2e4a 100755 --- a/test/functional/feature_blocksdir.py +++ b/test/functional/feature_blocksdir.py @@ -22,12 +22,12 @@ def run_test(self): assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "blocks")) shutil.rmtree(self.nodes[0].datadir) initialize_datadir(self.options.tmpdir, 0, self.chain) - self.log.info("Starting with non exiting blocksdir ...") + self.log.info("Starting with nonexistent blocksdir ...") blocksdir_path = os.path.join(self.options.tmpdir, 'blocksdir') self.nodes[0].assert_start_raises_init_error(["-blocksdir=" + blocksdir_path], 'Error: Specified blocks directory "' + blocksdir_path + '" does not exist.') os.mkdir(blocksdir_path) - self.log.info("Starting with exiting blocksdir ...") + self.log.info("Starting with existing blocksdir ...") self.start_node(0, ["-blocksdir=" + blocksdir_path]) self.log.info("mining blocks..") self.nodes[0].generate(10)