From 0670e573dbc5bbbad9f057433da635da3e0ef76d Mon Sep 17 00:00:00 2001 From: div72 <60045611+div72@users.noreply.github.com> Date: Sun, 13 Jun 2021 13:17:53 +0300 Subject: [PATCH 1/4] scripted-diff: arrow deref -BEGIN VERIFY SCRIPT- sed -i -r -e 's/([^a-zA-Z0-9])\(\*(\w+)\)\./\1\2->/g' $(git ls-files -- 'src/*.h' 'src/*.cpp' ':!src/leveldb/**' ':!src/univalue/**' ':!src/qt/locale') git diff -U0 | contrib/devtools/clang-format-diff.py -p1 -i -v -END VERIFY SCRIPT- --- src/addrman.cpp | 12 ++--- src/addrman.h | 6 +-- src/alert.cpp | 6 +-- src/banman.cpp | 6 +-- src/init.cpp | 4 +- src/keystore.cpp | 12 ++--- src/keystore.h | 6 +-- src/main.cpp | 26 +++++----- src/main.h | 8 ++-- src/miner.cpp | 4 +- src/net.h | 2 +- src/prevector.h | 2 +- src/qt/transactionrecord.cpp | 2 +- src/rpc/blockchain.h | 4 +- src/rpc/rawtransaction.cpp | 7 ++- src/rpc/server.cpp | 2 +- src/sync.cpp | 2 +- src/test/gridcoin/cpid_tests.cpp | 22 +++++++-- src/txdb-leveldb.cpp | 4 +- src/validation.cpp | 2 +- src/wallet/db.cpp | 4 +- src/wallet/rpcwallet.cpp | 50 ++++++++++--------- src/wallet/wallet.cpp | 82 ++++++++++++++++---------------- src/wallet/wallet.h | 2 +- src/wallet/walletdb.cpp | 8 ++-- 25 files changed, 147 insertions(+), 138 deletions(-) mode change 100755 => 100644 src/rpc/rawtransaction.cpp diff --git a/src/addrman.cpp b/src/addrman.cpp index 2f50117fec..892d567782 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -84,10 +84,10 @@ CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int *pnId) if (it == mapAddr.end()) return NULL; if (pnId) - *pnId = (*it).second; - std::map::iterator it2 = mapInfo.find((*it).second); + *pnId = it->second; + std::map::iterator it2 = mapInfo.find(it->second); if (it2 != mapInfo.end()) - return &(*it2).second; + return &it2->second; return NULL; } @@ -208,7 +208,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin) // remove the entry from all new buckets for (std::vector >::iterator it = vvNew.begin(); it != vvNew.end(); it++) { - if ((*it).erase(nId)) + if (it->erase(nId)) info.nRefCount--; } nNew--; @@ -438,8 +438,8 @@ int CAddrMan::Check_() for (std::map::iterator it = mapInfo.begin(); it != mapInfo.end(); it++) { - int n = (*it).first; - CAddrInfo &info = (*it).second; + int n = it->first; + CAddrInfo& info = it->second; if (info.fInTried) { diff --git a/src/addrman.h b/src/addrman.h index a481cb37c4..4e2cf543df 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -287,8 +287,8 @@ class CAddrMan int nIds = 0; for (std::map::const_iterator it = mapInfo.begin(); it != mapInfo.end(); it++) { if (nIds == nNew) break; // this means nNew was wrong, oh ow - mapUnkIds[(*it).first] = nIds; - const CAddrInfo &info = (*it).second; + mapUnkIds[it->first] = nIds; + const CAddrInfo& info = it->second; if (info.nRefCount) { s << info; nIds++; @@ -297,7 +297,7 @@ class CAddrMan nIds = 0; for (std::map::const_iterator it = mapInfo.begin(); it != mapInfo.end(); it++) { if (nIds == nTried) break; // this means nTried was wrong, oh ow - const CAddrInfo &info = (*it).second; + const CAddrInfo& info = it->second; if (info.fInTried) { s << info; nIds++; diff --git a/src/alert.cpp b/src/alert.cpp index 6af50048fb..5385675fa6 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -231,17 +231,17 @@ bool CAlert::ProcessAlert(bool fThread) // Cancel previous alerts for (map::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();) { - const CAlert& alert = (*mi).second; + const CAlert& alert = mi->second; if (Cancels(alert)) { LogPrint(BCLog::LogFlags::VERBOSE, "cancelling alert %d", alert.nID); - uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED); + uiInterface.NotifyAlertChanged(mi->first, CT_DELETED); mapAlerts.erase(mi++); } else if (!alert.IsInEffect()) { LogPrint(BCLog::LogFlags::VERBOSE, "expiring alert %d", alert.nID); - uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED); + uiInterface.NotifyAlertChanged(mi->first, CT_DELETED); mapAlerts.erase(mi++); } else diff --git a/src/banman.cpp b/src/banman.cpp index e3ba279893..8dd49a663c 100644 --- a/src/banman.cpp +++ b/src/banman.cpp @@ -116,7 +116,7 @@ bool BanMan::IsBanned(CSubNet sub_net) LOCK(m_cs_banned); banmap_t::iterator i = m_banned.find(sub_net); if (i != m_banned.end()) { - CBanEntry ban_entry = (*i).second; + CBanEntry ban_entry = i->second; if (current_time < ban_entry.nBanUntil) { return true; } @@ -199,8 +199,8 @@ void BanMan::SweepBanned() LOCK(m_cs_banned); banmap_t::iterator it = m_banned.begin(); while (it != m_banned.end()) { - CSubNet sub_net = (*it).first; - CBanEntry ban_entry = (*it).second; + CSubNet sub_net = it->first; + CBanEntry ban_entry = it->second; if (now > ban_entry.nBanUntil) { m_banned.erase(it++); diff --git a/src/init.cpp b/src/init.cpp index 03d6e10ab2..331237973e 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -1175,10 +1175,10 @@ bool AppInit2(ThreadHandlerPtr threads) int nFound = 0; for (BlockMap::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi) { - uint256 hash = (*mi).first; + uint256 hash = mi->first; if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0) { - CBlockIndex* pindex = (*mi).second; + CBlockIndex* pindex = mi->second; CBlock block; block.ReadFromDisk(pindex); block.print(); diff --git a/src/keystore.cpp b/src/keystore.cpp index 025508a433..e9a770b9d4 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -56,7 +56,7 @@ bool CBasicKeyStore::GetCScript(const CScriptID &hash, CScript& redeemScriptOut) ScriptMap::const_iterator mi = mapScripts.find(hash); if (mi != mapScripts.end()) { - redeemScriptOut = (*mi).second; + redeemScriptOut = mi->second; return true; } } @@ -100,8 +100,8 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn) CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin(); for (; mi != mapCryptedKeys.end(); ++mi) { - const CPubKey &vchPubKey = (*mi).second.first; - const std::vector &vchCryptedSecret = (*mi).second.second; + const CPubKey& vchPubKey = mi->second.first; + const std::vector& vchCryptedSecret = mi->second.second; CSecret vchSecret; if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, vchPubKey.GetHash(), vchSecret)) return false; @@ -165,8 +165,8 @@ bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address); if (mi != mapCryptedKeys.end()) { - const CPubKey &vchPubKey = (*mi).second.first; - const std::vector &vchCryptedSecret = (*mi).second.second; + const CPubKey& vchPubKey = mi->second.first; + const std::vector& vchCryptedSecret = mi->second.second; CSecret vchSecret; if (!DecryptSecret(vMasterKey, vchCryptedSecret, vchPubKey.GetHash(), vchSecret)) return false; @@ -190,7 +190,7 @@ bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) co CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address); if (mi != mapCryptedKeys.end()) { - vchPubKeyOut = (*mi).second.first; + vchPubKeyOut = mi->second.first; return true; } } diff --git a/src/keystore.h b/src/keystore.h index ab369bbf47..349c64b91d 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -73,7 +73,7 @@ class CBasicKeyStore : public CKeyStore KeyMap::const_iterator mi = mapKeys.begin(); while (mi != mapKeys.end()) { - setAddress.insert((*mi).first); + setAddress.insert(mi->first); mi++; } } @@ -86,7 +86,7 @@ class CBasicKeyStore : public CKeyStore if (mi != mapKeys.end()) { keyOut.Reset(); - keyOut.SetSecret((*mi).second.first, (*mi).second.second); + keyOut.SetSecret(mi->second.first, mi->second.second); return true; } } @@ -170,7 +170,7 @@ class CCryptoKeyStore : public CBasicKeyStore CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin(); while (mi != mapCryptedKeys.end()) { - setAddress.insert((*mi).first); + setAddress.insert(mi->first); mi++; } } diff --git a/src/main.cpp b/src/main.cpp index 1f9662b443..d6b95824c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -475,7 +475,7 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock) BlockMap::iterator mi = mapBlockIndex.find(hashBlock); if (mi == mapBlockIndex.end()) return 0; - CBlockIndex* pindex = (*mi).second; + CBlockIndex* pindex = mi->second; if (!pindex || !pindex->IsInMainChain()) return 0; @@ -718,7 +718,7 @@ void CTxMemPool::queryHashes(std::vector& vtxid) LOCK(cs); vtxid.reserve(mapTx.size()); for (map::iterator mi = mapTx.begin(); mi != mapTx.end(); ++mi) - vtxid.push_back((*mi).first); + vtxid.push_back(mi->first); } int CMerkleTx::GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const @@ -731,7 +731,7 @@ int CMerkleTx::GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const BlockMap::iterator mi = mapBlockIndex.find(hashBlock); if (mi == mapBlockIndex.end()) return 0; - CBlockIndex* pindex = (*mi).second; + CBlockIndex* pindex = mi->second; if (!pindex || !pindex->IsInMainChain()) return 0; @@ -1643,7 +1643,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) // Write queued txindex changes for (map::iterator mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi) { - if (!txdb.UpdateTxIndex((*mi).first, (*mi).second)) + if (!txdb.UpdateTxIndex(mi->first, mi->second)) return error("ConnectBlock[] : UpdateTxIndex failed"); } @@ -2065,7 +2065,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos, const u BlockMap::iterator miPrev = mapBlockIndex.find(hashPrevBlock); if (miPrev != mapBlockIndex.end()) { - pindexNew->pprev = (*miPrev).second; + pindexNew->pprev = miPrev->second; pindexNew->nHeight = pindexNew->pprev->nHeight + 1; } @@ -2087,7 +2087,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos, const u // Add to mapBlockIndex BlockMap::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; - pindexNew->phashBlock = &((*mi).first); + pindexNew->phashBlock = &(mi->first); // Write to disk block index CTxDB txdb; @@ -2278,7 +2278,7 @@ bool CBlock::AcceptBlock(bool generated_by_me) BlockMap::iterator mi = mapBlockIndex.find(hashPrevBlock); if (mi == mapBlockIndex.end()) return DoS(10, error("AcceptBlock() : prev block not found")); - CBlockIndex* pindexPrev = (*mi).second; + CBlockIndex* pindexPrev = mi->second; const int nHeight = pindexPrev->nHeight + 1; const int checkpoint_height = Params().Checkpoints().GetHeight(); @@ -2884,7 +2884,7 @@ void PrintBlockTree() map > mapNext; for (BlockMap::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi) { - CBlockIndex* pindex = (*mi).second; + CBlockIndex* pindex = mi->second; mapNext[pindex->pprev].push_back(pindex); } @@ -3328,7 +3328,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } int nRelayNodes = fReachable ? 2 : 1; // limited relaying of addresses outside our network(s) for (multimap::iterator mi = mapMix.begin(); mi != mapMix.end() && nRelayNodes-- > 0; ++mi) - ((*mi).second)->PushAddress(addr); + (mi->second)->PushAddress(addr); } } // Do not store addresses outside our network @@ -3433,7 +3433,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (mi != mapBlockIndex.end()) { CBlock block; - block.ReadFromDisk((*mi).second); + block.ReadFromDisk(mi->second); pfrom->PushMessage("encrypt", block); @@ -3458,7 +3458,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LOCK(cs_mapRelay); map::iterator mi = mapRelay.find(inv); if (mi != mapRelay.end()) { - pfrom->PushMessage(inv.GetCommand(), (*mi).second); + pfrom->PushMessage(inv.GetCommand(), mi->second); pushed = true; } } @@ -3567,7 +3567,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, BlockMap::iterator mi = mapBlockIndex.find(hashStop); if (mi == mapBlockIndex.end()) return true; - pindex = (*mi).second; + pindex = mi->second; } else { @@ -3725,7 +3725,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, map::iterator mi = pfrom->mapRequests.find(hashReply); if (mi != pfrom->mapRequests.end()) { - tracker = (*mi).second; + tracker = mi->second; pfrom->mapRequests.erase(mi); } } diff --git a/src/main.h b/src/main.h index 7119f78a18..7f2351561f 100644 --- a/src/main.h +++ b/src/main.h @@ -1033,7 +1033,7 @@ class CBlockLocator { BlockMap::iterator mi = mapBlockIndex.find(hashBlock); if (mi != mapBlockIndex.end()) - Set((*mi).second); + Set(mi->second); } CBlockLocator(const std::vector& vHaveIn) @@ -1091,7 +1091,7 @@ class CBlockLocator BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { - CBlockIndex* pindex = (*mi).second; + CBlockIndex* pindex = mi->second; if (pindex->IsInMainChain()) return nDistance; } @@ -1110,7 +1110,7 @@ class CBlockLocator BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { - CBlockIndex* pindex = (*mi).second; + CBlockIndex* pindex = mi->second; if (pindex->IsInMainChain()) return pindex; } @@ -1126,7 +1126,7 @@ class CBlockLocator BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { - CBlockIndex* pindex = (*mi).second; + CBlockIndex* pindex = mi->second; if (pindex->IsInMainChain()) return hash; } diff --git a/src/miner.cpp b/src/miner.cpp index 55e5b02061..368b71f47c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -306,7 +306,7 @@ bool CreateRestOfTheBlock(CBlock &block, CBlockIndex* pindexPrev) for (map::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) { - CTransaction& tx = (*mi).second; + CTransaction& tx = mi->second; if (tx.IsCoinBase() || tx.IsCoinStake() || !IsFinalTx(tx, nHeight)) continue; @@ -395,7 +395,7 @@ bool CreateRestOfTheBlock(CBlock &block, CBlockIndex* pindexPrev) } else { - vecPriority.push_back(TxPriority(dPriority, dFeePerKb, &(*mi).second)); + vecPriority.push_back(TxPriority(dPriority, dFeePerKb, &mi->second)); } } diff --git a/src/net.h b/src/net.h index 11f8da096b..1849d9985a 100644 --- a/src/net.h +++ b/src/net.h @@ -495,7 +495,7 @@ class CNode std::deque::iterator it = vSendMsg.insert(vSendMsg.end(), CSerializeData()); ssSend.GetAndClear(*it); - nSendSize += (*it).size(); + nSendSize += it->size(); // If write queue empty, attempt "optimistic write" if (it == vSendMsg.begin()) diff --git a/src/prevector.h b/src/prevector.h index 9d576321b6..df39d61384 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -408,7 +408,7 @@ class prevector { char* endp = (char*)&(*end()); if (!std::is_trivially_destructible::value) { while (p != last) { - (*p).~T(); + p->~T(); _size--; ++p; } diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index ee98f8f5ea..0940bee350 100755 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -356,7 +356,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) CBlockIndex* pindex = NULL; BlockMap::iterator mi = mapBlockIndex.find(wtx.hashBlock); if (mi != mapBlockIndex.end()) - pindex = (*mi).second; + pindex = mi->second; // Sort order, unrecorded transactions sort to the top status.sortKey = strprintf("%010d-%01d-%010u-%03d", diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index 7d748f0668..08d0ea6c2d 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -47,14 +47,14 @@ class MockBlockIndex : CDiskBlockIndex // Return existing BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) - return (*mi).second; + return mi->second; // Create new CBlockIndex* pindexNew = GRC::BlockIndexPool::GetNextBlockIndex(); if (!pindexNew) throw std::runtime_error("LoadBlockIndex() : new CBlockIndex failed"); mi = mapBlockIndex.insert(std::make_pair(hash, pindexNew)).first; - pindexNew->phashBlock = &((*mi).first); + pindexNew->phashBlock = &(mi->first); return pindexNew; } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp old mode 100755 new mode 100644 index f91e956062..e659e9adf8 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -46,7 +46,7 @@ std::vector> GetTxStakeBoincHashInfo(const C return res; } - pindex = (*mi).second; + pindex = mi->second; if (!block.ReadFromDisk(pindex)) { @@ -346,9 +346,8 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) { entry.pushKV("blockhash", hashBlock.GetHex()); BlockMap::iterator mi = mapBlockIndex.find(hashBlock); - if (mi != mapBlockIndex.end() && (*mi).second) - { - CBlockIndex* pindex = (*mi).second; + if (mi != mapBlockIndex.end() && mi->second) { + CBlockIndex* pindex = mi->second; if (pindex->IsInMainChain()) { entry.pushKV("confirmations", 1 + nBestHeight - pindex->nHeight); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 0a0b0f36b9..2963d0fe79 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -467,7 +467,7 @@ const CRPCCommand *CRPCTable::operator[](string name) const map::const_iterator it = mapCommands.find(name); if (it == mapCommands.end()) return NULL; - return (*it).second; + return it->second; } void ErrorReply(std::ostream& stream, const UniValue& objError, const UniValue& id) diff --git a/src/sync.cpp b/src/sync.cpp index ea5f2b420a..57e000d353 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -122,7 +122,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry) static void pop_lock() { - (*lockstack).pop_back(); + lockstack->pop_back(); } void EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry) diff --git a/src/test/gridcoin/cpid_tests.cpp b/src/test/gridcoin/cpid_tests.cpp index bfd6ab14a9..ceaac8fb02 100644 --- a/src/test/gridcoin/cpid_tests.cpp +++ b/src/test/gridcoin/cpid_tests.cpp @@ -318,10 +318,24 @@ BOOST_AUTO_TEST_CASE(it_parses_a_cpid_mining_id) if (const GRC::CpidOption cpid = mining_id.TryCpid()) { BOOST_CHECK(*cpid == expected); - BOOST_CHECK((*cpid).Raw() == (std::array { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, - })); + BOOST_CHECK(cpid->Raw() == (std::array{ + 0x00, + 0x01, + 0x02, + 0x03, + 0x04, + 0x05, + 0x06, + 0x07, + 0x08, + 0x09, + 0x10, + 0x11, + 0x12, + 0x13, + 0x14, + 0x15, + })); } else { BOOST_FAIL("MiningId variant does not contain the CPID."); } diff --git a/src/txdb-leveldb.cpp b/src/txdb-leveldb.cpp index 2c5857b265..60922ef797 100644 --- a/src/txdb-leveldb.cpp +++ b/src/txdb-leveldb.cpp @@ -291,14 +291,14 @@ static CBlockIndex *InsertBlockIndex(const uint256& hash) // Return existing BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) - return (*mi).second; + return mi->second; // Create new CBlockIndex* pindexNew = GRC::BlockIndexPool::GetNextBlockIndex(); if (!pindexNew) throw runtime_error("LoadBlockIndex() : new CBlockIndex failed"); mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; - pindexNew->phashBlock = &((*mi).first); + pindexNew->phashBlock = &(mi->first); return pindexNew; } diff --git a/src/validation.cpp b/src/validation.cpp index d819b442bb..03e25b8460 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -518,7 +518,7 @@ int GetDepthInMainChain(const CTxIndex& txi) BlockMap::iterator mi = mapBlockIndex.find(block.GetHash(true)); if (mi == mapBlockIndex.end()) return 0; - CBlockIndex* pindex = (*mi).second; + CBlockIndex* pindex = mi->second; if (!pindex || !pindex->IsInMainChain()) return 0; return 1 + nBestHeight - pindex->nHeight; diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 25e38852b7..2eb6a387dc 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -460,8 +460,8 @@ void CDBEnv::Flush(bool fShutdown) map::iterator mi = mapFileUseCount.begin(); while (mi != mapFileUseCount.end()) { - string strFile = (*mi).first; - int nRefCount = (*mi).second; + string strFile = mi->first; + int nRefCount = mi->second; LogPrint(BCLog::LogFlags::WALLETDB, "%s refcount=%d", strFile, nRefCount); if (nRefCount == 0) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fe1f3b8359..651abffd88 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -250,7 +250,7 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false) it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid(); ++it) { - const CWalletTx& wtx = (*it).second; + const CWalletTx& wtx = it->second; for (auto const& txout : wtx.vout) if (txout.scriptPubKey == scriptPubKey) bKeyUsed = true; @@ -339,8 +339,8 @@ UniValue getaccount(const UniValue& params, bool fHelp) string strAccount; map::iterator mi = pwalletMain->mapAddressBook.find(address.Get()); - if (mi != pwalletMain->mapAddressBook.end() && !(*mi).second.empty()) - strAccount = (*mi).second; + if (mi != pwalletMain->mapAddressBook.end() && !mi->second.empty()) + strAccount = mi->second; return strAccount; } @@ -553,7 +553,7 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) int64_t nAmount = 0; for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - const CWalletTx& wtx = (*it).second; + const CWalletTx& wtx = it->second; if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) continue; @@ -604,7 +604,7 @@ UniValue getreceivedbyaccount(const UniValue& params, bool fHelp) int64_t nAmount = 0; for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - const CWalletTx& wtx = (*it).second; + const CWalletTx& wtx = it->second; if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) continue; @@ -627,7 +627,7 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi // Tally wallet transactions for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - const CWalletTx& wtx = (*it).second; + const CWalletTx& wtx = it->second; if (!IsFinalTx(wtx) || wtx.GetDepthInMainChain() < 0) continue; @@ -1049,7 +1049,7 @@ UniValue sendmany(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - const CWalletTx& wtx = (*it).second; + const CWalletTx& wtx = it->second; if (!wtx.IsTrusted()) continue; @@ -1229,7 +1229,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) map mapTally; for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - const CWalletTx& wtx = (*it).second; + const CWalletTx& wtx = it->second; if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) continue; @@ -1276,9 +1276,9 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) bool fIsWatchonly = false; if (it != mapTally.end()) { - nAmount = (*it).second.nAmount; - nConf = (*it).second.nConf; - fIsWatchonly = (*it).second.fIsWatchonly; + nAmount = it->second.nAmount; + nConf = it->second.nConf; + fIsWatchonly = it->second.fIsWatchonly; } if (fByAccounts) @@ -1301,11 +1301,10 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) UniValue transactions(UniValue::VARR); if(it != mapTally.end()) { - for (const uint256& _item : (*it).second.txids) - { + for (const uint256& _item : it->second.txids) { transactions.push_back(_item.GetHex()); } - } + } obj.pushKV("txids", transactions); ret.push_back(obj); } @@ -1315,12 +1314,12 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) { for (map::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it) { - int64_t nAmount = (*it).second.nAmount; - int nConf = (*it).second.nConf; + int64_t nAmount = it->second.nAmount; + int nConf = it->second.nConf; UniValue obj(UniValue::VOBJ); - if((*it).second.fIsWatchonly) - obj.pushKV("involvesWatchonly", true); - obj.pushKV("account", (*it).first); + if (it->second.fIsWatchonly) + obj.pushKV("involvesWatchonly", true); + obj.pushKV("account", it->first); obj.pushKV("amount", ValueFromAmount(nAmount)); obj.pushKV("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf)); ret.push_back(obj); @@ -1626,10 +1625,10 @@ UniValue listtransactions(const UniValue& params, bool fHelp) // iterate backwards until we have nCount items to return: for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { - CWalletTx *const pwtx = (*it).second.first; + CWalletTx* const pwtx = it->second.first; if (pwtx != 0) ListTransactions(*pwtx, strAccount, 0, true, ret, filter); - CAccountingEntry *const pacentry = (*it).second.second; + CAccountingEntry* const pacentry = it->second.second; if (pacentry != 0) AcentryToJSON(*pacentry, strAccount, ret); @@ -1749,7 +1748,7 @@ UniValue listaccounts(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - const CWalletTx& wtx = (*it).second; + const CWalletTx& wtx = it->second; int64_t nFee; string strSentAccount; list listReceived; @@ -1832,7 +1831,7 @@ UniValue listsinceblock(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); it++) { - CWalletTx tx = (*it).second; + CWalletTx tx = it->second; if (depth == -1 || tx.GetDepthInMainChain() < depth) ListTransactions(tx, "*", 0, true, transactions, filter); @@ -1915,9 +1914,8 @@ UniValue gettransaction(const UniValue& params, bool fHelp) { entry.pushKV("blockhash", hashBlock.GetHex()); BlockMap::iterator mi = mapBlockIndex.find(hashBlock); - if (mi != mapBlockIndex.end() && (*mi).second) - { - CBlockIndex* pindex = (*mi).second; + if (mi != mapBlockIndex.end() && mi->second) { + CBlockIndex* pindex = mi->second; if (pindex->IsInMainChain()) entry.pushKV("confirmations", 1 + nBestHeight - pindex->nHeight); else diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 35c31bbbf2..54d3b19493 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -406,7 +406,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, // would make this much faster for applications that do this a lot. for (map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { - CWalletTx* wtx = &((*it).second); + CWalletTx* wtx = &(it->second); txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); } acentries.clear(); @@ -431,7 +431,7 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx, bool fBlock, CWalletDB* map::iterator mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) { - CWalletTx& wtx = (*mi).second; + CWalletTx& wtx = mi->second; if (txin.prevout.n >= wtx.vout.size()) LogPrintf("WalletUpdateSpent: bad wtx %s", wtx.GetHash().ToString()); else if (!wtx.IsSpent(txin.prevout.n) && (IsMine(wtx.vout[txin.prevout.n]) != ISMINE_NO)) @@ -448,7 +448,7 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx, bool fBlock, CWalletDB* { uint256 hash = tx.GetHash(); map::iterator mi = mapWallet.find(hash); - CWalletTx& wtx = (*mi).second; + CWalletTx& wtx = mi->second; for (auto const& txout : tx.vout) { @@ -617,7 +617,7 @@ isminetype CWallet::IsMine(const CTxIn &txin) const map::const_iterator mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) { - const CWalletTx& prev = (*mi).second; + const CWalletTx& prev = mi->second; if (txin.prevout.n < prev.vout.size()) return IsMine(prev.vout[txin.prevout.n]); } @@ -632,7 +632,7 @@ int64_t CWallet::GetDebit(const CTxIn &txin,const isminefilter& filter) const map::const_iterator mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) { - const CWalletTx& prev = (*mi).second; + const CWalletTx& prev = mi->second; if (txin.prevout.n < prev.vout.size()) if (IsMine(prev.vout[txin.prevout.n]) & filter) return prev.vout[txin.prevout.n].nValue; @@ -680,7 +680,7 @@ int CWalletTx::GetRequestCount() const { map::const_iterator mi = pwallet->mapRequestCount.find(hashBlock); if (mi != pwallet->mapRequestCount.end()) - nRequests = (*mi).second; + nRequests = mi->second; } } else @@ -689,14 +689,14 @@ int CWalletTx::GetRequestCount() const map::const_iterator mi = pwallet->mapRequestCount.find(GetHash()); if (mi != pwallet->mapRequestCount.end()) { - nRequests = (*mi).second; + nRequests = mi->second; // How about the block it's in? if (nRequests == 0 && !hashBlock.IsNull()) { map::const_iterator mi = pwallet->mapRequestCount.find(hashBlock); if (mi != pwallet->mapRequestCount.end()) - nRequests = (*mi).second; + nRequests = mi->second; else nRequests = 1; // If it's in someone else's block it must have got out } @@ -919,7 +919,7 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, int64_t& nReceived, if (pwallet->mapAddressBook.count(r.destination)) { map::const_iterator mi = pwallet->mapAddressBook.find(r.destination); - if (mi != pwallet->mapAddressBook.end() && (*mi).second == strAccount) + if (mi != pwallet->mapAddressBook.end() && mi->second == strAccount) nReceived += r.amount; } else if (strAccount.empty()) @@ -957,8 +957,8 @@ void CWalletTx::AddSupportingTransactions(CTxDB& txdb) map::const_iterator mi = pwallet->mapWallet.find(hash); if (mi != pwallet->mapWallet.end()) { - tx = (*mi).second; - for (auto const& txWalletPrev : (*mi).second.vtxPrev) + tx = mi->second; + for (auto const& txWalletPrev : mi->second.vtxPrev) mapWalletPrev[txWalletPrev.GetHash()] = &txWalletPrev; } else if (mapWalletPrev.count(hash)) @@ -1213,7 +1213,7 @@ int64_t CWallet::GetBalance() const LOCK2(cs_main, cs_wallet); for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { - const CWalletTx* pcoin = &(*it).second; + const CWalletTx* pcoin = &it->second; if (pcoin->IsTrusted() && (pcoin->IsConfirmed() || pcoin->fFromMe)) nTotal += pcoin->GetAvailableCredit(); } @@ -1229,7 +1229,7 @@ int64_t CWallet::GetUnconfirmedBalance() const LOCK2(cs_main, cs_wallet); for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { - const CWalletTx* pcoin = &(*it).second; + const CWalletTx* pcoin = &it->second; if (!IsFinalTx(*pcoin) || (!pcoin->IsConfirmed() && !pcoin->fFromMe && pcoin->IsInMainChain())) nTotal += pcoin->GetAvailableCredit(); } @@ -1244,7 +1244,7 @@ int64_t CWallet::GetImmatureBalance() const LOCK2(cs_main, cs_wallet); for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { - const CWalletTx& pcoin = (*it).second; + const CWalletTx& pcoin = it->second; if (pcoin.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.IsInMainChain()) nTotal += GetCredit(pcoin); } @@ -1261,25 +1261,24 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const LOCK2(cs_main, cs_wallet); for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { - const CWalletTx* pcoin = &(*it).second; - int nDepth = pcoin->GetDepthInMainChain(); + const CWalletTx* pcoin = &it->second; + int nDepth = pcoin->GetDepthInMainChain(); - if (!fIncludeStakedCoins) - { - if (!IsFinalTx(*pcoin)) - continue; + if (!fIncludeStakedCoins) { + if (!IsFinalTx(*pcoin)) + continue; - if (fOnlyConfirmed && !pcoin->IsTrusted()) - continue; + if (fOnlyConfirmed && !pcoin->IsTrusted()) + continue; - if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) - continue; + if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) + continue; - if(pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0) - continue; + if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0) + continue; - if (nDepth < 0) - continue; + if (nDepth < 0) + continue; } else { @@ -1289,12 +1288,11 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const for (unsigned int i = 0; i < pcoin->vout.size(); i++) { if ((!(pcoin->IsSpent(i)) && (IsMine(pcoin->vout[i]) != ISMINE_NO) && pcoin->vout[i].nValue >= nMinimumInputValue && - (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) - || (fIncludeStakedCoins && pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0)) - { - vCoins.push_back(COutput(pcoin, i, nDepth)); - } - } + (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected(it->first, i))) || + (fIncludeStakedCoins && pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0)) { + vCoins.push_back(COutput(pcoin, i, nDepth)); + } + } } } @@ -1452,7 +1450,7 @@ int64_t CWallet::GetStake() const LOCK2(cs_main, cs_wallet); for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { - const CWalletTx* pcoin = &(*it).second; + const CWalletTx* pcoin = &it->second; if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) nTotal += CWallet::GetCredit(*pcoin); } @@ -1465,7 +1463,7 @@ int64_t CWallet::GetNewMint() const LOCK2(cs_main, cs_wallet); for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { - const CWalletTx* pcoin = &(*it).second; + const CWalletTx* pcoin = &it->second; if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) nTotal += CWallet::GetCredit(*pcoin); } @@ -2286,7 +2284,7 @@ bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx) map::iterator mi = mapWallet.find(hashTx); if (mi != mapWallet.end()) { - wtx = (*mi).second; + wtx = mi->second; return true; } } @@ -2559,7 +2557,7 @@ set< set > CWallet::GetAddressGroupings() map< CTxDestination, set* >::iterator it; for (auto const& address : grouping) if ((it = setmap.find(address)) != setmap.end()) - hits.insert((*it).second); + hits.insert(it->second); // merge all hit groups into a new single group and delete old groups set* merged = new set(grouping); @@ -2597,7 +2595,7 @@ void CWallet::FixSpentCoins(int& nMismatchFound, int64_t& nBalanceInQuestion, bo vector vCoins; vCoins.reserve(mapWallet.size()); for (map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) - vCoins.push_back(&(*it).second); + vCoins.push_back(&it->second); CWalletDB walletdb(strWalletFile); @@ -2653,7 +2651,7 @@ void CWallet::DisableTransaction(const CTransaction &tx) map::iterator mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) { - CWalletTx& prev = (*mi).second; + CWalletTx& prev = mi->second; if (txin.prevout.n < prev.vout.size() && (IsMine(prev.vout[txin.prevout.n]) != ISMINE_NO)) { prev.MarkUnspent(txin.prevout.n); @@ -2832,7 +2830,7 @@ void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) const { std::vector vAffected; for (std::map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); it++) { // iterate over all wallet transactions... - const CWalletTx &wtx = (*it).second; + const CWalletTx& wtx = it->second; BlockMap::iterator blit = mapBlockIndex.find(wtx.hashBlock); if (blit != mapBlockIndex.end() && blit->second->IsInMainChain()) { // ... which are already in a block @@ -2882,7 +2880,7 @@ MinedType GetGeneratedType(const CWallet *wallet, const uint256& tx, unsigned in if (mi == mapBlockIndex.end()) return MinedType::UNKNOWN; - CBlockIndex* blkindex = (*mi).second; + CBlockIndex* blkindex = mi->second; // If we are calling GetGeneratedType, this is a transaction // that corresponds (is integral to) the block. We check whether diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 520e0225e1..881ecba0cb 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -355,7 +355,7 @@ class CWallet : public CCryptoKeyStore LOCK(cs_wallet); std::map::iterator mi = mapRequestCount.find(hash); if (mi != mapRequestCount.end()) - (*mi).second++; + mi->second++; } } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index ec1ae0cd87..79191b4c97 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -137,7 +137,7 @@ CWalletDB::ReorderTransactions(CWallet* pwallet) for (map::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it) { - CWalletTx* wtx = &((*it).second); + CWalletTx* wtx = &(it->second); txByTime.insert(make_pair(wtx->nTimeReceived, TxPair(wtx, (CAccountingEntry*)0))); } list acentries; @@ -152,8 +152,8 @@ CWalletDB::ReorderTransactions(CWallet* pwallet) std::vector nOrderPosOffsets; for (TxItems::iterator it = txByTime.begin(); it != txByTime.end(); ++it) { - CWalletTx *const pwtx = (*it).second.first; - CAccountingEntry *const pacentry = (*it).second.second; + CWalletTx* const pwtx = it->second.first; + CAccountingEntry* const pacentry = it->second.second; int64_t& nOrderPos = (pwtx != 0) ? pwtx->nOrderPos : pacentry->nOrderPos; if (nOrderPos == -1) @@ -658,7 +658,7 @@ void ThreadFlushWalletDB(void* parg) map::iterator mi = bitdb.mapFileUseCount.begin(); while (mi != bitdb.mapFileUseCount.end()) { - nRefCount += (*mi).second; + nRefCount += mi->second; mi++; } From 43a49cb26767795516e1903925a12e2341490bb5 Mon Sep 17 00:00:00 2001 From: div72 <60045611+div72@users.noreply.github.com> Date: Sun, 13 Jun 2021 13:20:49 +0300 Subject: [PATCH 2/4] scripted-diff: boost foreach -> c++11 for -BEGIN VERIFY SCRIPT- sed -i -r -e 's/BOOST_FOREACH\([ ]?(.*+)[ ]?,[ ]?(.*+)[ ]?\)/for (\1 : \2)/g' $(git grep -l 'BOOST_FOREACH' -- 'src/*.h' 'src/*.cpp' ':!src/leveldb/**' ':!src/univalue/**' ':!src/qt/locale') sed -i -r -e 's/foreach[ ]?\([ ]?(.*+)[ ]?,[ ]?(.*+)[ ]?\)/for (\1 : \2)/g' $(git grep -l 'foreach' -- 'src/*.h' 'src/*.cpp' ':!src/leveldb/**' ':!src/univalue/**' ':!src/qt/locale') sed -i -r -e '/foreach/d' $(git grep -l 'foreach' -- 'src/*.h' 'src/*.cpp' ':!src/leveldb/**' ':!src/univalue/**' ':!src/qt/locale') sed -i -r -e '/define PAIRTYPE/d' $(git grep -l 'PAIRTYPE' -- 'src/*.h' 'src/*.cpp' ':!src/leveldb/**' ':!src/univalue/**' ':!src/qt/locale') sed -i -r -e 's/PAIRTYPE\([ ]?(.*+)[ ]?,[ ]?(.*+)[ ]?\)/std::pair<\1, \2>/g' $(git grep -l 'PAIRTYPE' -- 'src/*.h' 'src/*.cpp' ':!src/leveldb/**' ':!src/univalue/**' ':!src/qt/locale') git diff -U0 | contrib/devtools/clang-format-diff.py -p1 -i -v -END VERIFY SCRIPT- --- src/qt/addressbookpage.cpp | 12 ++++-------- src/qt/bitcoingui.cpp | 3 +-- src/qt/coincontroldialog.cpp | 3 +-- src/qt/optionsdialog.cpp | 3 +-- src/qt/rpcconsole.cpp | 3 +-- src/qt/sendcoinsdialog.cpp | 3 +-- src/qt/trafficgraphwidget.cpp | 4 ++-- src/qt/transactiontablemodel.cpp | 3 +-- src/qt/walletmodel.cpp | 9 +++------ src/rpc/dataacq.cpp | 6 +++--- src/test/accounting_tests.cpp | 4 +--- src/test/checkpoints_tests.cpp | 1 - src/test/getarg_tests.cpp | 3 +-- src/test/multisig_tests.cpp | 4 +--- src/test/rpc_tests.cpp | 1 - src/test/script_p2sh_tests.cpp | 1 - src/test/script_tests.cpp | 7 ++----- src/test/sigopcount_tests.cpp | 1 - src/test/transaction_tests.cpp | 8 ++++---- src/test/util_tests.cpp | 1 - src/util.h | 2 -- 21 files changed, 27 insertions(+), 55 deletions(-) mode change 100755 => 100644 src/test/accounting_tests.cpp mode change 100755 => 100644 src/test/multisig_tests.cpp mode change 100755 => 100644 src/test/script_tests.cpp diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 67012e381f..52109b16f8 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -194,8 +194,7 @@ void AddressBookPage::on_signMessageButton_clicked() QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); QString addr; - foreach (QModelIndex index, indexes) - { + for (QModelIndex index : indexes) { QVariant address = index.data(); addr = address.toString(); } @@ -209,8 +208,7 @@ void AddressBookPage::on_verifyMessageButton_clicked() QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); QString addr; - foreach (QModelIndex index, indexes) - { + for (QModelIndex index : indexes) { QVariant address = index.data(); addr = address.toString(); } @@ -302,8 +300,7 @@ void AddressBookPage::done(int retval) // Figure out which address was selected, and return it QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); - foreach (QModelIndex index, indexes) - { + for (QModelIndex index : indexes) { QVariant address = table->model()->data(index); returnValue = address.toString(); } @@ -352,8 +349,7 @@ void AddressBookPage::on_showQRCodeButton_clicked() QTableView *table = ui->tableView; QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); - foreach (QModelIndex index, indexes) - { + for (QModelIndex index : indexes) { QString address = index.data().toString(), label = index.sibling(index.row(), 0).data(Qt::EditRole).toString(); QRCodeDialog *dialog = new QRCodeDialog(address, label, tab == ReceivingTab, this); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index d6776852cc..1c64888fc0 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1354,8 +1354,7 @@ void BitcoinGUI::dropEvent(QDropEvent *event) { int nValidUrisFound = 0; QList uris = event->mimeData()->urls(); - foreach(const QUrl &uri, uris) - { + for (const QUrl& uri : uris) { if (sendCoinsPage->handleURI(uri.toString())) nValidUrisFound++; } diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 48d0081e00..9f3ae29d47 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -649,8 +649,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, bool fLowOutput = false; bool fDust = false; CTransaction txDummy; - foreach(const qint64 &amount, *payAmounts) - { + for (const qint64& amount : *payAmounts) { nPayAmount += amount; if (amount > 0) diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 2d85a2a12f..f66e4b8aef 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -54,8 +54,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) : /* Display elements init */ QDir translations(":translations"); ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant("")); - foreach(const QString &langStr, translations.entryList()) - { + for (const QString& langStr : translations.entryList()) { QLocale locale(langStr); /** check if the locale name consists of 2 parts (language_country) */ diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index b79672a1f0..e41fe22c83 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -104,8 +104,7 @@ bool parseCommandLine(std::vector &args, const std::string &strComm STATE_ESCAPE_DOUBLEQUOTED } state = STATE_EATING_SPACES; std::string curarg; - foreach(char ch, strCommand) - { + for (char ch : strCommand) { switch(state) { case STATE_ARGUMENT: // In or after argument diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 2f7d7bed0b..60862736ec 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -150,8 +150,7 @@ void SendCoinsDialog::on_sendButton_clicked() // Format confirmation message QStringList formatted; - foreach(const SendCoinsRecipient &rcp, recipients) - { + for (const SendCoinsRecipient& rcp : recipients) { formatted.append(tr("%1 to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), rcp.label.toHtmlEscaped(), rcp.address)); } diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp index d63be2b7e3..7eda0af46b 100644 --- a/src/qt/trafficgraphwidget.cpp +++ b/src/qt/trafficgraphwidget.cpp @@ -151,10 +151,10 @@ void TrafficGraphWidget::updateRates() } float tmax = 0.0f; - foreach(float f, vSamplesIn) { + for (float f : vSamplesIn) { if(f > tmax) tmax = f; } - foreach(float f, vSamplesOut) { + for (float f : vSamplesOut) { if(f > tmax) tmax = f; } fMax = tmax; diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index b66956048c..f620afd263 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -172,8 +172,7 @@ class TransactionTablePriv { parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1); int insert_idx = lowerIndex; - foreach(const TransactionRecord &rec, toInsert) - { + for (const TransactionRecord& rec : toInsert) { cachedWallet.insert(insert_idx, rec); insert_idx += 1; } diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 5e05826052..55194749e7 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -184,8 +184,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList > vecSend; - foreach(const SendCoinsRecipient &rcp, recipients) - { + for (const SendCoinsRecipient& rcp : recipients) { CScript scriptPubKey; scriptPubKey.SetDestination(CBitcoinAddress(rcp.address.toStdString()).Get()); vecSend.push_back(std::make_pair(scriptPubKey, rcp.amount)); @@ -268,8 +266,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList list; + std::vector> list; std::copy(c_version.begin(), c_version.end(), back_inserter(list)); std::sort(list.begin(), list.end(), compare_second); @@ -301,7 +301,7 @@ UniValue rpc_getblockstats(const UniValue& params, bool fHelp) // cpids { UniValue result(UniValue::VOBJ); - std::vector list; + std::vector> list; std::copy(c_cpid.begin(), c_cpid.end(), back_inserter(list)); std::sort(list.begin(), list.end(), compare_second); @@ -315,7 +315,7 @@ UniValue rpc_getblockstats(const UniValue& params, bool fHelp) // orgs { UniValue result(UniValue::VOBJ); - std::vector list; + std::vector> list; std::copy(c_org.begin(), c_org.end(), back_inserter(list)); std::sort(list.begin(), list.end(), compare_second); diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp old mode 100755 new mode 100644 index 45518b7ce3..971cf5c853 --- a/src/test/accounting_tests.cpp +++ b/src/test/accounting_tests.cpp @@ -1,6 +1,5 @@ #include -#include #include "init.h" #include "wallet/wallet.h" @@ -18,8 +17,7 @@ GetResults(CWalletDB& walletdb, std::map& results) results.clear(); BOOST_CHECK(walletdb.ReorderTransactions(pwalletMain) == DB_LOAD_OK); walletdb.ListAccountCreditDebit("", aes); - BOOST_FOREACH(CAccountingEntry& ae, aes) - { + for (CAccountingEntry& ae : aes) { results[ae.nOrderPos] = ae; } } diff --git a/src/test/checkpoints_tests.cpp b/src/test/checkpoints_tests.cpp index eec0061179..809aa66afc 100644 --- a/src/test/checkpoints_tests.cpp +++ b/src/test/checkpoints_tests.cpp @@ -3,7 +3,6 @@ // #include // for 'map_list_of()' #include -#include #include "../chainparams.h" #include "../checkpoints.h" diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp index ebad94bdcc..30fdcfd16c 100644 --- a/src/test/getarg_tests.cpp +++ b/src/test/getarg_tests.cpp @@ -1,5 +1,4 @@ #include -#include #include #include "util/system.h" @@ -33,7 +32,7 @@ static bool ResetArgs(const std::string& strAddArg, const std::string& strArgIn // Convert to char*: std::vector vecChar; - BOOST_FOREACH(std::string& s, vecArg) + for (std::string& s : vecArg) vecChar.push_back(s.c_str()); std::string error; diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp old mode 100755 new mode 100644 index 0b5302b516..87bbae7963 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include @@ -33,8 +32,7 @@ sign_multisig(CScript scriptPubKey, vector keys, CTransaction transaction, CScript result; result << OP_0; // CHECKMULTISIG bug workaround - BOOST_FOREACH(CKey key, keys) - { + for (CKey key : keys) { vector vchSig; BOOST_CHECK(key.Sign(hash, vchSig)); vchSig.push_back((unsigned char)SIGHASH_ALL); diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index 238c51c1f5..cd832e983b 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -1,5 +1,4 @@ #include -#include #include "base58.h" #include "util.h" diff --git a/src/test/script_p2sh_tests.cpp b/src/test/script_p2sh_tests.cpp index f59fbf3bb0..8cd7573841 100755 --- a/src/test/script_p2sh_tests.cpp +++ b/src/test/script_p2sh_tests.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include "main.h" #include "policy/policy.h" diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp old mode 100755 new mode 100644 index 96f2634f30..132bb7bd75 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -49,8 +48,7 @@ ParseScript(string s) vector words; split(words, s, is_any_of(" \t\n"), token_compress_on); - BOOST_FOREACH(string w, words) - { + for (string w : words) { if (w.empty()) { // Empty string, ignore. (boost::split given '' will return one word) @@ -196,8 +194,7 @@ sign_multisig(CScript scriptPubKey, std::vector keys, CTransaction transac // and vice-versa) // result << OP_0; - BOOST_FOREACH(CKey key, keys) - { + for (CKey key : keys) { vector vchSig; BOOST_CHECK(key.Sign(hash, vchSig)); vchSig.push_back((unsigned char)SIGHASH_ALL); diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp index 9a300611e1..79c119fbb5 100644 --- a/src/test/sigopcount_tests.cpp +++ b/src/test/sigopcount_tests.cpp @@ -1,6 +1,5 @@ #include #include -#include #include "script.h" #include "key.h" diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index d0cbb1c3a6..b5a8940f7c 100755 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) // ... where all scripts are stringified scripts. Array tests = read_json("tx_valid.json"); - BOOST_FOREACH(Value& tv, tests) + for (Value& tv : tests) { Array test = tv.get_array(); string strTest = write_string(tv, false); @@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) map mapprevOutScriptPubKeys; Array inputs = test[0].get_array(); bool fValid = true; - BOOST_FOREACH(Value& input, inputs) + for (Value& input : inputs) { if (input.type() != array_type) { @@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) // ... where all scripts are stringified scripts. Array tests = read_json("tx_invalid.json"); - BOOST_FOREACH(Value& tv, tests) + for (Value& tv : tests) { Array test = tv.get_array(); string strTest = write_string(tv, false); @@ -113,7 +113,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) map mapprevOutScriptPubKeys; Array inputs = test[0].get_array(); bool fValid = true; - BOOST_FOREACH(Value& input, inputs) + for (Value& input : inputs) { if (input.type() != array_type) { diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 606228353c..6e66da2bac 100755 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -1,6 +1,5 @@ #include #include -#include #include "main.h" #include "wallet/wallet.h" diff --git a/src/util.h b/src/util.h index bb3777f29e..75f775f9e2 100644 --- a/src/util.h +++ b/src/util.h @@ -59,8 +59,6 @@ #define PRIpdu "tu" #define PRIpdd "td" -// This is needed because the foreach macro can't get over the comma in pair -#define PAIRTYPE(t1, t2) std::pair #ifdef WIN32 #define MSG_NOSIGNAL 0 From 4c4f1f5f2a4624f73e9bdb9591d45c78d8199ab0 Mon Sep 17 00:00:00 2001 From: div72 <60045611+div72@users.noreply.github.com> Date: Sun, 13 Jun 2021 16:23:01 +0300 Subject: [PATCH 3/4] NULL, 0 -> nullptr --- src/addrman.cpp | 4 +- src/addrman.h | 4 +- src/base58.h | 3 +- src/bignum.h | 26 ++--- src/crypter.cpp | 4 +- src/gridcoin/scraper/http.cpp | 8 +- src/gridcoin/scraper/scraper_net.cpp | 2 +- src/gridcoin/staking/kernel.cpp | 2 +- src/gridcoinresearchd.cpp | 4 +- src/init.cpp | 6 +- src/key.cpp | 126 ++++++++++++++----------- src/main.cpp | 53 +++++------ src/main.h | 10 +- src/miner.cpp | 7 +- src/net.cpp | 68 ++++++------- src/net.h | 10 +- src/netbase.cpp | 13 ++- src/netbase.h | 2 +- src/primitives/transaction.h | 8 +- src/qt/aboutdialog.h | 2 +- src/qt/addressbookpage.cpp | 13 ++- src/qt/addressbookpage.h | 2 +- src/qt/addresstablemodel.cpp | 7 +- src/qt/addresstablemodel.h | 2 +- src/qt/askpassphrasedialog.cpp | 11 +-- src/qt/askpassphrasedialog.h | 2 +- src/qt/bitcoin.cpp | 14 +-- src/qt/bitcoinaddressvalidator.h | 2 +- src/qt/bitcoinamountfield.cpp | 5 +- src/qt/bitcoinamountfield.h | 2 +- src/qt/bitcoingui.cpp | 35 ++++--- src/qt/bitcoingui.h | 2 +- src/qt/clientmodel.cpp | 5 +- src/qt/clientmodel.h | 2 +- src/qt/coincontroldialog.cpp | 13 ++- src/qt/coincontroldialog.h | 6 +- src/qt/coincontroltreewidget.h | 4 +- src/qt/csvmodelwriter.cpp | 5 +- src/qt/csvmodelwriter.h | 2 +- src/qt/diagnosticsdialog.h | 2 +- src/qt/editaddressdialog.cpp | 5 +- src/qt/editaddressdialog.h | 2 +- src/qt/guiutil.cpp | 14 +-- src/qt/guiutil.h | 6 +- src/qt/intro.cpp | 2 +- src/qt/optionsdialog.cpp | 15 ++- src/qt/optionsdialog.h | 2 +- src/qt/optionsmodel.h | 2 +- src/qt/overviewpage.h | 2 +- src/qt/qrcodedialog.cpp | 9 +- src/qt/qrcodedialog.h | 2 +- src/qt/qtipcserver.cpp | 4 +- src/qt/qvalidatedlineedit.h | 2 +- src/qt/qvaluecombobox.h | 2 +- src/qt/rpcconsole.cpp | 3 +- src/qt/rpcconsole.h | 2 +- src/qt/sendcoinsdialog.cpp | 15 ++- src/qt/sendcoinsdialog.h | 2 +- src/qt/sendcoinsentry.cpp | 7 +- src/qt/sendcoinsentry.h | 2 +- src/qt/signverifymessagedialog.cpp | 7 +- src/qt/signverifymessagedialog.h | 2 +- src/qt/trafficgraphwidget.cpp | 19 ++-- src/qt/trafficgraphwidget.h | 2 +- src/qt/transactiondescdialog.h | 2 +- src/qt/transactionfilterproxy.h | 2 +- src/qt/transactionrecord.cpp | 2 +- src/qt/transactiontablemodel.cpp | 2 +- src/qt/transactiontablemodel.h | 2 +- src/qt/transactionview.h | 2 +- src/qt/walletmodel.cpp | 15 ++- src/qt/walletmodel.h | 4 +- src/rpc/blockchain.cpp | 5 +- src/rpc/blockchain.h | 2 +- src/rpc/client.cpp | 2 +- src/rpc/protocol.cpp | 6 +- src/rpc/rawtransaction.cpp | 10 +- src/rpc/server.cpp | 30 +++--- src/script.cpp | 4 +- src/script.h | 4 +- src/sync.h | 2 +- src/test/gridcoin/superblock_tests.cpp | 2 +- src/test/rpc_tests.cpp | 2 +- src/txdb-leveldb.cpp | 24 ++--- src/txdb-leveldb.h | 4 +- src/util.cpp | 4 +- src/util.h | 2 +- src/util/system.cpp | 2 +- src/util/time.cpp | 2 +- src/validation.h | 2 +- src/wallet/db.cpp | 69 +++++++------- src/wallet/db.h | 24 ++--- src/wallet/rpcdump.cpp | 4 +- src/wallet/rpcwallet.cpp | 12 +-- src/wallet/wallet.cpp | 12 +-- src/wallet/wallet.h | 20 ++-- src/wallet/walletdb.cpp | 18 ++-- 97 files changed, 459 insertions(+), 468 deletions(-) mode change 100755 => 100644 src/qt/guiutil.cpp diff --git a/src/addrman.cpp b/src/addrman.cpp index 892d567782..69dcb6e54c 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -82,13 +82,13 @@ CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int *pnId) { std::map::iterator it = mapAddr.find(addr); if (it == mapAddr.end()) - return NULL; + return nullptr; if (pnId) *pnId = it->second; std::map::iterator it2 = mapInfo.find(it->second); if (it2 != mapInfo.end()) return &it2->second; - return NULL; + return nullptr; } CAddrInfo* CAddrMan::Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId) diff --git a/src/addrman.h b/src/addrman.h index 4e2cf543df..4485e142ed 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -201,11 +201,11 @@ class CAddrMan protected: // Find an entry. - CAddrInfo* Find(const CNetAddr& addr, int *pnId = NULL); + CAddrInfo* Find(const CNetAddr& addr, int* pnId = nullptr); // find an entry, creating it if necessary. // nTime and nServices of found node is updated, if necessary. - CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = NULL); + CAddrInfo* Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId = nullptr); // Swap two elements in vRandom. void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2); diff --git a/src/base58.h b/src/base58.h index f8279b2c77..9000474b79 100644 --- a/src/base58.h +++ b/src/base58.h @@ -88,8 +88,7 @@ inline bool DecodeBase58(const char* psz, std::vector& vchRet) for (const char* p = psz; *p; p++) { const char* p1 = strchr(pszBase58, *p); - if (p1 == NULL) - { + if (p1 == nullptr) { while (isspace(*p)) p++; if (*p != '\0') diff --git a/src/bignum.h b/src/bignum.h index 80ece0a78f..7724ab5b3f 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -36,20 +36,20 @@ class CAutoBN_CTX CAutoBN_CTX() { pctx = BN_CTX_new(); - if (pctx == NULL) - throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned NULL"); + if (pctx == nullptr) + throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned nullptr"); } ~CAutoBN_CTX() { - if (pctx != NULL) + if (pctx != nullptr) BN_CTX_free(pctx); } operator BN_CTX*() { return pctx; } BN_CTX& operator*() { return *pctx; } BN_CTX** operator&() { return &pctx; } - bool operator!() { return (pctx == NULL); } + bool operator!() { return (pctx == nullptr); } }; /* RAII wrapper for BIGNUM instance */ @@ -62,8 +62,8 @@ class CBigNumBase CBigNumBase() : pbn(BN_new()) { - if (pbn == NULL) - throw bignum_error("CBigNum : BN_new() returned NULL"); + if (pbn == nullptr) + throw bignum_error("CBigNum : BN_new() returned nullptr"); } ~CBigNumBase() @@ -214,7 +214,7 @@ class CBigNum : public CBigNumBase uint64_t getuint64() { - unsigned int nSize = BN_bn2mpi(pbn, NULL); + unsigned int nSize = BN_bn2mpi(pbn, nullptr); if (nSize < 4) return 0; std::vector vch(nSize); @@ -284,7 +284,7 @@ class CBigNum : public CBigNumBase uint256 getuint256() const { - unsigned int nSize = BN_bn2mpi(pbn, NULL); + unsigned int nSize = BN_bn2mpi(pbn, nullptr); if (nSize < 4) return uint256(); std::vector vch(nSize); @@ -315,7 +315,7 @@ class CBigNum : public CBigNumBase std::vector getvch() const { - unsigned int nSize = BN_bn2mpi(pbn, NULL); + unsigned int nSize = BN_bn2mpi(pbn, nullptr); if (nSize <= 4) return std::vector(); std::vector vch(nSize); @@ -339,7 +339,7 @@ class CBigNum : public CBigNumBase unsigned int GetCompact() const { - unsigned int nSize = BN_bn2mpi(pbn, NULL); + unsigned int nSize = BN_bn2mpi(pbn, nullptr); std::vector vch(nSize); nSize -= 4; BN_bn2mpi(pbn, &vch[0]); @@ -504,7 +504,7 @@ class CBigNum : public CBigNumBase */ static CBigNum generatePrime(const unsigned int numBits, bool safe = false) { CBigNum ret; - if(!BN_generate_prime_ex(&ret, numBits, safe, NULL, NULL, NULL)) + if (!BN_generate_prime_ex(&ret, numBits, safe, nullptr, nullptr, nullptr)) throw bignum_error("CBigNum::generatePrime*= :BN_generate_prime_ex"); return ret; } @@ -530,7 +530,7 @@ class CBigNum : public CBigNumBase */ bool isPrime(const int checks=BN_prime_checks) const { CAutoBN_CTX pctx; - int ret = BN_is_prime_ex(pbn, checks, pctx, NULL); + int ret = BN_is_prime_ex(pbn, checks, pctx, nullptr); if(ret < 0){ throw bignum_error("CBigNum::isPrime :BN_is_prime_ex"); } @@ -688,7 +688,7 @@ inline const CBigNum operator/(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_div(&r, NULL, &a, &b, pctx)) + if (!BN_div(&r, nullptr, &a, &b, pctx)) throw bignum_error("CBigNum::operator/ : BN_div failed"); return r; } diff --git a/src/crypter.cpp b/src/crypter.cpp index 7213bfc3c5..1292d18c71 100644 --- a/src/crypter.cpp +++ b/src/crypter.cpp @@ -73,7 +73,7 @@ bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector& vchCiphertext, CKeyingM if(!ctx) throw std::runtime_error("Error allocating cipher context"); - if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, vchKey.data(), vchIV.data()); + if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), nullptr, vchKey.data(), vchIV.data()); if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0])+nPLen, &nFLen); EVP_CIPHER_CTX_free(ctx); diff --git a/src/gridcoin/scraper/http.cpp b/src/gridcoin/scraper/http.cpp index 485be16995..5cd1d27234 100644 --- a/src/gridcoin/scraper/http.cpp +++ b/src/gridcoin/scraper/http.cpp @@ -224,7 +224,7 @@ std::string Http::GetEtag( const std::string &url, const std::string &userpass) { - struct curl_slist* headers = NULL; + struct curl_slist* headers = nullptr; headers = curl_slist_append(headers, "Accept: */*"); headers = curl_slist_append(headers, "User-Agent: curl/7.63.0"); std::string header; @@ -272,7 +272,7 @@ std::string Http::GetLatestVersionResponse() std::string header; std::string url = gArgs.GetArg("-updatecheckurl", "https://api.github.com/repos/gridcoin-community/Gridcoin-Research/releases/latest"); - struct curl_slist* headers = NULL; + struct curl_slist* headers = nullptr; headers = curl_slist_append(headers, "Accept: */*"); headers = curl_slist_append(headers, "User-Agent: curl/7.63.0"); @@ -318,7 +318,7 @@ void Http::DownloadSnapshot() std::string buffer; std::string header; - struct curl_slist* headers = NULL; + struct curl_slist* headers = nullptr; headers = curl_slist_append(headers, "Accept: */*"); headers = curl_slist_append(headers, "User-Agent: curl/7.63.0"); @@ -385,7 +385,7 @@ std::string Http::GetSnapshotSHA256() std::string header; std::string url = gArgs.GetArg("-snapshotsha256url", "https://snapshot.gridcoin.us/snapshot.zip.sha256"); - struct curl_slist* headers = NULL; + struct curl_slist* headers = nullptr; headers = curl_slist_append(headers, "Accept: */*"); headers = curl_slist_append(headers, "User-Agent: curl/7.63.0"); diff --git a/src/gridcoin/scraper/scraper_net.cpp b/src/gridcoin/scraper/scraper_net.cpp index 9b72d9aa44..d5d3e88ac8 100644 --- a/src/gridcoin/scraper/scraper_net.cpp +++ b/src/gridcoin/scraper/scraper_net.cpp @@ -126,7 +126,7 @@ int CSplitBlob::addPartData(CDataStream&& vData) /* missing data; use the supplied data */ /* prevent calling the Complete callback FIXME: make this look better */ cntPartsRcvd--; - CSplitBlob::RecvPart(0, vData); + CSplitBlob::RecvPart(nullptr, vData); cntPartsRcvd++; } return n; diff --git a/src/gridcoin/staking/kernel.cpp b/src/gridcoin/staking/kernel.cpp index 4fcf3c37fb..768d34d85b 100644 --- a/src/gridcoin/staking/kernel.cpp +++ b/src/gridcoin/staking/kernel.cpp @@ -222,7 +222,7 @@ static bool SelectBlockFromCandidates( { bool fSelected = false; arith_uint256 hashBest = 0; - *pindexSelected = (const CBlockIndex*) 0; + *pindexSelected = nullptr; for (auto const& item : vSortedByTimestamp) { diff --git a/src/gridcoinresearchd.cpp b/src/gridcoinresearchd.cpp index c9b7e8bcf9..167f794a91 100644 --- a/src/gridcoinresearchd.cpp +++ b/src/gridcoinresearchd.cpp @@ -209,7 +209,7 @@ bool AppInit(int argc, char* argv[]) } catch (...) { LogPrintf("AppInit()Exception2"); - PrintException(NULL, "AppInit()"); + PrintException(nullptr, "AppInit()"); } if(fRet) { @@ -217,7 +217,7 @@ bool AppInit(int argc, char* argv[]) MilliSleep(500); } - Shutdown(NULL); + Shutdown(nullptr); // delete thread handler threads->interruptAll(); diff --git a/src/init.cpp b/src/init.cpp index 331237973e..ecb4c42890 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -716,7 +716,7 @@ bool AppInit2(ThreadHandlerPtr threads) #ifdef _MSC_VER // Turn off Microsoft heap dump noise _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0)); + _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, 0)); #endif #if _MSC_VER >= 1400 // Disable confusing "helpful" text message on abort, Ctrl-C @@ -733,7 +733,7 @@ bool AppInit2(ThreadHandlerPtr threads) #endif typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD); PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy"); - if (setProcDEPPol != NULL) setProcDEPPol(PROCESS_DEP_ENABLE); + if (setProcDEPPol != nullptr) setProcDEPPol(PROCESS_DEP_ENABLE); #endif #ifndef WIN32 umask(077); @@ -1368,7 +1368,7 @@ bool AppInit2(ThreadHandlerPtr threads) LogPrintf("mapAddressBook.size() = %" PRIszu, pwalletMain->mapAddressBook.size()); } - if (!threads->createThread(StartNode, NULL, "Start Thread")) + if (!threads->createThread(StartNode, nullptr, "Start Thread")) InitError(_("Error: could not start node")); if (fServer) StartRPCThreads(); diff --git a/src/key.cpp b/src/key.cpp index 35b1010f34..1b534a8a90 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -16,7 +16,7 @@ #if OPENSSL_VERSION_NUMBER < 0x10100000L int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) { - if (r == NULL || s == NULL) + if (r == nullptr || s == nullptr) return 0; BN_clear_free(sig->r); BN_clear_free(sig->s); @@ -27,9 +27,9 @@ int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) { - if (pr != NULL) + if (pr != nullptr) *pr = sig->r; - if (ps != NULL) + if (ps != nullptr) *ps = sig->s; } #endif @@ -38,22 +38,22 @@ void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key) { int ok = 0; - BN_CTX *ctx = NULL; - EC_POINT *pub_key = NULL; + BN_CTX* ctx = nullptr; + EC_POINT* pub_key = nullptr; if (!eckey) return 0; const EC_GROUP *group = EC_KEY_get0_group(eckey); - if ((ctx = BN_CTX_new()) == NULL) + if ((ctx = BN_CTX_new()) == nullptr) goto err; pub_key = EC_POINT_new(group); - if (pub_key == NULL) + if (pub_key == nullptr) goto err; - if (!EC_POINT_mul(group, pub_key, priv_key, NULL, NULL, ctx)) + if (!EC_POINT_mul(group, pub_key, priv_key, nullptr, nullptr, ctx)) goto err; EC_KEY_set_private_key(eckey,priv_key); @@ -65,7 +65,7 @@ int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key) if (pub_key) EC_POINT_free(pub_key); - if (ctx != NULL) + if (ctx != nullptr) BN_CTX_free(ctx); return(ok); @@ -79,26 +79,29 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch if (!eckey) return 0; int ret = 0; - BN_CTX *ctx = NULL; - - BIGNUM *x = NULL; - BIGNUM *e = NULL; - BIGNUM *order = NULL; - BIGNUM *sor = NULL; - BIGNUM *eor = NULL; - BIGNUM *field = NULL; - EC_POINT *R = NULL; - EC_POINT *O = NULL; - EC_POINT *Q = NULL; - BIGNUM *rr = NULL; - BIGNUM *zero = NULL; + BN_CTX* ctx = nullptr; + + BIGNUM* x = nullptr; + BIGNUM* e = nullptr; + BIGNUM* order = nullptr; + BIGNUM* sor = nullptr; + BIGNUM* eor = nullptr; + BIGNUM* field = nullptr; + EC_POINT* R = nullptr; + EC_POINT* O = nullptr; + EC_POINT* Q = nullptr; + BIGNUM* rr = nullptr; + BIGNUM* zero = nullptr; int n = 0; int i = recid / 2; const BIGNUM *pr, *ps; ECDSA_SIG_get0(ecsig, &pr, &ps); const EC_GROUP *group = EC_KEY_get0_group(eckey); - if ((ctx = BN_CTX_new()) == NULL) { ret = -1; goto err; } + if ((ctx = BN_CTX_new()) == nullptr) { + ret = -1; + goto err; + } BN_CTX_start(ctx); order = BN_CTX_get(ctx); if (!EC_GROUP_get_order(group, order, ctx)) { ret = -2; goto err; } @@ -107,17 +110,32 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch if (!BN_mul_word(x, i)) { ret=-1; goto err; } if (!BN_add(x, x, pr)) { ret=-1; goto err; } field = BN_CTX_get(ctx); - if (!EC_GROUP_get_curve_GFp(group, field, NULL, NULL, ctx)) { ret=-2; goto err; } + if (!EC_GROUP_get_curve_GFp(group, field, nullptr, nullptr, ctx)) { + ret = -2; + goto err; + } if (BN_cmp(x, field) >= 0) { ret=0; goto err; } - if ((R = EC_POINT_new(group)) == NULL) { ret = -2; goto err; } + if ((R = EC_POINT_new(group)) == nullptr) { + ret = -2; + goto err; + } if (!EC_POINT_set_compressed_coordinates_GFp(group, R, x, recid % 2, ctx)) { ret=0; goto err; } if (check) { - if ((O = EC_POINT_new(group)) == NULL) { ret = -2; goto err; } - if (!EC_POINT_mul(group, O, NULL, R, order, ctx)) { ret=-2; goto err; } + if ((O = EC_POINT_new(group)) == nullptr) { + ret = -2; + goto err; + } + if (!EC_POINT_mul(group, O, nullptr, R, order, ctx)) { + ret = -2; + goto err; + } if (!EC_POINT_is_at_infinity(group, O)) { ret = 0; goto err; } } - if ((Q = EC_POINT_new(group)) == NULL) { ret = -2; goto err; } + if ((Q = EC_POINT_new(group)) == nullptr) { + ret = -2; + goto err; + } n = EC_GROUP_get_degree(group); e = BN_CTX_get(ctx); if (!BN_bin2bn(msg, msglen, e)) { ret=-1; goto err; } @@ -141,9 +159,9 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch BN_CTX_end(ctx); BN_CTX_free(ctx); } - if (R != NULL) EC_POINT_free(R); - if (O != NULL) EC_POINT_free(O); - if (Q != NULL) EC_POINT_free(Q); + if (R != nullptr) EC_POINT_free(R); + if (O != nullptr) EC_POINT_free(O); + if (Q != nullptr) EC_POINT_free(Q); return ret; } @@ -156,24 +174,24 @@ void CKey::SetCompressedPubKey() void CKey::Reset() { fCompressedPubKey = false; - if (pkey != NULL) + if (pkey != nullptr) EC_KEY_free(pkey); pkey = EC_KEY_new_by_curve_name(NID_secp256k1); - if (pkey == NULL) + if (pkey == nullptr) throw key_error("CKey::CKey() : EC_KEY_new_by_curve_name failed"); fSet = false; } CKey::CKey() { - pkey = NULL; + pkey = nullptr; Reset(); } CKey::CKey(const CKey& b) { pkey = EC_KEY_dup(b.pkey); - if (pkey == NULL) + if (pkey == nullptr) throw key_error("CKey::CKey(const CKey&) : EC_KEY_dup failed"); fSet = b.fSet; } @@ -274,9 +292,9 @@ bool CKey::SetPrivKey(const CPrivKey& vchPrivKey) } // If vchPrivKey data is bad d2i_ECPrivateKey() can // leave pkey in a state where calling EC_KEY_free() - // crashes. To avoid that, set pkey to NULL and + // crashes. To avoid that, set pkey to nullptr and // leak the memory (a leak is better than a crash) - pkey = NULL; + pkey = nullptr; Reset(); return false; } @@ -285,12 +303,12 @@ bool CKey::SetSecret(const CSecret& vchSecret, bool fCompressed) { EC_KEY_free(pkey); pkey = EC_KEY_new_by_curve_name(NID_secp256k1); - if (pkey == NULL) + if (pkey == nullptr) throw key_error("CKey::SetSecret() : EC_KEY_new_by_curve_name failed"); if (vchSecret.size() != 32) throw key_error("CKey::SetSecret() : secret must be 32 bytes"); BIGNUM *bn = BN_bin2bn(&vchSecret[0],32,BN_new()); - if (bn == NULL) + if (bn == nullptr) throw key_error("CKey::SetSecret() : BN_bin2bn failed"); if (!EC_KEY_regenerate_key(pkey,bn)) { @@ -310,7 +328,7 @@ CSecret CKey::GetSecret(bool &fCompressed) const vchRet.resize(32); const BIGNUM *bn = EC_KEY_get0_private_key(pkey); int nBytes = BN_num_bytes(bn); - if (bn == NULL) + if (bn == nullptr) throw key_error("CKey::GetSecret() : EC_KEY_get0_private_key failed"); int n=BN_bn2bin(bn,&vchRet[32 - nBytes]); if (n != nBytes) @@ -321,7 +339,7 @@ CSecret CKey::GetSecret(bool &fCompressed) const CPrivKey CKey::GetPrivKey() const { - int nSize = i2d_ECPrivateKey(pkey, NULL); + int nSize = i2d_ECPrivateKey(pkey, nullptr); if (!nSize) throw key_error("CKey::GetPrivKey() : i2d_ECPrivateKey failed"); CPrivKey vchPrivKey(nSize, 0); @@ -341,14 +359,14 @@ bool CKey::SetPubKey(const CPubKey& vchPubKey) SetCompressedPubKey(); return true; } - pkey = NULL; + pkey = nullptr; Reset(); return false; } CPubKey CKey::GetPubKey() const { - int nSize = i2o_ECPublicKey(pkey, NULL); + int nSize = i2o_ECPublicKey(pkey, nullptr); if (!nSize) throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed"); std::vector vchPubKey(nSize, 0); @@ -362,7 +380,7 @@ bool CKey::Sign(uint256 hash, std::vector& vchSig) { vchSig.clear(); ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey); - if (sig == NULL) + if (sig == nullptr) return false; BN_CTX *ctx = BN_CTX_new(); BN_CTX_start(ctx); @@ -378,12 +396,12 @@ bool CKey::Sign(uint256 hash, std::vector& vchSig) // enforce low S values, by negating the value (modulo the order) if above order/2. BIGNUM *nps = BN_dup(ps); if(!nps) - throw std::runtime_error("CKey : BN_dup() returned NULL"); + throw std::runtime_error("CKey : BN_dup() returned nullptr"); BIGNUM *npr = BN_dup(pr); if(!npr) { BN_free(nps); - throw std::runtime_error("CKey : BN_dup() returned NULL"); + throw std::runtime_error("CKey : BN_dup() returned nullptr"); } BN_sub(nps, order, nps); @@ -408,7 +426,7 @@ bool CKey::SignCompact(uint256 hash, std::vector& vchSig) { bool fOk = false; ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey); - if (sig==NULL) + if (sig == nullptr) return false; vchSig.clear(); vchSig.resize(65,0); @@ -457,12 +475,12 @@ bool CKey::ReserealizeSignature(std::vector& vchSig) { return false; pos = &vchSig[0]; - ECDSA_SIG *sig = d2i_ECDSA_SIG(NULL, (const unsigned char **)&pos, vchSig.size()); - if (sig == NULL) + ECDSA_SIG* sig = d2i_ECDSA_SIG(nullptr, (const unsigned char**)&pos, vchSig.size()); + if (sig == nullptr) return false; bool ret = false; - int nSize = i2d_ECDSA_SIG(sig, NULL); + int nSize = i2d_ECDSA_SIG(sig, nullptr); if (nSize > 0) { vchSig.resize(nSize); // grow or shrink as needed @@ -492,8 +510,8 @@ bool CKey::SetCompactSignature(uint256 hash, const std::vector& v ECDSA_SIG *sig = ECDSA_SIG_new(); ECDSA_SIG_set0( sig, - BN_bin2bn(&vchSig[1],32,NULL), - BN_bin2bn(&vchSig[33],32,NULL)); + BN_bin2bn(&vchSig[1], 32, nullptr), + BN_bin2bn(&vchSig[33], 32, nullptr)); EC_KEY_free(pkey); pkey = EC_KEY_new_by_curve_name(NID_secp256k1); @@ -517,7 +535,7 @@ bool CKey::SetCompactSignature(uint256 hash, const std::vector& v { // BIP66 Compatibility: // New versions of OpenSSL (1.0.0p+ and 1.0.1k+) will reject non-canonical DER signatures. de/re-serialize first. - unsigned char *norm_der = NULL; + unsigned char* norm_der = nullptr; ECDSA_SIG *norm_sig = ECDSA_SIG_new(); const unsigned char* sigptr = &vchSig[0]; d2i_ECDSA_SIG(&norm_sig, &sigptr, vchSig.size()); @@ -550,7 +568,7 @@ bool CKey::IsValid() bool ECC_InitSanityCheck() { EC_KEY *pkey = EC_KEY_new_by_curve_name(NID_secp256k1); - if(pkey == NULL) + if (pkey == nullptr) return false; EC_KEY_free(pkey); diff --git a/src/main.cpp b/src/main.cpp index d6b95824c0..90b86de769 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,11 +82,11 @@ unsigned int nStakeMaxAge = -1; // unlimited // Gridcoin: int nCoinbaseMaturity = 100; -CBlockIndex* pindexGenesisBlock = NULL; +CBlockIndex* pindexGenesisBlock = nullptr; int nBestHeight = -1; uint256 hashBestChain; -CBlockIndex* pindexBest = NULL; +CBlockIndex* pindexBest = nullptr; std::atomic g_previous_block_time; std::atomic g_nTimeBestReceived; CMedianFilter cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have @@ -446,8 +446,7 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock) AssertLockHeld(cs_main); CBlock blockTmp; - if (pblock == NULL) - { + if (pblock == nullptr) { // Load the block this tx is in CTxIndex txindex; if (!CTxDB("r").ReadTxIndex(GetHash(), txindex)) @@ -522,7 +521,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CTransaction &tx, bool* pfMissingInput return false; // Check for conflicts with in-memory transactions - CTransaction* ptxOld = NULL; + CTransaction* ptxOld = nullptr; { LOCK(pool.cs); // protect pool.mapNextTx for (unsigned int i = 0; i < tx.vin.size(); i++) @@ -759,7 +758,7 @@ int CMerkleTx::GetBlocksToMaturity() const bool CMerkleTx::AcceptToMemoryPool() { - return ::AcceptToMemoryPool(mempool, *this, NULL); + return ::AcceptToMemoryPool(mempool, *this, nullptr); } @@ -871,7 +870,7 @@ int GetNumBlocksOfPeers() bool IsInitialBlockDownload() { LOCK(cs_main); - if ((pindexBest == NULL || nBestHeight < GetNumBlocksOfPeers()) && nBestHeight<1185000) + if ((pindexBest == nullptr || nBestHeight < GetNumBlocksOfPeers()) && nBestHeight < 1185000) return true; static int64_t nLastUpdate; static CBlockIndex* pindexLastBest; @@ -1020,7 +1019,7 @@ int64_t ReturnCurrentMoneySupply(CBlockIndex* pindexcurrent) { return (pindexcurrent->pprev? pindexcurrent->pprev->nMoneySupply : 0); } - // At this point, either the last block pointer was NULL, or the client erased the money supply previously, fix it: + // At this point, either the last block pointer was nullptr, or the client erased the money supply previously, fix it: CBlockIndex* pblockIndex = pindexcurrent; CBlockIndex* pblockMemory = pindexcurrent; int nMinDepth = (pindexcurrent->nHeight)-140000; @@ -1030,7 +1029,7 @@ int64_t ReturnCurrentMoneySupply(CBlockIndex* pindexcurrent) pblockIndex = pblockIndex->pprev; LogPrintf("Money Supply height %d", pblockIndex->nHeight); - if (pblockIndex == NULL || !pblockIndex->IsInMainChain()) continue; + if (pblockIndex == nullptr || !pblockIndex->IsInMainChain()) continue; if (pblockIndex == pindexGenesisBlock) { return nGenesisSupply; @@ -1729,7 +1728,7 @@ bool DisconnectBlocksBatch(CTxDB& txdb, list& vResurrect, unsigned // disconnect from memory assert(!pindexBest->pnext); if (pindexBest->pprev) - pindexBest->pprev->pnext = NULL; + pindexBest->pprev->pnext = nullptr; // Queue memory transactions to resurrect. // We only do this for blocks after the last checkpoint (reorganisation before that @@ -1802,7 +1801,7 @@ bool DisconnectBlocksBatch(CTxDB& txdb, list& vResurrect, unsigned { // Resurrect memory transactions that were in the disconnected branch for( CTransaction& tx : vResurrect) - AcceptToMemoryPool(mempool, tx, NULL); + AcceptToMemoryPool(mempool, tx, nullptr); if (!txdb.TxnCommit()) return error("DisconnectBlocksBatch: TxnCommit failed"); /*fatal*/ @@ -1840,12 +1839,11 @@ bool ReorganizeChain(CTxDB& txdb, unsigned &cnt_dis, unsigned &cnt_con, CBlock & set vRereadCPIDs; /* find fork point */ - CBlockIndex *pcommon = NULL; + CBlockIndex* pcommon = nullptr; if(pindexGenesisBlock) { pcommon = pindexNew; - while( pcommon->pnext==NULL && pcommon!=pindexBest ) - { + while (pcommon->pnext == nullptr && pcommon != pindexBest) { pcommon = pcommon->pprev; if(!pcommon) @@ -1925,17 +1923,14 @@ bool ReorganizeChain(CTxDB& txdb, unsigned &cnt_dis, unsigned &cnt_con, CBlock & if (!txdb.TxnBegin()) return error("ReorganizeChain: TxnBegin failed"); - if (pindexGenesisBlock == NULL) - { + if (pindexGenesisBlock == nullptr) { if(hash != (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) { txdb.TxnAbort(); return error("ReorganizeChain: genesis block hash does not match"); } pindexGenesisBlock = pindex; - } - else - { + } else { assert(pindex->GetBlockHash()==block.GetHash(true)); assert(pindex->pprev == pindexBest); if (!block.ConnectBlock(txdb, pindex, false)) @@ -2558,8 +2553,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock, bool generated_by_me) { // Extra checks to prevent "fill up memory by spamming with bogus blocks" const CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex); - if(pcheckpoint != NULL) - { + if (pcheckpoint != nullptr) { int64_t deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime; if (deltaTime < 0) { @@ -2708,16 +2702,16 @@ static fs::path BlockFilePath(unsigned int nFile) FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode) { if ((nFile < 1) || (nFile == (unsigned int) -1)) - return NULL; + return nullptr; FILE* file = fsbridge::fopen(BlockFilePath(nFile), pszMode); if (!file) - return NULL; + return nullptr; if (nBlockPos != 0 && !strchr(pszMode, 'a') && !strchr(pszMode, 'w')) { if (fseek(file, nBlockPos, SEEK_SET) != 0) { fclose(file); - return NULL; + return nullptr; } } return file; @@ -2732,9 +2726,9 @@ FILE* AppendBlockFile(unsigned int& nFileRet) { FILE* file = OpenBlockFile(nCurrentBlockFile, 0, "ab"); if (!file) - return NULL; + return nullptr; if (fseek(file, 0, SEEK_END) != 0) - return NULL; + return nullptr; // FAT32 file size max 4GB, fseek and ftell max 2GB, so we must stay under 2GB if (ftell(file) < (long)(0x7F000000 - MAX_SIZE)) { @@ -2990,8 +2984,7 @@ bool LoadExternalBlockFile(FILE* fileIn) { CBlock block; blkdat >> block; - if (ProcessBlock(NULL,&block,false)) - { + if (ProcessBlock(nullptr, &block, false)) { nLoaded++; LogPrintf("Blocks/s: %f", nLoaded / ((GetTimeMillis() - nStart) / 1000.0)); nPos += 4 + nSize; @@ -3560,7 +3553,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LOCK(cs_main); - CBlockIndex* pindex = NULL; + CBlockIndex* pindex = nullptr; if (locator.IsNull()) { // If locator is null, return the hashStop block @@ -3966,7 +3959,7 @@ bool ProcessMessages(CNode* pfrom) catch (std::exception& e) { PrintExceptionContinue(&e, "ProcessMessages()"); } catch (...) { - PrintExceptionContinue(NULL, "ProcessMessages()"); + PrintExceptionContinue(nullptr, "ProcessMessages()"); } if (!fRet) diff --git a/src/main.h b/src/main.h index 7f2351561f..8453994c0a 100644 --- a/src/main.h +++ b/src/main.h @@ -186,7 +186,7 @@ class CTxIndex; void RegisterWallet(CWallet* pwalletIn); void UnregisterWallet(CWallet* pwalletIn); -void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL, bool fUpdate = false, bool fConnect = true); +void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = nullptr, bool fUpdate = false, bool fConnect = true); bool ProcessBlock(CNode* pfrom, CBlock* pblock, bool Generated_By_Me); bool CheckDiskSpace(uint64_t nAdditionalBytes=0); FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb"); @@ -251,7 +251,7 @@ class CMerkleTx : public CTransaction READWRITE(nIndex); } - int SetMerkleBranch(const CBlock* pblock=NULL); + int SetMerkleBranch(const CBlock* pblock = nullptr); // Return depth of transaction in blockchain: // -1 : not in blockchain, and not in memory pool (conflicted transaction) @@ -645,9 +645,9 @@ class CBlockIndex void SetNull() { - phashBlock = NULL; - pprev = NULL; - pnext = NULL; + phashBlock = nullptr; + pprev = nullptr; + pnext = nullptr; nFile = 0; nBlockPos = 0; nHeight = 0; diff --git a/src/miner.cpp b/src/miner.cpp index 368b71f47c..1685c43641 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -323,7 +323,7 @@ bool CreateRestOfTheBlock(CBlock &block, CBlockIndex* pindexPrev) continue; } - COrphan* porphan = NULL; + COrphan* porphan = nullptr; double dPriority = 0; int64_t nTotalIn = 0; bool fMissingInputs = false; @@ -347,7 +347,7 @@ bool CreateRestOfTheBlock(CBlock &block, CBlockIndex* pindexPrev) if (LogInstance().WillLogCategory(BCLog::LogFlags::VERBOSE)) { - assert("mempool transaction missing input" == 0); + assert("mempool transaction missing input" == nullptr); } fMissingInputs = true; @@ -1425,8 +1425,7 @@ void StakeMiner(CWallet *pwallet) } // * delegate to ProcessBlock - if (!ProcessBlock(NULL, &StakeBlock, true)) - { + if (!ProcessBlock(nullptr, &StakeBlock, true)) { error("StakeMiner: Block vehemently rejected"); continue; } diff --git a/src/net.cpp b/src/net.cpp index 88bedb2c72..e08562659c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -50,7 +50,7 @@ void ThreadOpenAddedConnections2(void* parg); void ThreadMapPort2(void* parg); #endif void ThreadDNSAddressSeed2(void* parg); -bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false); +bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant* grantOutbound = nullptr, const char* strDest = nullptr, bool fOneShot = false); void StakeMiner(CWallet *pwallet); // @@ -62,7 +62,7 @@ ServiceFlags nLocalServices = NODE_NETWORK; CCriticalSection cs_mapLocalHost; std::map mapLocalHost; static bool vfLimited[NET_MAX] GUARDED_BY(cs_mapLocalHost) = {}; -static CNode* pnodeLocalHost = NULL; +static CNode* pnodeLocalHost = nullptr; CAddress addrSeenByPeer(CService("0.0.0.0", 0), nLocalServices); uint64_t nLocalHostNonce = 0; @@ -96,7 +96,7 @@ CCriticalSection cs_setservAddNodeAddresses; std::map> CNode::mapMisbehavior; CCriticalSection CNode::cs_mapMisbehavior; -static CSemaphore *semOutbound = NULL; +static CSemaphore* semOutbound = nullptr; // This caches the block locators used to ask for a range of blocks. Due to a // sub-optimal workaround in our old net messaging code, a node will ask each @@ -410,7 +410,7 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest) } else { - return NULL; + return nullptr; } } @@ -1135,7 +1135,7 @@ void ThreadMapPort(void* parg) } catch (...) { - PrintException(NULL, "ThreadMapPort()"); + PrintException(nullptr, "ThreadMapPort()"); } LogPrintf("ThreadMapPort exited"); } @@ -1145,9 +1145,9 @@ void ThreadMapPort2(void* parg) LogPrint(BCLog::LogFlags::NET, "ThreadMapPort started"); std::string port = strprintf("%u", GetListenPort()); - const char * multicastif = 0; - const char * minissdpdpath = 0; - struct UPNPDev * devlist = 0; + const char* multicastif = nullptr; + const char* minissdpdpath = nullptr; + struct UPNPDev* devlist = nullptr; char lanaddr[64]; int error = 0; @@ -1184,7 +1184,7 @@ void ThreadMapPort2(void* parg) string strDesc = "Gridcoin " + FormatFullVersion(); r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0"); + port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", nullptr, "0"); if(r!=UPNPCOMMAND_SUCCESS) LogPrintf("AddPortMapping(%s, %s, %s) unsuccessful with code %d (%s)", @@ -1196,9 +1196,10 @@ void ThreadMapPort2(void* parg) { if (fShutdown || !fUseUPnP) { - r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0); + r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", nullptr); LogPrintf("UPNP_DeletePortMapping() returned : %d", r); - freeUPNPDevlist(devlist); devlist = 0; + freeUPNPDevlist(devlist); + devlist = nullptr; FreeUPNPUrls(&urls); return; } @@ -1211,7 +1212,7 @@ void ThreadMapPort2(void* parg) #else /* miniupnpc 1.6 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0"); + port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", nullptr, "0"); #endif if(r!=UPNPCOMMAND_SUCCESS) @@ -1225,7 +1226,8 @@ void ThreadMapPort2(void* parg) } } else { LogPrint(BCLog::LogFlags::NET, "No valid UPnP IGDs found"); - freeUPNPDevlist(devlist); devlist = 0; + freeUPNPDevlist(devlist); + devlist = nullptr; if (r != 0) FreeUPNPUrls(&urls); while (true) @@ -1241,7 +1243,7 @@ void MapPort() { if (fUseUPnP && !netThreads->threadExists("ThreadMapPort")) { - if (!netThreads->createThread(ThreadMapPort,NULL,"ThreadMapPort")) + if (!netThreads->createThread(ThreadMapPort, nullptr, "ThreadMapPort")) LogPrintf("Error: createThread(ThreadMapPort) failed"); } } @@ -1381,7 +1383,7 @@ void ThreadDumpAddress(void* parg) } catch (...) { - PrintException(NULL, "ThreadDumpAddress"); + PrintException(nullptr, "ThreadDumpAddress"); } LogPrintf("ThreadDumpAddress exited"); } @@ -1406,7 +1408,7 @@ void ThreadOpenConnections(void* parg) } catch (...) { - PrintException(NULL, "ThreadOpenConnections()"); + PrintException(nullptr, "ThreadOpenConnections()"); } LogPrintf("ThreadOpenConnections exited"); } @@ -1449,7 +1451,7 @@ void static ThreadStakeMiner(void* parg) } catch (...) { - PrintException(NULL, "ThreadStakeMiner()"); + PrintException(nullptr, "ThreadStakeMiner()"); } LogPrintf("ThreadStakeMiner exited"); } @@ -1487,7 +1489,7 @@ void ThreadOpenConnections2(void* parg) for (auto const& strAddr : gArgs.GetArgs("-connect")) { CAddress addr; - OpenNetworkConnection(addr, NULL, strAddr.c_str()); + OpenNetworkConnection(addr, nullptr, strAddr.c_str()); for (int i = 0; i < 10 && i < nLoop; i++) { MilliSleep(500); @@ -1611,7 +1613,7 @@ void ThreadOpenAddedConnections(void* parg) } catch (...) { - PrintException(NULL, "ThreadOpenAddedConnections()"); + PrintException(nullptr, "ThreadOpenAddedConnections()"); } LogPrintf("ThreadOpenAddedConnections exited"); } @@ -1733,7 +1735,7 @@ void ThreadMessageHandler(void* parg) } catch (...) { - PrintException(NULL, "ThreadMessageHandler()"); + PrintException(nullptr, "ThreadMessageHandler()"); } LogPrintf("ThreadMessageHandler exited"); } @@ -1752,7 +1754,7 @@ void ThreadMessageHandler2(void* parg) } // Poll the connected nodes for messages - CNode* pnodeTrickle = NULL; + CNode* pnodeTrickle = nullptr; if (!vNodesCopy.empty()) pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())]; for (auto const& pnode : vNodesCopy) @@ -1952,9 +1954,8 @@ void static Discover() struct ifaddrs* myaddrs; if (getifaddrs(&myaddrs) == 0) { - for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) - { - if (ifa->ifa_addr == NULL) continue; + for (struct ifaddrs* ifa = myaddrs; ifa != nullptr; ifa = ifa->ifa_next) { + if (ifa->ifa_addr == nullptr) continue; if ((ifa->ifa_flags & IFF_UP) == 0) continue; if (strcmp(ifa->ifa_name, "lo") == 0) continue; if (strcmp(ifa->ifa_name, "lo0") == 0) continue; @@ -1985,7 +1986,7 @@ void StartNode(void* parg) fShutdown = false; MAX_OUTBOUND_CONNECTIONS = (int)gArgs.GetArg("-maxoutboundconnections", 8); int nMaxOutbound = 0; - if (semOutbound == NULL) { + if (semOutbound == nullptr) { // initialize semaphore nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, (int)gArgs.GetArg("-maxconnections", 125)); semOutbound = new CSemaphore(nMaxOutbound); @@ -1993,7 +1994,7 @@ void StartNode(void* parg) LogPrintf("Using %i OutboundConnections with a MaxConnections of %" PRId64, MAX_OUTBOUND_CONNECTIONS, gArgs.GetArg("-maxconnections", 125)); - if (pnodeLocalHost == NULL) + if (pnodeLocalHost == nullptr) pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); Discover(); @@ -2004,32 +2005,31 @@ void StartNode(void* parg) if (!gArgs.GetBoolArg("-dnsseed", true)) LogPrintf("DNS seeding disabled"); - else - if (!netThreads->createThread(ThreadDNSAddressSeed,NULL,"ThreadDNSAddressSeed")) - LogPrintf("Error: createThread(ThreadDNSAddressSeed) failed"); + else if (!netThreads->createThread(ThreadDNSAddressSeed, nullptr, "ThreadDNSAddressSeed")) + LogPrintf("Error: createThread(ThreadDNSAddressSeed) failed"); // Map ports with UPnP if (fUseUPnP) MapPort(); // Send and receive from sockets, accept connections - if (!netThreads->createThread(ThreadSocketHandler,NULL,"ThreadSocketHandler")) + if (!netThreads->createThread(ThreadSocketHandler, nullptr, "ThreadSocketHandler")) LogPrintf("Error: createThread(ThreadSocketHandler) failed"); // Initiate outbound connections from -addnode - if (!netThreads->createThread(ThreadOpenAddedConnections,NULL,"ThreadOpenAddedConnections")) + if (!netThreads->createThread(ThreadOpenAddedConnections, nullptr, "ThreadOpenAddedConnections")) LogPrintf("Error: createThread(ThreadOpenAddedConnections) failed"); // Initiate outbound connections - if (!netThreads->createThread(ThreadOpenConnections,NULL,"ThreadOpenConnections")) + if (!netThreads->createThread(ThreadOpenConnections, nullptr, "ThreadOpenConnections")) LogPrintf("Error: createThread(ThreadOpenConnections) failed"); // Process messages - if (!netThreads->createThread(ThreadMessageHandler,NULL,"ThreadMessageHandler")) + if (!netThreads->createThread(ThreadMessageHandler, nullptr, "ThreadMessageHandler")) LogPrintf("Error: createThread(ThreadMessageHandler) failed"); // Dump network addresses - if (!netThreads->createThread(ThreadDumpAddress,NULL,"ThreadDumpAddress")) + if (!netThreads->createThread(ThreadDumpAddress, nullptr, "ThreadDumpAddress")) LogPrintf("Error: createThread(ThreadDumpAddress) failed"); // Mine proof-of-stake blocks in the background diff --git a/src/net.h b/src/net.h index 1849d9985a..a8d8209f94 100644 --- a/src/net.h +++ b/src/net.h @@ -45,7 +45,7 @@ bool GetMyExternalIP(CNetAddr& ipRet); void AddressCurrentlyConnected(const CService& addr); CNode* FindNode(const CNetAddr& ip); CNode* FindNode(const CService& ip); -CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL); +CNode* ConnectNode(CAddress addrConnect, const char* strDest = nullptr); void MapPort(); unsigned short GetListenPort(); bool BindListenPort(const CService &bindAddr, std::string& strError=REF(std::string())); @@ -81,10 +81,10 @@ bool AddLocal(const CService& addr, int nScore = LOCAL_NONE); bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE); bool SeenLocal(const CService& addr); bool IsLocal(const CService& addr); -bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL); +bool GetLocal(CService& addr, const CNetAddr* paddrPeer = nullptr); bool IsReachable(const CNetAddr &addr); void SetReachable(enum Network net, bool fFlag = false); -CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL); +CAddress GetLocalAddress(const CNetAddr* paddrPeer = nullptr); void AdvertiseLocal(CNode *pnode = nullptr); enum @@ -103,7 +103,7 @@ class CRequestTracker void (*fn)(void*, CDataStream&); void* param1; - explicit CRequestTracker(void (*fnIn)(void*, CDataStream&)=NULL, void* param1In=NULL) + explicit CRequestTracker(void (*fnIn)(void*, CDataStream&) = nullptr, void* param1In = nullptr) { fn = fnIn; param1 = param1In; @@ -111,7 +111,7 @@ class CRequestTracker bool IsNull() { - return fn == NULL; + return fn == nullptr; } }; diff --git a/src/netbase.cpp b/src/netbase.cpp index 14331ec04b..d13466fa00 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -61,14 +61,13 @@ bool static LookupIntern(const char *pszName, std::vector& vIP, unsign #else aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST; #endif - struct addrinfo *aiRes = NULL; - int nErr = getaddrinfo(pszName, NULL, &aiHint, &aiRes); + struct addrinfo* aiRes = nullptr; + int nErr = getaddrinfo(pszName, nullptr, &aiHint, &aiRes); if (nErr) return false; struct addrinfo *aiTrav = aiRes; - while (aiTrav != NULL && (nMaxSolutions == 0 || vIP.size() < nMaxSolutions)) - { + while (aiTrav != nullptr && (nMaxSolutions == 0 || vIP.size() < nMaxSolutions)) { if (aiTrav->ai_family == AF_INET) { assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in)); @@ -366,7 +365,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe fd_set fdset; FD_ZERO(&fdset); FD_SET(hSocket, &fdset); - int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout); + int nRet = select(hSocket + 1, nullptr, &fdset, nullptr, &timeout); if (nRet == 0) { closesocket(hSocket); @@ -789,7 +788,7 @@ std::string CNetAddr::ToStringIP() const socklen_t socklen = sizeof(sockaddr); if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) { char name[1025] = ""; - if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), NULL, 0, NI_NUMERICHOST)) + if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), nullptr, 0, NI_NUMERICHOST)) return std::string(name); } if (IsIPv4()) @@ -930,7 +929,7 @@ static const int NET_UNKNOWN = NET_MAX + 0; static const int NET_TEREDO = NET_MAX + 1; int static GetExtNetwork(const CNetAddr *addr) { - if (addr == NULL) + if (addr == nullptr) return NET_UNKNOWN; if (addr->IsRFC4380()) return NET_TEREDO; diff --git a/src/netbase.h b/src/netbase.h index 1abd16e685..42e73b7a4c 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -70,7 +70,7 @@ class CNetAddr uint64_t GetHash() const; bool GetInAddr(struct in_addr* pipv4Addr) const; std::vector GetGroup() const; - int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const; + int GetReachabilityFrom(const CNetAddr* paddrPartner = nullptr) const; void print() const; CNetAddr(const struct in6_addr& pipv6Addr); diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index f14729a9ff..592760e72d 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -20,8 +20,12 @@ class CInPoint CInPoint() { SetNull(); } CInPoint(CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; } - void SetNull() { ptx = NULL; n = (unsigned int) -1; } - bool IsNull() const { return (ptx == NULL && n == (unsigned int) -1); } + void SetNull() + { + ptx = nullptr; + n = (unsigned int)-1; + } + bool IsNull() const { return (ptx == nullptr && n == (unsigned int)-1); } }; diff --git a/src/qt/aboutdialog.h b/src/qt/aboutdialog.h index 2ed9e9e7c4..a6e12ce4ec 100644 --- a/src/qt/aboutdialog.h +++ b/src/qt/aboutdialog.h @@ -14,7 +14,7 @@ class AboutDialog : public QDialog Q_OBJECT public: - explicit AboutDialog(QWidget *parent = 0); + explicit AboutDialog(QWidget* parent = nullptr); ~AboutDialog(); void setModel(ClientModel *model); diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 52109b16f8..118dc23c79 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -17,13 +17,12 @@ #include "qrcodedialog.h" #endif -AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : - QDialog(parent), - ui(new Ui::AddressBookPage), - model(0), - optionsModel(0), - mode(mode), - tab(tab) +AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget* parent) : QDialog(parent), + ui(new Ui::AddressBookPage), + model(nullptr), + optionsModel(nullptr), + mode(mode), + tab(tab) { ui->setupUi(this); diff --git a/src/qt/addressbookpage.h b/src/qt/addressbookpage.h index 64c900542e..c95fd3c4c4 100644 --- a/src/qt/addressbookpage.h +++ b/src/qt/addressbookpage.h @@ -34,7 +34,7 @@ class AddressBookPage : public QDialog ForEditing /**< Open address book for editing */ }; - explicit AddressBookPage(Mode mode, Tabs tab, QWidget *parent = 0); + explicit AddressBookPage(Mode mode, Tabs tab, QWidget* parent = nullptr); ~AddressBookPage(); void setModel(AddressTableModel *model); diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index eec0d1ce11..7f02c614df 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -134,13 +134,12 @@ class AddressTablePriv } else { - return 0; + return nullptr; } } }; -AddressTableModel::AddressTableModel(CWallet *wallet, WalletModel *parent) : - QAbstractTableModel(parent),walletModel(parent),wallet(wallet),priv(0) +AddressTableModel::AddressTableModel(CWallet* wallet, WalletModel* parent) : QAbstractTableModel(parent), walletModel(parent), wallet(wallet), priv(nullptr) { columns << tr("Label") << tr("Address"); priv = new AddressTablePriv(wallet, this); @@ -285,7 +284,7 @@ QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation, Qt::ItemFlags AddressTableModel::flags(const QModelIndex &index) const { if(!index.isValid()) - return 0; + return nullptr; AddressTableEntry *rec = static_cast(index.internalPointer()); Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled; diff --git a/src/qt/addresstablemodel.h b/src/qt/addresstablemodel.h index b7dafa39d3..8616460e5f 100644 --- a/src/qt/addresstablemodel.h +++ b/src/qt/addresstablemodel.h @@ -17,7 +17,7 @@ class AddressTableModel : public QAbstractTableModel { Q_OBJECT public: - explicit AddressTableModel(CWallet *wallet, WalletModel *parent = 0); + explicit AddressTableModel(CWallet* wallet, WalletModel* parent = nullptr); ~AddressTableModel(); enum ColumnIndex { diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index c8149d15dd..ea8d9bbb83 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -10,12 +10,11 @@ extern bool fWalletUnlockStakingOnly; -AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : - QDialog(parent), - ui(new Ui::AskPassphraseDialog), - mode(mode), - model(0), - fCapsLock(false) +AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent) : QDialog(parent), + ui(new Ui::AskPassphraseDialog), + mode(mode), + model(nullptr), + fCapsLock(false) { ui->setupUi(this); ui->oldPassphraseEdit->setMaxLength(MAX_PASSPHRASE_SIZE); diff --git a/src/qt/askpassphrasedialog.h b/src/qt/askpassphrasedialog.h index f604ffe142..32b9cf07f0 100644 --- a/src/qt/askpassphrasedialog.h +++ b/src/qt/askpassphrasedialog.h @@ -24,7 +24,7 @@ class AskPassphraseDialog : public QDialog Decrypt /**< Ask passphrase and decrypt wallet */ }; - explicit AskPassphraseDialog(Mode mode, QWidget *parent = 0); + explicit AskPassphraseDialog(Mode mode, QWidget* parent = nullptr); ~AskPassphraseDialog(); void accept(); diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 99e6884130..3d94da38f1 100755 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -245,7 +245,7 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons static void handleRunawayException(std::exception *e) { PrintExceptionContinue(e, "Runaway exception"); - QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Gridcoin can no longer continue safely and will quit.") + QString("\n") + QString::fromStdString(strMiscWarning)); + QMessageBox::critical(nullptr, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Gridcoin can no longer continue safely and will quit.") + QString("\n") + QString::fromStdString(strMiscWarning)); exit(1); } @@ -679,14 +679,14 @@ int StartGridcoinQt(int argc, char *argv[], QApplication& app, OptionsModel& opt app.exec(); window.hide(); - window.setClientModel(0); - window.setWalletModel(0); - window.setResearcherModel(0); - guiref = 0; + window.setClientModel(nullptr); + window.setWalletModel(nullptr); + window.setResearcherModel(nullptr); + guiref = nullptr; } // Shutdown the core and its threads, but don't exit Bitcoin-Qt here LogPrintf("Main calling Shutdown..."); - Shutdown(NULL); + Shutdown(nullptr); } } @@ -696,7 +696,7 @@ int StartGridcoinQt(int argc, char *argv[], QApplication& app, OptionsModel& opt } catch (...) { - handleRunawayException(NULL); + handleRunawayException(nullptr); } // delete thread handler diff --git a/src/qt/bitcoinaddressvalidator.h b/src/qt/bitcoinaddressvalidator.h index 9710d122b6..2f83271992 100644 --- a/src/qt/bitcoinaddressvalidator.h +++ b/src/qt/bitcoinaddressvalidator.h @@ -10,7 +10,7 @@ class BitcoinAddressValidator : public QValidator { Q_OBJECT public: - explicit BitcoinAddressValidator(QObject *parent = 0); + explicit BitcoinAddressValidator(QObject* parent = nullptr); State validate(QString &input, int &pos) const; diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index 54f10e23b9..2f62da5b04 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -14,8 +14,7 @@ #include #include -BitcoinAmountField::BitcoinAmountField(QWidget *parent): - QWidget(parent), amount(0), currentUnit(-1), valid(true) +BitcoinAmountField::BitcoinAmountField(QWidget* parent) : QWidget(parent), amount(nullptr), currentUnit(-1), valid(true) { amount = new QDoubleSpinBox(this); amount->setLocale(QLocale::c()); @@ -65,7 +64,7 @@ bool BitcoinAmountField::validate() bool valid = true; if (amount->value() == 0.0) valid = false; - if (valid && !BitcoinUnits::parse(currentUnit, text(), 0)) + if (valid && !BitcoinUnits::parse(currentUnit, text(), nullptr)) valid = false; setValid(valid); diff --git a/src/qt/bitcoinamountfield.h b/src/qt/bitcoinamountfield.h index 165e7c82b6..bc735012c9 100644 --- a/src/qt/bitcoinamountfield.h +++ b/src/qt/bitcoinamountfield.h @@ -15,7 +15,7 @@ class BitcoinAmountField: public QWidget Q_OBJECT Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true) public: - explicit BitcoinAmountField(QWidget *parent = 0); + explicit BitcoinAmountField(QWidget* parent = nullptr); qint64 value(bool *valid=0) const; void setValue(qint64 value); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 1c64888fc0..bed6b0b53d 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -94,18 +94,17 @@ extern CWallet* pwalletMain; extern std::string FromQString(QString qs); extern CCriticalSection cs_ConvergedScraperStatsCache; -BitcoinGUI::BitcoinGUI(QWidget *parent): - QMainWindow(parent), - clientModel(0), - walletModel(0), - encryptWalletAction(0), - changePassphraseAction(0), - unlockWalletAction(0), - lockWalletAction(0), - trayIcon(0), - notificator(0), - rpcConsole(0), - nWeight(0) +BitcoinGUI::BitcoinGUI(QWidget* parent) : QMainWindow(parent), + clientModel(nullptr), + walletModel(nullptr), + encryptWalletAction(nullptr), + changePassphraseAction(nullptr), + unlockWalletAction(nullptr), + lockWalletAction(nullptr), + trayIcon(nullptr), + notificator(nullptr), + rpcConsole(nullptr), + nWeight(0) { QSettings settings; if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) { @@ -1272,7 +1271,7 @@ void BitcoinGUI::gotoOverviewPage() centralWidget->setCurrentWidget(overviewPage); exportAction->setEnabled(false); - disconnect(exportAction, SIGNAL(triggered()), 0, 0); + disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr); } void BitcoinGUI::gotoHistoryPage() @@ -1281,7 +1280,7 @@ void BitcoinGUI::gotoHistoryPage() centralWidget->setCurrentWidget(transactionView); exportAction->setEnabled(true); - disconnect(exportAction, SIGNAL(triggered()), 0, 0); + disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr); connect(exportAction, SIGNAL(triggered()), transactionView, SLOT(exportClicked())); } @@ -1291,7 +1290,7 @@ void BitcoinGUI::gotoAddressBookPage() centralWidget->setCurrentWidget(addressBookPage); exportAction->setEnabled(true); - disconnect(exportAction, SIGNAL(triggered()), 0, 0); + disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr); connect(exportAction, SIGNAL(triggered()), addressBookPage, SLOT(exportClicked())); } @@ -1301,7 +1300,7 @@ void BitcoinGUI::gotoReceiveCoinsPage() centralWidget->setCurrentWidget(receiveCoinsPage); exportAction->setEnabled(true); - disconnect(exportAction, SIGNAL(triggered()), 0, 0); + disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr); connect(exportAction, SIGNAL(triggered()), receiveCoinsPage, SLOT(exportClicked())); } @@ -1311,7 +1310,7 @@ void BitcoinGUI::gotoSendCoinsPage() centralWidget->setCurrentWidget(sendCoinsPage); exportAction->setEnabled(false); - disconnect(exportAction, SIGNAL(triggered()), 0, 0); + disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr); } void BitcoinGUI::gotoVotingPage() @@ -1320,7 +1319,7 @@ void BitcoinGUI::gotoVotingPage() centralWidget->setCurrentWidget(votingPage); exportAction->setEnabled(false); - disconnect(exportAction, SIGNAL(triggered()), 0, 0); + disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr); } void BitcoinGUI::gotoSignMessageTab(QString addr) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 3f6d7bddf7..63e1b73e47 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -47,7 +47,7 @@ class BitcoinGUI : public QMainWindow { Q_OBJECT public: - explicit BitcoinGUI(QWidget *parent = 0); + explicit BitcoinGUI(QWidget* parent = nullptr); ~BitcoinGUI(); diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 0b51642b7e..9e81a56b12 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -21,9 +21,8 @@ static const int64_t nClientStartupTime = GetTime(); extern ConvergedScraperStats ConvergedScraperStatsCache; -ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : - QObject(parent), optionsModel(optionsModel), peerTableModel(nullptr), - banTableModel(nullptr), cachedNumBlocks(0), cachedNumBlocksOfPeers(0), pollTimer(0) +ClientModel::ClientModel(OptionsModel* optionsModel, QObject* parent) : QObject(parent), optionsModel(optionsModel), peerTableModel(nullptr), + banTableModel(nullptr), cachedNumBlocks(0), cachedNumBlocksOfPeers(0), pollTimer(nullptr) { numBlocksAtStartup = -1; peerTableModel = new PeerTableModel(this); diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index d088e83efd..35ce2cb6c5 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -22,7 +22,7 @@ class ClientModel : public QObject { Q_OBJECT public: - explicit ClientModel(OptionsModel *optionsModel, QObject *parent = 0); + explicit ClientModel(OptionsModel* optionsModel, QObject* parent = nullptr); ~ClientModel(); OptionsModel *getOptionsModel(); diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 9f3ae29d47..b15a313857 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -26,13 +26,12 @@ using namespace std; -CoinControlDialog::CoinControlDialog(QWidget *parent, CCoinControl *coinControl, QList *payAmounts) : - QDialog(parent), - m_inputSelectionLimit(GetMaxInputsForConsolidationTxn()), - ui(new Ui::CoinControlDialog), - coinControl(coinControl), - payAmounts(payAmounts), - model(0) +CoinControlDialog::CoinControlDialog(QWidget* parent, CCoinControl* coinControl, QList* payAmounts) : QDialog(parent), + m_inputSelectionLimit(GetMaxInputsForConsolidationTxn()), + ui(new Ui::CoinControlDialog), + coinControl(coinControl), + payAmounts(payAmounts), + model(nullptr) { assert(coinControl != nullptr && payAmounts != nullptr); diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h index 820261b822..36c27a0fc5 100644 --- a/src/qt/coincontroldialog.h +++ b/src/qt/coincontroldialog.h @@ -24,9 +24,9 @@ class CoinControlDialog : public QDialog Q_OBJECT public: - explicit CoinControlDialog(QWidget *parent = 0, - CCoinControl *coinControl = nullptr, - QList *payAmounts = nullptr); + explicit CoinControlDialog(QWidget* parent = nullptr, + CCoinControl* coinControl = nullptr, + QList* payAmounts = nullptr); ~CoinControlDialog(); void setModel(WalletModel *model); diff --git a/src/qt/coincontroltreewidget.h b/src/qt/coincontroltreewidget.h index 654bd35c3f..a1118095aa 100644 --- a/src/qt/coincontroltreewidget.h +++ b/src/qt/coincontroltreewidget.h @@ -8,8 +8,8 @@ class CoinControlTreeWidget : public QTreeWidget { Q_OBJECT public: - explicit CoinControlTreeWidget(QWidget *parent = 0); - + explicit CoinControlTreeWidget(QWidget* parent = nullptr); + protected: virtual void keyPressEvent(QKeyEvent *event); }; diff --git a/src/qt/csvmodelwriter.cpp b/src/qt/csvmodelwriter.cpp index 8a50bbab3f..c0acd474ea 100644 --- a/src/qt/csvmodelwriter.cpp +++ b/src/qt/csvmodelwriter.cpp @@ -4,9 +4,8 @@ #include #include -CSVModelWriter::CSVModelWriter(const QString &filename, QObject *parent) : - QObject(parent), - filename(filename), model(0) +CSVModelWriter::CSVModelWriter(const QString& filename, QObject* parent) : QObject(parent), + filename(filename), model(nullptr) { } diff --git a/src/qt/csvmodelwriter.h b/src/qt/csvmodelwriter.h index 6c9dcbaf3b..ae88618e8d 100644 --- a/src/qt/csvmodelwriter.h +++ b/src/qt/csvmodelwriter.h @@ -15,7 +15,7 @@ class CSVModelWriter : public QObject { Q_OBJECT public: - explicit CSVModelWriter(const QString &filename, QObject *parent = 0); + explicit CSVModelWriter(const QString& filename, QObject* parent = nullptr); void setModel(const QAbstractItemModel *model); void addColumn(const QString &title, int column, int role=Qt::EditRole); diff --git a/src/qt/diagnosticsdialog.h b/src/qt/diagnosticsdialog.h index 6641dee198..0a7e16d5e3 100644 --- a/src/qt/diagnosticsdialog.h +++ b/src/qt/diagnosticsdialog.h @@ -25,7 +25,7 @@ class DiagnosticsDialog : public QDialog Q_OBJECT public: - explicit DiagnosticsDialog(QWidget *parent = 0, ResearcherModel* researcher_model = nullptr); + explicit DiagnosticsDialog(QWidget* parent = nullptr, ResearcherModel* researcher_model = nullptr); ~DiagnosticsDialog(); enum DiagnosticResult diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp index d8c7109f59..4d655d2e5a 100644 --- a/src/qt/editaddressdialog.cpp +++ b/src/qt/editaddressdialog.cpp @@ -6,9 +6,8 @@ #include #include -EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) : - QDialog(parent), - ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0) +EditAddressDialog::EditAddressDialog(Mode mode, QWidget* parent) : QDialog(parent), + ui(new Ui::EditAddressDialog), mapper(nullptr), mode(mode), model(nullptr) { ui->setupUi(this); diff --git a/src/qt/editaddressdialog.h b/src/qt/editaddressdialog.h index 0e4183bd52..50be2f59d7 100644 --- a/src/qt/editaddressdialog.h +++ b/src/qt/editaddressdialog.h @@ -26,7 +26,7 @@ class EditAddressDialog : public QDialog EditSendingAddress }; - explicit EditAddressDialog(Mode mode, QWidget *parent = 0); + explicit EditAddressDialog(Mode mode, QWidget* parent = nullptr); ~EditAddressDialog(); void setModel(AddressTableModel *model); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp old mode 100755 new mode 100644 index 4f9f9c176e..42000bfb2d --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -520,19 +520,19 @@ bool SetStartOnSystemStartup(bool fAutoStart, bool fStartMin) if (fAutoStart) { - CoInitialize(NULL); + CoInitialize(nullptr); // Get a pointer to the IShellLink interface. - IShellLinkW* psl = NULL; - HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, - CLSCTX_INPROC_SERVER, IID_IShellLinkW, - reinterpret_cast(&psl)); + IShellLinkW* psl = nullptr; + HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, + CLSCTX_INPROC_SERVER, IID_IShellLinkW, + reinterpret_cast(&psl)); if (SUCCEEDED(hres)) { // Get the current executable path WCHAR pszExePath[MAX_PATH]; - GetModuleFileNameW(NULL, pszExePath, sizeof(pszExePath)); + GetModuleFileNameW(nullptr, pszExePath, sizeof(pszExePath)); std::wstring autostartup_arguments; std::wstring_convert> converter; @@ -566,7 +566,7 @@ bool SetStartOnSystemStartup(bool fAutoStart, bool fStartMin) // Query IShellLink for the IPersistFile interface for // saving the shortcut in persistent storage. - IPersistFile* ppf = NULL; + IPersistFile* ppf = nullptr; hres = psl->QueryInterface(IID_IPersistFile, reinterpret_cast(&ppf)); if (SUCCEEDED(hres)) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 25b2520c53..38c7546042 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -109,7 +109,7 @@ namespace GUIUtil Q_OBJECT public: - explicit ToolTipToRichTextFilter(int size_threshold, QObject *parent = 0); + explicit ToolTipToRichTextFilter(int size_threshold, QObject* parent = nullptr); protected: bool eventFilter(QObject *obj, QEvent *evt); @@ -126,7 +126,7 @@ namespace GUIUtil Q_OBJECT public: - explicit WindowContextHelpButtonHintFilter(QObject *parent = 0); + explicit WindowContextHelpButtonHintFilter(QObject* parent = nullptr); protected: bool eventFilter(QObject *obj, QEvent *evt); @@ -142,7 +142,7 @@ namespace GUIUtil Q_OBJECT public: - HelpMessageBox(QWidget *parent = 0); + HelpMessageBox(QWidget* parent = nullptr); /** Show message box or print help message to standard output, based on operating system. */ void showOrPrint(); diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp index 1c21b882da..209cf1deba 100644 --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -192,7 +192,7 @@ bool Intro::showIfNeeded(bool& did_show_intro) } /* If current default data directory does not exist, let the user choose one */ - Intro intro(0, Params().AssumedBlockchainSize()); + Intro intro(nullptr, Params().AssumedBlockchainSize()); intro.setDataDirectory(dataDir); intro.setWindowIcon(QIcon(":/images/gridcoin")); did_show_intro = true; diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index f66e4b8aef..d2ddcfc8ef 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -14,14 +14,13 @@ #include #include -OptionsDialog::OptionsDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::OptionsDialog), - model(0), - mapper(0), - fRestartWarningDisplayed_Proxy(false), - fRestartWarningDisplayed_Lang(false), - fProxyIpValid(true) +OptionsDialog::OptionsDialog(QWidget* parent) : QDialog(parent), + ui(new Ui::OptionsDialog), + model(nullptr), + mapper(nullptr), + fRestartWarningDisplayed_Proxy(false), + fRestartWarningDisplayed_Lang(false), + fProxyIpValid(true) { ui->setupUi(this); diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 4509795bdd..0beda2c179 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -16,7 +16,7 @@ class OptionsDialog : public QDialog Q_OBJECT public: - explicit OptionsDialog(QWidget *parent = 0); + explicit OptionsDialog(QWidget* parent = nullptr); ~OptionsDialog(); void setModel(OptionsModel *model); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 6d77b0a794..0a6b317fd0 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -15,7 +15,7 @@ class OptionsModel : public QAbstractListModel Q_OBJECT public: - explicit OptionsModel(QObject *parent = 0); + explicit OptionsModel(QObject* parent = nullptr); enum OptionID { StartAtStartup, // bool diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 01c67db5d1..47ef90545a 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -22,7 +22,7 @@ class OverviewPage : public QWidget Q_OBJECT public: - explicit OverviewPage(QWidget *parent = 0); + explicit OverviewPage(QWidget* parent = nullptr); ~OverviewPage(); void setResearcherModel(ResearcherModel *model); diff --git a/src/qt/qrcodedialog.cpp b/src/qt/qrcodedialog.cpp index 722e5a88e7..00de650141 100644 --- a/src/qt/qrcodedialog.cpp +++ b/src/qt/qrcodedialog.cpp @@ -11,11 +11,10 @@ #include -QRCodeDialog::QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent) : - QDialog(parent), - ui(new Ui::QRCodeDialog), - model(0), - address(addr) +QRCodeDialog::QRCodeDialog(const QString& addr, const QString& label, bool enableReq, QWidget* parent) : QDialog(parent), + ui(new Ui::QRCodeDialog), + model(nullptr), + address(addr) { ui->setupUi(this); diff --git a/src/qt/qrcodedialog.h b/src/qt/qrcodedialog.h index b7d11b8184..0b79df1812 100644 --- a/src/qt/qrcodedialog.h +++ b/src/qt/qrcodedialog.h @@ -14,7 +14,7 @@ class QRCodeDialog : public QDialog Q_OBJECT public: - explicit QRCodeDialog(const QString &addr, const QString &label, bool enableReq, QWidget *parent = 0); + explicit QRCodeDialog(const QString& addr, const QString& label, bool enableReq, QWidget* parent = nullptr); ~QRCodeDialog(); void setModel(OptionsModel *model); diff --git a/src/qt/qtipcserver.cpp b/src/qt/qtipcserver.cpp index 140d93d0e0..b1fdea4be8 100644 --- a/src/qt/qtipcserver.cpp +++ b/src/qt/qtipcserver.cpp @@ -83,7 +83,7 @@ static void ipcThread(void* pArg) catch (std::exception& e) { PrintExceptionContinue(&e, "ipcThread()"); } catch (...) { - PrintExceptionContinue(NULL, "ipcThread()"); + PrintExceptionContinue(nullptr, "ipcThread()"); } LogPrintf("ipcThread exited"); } @@ -118,7 +118,7 @@ static void ipcThread2(void* pArg) void ipcInit(int argc, char *argv[]) { - message_queue* mq = NULL; + message_queue* mq = nullptr; char buffer[MAX_URI_LENGTH + 1] = ""; size_t nSize = 0; unsigned int nPriority = 0; diff --git a/src/qt/qvalidatedlineedit.h b/src/qt/qvalidatedlineedit.h index 66e26be9a3..793e56e247 100644 --- a/src/qt/qvalidatedlineedit.h +++ b/src/qt/qvalidatedlineedit.h @@ -10,7 +10,7 @@ class QValidatedLineEdit : public QLineEdit { Q_OBJECT public: - explicit QValidatedLineEdit(QWidget *parent = 0); + explicit QValidatedLineEdit(QWidget* parent = nullptr); void clear(); protected: diff --git a/src/qt/qvaluecombobox.h b/src/qt/qvaluecombobox.h index 1a47bb6565..69f3341328 100644 --- a/src/qt/qvaluecombobox.h +++ b/src/qt/qvaluecombobox.h @@ -10,7 +10,7 @@ class QValueComboBox : public QComboBox Q_OBJECT Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true) public: - explicit QValueComboBox(QWidget *parent = 0); + explicit QValueComboBox(QWidget* parent = nullptr); QVariant value() const; void setValue(const QVariant &value); diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index e41fe22c83..6df3cf7e16 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -44,8 +44,7 @@ const struct { {"cmd-reply", ":/icons/tx_output"}, {"cmd-error", ":/icons/tx_output"}, {"misc", ":/icons/tx_inout"}, - {NULL, NULL} -}; + {nullptr, nullptr}}; /* Object for executing console RPC commands in a separate thread. */ diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 9033ca441c..db2f9ccb2e 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -27,7 +27,7 @@ class RPCConsole: public QDialog Q_OBJECT public: - explicit RPCConsole(QWidget *parent = 0); + explicit RPCConsole(QWidget* parent = nullptr); ~RPCConsole(); void setClientModel(ClientModel *model); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 60862736ec..3b90368ae5 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -24,12 +24,11 @@ #include #include -SendCoinsDialog::SendCoinsDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::SendCoinsDialog), - coinControl(new CCoinControl), - payAmounts(new QList), - model(0) +SendCoinsDialog::SendCoinsDialog(QWidget* parent) : QDialog(parent), + ui(new Ui::SendCoinsDialog), + coinControl(new CCoinControl), + payAmounts(new QList), + model(nullptr) { ui->setupUi(this); @@ -298,7 +297,7 @@ void SendCoinsDialog::updateRemoveEnabled() entry->setMessageEnabled(i == 0); } } - setupTabChain(0); + setupTabChain(nullptr); coinControlUpdateLabels(); } @@ -328,7 +327,7 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) if(!fNewRecipientAllowed) return; - SendCoinsEntry *entry = 0; + SendCoinsEntry* entry = nullptr; // Replace the first entry if it is still unused if(ui->entries->count() == 1) { diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 33903cc5f9..2ed6eb707a 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -21,7 +21,7 @@ class SendCoinsDialog : public QDialog Q_OBJECT public: - explicit SendCoinsDialog(QWidget *parent = 0); + explicit SendCoinsDialog(QWidget* parent = nullptr); ~SendCoinsDialog(); void setModel(WalletModel *model); diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index ddc5fa1198..8c745478c2 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -10,10 +10,9 @@ #include #include -SendCoinsEntry::SendCoinsEntry(QWidget *parent) : - QFrame(parent), - ui(new Ui::SendCoinsEntry), - model(0) +SendCoinsEntry::SendCoinsEntry(QWidget* parent) : QFrame(parent), + ui(new Ui::SendCoinsEntry), + model(nullptr) { ui->setupUi(this); diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index c1592352ef..34713bbdac 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -15,7 +15,7 @@ class SendCoinsEntry : public QFrame Q_OBJECT public: - explicit SendCoinsEntry(QWidget *parent = 0); + explicit SendCoinsEntry(QWidget* parent = nullptr); ~SendCoinsEntry(); void setModel(WalletModel *model); diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp index fb62ed47e7..27521d970f 100644 --- a/src/qt/signverifymessagedialog.cpp +++ b/src/qt/signverifymessagedialog.cpp @@ -16,10 +16,9 @@ #include -SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::SignVerifyMessageDialog), - model(0) +SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget* parent) : QDialog(parent), + ui(new Ui::SignVerifyMessageDialog), + model(nullptr) { ui->setupUi(this); diff --git a/src/qt/signverifymessagedialog.h b/src/qt/signverifymessagedialog.h index 5569c8bf33..dd6b202d2f 100644 --- a/src/qt/signverifymessagedialog.h +++ b/src/qt/signverifymessagedialog.h @@ -16,7 +16,7 @@ class SignVerifyMessageDialog : public QDialog Q_OBJECT public: - explicit SignVerifyMessageDialog(QWidget *parent = 0); + explicit SignVerifyMessageDialog(QWidget* parent = nullptr); ~SignVerifyMessageDialog(); void setModel(WalletModel *model); diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp index 7eda0af46b..1798419e92 100644 --- a/src/qt/trafficgraphwidget.cpp +++ b/src/qt/trafficgraphwidget.cpp @@ -14,16 +14,15 @@ #define XMARGIN 10 #define YMARGIN 10 -TrafficGraphWidget::TrafficGraphWidget(QWidget *parent) : - QWidget(parent), - timer(0), - fMax(0.0f), - nMins(0), - vSamplesIn(), - vSamplesOut(), - nLastBytesIn(0), - nLastBytesOut(0), - clientModel(0) +TrafficGraphWidget::TrafficGraphWidget(QWidget* parent) : QWidget(parent), + timer(nullptr), + fMax(0.0f), + nMins(0), + vSamplesIn(), + vSamplesOut(), + nLastBytesIn(0), + nLastBytesOut(0), + clientModel(nullptr) { timer = new QTimer(this); connect(timer, SIGNAL(timeout()), SLOT(updateRates())); diff --git a/src/qt/trafficgraphwidget.h b/src/qt/trafficgraphwidget.h index e2a6e60f6e..490ffe585a 100644 --- a/src/qt/trafficgraphwidget.h +++ b/src/qt/trafficgraphwidget.h @@ -16,7 +16,7 @@ class TrafficGraphWidget : public QWidget Q_OBJECT public: - explicit TrafficGraphWidget(QWidget *parent = 0); + explicit TrafficGraphWidget(QWidget* parent = nullptr); void setClientModel(ClientModel *model); int getGraphRangeMins() const; diff --git a/src/qt/transactiondescdialog.h b/src/qt/transactiondescdialog.h index e86fb58a64..eea4a6e10f 100644 --- a/src/qt/transactiondescdialog.h +++ b/src/qt/transactiondescdialog.h @@ -16,7 +16,7 @@ class TransactionDescDialog : public QDialog Q_OBJECT public: - explicit TransactionDescDialog(const QModelIndex &idx, QWidget *parent = 0); + explicit TransactionDescDialog(const QModelIndex& idx, QWidget* parent = nullptr); ~TransactionDescDialog(); private: diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h index 429ce1407c..6babb9b782 100644 --- a/src/qt/transactionfilterproxy.h +++ b/src/qt/transactionfilterproxy.h @@ -9,7 +9,7 @@ class TransactionFilterProxy : public QSortFilterProxyModel { Q_OBJECT public: - explicit TransactionFilterProxy(QObject *parent = 0); + explicit TransactionFilterProxy(QObject* parent = nullptr); /** Earliest date that can be represented (far in the past) */ static const QDateTime MIN_DATE; diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 0940bee350..8d4a1df13b 100755 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -353,7 +353,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) // Determine transaction status // Find the block the tx is in - CBlockIndex* pindex = NULL; + CBlockIndex* pindex = nullptr; BlockMap::iterator mi = mapBlockIndex.find(wtx.hashBlock); if (mi != mapBlockIndex.end()) pindex = mi->second; diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index f620afd263..f9688eb21e 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -235,7 +235,7 @@ class TransactionTablePriv } else { - return 0; + return nullptr; } } diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index 2c7d07dee4..e25f767b9a 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -15,7 +15,7 @@ class TransactionTableModel : public QAbstractTableModel { Q_OBJECT public: - explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0); + explicit TransactionTableModel(CWallet* wallet, WalletModel* parent = nullptr); ~TransactionTableModel(); enum ColumnIndex { diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 7f1bead3e4..d4dee755e3 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -23,7 +23,7 @@ class TransactionView : public QFrame { Q_OBJECT public: - explicit TransactionView(QWidget *parent = 0); + explicit TransactionView(QWidget* parent = nullptr); void setModel(WalletModel *model); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 55194749e7..01d55297b9 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -15,13 +15,12 @@ void qtInsertConfirm(double dAmt, std::string sFrom, std::string sTo, std::string txid); -WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) : - QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0), - transactionTableModel(0), - cachedBalance(0), cachedStake(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0), - cachedNumTransactions(0), - cachedEncryptionStatus(Unencrypted), - cachedNumBlocks(0) +WalletModel::WalletModel(CWallet* wallet, OptionsModel* optionsModel, QObject* parent) : QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(nullptr), + transactionTableModel(nullptr), + cachedBalance(0), cachedStake(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0), + cachedNumTransactions(0), + cachedEncryptionStatus(Unencrypted), + cachedNumBlocks(0) { addressTableModel = new AddressTableModel(wallet, this); transactionTableModel = new TransactionTableModel(wallet, this); @@ -497,7 +496,7 @@ void WalletModel::getOutputs(const std::vector& vOutpoints, std::vect void WalletModel::listCoins(std::map >& mapCoins) const { std::vector vCoins; - wallet->AvailableCoins(vCoins,true,NULL,false); + wallet->AvailableCoins(vCoins, true, nullptr, false); LOCK2(cs_main, wallet->cs_wallet); // ListLockedCoins, mapWallet std::vector vLockedCoins; diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 2c2bfaba46..248f8386b0 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -38,7 +38,7 @@ class WalletModel : public QObject Q_OBJECT public: - explicit WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent = 0); + explicit WalletModel(CWallet* wallet, OptionsModel* optionsModel, QObject* parent = nullptr); ~WalletModel(); enum StatusCode // Returned by sendCoins @@ -88,7 +88,7 @@ class WalletModel : public QObject }; // Send coins to a list of recipients - SendCoinsReturn sendCoins(const QList &recipients, const CCoinControl *coinControl=NULL); + SendCoinsReturn sendCoins(const QList& recipients, const CCoinControl* coinControl = nullptr); // Wallet encryption bool setWalletEncrypted(bool encrypted, const SecureString &passphrase); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 40f49bfbdc..c4c2a2d193 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -345,7 +345,7 @@ UniValue showblock(const UniValue& params, bool fHelp) CBlockIndex* pblockindex = RPCBlockFinder.FindByHeight(nHeight); - if (pblockindex==NULL) + if (pblockindex == nullptr) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); CBlock block; block.ReadFromDisk(pblockindex); @@ -2056,8 +2056,7 @@ UniValue getcheckpoint(const UniValue& params, bool fHelp) LOCK(cs_main); const CBlockIndex* pindexCheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex); - if(pindexCheckpoint != NULL) - { + if (pindexCheckpoint != nullptr) { result.pushKV("synccheckpoint", pindexCheckpoint->GetBlockHash().ToString().c_str()); result.pushKV("height", pindexCheckpoint->nHeight); result.pushKV("timestamp", DateTimeStrFormat(pindexCheckpoint->GetBlockTime()).c_str()); diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index 08d0ea6c2d..9b2eee4d2f 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -42,7 +42,7 @@ class MockBlockIndex : CDiskBlockIndex static CBlockIndex* InsertBlockIndex(const uint256& hash) { if (hash.IsNull()) - return NULL; + return nullptr; // Return existing BlockMap::iterator mi = mapBlockIndex.find(hash); diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 82958741f1..1127397f77 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -343,7 +343,7 @@ int CommandLineRPC(int argc, char *argv[]) } catch (...) { - PrintException(NULL, "CommandLineRPC()"); + PrintException(nullptr, "CommandLineRPC()"); } if (strPrint != "") diff --git a/src/rpc/protocol.cpp b/src/rpc/protocol.cpp index 7bad395f58..6ad6b01a41 100644 --- a/src/rpc/protocol.cpp +++ b/src/rpc/protocol.cpp @@ -53,7 +53,7 @@ std::string rfc1123Time() time_t now; time(&now); struct tm* now_gmt = gmtime(&now); - std::string locale(setlocale(LC_TIME, NULL)); + std::string locale(setlocale(LC_TIME, nullptr)); setlocale(LC_TIME, "C"); // we want POSIX (aka "C") weekday/month strings strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S +0000", now_gmt); setlocale(LC_TIME, locale.c_str()); @@ -158,7 +158,7 @@ bool ReadHTTPRequestLine(std::basic_istream& stream, int &proto, proto = 0; const char *ver = strstr(strProto.c_str(), "HTTP/1."); - if (ver != NULL) + if (ver != nullptr) proto = atoi(ver+7); return true; @@ -174,7 +174,7 @@ int ReadHTTPStatus(std::basic_istream& stream, int &proto) return HTTP_INTERNAL_SERVER_ERROR; proto = 0; const char *ver = strstr(str.c_str(), "HTTP/1."); - if (ver != NULL) + if (ver != nullptr) proto = atoi(ver+7); return atoi(vWords[1].c_str()); } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index e659e9adf8..a07293218b 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -36,7 +36,7 @@ std::vector> GetTxStakeBoincHashInfo(const C std::vector> res; // Fetch BlockIndex for tx block - CBlockIndex* pindex = NULL; + CBlockIndex* pindex = nullptr; CBlock block; { BlockMap::iterator mi = mapBlockIndex.find(mtx.hashBlock); @@ -442,7 +442,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) vector vecOutputs; - pwalletMain->AvailableCoins(vecOutputs, false, NULL, false); + pwalletMain->AvailableCoins(vecOutputs, false, nullptr, false); LOCK(pwalletMain->cs_wallet); @@ -576,7 +576,7 @@ UniValue consolidateunspent(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); // Get the current UTXO's. - pwalletMain->AvailableCoins(vecInputs, false, NULL, false); + pwalletMain->AvailableCoins(vecInputs, false, nullptr, false); // Filter outputs in the wallet that are the candidate inputs by matching address and insert into sorted multimap. for (auto const& out : vecInputs) @@ -1761,10 +1761,10 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp) else { // push to local node - if (!AcceptToMemoryPool(mempool, tx, NULL)) + if (!AcceptToMemoryPool(mempool, tx, nullptr)) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX rejected"); - SyncWithWallets(tx, NULL, true); + SyncWithWallets(tx, nullptr, true); } RelayTransaction(tx, hashTx); diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 2963d0fe79..0155e7299a 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -36,9 +36,9 @@ void ThreadRPCServer2(void* parg); static std::string strRPCUserColonPass; // These are created by StartRPCThreads, destroyed in StopRPCThreads -static ioContext* rpc_io_service = NULL; -static ssl::context* rpc_ssl_context = NULL; -static boost::thread_group* rpc_worker_group = NULL; +static ioContext* rpc_io_service = nullptr; +static ssl::context* rpc_ssl_context = nullptr; +static boost::thread_group* rpc_worker_group = nullptr; const UniValue emptyobj(UniValue::VOBJ); @@ -466,7 +466,7 @@ const CRPCCommand *CRPCTable::operator[](string name) const { map::const_iterator it = mapCommands.find(name); if (it == mapCommands.end()) - return NULL; + return nullptr; return it->second; } @@ -606,7 +606,7 @@ void StartRPCThreads() const bool fUseSSL = gArgs.GetBoolArg("-rpcssl"); - assert(rpc_io_service == NULL); + assert(rpc_io_service == nullptr); rpc_io_service = new ioContext(); rpc_ssl_context = new ssl::context(ssl::context::sslv23); @@ -703,15 +703,15 @@ void StopRPCThreads() } rpc_io_service->stop(); - if (rpc_worker_group != NULL) + if (rpc_worker_group != nullptr) rpc_worker_group->join_all(); delete rpc_worker_group; - rpc_worker_group = NULL; + rpc_worker_group = nullptr; delete rpc_ssl_context; - rpc_ssl_context = NULL; + rpc_ssl_context = nullptr; delete rpc_io_service; - rpc_io_service = NULL; + rpc_io_service = nullptr; } class JSONRequest @@ -927,18 +927,18 @@ int main(int argc, char *argv[]) #ifdef _MSC_VER // Turn off Microsoft heap dump noise _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0)); + _CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, 0)); #endif - setbuf(stdin, NULL); - setbuf(stdout, NULL); - setbuf(stderr, NULL); + setbuf(stdin, nullptr); + setbuf(stdout, nullptr); + setbuf(stderr, nullptr); try { if (argc >= 2 && string(argv[1]) == "-server") { LogPrintf("server ready"); - ThreadRPCServer(NULL); + ThreadRPCServer(nullptr); } else { @@ -948,7 +948,7 @@ int main(int argc, char *argv[]) catch (std::exception& e) { PrintException(&e, "main()"); } catch (...) { - PrintException(NULL, "main()"); + PrintException(nullptr, "main()"); } return 0; } diff --git a/src/script.cpp b/src/script.cpp index 5d63cfa3a3..9dd4720f68 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -102,7 +102,7 @@ const char* GetTxnOutputType(txnouttype t) case TX_MULTISIG: return "multisig"; case TX_NULL_DATA: return "nulldata"; } - return NULL; + return nullptr; } @@ -886,7 +886,7 @@ bool EvalScript(vector >& stack, const CScript& script, co break; case OP_DIV: - if (!BN_div(&bn, NULL, &bn1, &bn2, pctx)) + if (!BN_div(&bn, nullptr, &bn1, &bn2, pctx)) return false; break; diff --git a/src/script.h b/src/script.h index ceb22cecae..c566521a21 100644 --- a/src/script.h +++ b/src/script.h @@ -421,7 +421,7 @@ class CScript : public CScriptBase bool GetOp(iterator& pc, opcodetype& opcodeRet) { const_iterator pc2 = pc; - bool fRet = GetOp2(pc2, opcodeRet, NULL); + bool fRet = GetOp2(pc2, opcodeRet, nullptr); pc = begin() + (pc2 - begin()); return fRet; } @@ -433,7 +433,7 @@ class CScript : public CScriptBase bool GetOp(const_iterator& pc, opcodetype& opcodeRet) const { - return GetOp2(pc, opcodeRet, NULL); + return GetOp2(pc, opcodeRet, nullptr); } bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector* pvchRet) const diff --git a/src/sync.h b/src/sync.h index a92ed4f631..9b0efa017d 100644 --- a/src/sync.h +++ b/src/sync.h @@ -396,7 +396,7 @@ class CSemaphoreGrant fHaveGrant = false; } - CSemaphoreGrant() : sem(NULL), fHaveGrant(false) {} + CSemaphoreGrant() : sem(nullptr), fHaveGrant(false) {} explicit CSemaphoreGrant(CSemaphore& sema, bool fTry = false) : sem(&sema), fHaveGrant(false) { diff --git a/src/test/gridcoin/superblock_tests.cpp b/src/test/gridcoin/superblock_tests.cpp index 9aeb755f3f..7438c6e481 100644 --- a/src/test/gridcoin/superblock_tests.cpp +++ b/src/test/gridcoin/superblock_tests.cpp @@ -110,7 +110,7 @@ struct Legacy std::copy_n(binary_cpid.begin(), researcher.cpid.size(), researcher.cpid.begin()); // Ensure we do not blow out the binary space (technically we can handle 0-65535) - double magnitude_d = strtod(ExtractValue(entry, ",", 1).c_str(), NULL); + double magnitude_d = strtod(ExtractValue(entry, ",", 1).c_str(), nullptr); // Changed to 65535 for the new NN. This will still be able to be successfully unpacked by any node. magnitude_d = std::clamp(magnitude_d, 0.0, 65535.0); researcher.magnitude = htobe16(roundint(magnitude_d)); diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index cd832e983b..64e9ec7801 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -12,7 +12,7 @@ using namespace std; BOOST_AUTO_TEST_SUITE(rpc_tests) static UniValue -createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL) +createArgs(int nRequired, const char* address1 = nullptr, const char* address2 = nullptr) { UniValue result(UniValue::VARR); result.push_back(nRequired); diff --git a/src/txdb-leveldb.cpp b/src/txdb-leveldb.cpp index 60922ef797..89e9ca8a9b 100644 --- a/src/txdb-leveldb.cpp +++ b/src/txdb-leveldb.cpp @@ -69,7 +69,7 @@ void init_blockindex(leveldb::Options& options, bool fRemoveOld = false) { CTxDB::CTxDB(const char* pszMode) { assert(pszMode); - activeBatch = NULL; + activeBatch = nullptr; fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w')); if (txdb) { @@ -97,9 +97,9 @@ CTxDB::CTxDB(const char* pszMode) // Leveldb instance destruction delete txdb; - txdb = pdb = NULL; + txdb = pdb = nullptr; delete activeBatch; - activeBatch = NULL; + activeBatch = nullptr; init_blockindex(options, true); // Remove directory and create new database pdb = txdb; @@ -124,13 +124,13 @@ CTxDB::CTxDB(const char* pszMode) void CTxDB::Close() { delete txdb; - txdb = pdb = NULL; + txdb = pdb = nullptr; delete options.filter_policy; - options.filter_policy = NULL; + options.filter_policy = nullptr; delete options.block_cache; - options.block_cache = NULL; + options.block_cache = nullptr; delete activeBatch; - activeBatch = NULL; + activeBatch = nullptr; } bool CTxDB::TxnBegin() @@ -145,7 +145,7 @@ bool CTxDB::TxnCommit() assert(activeBatch); leveldb::Status status = pdb->Write(leveldb::WriteOptions(), activeBatch); delete activeBatch; - activeBatch = NULL; + activeBatch = nullptr; if (!status.ok()) { LogPrintf("LevelDB batch commit failure: %s", status.ToString()); return false; @@ -286,7 +286,7 @@ bool CTxDB::WriteGenericData(const std::string& strKey,const std::string& strDat static CBlockIndex *InsertBlockIndex(const uint256& hash) { if (hash.IsNull()) - return NULL; + return nullptr; // Return existing BlockMap::iterator mi = mapBlockIndex.find(hash); @@ -398,7 +398,7 @@ bool CTxDB::LoadBlockIndex() nBlockCount++; // Watch for genesis block - if (pindexGenesisBlock == NULL && blockHash == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) + if (pindexGenesisBlock == nullptr && blockHash == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) pindexGenesisBlock = pindexNew; if(fQtActive) @@ -431,7 +431,7 @@ bool CTxDB::LoadBlockIndex() // Load hashBestChain pointer to end of best chain if (!ReadHashBestChain(hashBestChain)) { - if (pindexGenesisBlock == NULL) + if (pindexGenesisBlock == nullptr) return true; return error("CTxDB::LoadBlockIndex() : hashBestChain not loaded"); } @@ -451,7 +451,7 @@ bool CTxDB::LoadBlockIndex() int nCheckDepth = gArgs.GetArg( "-checkblocks", 1000); LogPrintf("Verifying last %i blocks at level %i", nCheckDepth, nCheckLevel); - CBlockIndex* pindexFork = NULL; + CBlockIndex* pindexFork = nullptr; map, CBlockIndex*> mapBlockPos; for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev) { diff --git a/src/txdb-leveldb.h b/src/txdb-leveldb.h index d11bb32718..188c72eee5 100644 --- a/src/txdb-leveldb.h +++ b/src/txdb-leveldb.h @@ -42,7 +42,7 @@ class CTxDB leveldb::DB *pdb; // Points to the global instance. // A batch stores up writes and deletes for atomic application. When this - // field is non-NULL, writes/deletes go there instead of directly to disk. + // field is non-nullptr, writes/deletes go there instead of directly to disk. leveldb::WriteBatch *activeBatch; leveldb::Options options; bool fReadOnly; @@ -166,7 +166,7 @@ class CTxDB bool TxnAbort() { delete activeBatch; - activeBatch = NULL; + activeBatch = nullptr; return true; } diff --git a/src/util.cpp b/src/util.cpp index 9987f8743a..5de3d0ae69 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -102,7 +102,7 @@ class CInit // Securely erase the memory used by the PRNG RAND_cleanup(); // Shutdown OpenSSL library multithreading support - CRYPTO_set_locking_callback(NULL); + CRYPTO_set_locking_callback(nullptr); for (int i = 0; i < CRYPTO_num_locks(); i++) delete ppmutexOpenSSL[i]; OPENSSL_free(ppmutexOpenSSL); @@ -134,7 +134,7 @@ void RandAddSeedPerfmon() unsigned char pdata[250000]; memset(pdata, 0, sizeof(pdata)); unsigned long nSize = sizeof(pdata); - long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize); + long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", nullptr, nullptr, pdata, &nSize); RegCloseKey(HKEY_PERFORMANCE_DATA); if (ret == ERROR_SUCCESS) { diff --git a/src/util.h b/src/util.h index 75f775f9e2..5f0a780fd0 100644 --- a/src/util.h +++ b/src/util.h @@ -191,7 +191,7 @@ inline int64_t GetPerformanceCounter() QueryPerformanceCounter((LARGE_INTEGER*)&nCounter); #else timeval t; - gettimeofday(&t, NULL); + gettimeofday(&t, nullptr); nCounter = (int64_t) t.tv_sec * 1000000 + t.tv_usec; #endif return nCounter; diff --git a/src/util/system.cpp b/src/util/system.cpp index bbacfb38f0..6af6aca2cb 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -672,7 +672,7 @@ static std::string FormatException(std::exception* pex, const char* pszThread) { #ifdef WIN32 char pszModule[MAX_PATH] = ""; - GetModuleFileNameA(NULL, pszModule, sizeof(pszModule)); + GetModuleFileNameA(nullptr, pszModule, sizeof(pszModule)); #else const char* pszModule = "gridcoin"; #endif diff --git a/src/util/time.cpp b/src/util/time.cpp index 4664aa7f41..c761efce74 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -24,7 +24,7 @@ int64_t GetTime() { if (nMockTime) return nMockTime; - return time(NULL); + return time(nullptr); } int64_t GetMockTime() diff --git a/src/validation.h b/src/validation.h index 9e84d93bd5..c67565d8e4 100644 --- a/src/validation.h +++ b/src/validation.h @@ -17,7 +17,7 @@ class CBlockHeader; typedef std::map> MapPrevTx; -bool ReadTxFromDisk(CTransaction& tx, CDiskTxPos pos, FILE** pfileRet=NULL); +bool ReadTxFromDisk(CTransaction& tx, CDiskTxPos pos, FILE** pfileRet = nullptr); bool ReadTxFromDisk(CTransaction& tx, CTxDB& txdb, COutPoint prevout, CTxIndex& txindexRet); bool ReadTxFromDisk(CTransaction& tx, CTxDB& txdb, COutPoint prevout); bool ReadTxFromDisk(CTransaction& tx, COutPoint prevout); diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 2eb6a387dc..860e75f40b 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -129,15 +129,15 @@ void CDBEnv::MakeMock() #ifdef DB_LOG_IN_MEMORY dbenv.log_set_config(DB_LOG_IN_MEMORY, 1); #endif - int ret = dbenv.open(NULL, - DB_CREATE | - DB_INIT_LOCK | - DB_INIT_LOG | - DB_INIT_MPOOL | - DB_INIT_TXN | - DB_THREAD | - DB_PRIVATE, - S_IRUSR | S_IWUSR); + int ret = dbenv.open(nullptr, + DB_CREATE | + DB_INIT_LOCK | + DB_INIT_LOG | + DB_INIT_MPOOL | + DB_INIT_TXN | + DB_THREAD | + DB_PRIVATE, + S_IRUSR | S_IWUSR); if (ret > 0) throw runtime_error(strprintf("CDBEnv::MakeMock(): error %d opening database environment", ret)); @@ -151,10 +151,10 @@ CDBEnv::VerifyResult CDBEnv::Verify(std::string strFile, bool (*recoverFunc)(CDB assert(mapFileUseCount.count(strFile) == 0); Db db(&dbenv, 0); - int result = db.verify(strFile.c_str(), NULL, NULL, 0); + int result = db.verify(strFile.c_str(), nullptr, nullptr, 0); if (result == 0) return VERIFY_OK; - else if (recoverFunc == NULL) + else if (recoverFunc == nullptr) return RECOVER_FAIL; // Try to recover: @@ -174,7 +174,7 @@ bool CDBEnv::Salvage(std::string strFile, bool fAggressive, stringstream strDump; Db db(&dbenv, 0); - int result = db.verify(strFile.c_str(), NULL, &strDump, flags); + int result = db.verify(strFile.c_str(), nullptr, &strDump, flags); if (result == DB_VERIFY_BAD) { LogPrintf("Error: Salvage found errors, all data may not be recoverable."); @@ -233,8 +233,7 @@ void CDBEnv::lsn_reset(const std::string& strFile) dbenv.lsn_reset(strFile.c_str(),0); } -CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnCloseIn) : - pdb(NULL), activeTxn(NULL) +CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnCloseIn) : pdb(nullptr), activeTxn(nullptr) { int ret; @@ -256,8 +255,7 @@ CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnClose strFile = strFilename; ++bitdb.mapFileUseCount[strFile]; pdb = bitdb.mapDb[strFile]; - if (pdb == NULL) - { + if (pdb == nullptr) { pdb = new Db(&bitdb.dbenv, 0); bool fMockDb = bitdb.IsMock(); @@ -269,17 +267,17 @@ CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnClose throw runtime_error(strprintf("CDB() : failed to configure for no temp file backing for database %s", strFile)); } - ret = pdb->open(NULL, // Txn pointer - fMockDb ? NULL : strFile.c_str(), // Filename - "main", // Logical db name - DB_BTREE, // Database type - nFlags, // Flags + ret = pdb->open(nullptr, // Txn pointer + fMockDb ? nullptr : strFile.c_str(), // Filename + "main", // Logical db name + DB_BTREE, // Database type + nFlags, // Flags 0); if (ret != 0) { delete pdb; - pdb = NULL; + pdb = nullptr; --bitdb.mapFileUseCount[strFile]; strFile = ""; throw runtime_error(strprintf("CDB() : can't open database file %s, error %d", strFile, ret)); @@ -317,8 +315,8 @@ void CDB::Close() return; if (activeTxn) activeTxn->abort(); - activeTxn = NULL; - pdb = NULL; + activeTxn = nullptr; + pdb = nullptr; if (fFlushOnClose) Flush(); @@ -333,13 +331,12 @@ void CDBEnv::CloseDb(const string& strFile) { { LOCK(cs_db); - if (mapDb[strFile] != NULL) - { + if (mapDb[strFile] != nullptr) { // Close the database handle Db* pdb = mapDb[strFile]; pdb->close(0); delete pdb; - mapDb[strFile] = NULL; + mapDb[strFile] = nullptr; } } } @@ -349,7 +346,7 @@ bool CDBEnv::RemoveDb(const string& strFile) this->CloseDb(strFile); LOCK(cs_db); - int rc = dbenv.dbremove(NULL, strFile.c_str(), NULL, DB_AUTO_COMMIT); + int rc = dbenv.dbremove(nullptr, strFile.c_str(), nullptr, DB_AUTO_COMMIT); return (rc == 0); } @@ -373,11 +370,11 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) CDB db(strFile.c_str(), "r"); Db* pdbCopy = new Db(&bitdb.dbenv, 0); - int ret = pdbCopy->open(NULL, // Txn pointer - strFileRes.c_str(), // Filename - "main", // Logical db name - DB_BTREE, // Database type - DB_CREATE, // Flags + int ret = pdbCopy->open(nullptr, // Txn pointer + strFileRes.c_str(), // Filename + "main", // Logical db name + DB_BTREE, // Database type + DB_CREATE, // Flags 0); if (ret > 0) { @@ -414,7 +411,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) } Dbt datKey(&ssKey[0], ssKey.size()); Dbt datValue(&ssValue[0], ssValue.size()); - int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE); + int ret2 = pdbCopy->put(nullptr, &datKey, &datValue, DB_NOOVERWRITE); if (ret2 > 0) fSuccess = false; } @@ -430,10 +427,10 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) if (fSuccess) { Db dbA(&bitdb.dbenv, 0); - if (dbA.remove(strFile.c_str(), NULL, 0)) + if (dbA.remove(strFile.c_str(), nullptr, 0)) fSuccess = false; Db dbB(&bitdb.dbenv, 0); - if (dbB.rename(strFileRes.c_str(), NULL, strFile.c_str(), 0)) + if (dbB.rename(strFileRes.c_str(), nullptr, strFile.c_str(), 0)) fSuccess = false; } if (!fSuccess) diff --git a/src/wallet/db.h b/src/wallet/db.h index bdaff79c05..6f519337b9 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -80,10 +80,10 @@ class CDBEnv DbTxn *TxnBegin(int flags=DB_TXN_WRITE_NOSYNC) { - DbTxn* ptxn = NULL; - int ret = dbenv.txn_begin(NULL, &ptxn, flags); + DbTxn* ptxn = nullptr; + int ret = dbenv.txn_begin(nullptr, &ptxn, flags); if (!ptxn || ret != 0) - return NULL; + return nullptr; return ptxn; } }; @@ -128,7 +128,7 @@ class CDB datValue.set_flags(DB_DBT_MALLOC); int ret = pdb->get(activeTxn, &datKey, &datValue, 0); memset(datKey.get_data(), 0, datKey.get_size()); - if (datValue.get_data() == NULL) + if (datValue.get_data() == nullptr) return false; // Unserialize value @@ -220,11 +220,11 @@ class CDB Dbc* GetCursor() { if (!pdb) - return NULL; - Dbc* pcursor = NULL; - int ret = pdb->cursor(NULL, &pcursor, 0); + return nullptr; + Dbc* pcursor = nullptr; + int ret = pdb->cursor(nullptr, &pcursor, 0); if (ret != 0) - return NULL; + return nullptr; return pcursor; } @@ -248,7 +248,7 @@ class CDB int ret = pcursor->get(&datKey, &datValue, fFlags); if (ret != 0) return ret; - else if (datKey.get_data() == NULL || datValue.get_data() == NULL) + else if (datKey.get_data() == nullptr || datValue.get_data() == nullptr) return 99999; // Convert to streams @@ -284,7 +284,7 @@ class CDB if (!pdb || !activeTxn) return false; int ret = activeTxn->commit(0); - activeTxn = NULL; + activeTxn = nullptr; return (ret == 0); } @@ -293,7 +293,7 @@ class CDB if (!pdb || !activeTxn) return false; int ret = activeTxn->abort(); - activeTxn = NULL; + activeTxn = nullptr; return (ret == 0); } @@ -308,7 +308,7 @@ class CDB return Write(std::string("version"), nVersion); } - bool static Rewrite(const std::string& strFile, const char* pszSkip = NULL); + bool static Rewrite(const std::string& strFile, const char* pszSkip = nullptr); }; #endif // BITCOIN_DB_H diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 507559615e..c15575510c 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -88,9 +88,9 @@ class CTxDump bool fSpent; CWalletTx* ptx; int nOut; - CTxDump(CWalletTx* ptx = NULL, int nOut = -1) + CTxDump(CWalletTx* ptx = nullptr, int nOut = -1) { - pindex = NULL; + pindex = nullptr; nValue = 0; fSpent = false; this->ptx = ptx; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 651abffd88..380ab13adb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1626,10 +1626,10 @@ UniValue listtransactions(const UniValue& params, bool fHelp) for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { CWalletTx* const pwtx = it->second.first; - if (pwtx != 0) + if (pwtx != nullptr) ListTransactions(*pwtx, strAccount, 0, true, ret, filter); CAccountingEntry* const pacentry = it->second.second; - if (pacentry != 0) + if (pacentry != nullptr) AcentryToJSON(*pacentry, strAccount, ret); if ((int)ret.size() >= (nCount+nFrom)) break; @@ -1693,10 +1693,10 @@ UniValue liststakes(const UniValue& params, bool fHelp) for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { CWalletTx *const pwtx = it->second.first; - if (pwtx != 0) + if (pwtx != nullptr) ListTransactions(*pwtx, strAccount, 0, true, ret_superset, filter, true); CAccountingEntry *const pacentry = it->second.second; - if (pacentry != 0) + if (pacentry != nullptr) AcentryToJSON(*pacentry, strAccount, ret_superset); if ((int)ret_superset.size() >= nCount) break; @@ -1799,7 +1799,7 @@ UniValue listsinceblock(const UniValue& params, bool fHelp) LOCK2(cs_main, pwalletMain->cs_wallet); - CBlockIndex *pindex = NULL; + CBlockIndex* pindex = nullptr; int target_confirms = 1; isminefilter filter = ISMINE_SPENDABLE; if (params.size() > 0) @@ -2181,7 +2181,7 @@ UniValue walletpassphrase(const UniValue& params, bool fHelp) "walletpassphrase \n" "Stores the wallet decryption key in memory for seconds."); - NewThread(ThreadTopUpKeyPool, NULL); + NewThread(ThreadTopUpKeyPool, nullptr); int64_t* pnSleepTime = new int64_t(nSleepTime); NewThread(ThreadCleanWalletPassphrase, pnSleepTime); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 54d3b19493..0a1def3df1 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -364,7 +364,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) exit(1); //We now have keys encrypted in memory, but no on disk...die to avoid confusion and let the user reload their unencrypted wallet. delete pwalletdbEncryption; - pwalletdbEncryption = NULL; + pwalletdbEncryption = nullptr; } Lock(); @@ -407,13 +407,13 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, for (map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { CWalletTx* wtx = &(it->second); - txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); + txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, nullptr))); } acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); for (auto &entry : acentries) { - txOrdered.insert(make_pair(entry.nOrderPos, TxPair((CWalletTx*)0, &entry))); + txOrdered.insert(make_pair(entry.nOrderPos, TxPair(nullptr, &entry))); } return txOrdered; @@ -1490,7 +1490,7 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, // List of values less than target pair > coinLowestLarger; coinLowestLarger.first = std::numeric_limits::max(); - coinLowestLarger.second.first = NULL; + coinLowestLarger.second.first = nullptr; vector > > vValue; int64_t nTotalLower = 0; @@ -1543,7 +1543,7 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, if (nTotalLower < nTargetValue) { - if (coinLowestLarger.second.first == NULL) + if (coinLowestLarger.second.first == nullptr) return false; setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; @@ -2073,7 +2073,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) // This is only to keep the database open to defeat the auto-flush for the // duration of this scope. This is the only place where this optimization // maybe makes sense; please don't do it anywhere else. - CWalletDB* pwalletdb = fFileBacked ? new CWalletDB(strWalletFile,"r+") : NULL; + CWalletDB* pwalletdb = fFileBacked ? new CWalletDB(strWalletFile, "r+") : nullptr; // Take key pair from key pool so it won't be used again reservekey.KeepKey(); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 881ecba0cb..30dd197a03 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -81,7 +81,7 @@ class CKeyPool class CWallet : public CCryptoKeyStore { private: - bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL, bool contract = false) const; + bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set>& setCoinsRet, int64_t& nValueRet, const CCoinControl* coinControl = nullptr, bool contract = false) const; CWalletDB *pwalletdbEncryption; @@ -171,7 +171,7 @@ class CWallet : public CCryptoKeyStore nWalletMaxVersion = FEATURE_BASE; fFileBacked = false; nMasterKeyMaxID = 0; - pwalletdbEncryption = NULL; + pwalletdbEncryption = nullptr; nOrderPosNext = 0; nTimeFirstKey = 0; } @@ -191,7 +191,7 @@ class CWallet : public CCryptoKeyStore void AvailableCoinsForStaking(std::vector& vCoins, unsigned int nSpendTime, int64_t& nBalanceOut) const; bool SelectCoinsForStaking(unsigned int nSpendTime, std::vector >& vCoinsRet, GRC::MinerStatus::ReasonNotStakingCategory& not_staking_error, int64_t& balance_out, bool fMiner = false) const; - void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL, bool fIncludeStakingCoins=false) const; + void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed = true, const CCoinControl* coinControl = nullptr, bool fIncludeStakingCoins = false) const; bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; bool SelectSmallestCoins(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; @@ -224,7 +224,7 @@ class CWallet : public CCryptoKeyStore /** Increment the next transaction order id @return next transaction order id */ - int64_t IncOrderPosNext(CWalletDB *pwalletdb = NULL); + int64_t IncOrderPosNext(CWalletDB* pwalletdb = nullptr); typedef std::pair TxPair; typedef std::multimap TxItems; @@ -248,9 +248,9 @@ class CWallet : public CCryptoKeyStore int64_t GetImmatureBalance() const; int64_t GetStake() const; int64_t GetNewMint() const; - bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl *coinControl=NULL); - bool CreateTransaction(const std::vector >& vecSend, std::set>& setCoins, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl *coinControl=NULL); - bool CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl *coinControl=NULL); + bool CreateTransaction(const std::vector>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl = nullptr); + bool CreateTransaction(const std::vector>& vecSend, std::set>& setCoins, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl = nullptr); + bool CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl = nullptr); bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false); @@ -370,7 +370,7 @@ class CWallet : public CCryptoKeyStore bool SetDefaultKey(const CPubKey &vchPubKey); // signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower - bool SetMinVersion(enum WalletFeature, CWalletDB* pwalletdbIn = NULL, bool fExplicit = false); + bool SetMinVersion(enum WalletFeature, CWalletDB* pwalletdbIn = nullptr, bool fExplicit = false); // change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format) bool SetMaxVersion(int nVersion); @@ -497,7 +497,7 @@ class CWalletTx : public CMerkleTx CWalletTx() { - Init(NULL); + Init(nullptr); } CWalletTx(const CWallet* pwalletIn) @@ -550,7 +550,7 @@ class CWalletTx : public CMerkleTx char fSpent = false; if (ser_action.ForRead()) { - Init(NULL); + Init(nullptr); } else { mapValue["fromaccount"] = strFromAccount; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 79191b4c97..de40058a14 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -138,13 +138,13 @@ CWalletDB::ReorderTransactions(CWallet* pwallet) for (map::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it) { CWalletTx* wtx = &(it->second); - txByTime.insert(make_pair(wtx->nTimeReceived, TxPair(wtx, (CAccountingEntry*)0))); + txByTime.insert(make_pair(wtx->nTimeReceived, TxPair(wtx, nullptr))); } list acentries; ListAccountCreditDebit("", acentries); for (auto &entry : acentries) { - txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); + txByTime.insert(make_pair(entry.nTime, TxPair(nullptr, &entry))); } int64_t& nOrderPosNext = pwallet->nOrderPosNext; @@ -154,7 +154,7 @@ CWalletDB::ReorderTransactions(CWallet* pwallet) { CWalletTx* const pwtx = it->second.first; CAccountingEntry* const pacentry = it->second.second; - int64_t& nOrderPos = (pwtx != 0) ? pwtx->nOrderPos : pacentry->nOrderPos; + int64_t& nOrderPos = (pwtx != nullptr) ? pwtx->nOrderPos : pacentry->nOrderPos; if (nOrderPos == -1) { @@ -702,7 +702,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys) int64_t now = GetTime(); std::string newFilename = strprintf("wallet.%" PRId64 ".bak", now); - int result = dbenv.dbenv.dbrename(NULL, filename.c_str(), NULL, + int result = dbenv.dbenv.dbrename(nullptr, filename.c_str(), nullptr, newFilename.c_str(), DB_AUTO_COMMIT); if (result == 0) LogPrintf("Renamed %s to %s", filename, newFilename); @@ -724,11 +724,11 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys) bool fSuccess = allOK; //Db* pdbCopy = new Db(&dbenv.dbenv, 0); boost::scoped_ptr pdbCopy(new Db(&dbenv.dbenv, 0)); - int ret = pdbCopy->open(NULL, // Txn pointer - filename.c_str(), // Filename - "main", // Logical db name - DB_BTREE, // Database type - DB_CREATE, // Flags + int ret = pdbCopy->open(nullptr, // Txn pointer + filename.c_str(), // Filename + "main", // Logical db name + DB_BTREE, // Database type + DB_CREATE, // Flags 0); if (ret > 0) { From c46e7fa08b5128add6b04f75dc46ac6977502daa Mon Sep 17 00:00:00 2001 From: div72 <60045611+div72@users.noreply.github.com> Date: Fri, 18 Jun 2021 00:17:42 +0300 Subject: [PATCH 4/4] Fix formatting --- src/miner.cpp | 5 -- src/net.cpp | 30 ++++++---- src/primitives/transaction.h | 6 +- src/qt/addressbookpage.cpp | 13 +++-- src/qt/addresstablemodel.cpp | 6 +- src/qt/askpassphrasedialog.cpp | 11 ++-- src/qt/bitcoingui.cpp | 23 ++++---- src/qt/clientmodel.cpp | 10 +++- src/qt/coincontroldialog.cpp | 13 +++-- src/qt/csvmodelwriter.cpp | 6 +- src/qt/editaddressdialog.cpp | 8 ++- src/qt/optionsdialog.cpp | 15 ++--- src/qt/qrcodedialog.cpp | 9 +-- src/qt/sendcoinsdialog.cpp | 11 ++-- src/qt/sendcoinsentry.cpp | 7 ++- src/qt/signverifymessagedialog.cpp | 7 ++- src/qt/trafficgraphwidget.cpp | 19 ++++--- src/qt/walletmodel.cpp | 19 +++++-- src/qt/walletmodel.h | 6 +- src/rpc/server.cpp | 10 ++-- src/test/getarg_tests.cpp | 3 +- src/test/gridcoin/cpid_tests.cpp | 22 ++------ src/wallet/db.h | 14 +++-- src/wallet/rpcwallet.cpp | 71 ++++++++++++++---------- src/wallet/wallet.cpp | 88 +++++++++++++++++------------- src/wallet/wallet.h | 22 +++++--- 26 files changed, 257 insertions(+), 197 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1685c43641..dddad22330 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -345,11 +345,6 @@ bool CreateRestOfTheBlock(CBlock &block, CBlockIndex* pindexPrev) { LogPrintf("ERROR: mempool transaction missing input"); - if (LogInstance().WillLogCategory(BCLog::LogFlags::VERBOSE)) - { - assert("mempool transaction missing input" == nullptr); - } - fMissingInputs = true; if (porphan) vOrphan.pop_back(); diff --git a/src/net.cpp b/src/net.cpp index e08562659c..ebffbcce99 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2003,41 +2003,47 @@ void StartNode(void* parg) // Start threads // - if (!gArgs.GetBoolArg("-dnsseed", true)) + if (!gArgs.GetBoolArg("-dnsseed", true)) { LogPrintf("DNS seeding disabled"); - else if (!netThreads->createThread(ThreadDNSAddressSeed, nullptr, "ThreadDNSAddressSeed")) + } else if (!netThreads->createThread(ThreadDNSAddressSeed, nullptr, "ThreadDNSAddressSeed")) { LogPrintf("Error: createThread(ThreadDNSAddressSeed) failed"); - + } // Map ports with UPnP - if (fUseUPnP) + if (fUseUPnP) { MapPort(); + } // Send and receive from sockets, accept connections - if (!netThreads->createThread(ThreadSocketHandler, nullptr, "ThreadSocketHandler")) + if (!netThreads->createThread(ThreadSocketHandler, nullptr, "ThreadSocketHandler")) { LogPrintf("Error: createThread(ThreadSocketHandler) failed"); + } // Initiate outbound connections from -addnode - if (!netThreads->createThread(ThreadOpenAddedConnections, nullptr, "ThreadOpenAddedConnections")) + if (!netThreads->createThread(ThreadOpenAddedConnections, nullptr, "ThreadOpenAddedConnections")) { LogPrintf("Error: createThread(ThreadOpenAddedConnections) failed"); + } // Initiate outbound connections - if (!netThreads->createThread(ThreadOpenConnections, nullptr, "ThreadOpenConnections")) + if (!netThreads->createThread(ThreadOpenConnections, nullptr, "ThreadOpenConnections")) { LogPrintf("Error: createThread(ThreadOpenConnections) failed"); + } // Process messages - if (!netThreads->createThread(ThreadMessageHandler, nullptr, "ThreadMessageHandler")) + if (!netThreads->createThread(ThreadMessageHandler, nullptr, "ThreadMessageHandler")) { LogPrintf("Error: createThread(ThreadMessageHandler) failed"); + } // Dump network addresses - if (!netThreads->createThread(ThreadDumpAddress, nullptr, "ThreadDumpAddress")) + if (!netThreads->createThread(ThreadDumpAddress, nullptr, "ThreadDumpAddress")) { LogPrintf("Error: createThread(ThreadDumpAddress) failed"); + } // Mine proof-of-stake blocks in the background - if (!gArgs.GetBoolArg("-staking", true)) + if (!gArgs.GetBoolArg("-staking", true)) { LogPrintf("Staking disabled"); - else - if (!netThreads->createThread(ThreadStakeMiner,pwalletMain,"ThreadStakeMiner")) + } else if (!netThreads->createThread(ThreadStakeMiner,pwalletMain,"ThreadStakeMiner")) { LogPrintf("Error: createThread(ThreadStakeMiner) failed"); + } } bool StopNode() diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 592760e72d..3ac7336134 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -20,11 +20,7 @@ class CInPoint CInPoint() { SetNull(); } CInPoint(CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; } - void SetNull() - { - ptx = nullptr; - n = (unsigned int)-1; - } + void SetNull() { ptx = nullptr; n = (unsigned int)-1; } bool IsNull() const { return (ptx == nullptr && n == (unsigned int)-1); } }; diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 118dc23c79..12769fd8bd 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -17,12 +17,13 @@ #include "qrcodedialog.h" #endif -AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget* parent) : QDialog(parent), - ui(new Ui::AddressBookPage), - model(nullptr), - optionsModel(nullptr), - mode(mode), - tab(tab) +AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget* parent) + : QDialog(parent) + , ui(new Ui::AddressBookPage) + , model(nullptr) + , optionsModel(nullptr) + , mode(mode) + , tab(tab) { ui->setupUi(this); diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index 7f02c614df..faecf34e68 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -139,7 +139,11 @@ class AddressTablePriv } }; -AddressTableModel::AddressTableModel(CWallet* wallet, WalletModel* parent) : QAbstractTableModel(parent), walletModel(parent), wallet(wallet), priv(nullptr) +AddressTableModel::AddressTableModel(CWallet* wallet, WalletModel* parent) + : QAbstractTableModel(parent) + , walletModel(parent) + , wallet(wallet) + , priv(nullptr) { columns << tr("Label") << tr("Address"); priv = new AddressTablePriv(wallet, this); diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index ea8d9bbb83..8a972570da 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -10,11 +10,12 @@ extern bool fWalletUnlockStakingOnly; -AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent) : QDialog(parent), - ui(new Ui::AskPassphraseDialog), - mode(mode), - model(nullptr), - fCapsLock(false) +AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent) + : QDialog(parent) + , ui(new Ui::AskPassphraseDialog) + , mode(mode) + , model(nullptr) + , fCapsLock(false) { ui->setupUi(this); ui->oldPassphraseEdit->setMaxLength(MAX_PASSPHRASE_SIZE); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index bed6b0b53d..71e6b7d4b8 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -94,17 +94,18 @@ extern CWallet* pwalletMain; extern std::string FromQString(QString qs); extern CCriticalSection cs_ConvergedScraperStatsCache; -BitcoinGUI::BitcoinGUI(QWidget* parent) : QMainWindow(parent), - clientModel(nullptr), - walletModel(nullptr), - encryptWalletAction(nullptr), - changePassphraseAction(nullptr), - unlockWalletAction(nullptr), - lockWalletAction(nullptr), - trayIcon(nullptr), - notificator(nullptr), - rpcConsole(nullptr), - nWeight(0) +BitcoinGUI::BitcoinGUI(QWidget* parent) + : QMainWindow(parent) + , clientModel(nullptr) + , walletModel(nullptr) + , encryptWalletAction(nullptr) + , changePassphraseAction(nullptr) + , unlockWalletAction(nullptr) + , lockWalletAction(nullptr) + , trayIcon(nullptr) + , notificator(nullptr) + , rpcConsole(nullptr) + , nWeight(0) { QSettings settings; if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) { diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 9e81a56b12..058c04e93f 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -21,8 +21,14 @@ static const int64_t nClientStartupTime = GetTime(); extern ConvergedScraperStats ConvergedScraperStatsCache; -ClientModel::ClientModel(OptionsModel* optionsModel, QObject* parent) : QObject(parent), optionsModel(optionsModel), peerTableModel(nullptr), - banTableModel(nullptr), cachedNumBlocks(0), cachedNumBlocksOfPeers(0), pollTimer(nullptr) +ClientModel::ClientModel(OptionsModel* optionsModel, QObject* parent) + : QObject(parent) + , optionsModel(optionsModel) + , peerTableModel(nullptr) + , banTableModel(nullptr) + , cachedNumBlocks(0) + , cachedNumBlocksOfPeers(0) + , pollTimer(nullptr) { numBlocksAtStartup = -1; peerTableModel = new PeerTableModel(this); diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index b15a313857..5bf7711b75 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -26,12 +26,13 @@ using namespace std; -CoinControlDialog::CoinControlDialog(QWidget* parent, CCoinControl* coinControl, QList* payAmounts) : QDialog(parent), - m_inputSelectionLimit(GetMaxInputsForConsolidationTxn()), - ui(new Ui::CoinControlDialog), - coinControl(coinControl), - payAmounts(payAmounts), - model(nullptr) +CoinControlDialog::CoinControlDialog(QWidget* parent, CCoinControl* coinControl, QList* payAmounts) + : QDialog(parent) + , m_inputSelectionLimit(GetMaxInputsForConsolidationTxn()) + , ui(new Ui::CoinControlDialog) + , coinControl(coinControl) + , payAmounts(payAmounts) + , model(nullptr) { assert(coinControl != nullptr && payAmounts != nullptr); diff --git a/src/qt/csvmodelwriter.cpp b/src/qt/csvmodelwriter.cpp index c0acd474ea..04cc9f0464 100644 --- a/src/qt/csvmodelwriter.cpp +++ b/src/qt/csvmodelwriter.cpp @@ -4,8 +4,10 @@ #include #include -CSVModelWriter::CSVModelWriter(const QString& filename, QObject* parent) : QObject(parent), - filename(filename), model(nullptr) +CSVModelWriter::CSVModelWriter(const QString& filename, QObject* parent) + : QObject(parent) + , filename(filename) + , model(nullptr) { } diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp index 4d655d2e5a..6c8d9278b6 100644 --- a/src/qt/editaddressdialog.cpp +++ b/src/qt/editaddressdialog.cpp @@ -6,8 +6,12 @@ #include #include -EditAddressDialog::EditAddressDialog(Mode mode, QWidget* parent) : QDialog(parent), - ui(new Ui::EditAddressDialog), mapper(nullptr), mode(mode), model(nullptr) +EditAddressDialog::EditAddressDialog(Mode mode, QWidget* parent) + : QDialog(parent) + , ui(new Ui::EditAddressDialog) + , mapper(nullptr) + , mode(mode) + , model(nullptr) { ui->setupUi(this); diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index d2ddcfc8ef..42ed831c28 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -14,13 +14,14 @@ #include #include -OptionsDialog::OptionsDialog(QWidget* parent) : QDialog(parent), - ui(new Ui::OptionsDialog), - model(nullptr), - mapper(nullptr), - fRestartWarningDisplayed_Proxy(false), - fRestartWarningDisplayed_Lang(false), - fProxyIpValid(true) +OptionsDialog::OptionsDialog(QWidget* parent) + : QDialog(parent) + , ui(new Ui::OptionsDialog) + , model(nullptr) + , mapper(nullptr) + , fRestartWarningDisplayed_Proxy(false) + , fRestartWarningDisplayed_Lang(false) + , fProxyIpValid(true) { ui->setupUi(this); diff --git a/src/qt/qrcodedialog.cpp b/src/qt/qrcodedialog.cpp index 00de650141..2982a982c3 100644 --- a/src/qt/qrcodedialog.cpp +++ b/src/qt/qrcodedialog.cpp @@ -11,10 +11,11 @@ #include -QRCodeDialog::QRCodeDialog(const QString& addr, const QString& label, bool enableReq, QWidget* parent) : QDialog(parent), - ui(new Ui::QRCodeDialog), - model(nullptr), - address(addr) +QRCodeDialog::QRCodeDialog(const QString& addr, const QString& label, bool enableReq, QWidget* parent) + : QDialog(parent) + , ui(new Ui::QRCodeDialog) + , model(nullptr) + , address(addr) { ui->setupUi(this); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 3b90368ae5..2ec584f34c 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -24,11 +24,12 @@ #include #include -SendCoinsDialog::SendCoinsDialog(QWidget* parent) : QDialog(parent), - ui(new Ui::SendCoinsDialog), - coinControl(new CCoinControl), - payAmounts(new QList), - model(nullptr) +SendCoinsDialog::SendCoinsDialog(QWidget* parent) + : QDialog(parent) + , ui(new Ui::SendCoinsDialog) + , coinControl(new CCoinControl) + , payAmounts(new QList) + , model(nullptr) { ui->setupUi(this); diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 8c745478c2..b947958a94 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -10,9 +10,10 @@ #include #include -SendCoinsEntry::SendCoinsEntry(QWidget* parent) : QFrame(parent), - ui(new Ui::SendCoinsEntry), - model(nullptr) +SendCoinsEntry::SendCoinsEntry(QWidget* parent) + : QFrame(parent) + , ui(new Ui::SendCoinsEntry) + , model(nullptr) { ui->setupUi(this); diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp index 27521d970f..c7a6097429 100644 --- a/src/qt/signverifymessagedialog.cpp +++ b/src/qt/signverifymessagedialog.cpp @@ -16,9 +16,10 @@ #include -SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget* parent) : QDialog(parent), - ui(new Ui::SignVerifyMessageDialog), - model(nullptr) +SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget* parent) + : QDialog(parent) + , ui(new Ui::SignVerifyMessageDialog) + , model(nullptr) { ui->setupUi(this); diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp index 1798419e92..b6c3e0be06 100644 --- a/src/qt/trafficgraphwidget.cpp +++ b/src/qt/trafficgraphwidget.cpp @@ -14,15 +14,16 @@ #define XMARGIN 10 #define YMARGIN 10 -TrafficGraphWidget::TrafficGraphWidget(QWidget* parent) : QWidget(parent), - timer(nullptr), - fMax(0.0f), - nMins(0), - vSamplesIn(), - vSamplesOut(), - nLastBytesIn(0), - nLastBytesOut(0), - clientModel(nullptr) +TrafficGraphWidget::TrafficGraphWidget(QWidget* parent) + : QWidget(parent) + , timer(nullptr) + , fMax(0.0f) + , nMins(0) + , vSamplesIn() + , vSamplesOut() + , nLastBytesIn(0) + , nLastBytesOut(0) + , clientModel(nullptr) { timer = new QTimer(this); connect(timer, SIGNAL(timeout()), SLOT(updateRates())); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 01d55297b9..d6ddc30a84 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -15,12 +15,19 @@ void qtInsertConfirm(double dAmt, std::string sFrom, std::string sTo, std::string txid); -WalletModel::WalletModel(CWallet* wallet, OptionsModel* optionsModel, QObject* parent) : QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(nullptr), - transactionTableModel(nullptr), - cachedBalance(0), cachedStake(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0), - cachedNumTransactions(0), - cachedEncryptionStatus(Unencrypted), - cachedNumBlocks(0) +WalletModel::WalletModel(CWallet* wallet, OptionsModel* optionsModel, QObject* parent) + : QObject(parent) + , wallet(wallet) + , optionsModel(optionsModel) + , addressTableModel(nullptr) + , transactionTableModel(nullptr) + , cachedBalance(0) + , cachedStake(0) + , cachedUnconfirmedBalance(0) + , cachedImmatureBalance(0) + , cachedNumTransactions(0) + , cachedEncryptionStatus(Unencrypted) + , cachedNumBlocks(0) { addressTableModel = new AddressTableModel(wallet, this); transactionTableModel = new TransactionTableModel(wallet, this); diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 248f8386b0..03be37d084 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -91,10 +91,10 @@ class WalletModel : public QObject SendCoinsReturn sendCoins(const QList& recipients, const CCoinControl* coinControl = nullptr); // Wallet encryption - bool setWalletEncrypted(bool encrypted, const SecureString &passphrase); + bool setWalletEncrypted(bool encrypted, const SecureString& passphrase); // Passphrase only needed when unlocking - bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString()); - bool changePassphrase(const SecureString &oldPass, const SecureString &newPass); + bool setWalletLocked(bool locked, const SecureString& passPhrase=SecureString()); + bool changePassphrase(const SecureString& oldPass, const SecureString& newPass); // RAI object for unlocking wallet, returned by requestUnlock() class UnlockContext diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 0155e7299a..0539d7ef43 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -462,11 +462,12 @@ CRPCTable::CRPCTable() } } -const CRPCCommand *CRPCTable::operator[](string name) const +const CRPCCommand* CRPCTable::operator[](string name) const { - map::const_iterator it = mapCommands.find(name); - if (it == mapCommands.end()) + auto it = mapCommands.find(name); + if (it == mapCommands.end()) { return nullptr; + } return it->second; } @@ -703,8 +704,9 @@ void StopRPCThreads() } rpc_io_service->stop(); - if (rpc_worker_group != nullptr) + if (rpc_worker_group != nullptr) { rpc_worker_group->join_all(); + } delete rpc_worker_group; rpc_worker_group = nullptr; diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp index 30fdcfd16c..bcf7ccd636 100644 --- a/src/test/getarg_tests.cpp +++ b/src/test/getarg_tests.cpp @@ -32,8 +32,9 @@ static bool ResetArgs(const std::string& strAddArg, const std::string& strArgIn // Convert to char*: std::vector vecChar; - for (std::string& s : vecArg) + for (std::string& s : vecArg) { vecChar.push_back(s.c_str()); + } std::string error; diff --git a/src/test/gridcoin/cpid_tests.cpp b/src/test/gridcoin/cpid_tests.cpp index ceaac8fb02..4116a74b40 100644 --- a/src/test/gridcoin/cpid_tests.cpp +++ b/src/test/gridcoin/cpid_tests.cpp @@ -318,24 +318,10 @@ BOOST_AUTO_TEST_CASE(it_parses_a_cpid_mining_id) if (const GRC::CpidOption cpid = mining_id.TryCpid()) { BOOST_CHECK(*cpid == expected); - BOOST_CHECK(cpid->Raw() == (std::array{ - 0x00, - 0x01, - 0x02, - 0x03, - 0x04, - 0x05, - 0x06, - 0x07, - 0x08, - 0x09, - 0x10, - 0x11, - 0x12, - 0x13, - 0x14, - 0x15, - })); + BOOST_CHECK(cpid->Raw() == (std::array { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, + })); } else { BOOST_FAIL("MiningId variant does not contain the CPID."); } diff --git a/src/wallet/db.h b/src/wallet/db.h index 6f519337b9..51a60bc5e8 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -128,8 +128,9 @@ class CDB datValue.set_flags(DB_DBT_MALLOC); int ret = pdb->get(activeTxn, &datKey, &datValue, 0); memset(datKey.get_data(), 0, datKey.get_size()); - if (datValue.get_data() == nullptr) + if (datValue.get_data() == nullptr) { return false; + } // Unserialize value try { @@ -219,12 +220,14 @@ class CDB Dbc* GetCursor() { - if (!pdb) + if (!pdb) { return nullptr; + } Dbc* pcursor = nullptr; int ret = pdb->cursor(nullptr, &pcursor, 0); - if (ret != 0) + if (ret != 0) { return nullptr; + } return pcursor; } @@ -246,10 +249,11 @@ class CDB datKey.set_flags(DB_DBT_MALLOC); datValue.set_flags(DB_DBT_MALLOC); int ret = pcursor->get(&datKey, &datValue, fFlags); - if (ret != 0) + if (ret != 0) { return ret; - else if (datKey.get_data() == nullptr || datValue.get_data() == nullptr) + } else if (datKey.get_data() == nullptr || datValue.get_data() == nullptr) { return 99999; + } // Convert to streams ssKey.SetType(SER_DISK); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 380ab13adb..853f0cbb3d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -339,8 +339,9 @@ UniValue getaccount(const UniValue& params, bool fHelp) string strAccount; map::iterator mi = pwalletMain->mapAddressBook.find(address.Get()); - if (mi != pwalletMain->mapAddressBook.end() && !mi->second.empty()) + if (mi != pwalletMain->mapAddressBook.end() && !mi->second.empty()) { strAccount = mi->second; + } return strAccount; } @@ -554,13 +555,17 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = it->second; - if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) + if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) { continue; + } - for (auto const& txout : wtx.vout) - if (txout.scriptPubKey == scriptPubKey) - if (wtx.GetDepthInMainChain() >= nMinDepth) + for (auto const& txout : wtx.vout) { + if (txout.scriptPubKey == scriptPubKey) { + if (wtx.GetDepthInMainChain() >= nMinDepth) { nAmount += txout.nValue; + } + } + } } return ValueFromAmount(nAmount); @@ -605,15 +610,18 @@ UniValue getreceivedbyaccount(const UniValue& params, bool fHelp) for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = it->second; - if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) + if (wtx.IsCoinBase() || wtx.IsCoinStake() || !IsFinalTx(wtx)) { continue; + } for (auto const& txout : wtx.vout) { CTxDestination address; - if (ExtractDestination(txout.scriptPubKey, address) && (IsMine(*pwalletMain, address) != ISMINE_NO) && setAddress.count(address)) - if (wtx.GetDepthInMainChain() >= nMinDepth) + if (ExtractDestination(txout.scriptPubKey, address) && (IsMine(*pwalletMain, address) != ISMINE_NO) && setAddress.count(address)) { + if (wtx.GetDepthInMainChain() >= nMinDepth) { nAmount += txout.nValue; + } + } } } @@ -628,8 +636,9 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = it->second; - if (!IsFinalTx(wtx) || wtx.GetDepthInMainChain() < 0) + if (!IsFinalTx(wtx) || wtx.GetDepthInMainChain() < 0) { continue; + } int64_t nReceived, nSent, nFee; wtx.GetAccountAmounts(strAccount, nReceived, nSent, nFee, filter); @@ -1040,18 +1049,17 @@ UniValue sendmany(const UniValue& params, bool fHelp) // Check funds & Support non-account sendmany int64_t nBalance = 0; - if (bFromAccount) + if (bFromAccount) { nBalance = GetAccountBalance(strAccount, nMinDepth); - - else - { + } else { isminefilter filter = ISMINE_SPENDABLE; for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = it->second; - if (!wtx.IsTrusted()) + if (!wtx.IsTrusted()) { continue; + } int64_t allFee; string strSentAccount; @@ -1060,11 +1068,13 @@ UniValue sendmany(const UniValue& params, bool fHelp) wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); if (wtx.GetDepthInMainChain() >= nMinDepth && wtx.GetBlocksToMaturity() == 0) { - for (auto const& r : listReceived) + for (auto const& r : listReceived) { nBalance += r.amount; + } } - for (auto const& r : listSent) + for (auto const& r : listSent) { nBalance -= r.amount; + } nBalance -= allFee; } } @@ -1291,8 +1301,9 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) else { UniValue obj(UniValue::VOBJ); - if(fIsWatchonly) - obj.pushKV("involvesWatchonly", true); + if (fIsWatchonly) { + obj.pushKV("involvesWatchonly", true); + } obj.pushKV("address", address.ToString()); obj.pushKV("account", strAccount); obj.pushKV("amount", ValueFromAmount(nAmount)); @@ -1304,7 +1315,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) for (const uint256& _item : it->second.txids) { transactions.push_back(_item.GetHex()); } - } + } obj.pushKV("txids", transactions); ret.push_back(obj); } @@ -1312,15 +1323,15 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts) if (fByAccounts) { - for (map::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it) + for (const auto& it : mapAccountTally) { - int64_t nAmount = it->second.nAmount; - int nConf = it->second.nConf; + int64_t nAmount = it.second.nAmount; + int nConf = it.second.nConf; UniValue obj(UniValue::VOBJ); - if (it->second.fIsWatchonly) + if (it.second.fIsWatchonly) obj.pushKV("involvesWatchonly", true); - obj.pushKV("account", it->first); - obj.pushKV("amount", ValueFromAmount(nAmount)); + obj.pushKV("account", it.first); + obj.pushKV("amount", ValueFromAmount(nAmount)); obj.pushKV("confirmations", (nConf == std::numeric_limits::max() ? 0 : nConf)); ret.push_back(obj); } @@ -1626,13 +1637,17 @@ UniValue listtransactions(const UniValue& params, bool fHelp) for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { CWalletTx* const pwtx = it->second.first; - if (pwtx != nullptr) + if (pwtx != nullptr) { ListTransactions(*pwtx, strAccount, 0, true, ret, filter); + } CAccountingEntry* const pacentry = it->second.second; - if (pacentry != nullptr) + if (pacentry != nullptr) { AcentryToJSON(*pacentry, strAccount, ret); + } - if ((int)ret.size() >= (nCount+nFrom)) break; + if ((int)ret.size() >= (nCount + nFrom)) { + break; + } } // ret is newest to oldest diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0a1def3df1..31279fe772 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -428,14 +428,13 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx, bool fBlock, CWalletDB* LOCK(cs_wallet); for (auto const& txin : tx.vin) { - map::iterator mi = mapWallet.find(txin.prevout.hash); + auto mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) { CWalletTx& wtx = mi->second; - if (txin.prevout.n >= wtx.vout.size()) + if (txin.prevout.n >= wtx.vout.size()) { LogPrintf("WalletUpdateSpent: bad wtx %s", wtx.GetHash().ToString()); - else if (!wtx.IsSpent(txin.prevout.n) && (IsMine(wtx.vout[txin.prevout.n]) != ISMINE_NO)) - { + } else if (!wtx.IsSpent(txin.prevout.n) && (IsMine(wtx.vout[txin.prevout.n]) != ISMINE_NO)) { LogPrint(BCLog::LogFlags::VERBOSE, "WalletUpdateSpent found spent coin %s gC %s", FormatMoney(wtx.GetCredit()), wtx.GetHash().ToString()); wtx.MarkSpent(txin.prevout.n); wtx.WriteToDisk(pwalletdb); @@ -447,7 +446,7 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx, bool fBlock, CWalletDB* if (fBlock) { uint256 hash = tx.GetHash(); - map::iterator mi = mapWallet.find(hash); + auto mi = mapWallet.find(hash); CWalletTx& wtx = mi->second; for (auto const& txout : tx.vout) @@ -614,12 +613,13 @@ isminetype CWallet::IsMine(const CTxIn &txin) const { { LOCK(cs_wallet); - map::const_iterator mi = mapWallet.find(txin.prevout.hash); + const auto mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) { const CWalletTx& prev = mi->second; - if (txin.prevout.n < prev.vout.size()) + if (txin.prevout.n < prev.vout.size()) { return IsMine(prev.vout[txin.prevout.n]); + } } } return ISMINE_NO; @@ -678,15 +678,16 @@ int CWalletTx::GetRequestCount() const // Generated block if (!hashBlock.IsNull()) { - map::const_iterator mi = pwallet->mapRequestCount.find(hashBlock); - if (mi != pwallet->mapRequestCount.end()) + const auto mi = pwallet->mapRequestCount.find(hashBlock); + if (mi != pwallet->mapRequestCount.end()) { nRequests = mi->second; + } } } else { // Did anyone request this transaction? - map::const_iterator mi = pwallet->mapRequestCount.find(GetHash()); + const auto mi = pwallet->mapRequestCount.find(GetHash()); if (mi != pwallet->mapRequestCount.end()) { nRequests = mi->second; @@ -694,11 +695,12 @@ int CWalletTx::GetRequestCount() const // How about the block it's in? if (nRequests == 0 && !hashBlock.IsNull()) { - map::const_iterator mi = pwallet->mapRequestCount.find(hashBlock); - if (mi != pwallet->mapRequestCount.end()) + const auto mi = pwallet->mapRequestCount.find(hashBlock); + if (mi != pwallet->mapRequestCount.end()) { nRequests = mi->second; - else + } else { nRequests = 1; // If it's in someone else's block it must have got out + } } } } @@ -918,9 +920,10 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, int64_t& nReceived, { if (pwallet->mapAddressBook.count(r.destination)) { - map::const_iterator mi = pwallet->mapAddressBook.find(r.destination); - if (mi != pwallet->mapAddressBook.end() && mi->second == strAccount) + const auto mi = pwallet->mapAddressBook.find(r.destination); + if (mi != pwallet->mapAddressBook.end() && mi->second == strAccount) { nReceived += r.amount; + } } else if (strAccount.empty()) { @@ -938,8 +941,9 @@ void CWalletTx::AddSupportingTransactions(CTxDB& txdb) if (SetMerkleBranch() < COPY_DEPTH) { vector vWorkQueue; - for (auto const& txin : vin) + for (auto const& txin : vin) { vWorkQueue.push_back(txin.prevout.hash); + } // This critsect is OK because txdb is already open { @@ -1230,8 +1234,9 @@ int64_t CWallet::GetUnconfirmedBalance() const for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &it->second; - if (!IsFinalTx(*pcoin) || (!pcoin->IsConfirmed() && !pcoin->fFromMe && pcoin->IsInMainChain())) + if (!IsFinalTx(*pcoin) || (!pcoin->IsConfirmed() && !pcoin->fFromMe && pcoin->IsInMainChain())) { nTotal += pcoin->GetAvailableCredit(); + } } } return nTotal; @@ -1245,8 +1250,9 @@ int64_t CWallet::GetImmatureBalance() const for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx& pcoin = it->second; - if (pcoin.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.IsInMainChain()) + if (pcoin.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.IsInMainChain()) { nTotal += GetCredit(pcoin); + } } } return nTotal; @@ -1265,25 +1271,28 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const int nDepth = pcoin->GetDepthInMainChain(); if (!fIncludeStakedCoins) { - if (!IsFinalTx(*pcoin)) + if (!IsFinalTx(*pcoin)) { continue; + } - if (fOnlyConfirmed && !pcoin->IsTrusted()) + if (fOnlyConfirmed && !pcoin->IsTrusted()) { continue; + } - if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) + if ((pcoin->IsCoinBase() || pcoin->IsCoinStake()) && pcoin->GetBlocksToMaturity() > 0) { continue; + } - if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0) + if (nDepth < 0) { continue; - - if (nDepth < 0) + } + } + else + { + if (nDepth < 1) { continue; - } - else - { - if (nDepth < 1) continue; - } + } + } for (unsigned int i = 0; i < pcoin->vout.size(); i++) { @@ -1292,8 +1301,7 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const (fIncludeStakedCoins && pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0)) { vCoins.push_back(COutput(pcoin, i, nDepth)); } - } - + } } } } @@ -1451,8 +1459,9 @@ int64_t CWallet::GetStake() const for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &it->second; - if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) + if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) { nTotal += CWallet::GetCredit(*pcoin); + } } return nTotal; } @@ -1464,8 +1473,9 @@ int64_t CWallet::GetNewMint() const for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &it->second; - if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) + if (pcoin->IsCoinStake() && pcoin->GetBlocksToMaturity() > 0 && pcoin->GetDepthInMainChain() > 0) { nTotal += CWallet::GetCredit(*pcoin); + } } return nTotal; } @@ -1543,8 +1553,9 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, if (nTotalLower < nTargetValue) { - if (coinLowestLarger.second.first == nullptr) + if (coinLowestLarger.second.first == nullptr) { return false; + } setCoinsRet.insert(coinLowestLarger.second); nValueRet += coinLowestLarger.first; return true; @@ -2594,8 +2605,9 @@ void CWallet::FixSpentCoins(int& nMismatchFound, int64_t& nBalanceInQuestion, bo LOCK(cs_wallet); vector vCoins; vCoins.reserve(mapWallet.size()); - for (map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + for (map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { vCoins.push_back(&it->second); + } CWalletDB walletdb(strWalletFile); @@ -2604,8 +2616,9 @@ void CWallet::FixSpentCoins(int& nMismatchFound, int64_t& nBalanceInQuestion, bo { // Find the corresponding transaction index CTxIndex txindex; - if (!txdb.ReadTxIndex(pcoin->GetHash(), txindex)) + if (!txdb.ReadTxIndex(pcoin->GetHash(), txindex)) { continue; + } for (unsigned int n=0; n < pcoin->vout.size(); n++) { if ((IsMine(pcoin->vout[n]) != ISMINE_NO) && pcoin->IsSpent(n) && (txindex.vSpent.size() <= n || txindex.vSpent[n].IsNull())) @@ -2877,8 +2890,9 @@ MinedType GetGeneratedType(const CWallet *wallet, const uint256& tx, unsigned in BlockMap::iterator mi = mapBlockIndex.find(hashblock); - if (mi == mapBlockIndex.end()) + if (mi == mapBlockIndex.end()) { return MinedType::UNKNOWN; + } CBlockIndex* blkindex = mi->second; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 30dd197a03..c1c402d635 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -81,7 +81,9 @@ class CKeyPool class CWallet : public CCryptoKeyStore { private: - bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set>& setCoinsRet, int64_t& nValueRet, const CCoinControl* coinControl = nullptr, bool contract = false) const; + bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, + std::set>& setCoinsRet, int64_t& nValueRet, + const CCoinControl* coinControl = nullptr, bool contract = false) const; CWalletDB *pwalletdbEncryption; @@ -191,9 +193,12 @@ class CWallet : public CCryptoKeyStore void AvailableCoinsForStaking(std::vector& vCoins, unsigned int nSpendTime, int64_t& nBalanceOut) const; bool SelectCoinsForStaking(unsigned int nSpendTime, std::vector >& vCoinsRet, GRC::MinerStatus::ReasonNotStakingCategory& not_staking_error, int64_t& balance_out, bool fMiner = false) const; - void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed = true, const CCoinControl* coinControl = nullptr, bool fIncludeStakingCoins = false) const; - bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; - bool SelectSmallestCoins(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, int64_t& nValueRet) const; + void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed = true, const CCoinControl* coinControl = nullptr, + bool fIncludeStakingCoins = false) const; + bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, + std::set >& setCoinsRet, int64_t& nValueRet) const; + bool SelectSmallestCoins(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector vCoins, + std::set >& setCoinsRet, int64_t& nValueRet) const; // keystore implementation // Generate a new key @@ -248,9 +253,12 @@ class CWallet : public CCryptoKeyStore int64_t GetImmatureBalance() const; int64_t GetStake() const; int64_t GetNewMint() const; - bool CreateTransaction(const std::vector>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl = nullptr); - bool CreateTransaction(const std::vector>& vecSend, std::set>& setCoins, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl = nullptr); - bool CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl = nullptr); + bool CreateTransaction(const std::vector>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, + int64_t& nFeeRet, const CCoinControl* coinControl = nullptr); + bool CreateTransaction(const std::vector>& vecSend, std::set>& setCoins, + CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl = nullptr); + bool CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, + const CCoinControl* coinControl = nullptr); bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);