// Alert system
//
-#include <boost/foreach.hpp>
#include <map>
#include "alert.h"
std::string CUnsignedAlert::ToString() const
{
std::string strSetCancel;
- BOOST_FOREACH(int n, setCancel)
+ for (int n : setCancel)
strSetCancel += strprintf("%d ", n);
std::string strSetSubVer;
- BOOST_FOREACH(std::string str, setSubVer)
+ for (const std::string& str : setSubVer)
strSetSubVer += "\"" + str + "\" ";
return strprintf(
"CAlert(\n"
return (alert.nID <= nCancel || setCancel.count(alert.nID));
}
-bool CAlert::AppliesTo(int nVersion, std::string strSubVerIn) const
+bool CAlert::AppliesTo(int nVersion, const std::string& strSubVerIn) const
{
// TODO: rework for client-version-embedded-in-strSubVer ?
return (IsInEffect() &&
CAlert retval;
{
LOCK(cs_mapAlerts);
- map<uint256, CAlert>::iterator mi = mapAlerts.find(hash);
+ auto mi = mapAlerts.find(hash);
if(mi != mapAlerts.end())
retval = mi->second;
}
{
LOCK(cs_mapAlerts);
// Cancel previous alerts
- for (map<uint256, CAlert>::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();)
+ for (auto mi = mapAlerts.begin(); mi != mapAlerts.end();)
{
const CAlert& alert = (*mi).second;
if (Cancels(alert))
}
// Check if this alert has been cancelled
- BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
+ for (auto& item : mapAlerts)
{
const CAlert& alert = item.second;
if (alert.Cancels(*this))
uint256 GetHash() const;
bool IsInEffect() const;
bool Cancels(const CAlert& alert) const;
- bool AppliesTo(int nVersion, std::string strSubVerIn) const;
+ bool AppliesTo(int nVersion, const std::string& strSubVerIn) const;
bool AppliesToMe() const;
bool RelayTo(CNode* pnode) const;
bool CheckSignature() const;
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <boost/assign/list_of.hpp> // for 'map_list_of()'
-#include <boost/foreach.hpp>
#include <algorithm>
#include "checkpoints.h"
{
MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
- BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints)
+ for(auto it = checkpoints.rbegin(); it != checkpoints.rend(); ++it)
{
- const uint256& hash = i.second.first;
- std::map<uint256, CBlockIndex*>::const_iterator t = mapBlockIndex.find(hash);
+ const uint256& hash = it->second.first;
+ auto t = mapBlockIndex.find(hash);
if (t != mapBlockIndex.end())
return t->second;
}
printf("ResetSyncCheckpoint: pending for sync-checkpoint %s\n", hashPendingCheckpoint.ToString().c_str());
}
- BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
+ for(auto it = mapCheckpoints.rbegin(); it != mapCheckpoints.rend(); ++it)
{
- const uint256& hash = i.second.first;
+ const uint256& hash = it->second.first;
if (mapBlockIndex.count(hash) && mapBlockIndex[hash]->IsInMainChain())
{
if (!WriteSyncCheckpoint(hash))
#include <algorithm>
#include <vector>
-#include <boost/foreach.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
fOk = fAllOk;
}
// execute work
- BOOST_FOREACH(T &check, vChecks)
+ for (T &check : vChecks)
if (fOk)
fOk = check();
vChecks.clear();
// Add a batch of checks to the queue
void Add(std::vector<T> &vChecks) {
boost::unique_lock<boost::mutex> lock(mutex);
- BOOST_FOREACH(T &check, vChecks) {
+ for (T &check : vChecks) {
queue.push_back(T());
check.swap(queue.back());
}
if (mapArgs.count("-onlynet")) {
std::set<enum Network> nets;
- BOOST_FOREACH(std::string snet, mapMultiArgs["-onlynet"]) {
+ for (std::string snet : mapMultiArgs["-onlynet"]) {
enum Network net = ParseNetwork(snet);
if (net == NET_UNROUTABLE)
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet.c_str()));
{
std::string strError;
if (mapArgs.count("-bind")) {
- BOOST_FOREACH(std::string strBind, mapMultiArgs["-bind"]) {
+ for(std::string strBind : mapMultiArgs["-bind"]) {
CService addrBind;
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind.c_str()));
if (mapArgs.count("-externalip"))
{
- BOOST_FOREACH(string strAddr, mapMultiArgs["-externalip"]) {
+ for (string strAddr : mapMultiArgs["-externalip"]) {
CService addrLocal(strAddr, GetListenPort(), fNameLookup);
if (!addrLocal.IsValid())
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr.c_str()));
InitError(_("Unable to sign checkpoint, wrong checkpointkey?\n"));
}
- BOOST_FOREACH(string strDest, mapMultiArgs["-seednode"])
+ for (string strDest : mapMultiArgs["-seednode"])
AddOneShot(strDest);
// ********************************************************* Step 7: load blockchain
{
uiInterface.InitMessage(_("Importing blockchain data file."));
- BOOST_FOREACH(string strFile, mapMultiArgs["-loadblock"])
+ for (string strFile : mapMultiArgs["-loadblock"])
{
FILE *file = fopen(strFile.c_str(), "rb");
if (file)
bool fSelected = false;
uint256 hashBest = 0;
*pindexSelected = (const CBlockIndex*) 0;
- BOOST_FOREACH(const PAIRTYPE(int64_t, uint256)& item, vSortedByTimestamp)
+ for (const auto& item : vSortedByTimestamp)
{
if (!mapBlockIndex.count(item.second))
return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString().c_str());
strSelectionMap.replace(pindex->nHeight - nHeightFirstCandidate, 1, "=");
pindex = pindex->pprev;
}
- BOOST_FOREACH(const PAIRTYPE(uint256, const CBlockIndex*)& item, mapSelectedBlocks)
+ for (const auto& item : mapSelectedBlocks)
{
// 'S' indicates selected proof-of-stake blocks
// 'W' indicates selected proof-of-work blocks
return false;
fUseCrypto = true;
- BOOST_FOREACH(KeyMap::value_type& mKey, mapKeys)
+ for (KeyMap::value_type& mKey : mapKeys)
{
CKey key;
if (!key.SetSecret(mKey.second.first, mKey.second.second))
}
mapKeys.clear();
- BOOST_FOREACH(MalleableKeyMap::value_type& mKey, mapMalleableKeys)
+ for (MalleableKeyMap::value_type& mKey : mapMalleableKeys)
{
const CPubKey vchPubKeyH = mKey.first.GetMalleablePubKey().GetH();
std::vector<unsigned char> vchCryptedSecretH;
// check whether the passed transaction is from us
bool static IsFromMe(CTransaction& tx)
{
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
+ for (CWallet* pwallet : setpwalletRegistered)
if (pwallet->IsFromMe(tx))
return true;
return false;
// erases transaction with the given hash from all wallets
void static EraseFromWallets(uint256 hash)
{
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
+ for (CWallet* pwallet : setpwalletRegistered)
pwallet->EraseFromWallet(hash);
}
// wallets need to refund inputs when disconnecting coinstake
if (tx.IsCoinStake())
{
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
+ for (CWallet* pwallet : setpwalletRegistered)
if (pwallet->IsFromMe(tx))
pwallet->DisableTransaction(tx);
}
return;
}
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
+ for (CWallet* pwallet : setpwalletRegistered)
pwallet->AddToWalletIfInvolvingMe(tx, pblock, fUpdate);
}
// notify wallets about a new best chain
void static SetBestChain(const CBlockLocator& loc)
{
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
+ for (CWallet* pwallet : setpwalletRegistered)
pwallet->SetBestChain(loc);
}
// notify wallets about an updated transaction
void static UpdatedTransaction(const uint256& hashTx)
{
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
+ for (CWallet* pwallet : setpwalletRegistered)
pwallet->UpdatedTransaction(hashTx);
}
// dump all wallets
void static PrintWallets(const CBlock& block)
{
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
+ for (CWallet* pwallet : setpwalletRegistered)
pwallet->PrintWallet(block);
}
// notify wallets about an incoming inventory (for request counts)
void static Inventory(const uint256& hash)
{
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
+ for (CWallet* pwallet : setpwalletRegistered)
pwallet->Inventory(hash);
}
// ask wallets to resend their transactions
void ResendWalletTransactions(bool fForceResend)
{
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
+ for (CWallet* pwallet : setpwalletRegistered)
pwallet->ResendWalletTransactions(fForceResend);
}
}
mapOrphanTransactions[hash] = tx;
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash);
printf("stored orphan tx %s (mapsz %" PRIszu ")\n", hash.ToString().substr(0,10).c_str(),
if (!mapOrphanTransactions.count(hash))
return;
const CTransaction& tx = mapOrphanTransactions[hash];
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
{
mapOrphanTransactionsByPrev[txin.prevout.hash].erase(hash);
if (mapOrphanTransactionsByPrev[txin.prevout.hash].empty())
unsigned int nDataOut = 0;
txnouttype whichType;
- BOOST_FOREACH(const CTxIn& txin, vin)
+ for (const CTxIn& txin : vin)
{
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
// keys. (remember the 520 byte limit on redeemScript size) That works
return false;
}
}
- BOOST_FOREACH(const CTxOut& txout, vout) {
+ for (const CTxOut& txout : vout) {
if (!::IsStandard(txout.scriptPubKey, whichType)) {
strReason = "scriptpubkey";
return false;
{
// Coinbase scriptsigs are never executed, so there is
// no sense in calculation of sigops.
- BOOST_FOREACH(const CTxIn& txin, vin)
+ for (const CTxIn& txin : vin)
{
nSigOps += txin.scriptSig.GetSigOpCount(false);
}
}
- BOOST_FOREACH(const CTxOut& txout, vout)
+ for (const CTxOut& txout : vout)
{
nSigOps += txout.scriptPubKey.GetSigOpCount(false);
}
// Check for duplicate inputs
set<COutPoint> vInOutPoints;
- BOOST_FOREACH(const CTxIn& txin, vin)
+ for (const CTxIn& txin : vin)
{
if (vInOutPoints.count(txin.prevout))
return false;
}
else
{
- BOOST_FOREACH(const CTxIn& txin, vin)
+ for (const CTxIn& txin : vin)
if (txin.prevout.IsNull())
return DoS(10, error("CTransaction::CheckTransaction() : prevout is null"));
}
//
// It's safe to ignore empty outputs here, because these inputs are allowed
// only for coinbase and coinstake transactions.
- BOOST_FOREACH(const CTxOut& txout, vout)
+ for (const CTxOut& txout : vout)
if (txout.nValue < CENT && !txout.IsEmpty())
nMinFee += nBaseFee;
uint256 hash = tx.GetHash();
if (mapTx.count(hash))
{
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
mapNextTx.erase(txin.prevout);
mapTx.erase(hash);
nTransactionsUpdated++;
{
LOCK(mempool.cs);
// Add previous supporting transactions first
- BOOST_FOREACH(CMerkleTx& tx, vtxPrev)
+ for (CMerkleTx& tx : vtxPrev)
{
if (!(tx.IsCoinBase() || tx.IsCoinStake()))
{
// Relinquish previous transactions' spent pointers
if (!IsCoinBase())
{
- BOOST_FOREACH(const CTxIn& txin, vin)
+ for (const CTxIn& txin : vin)
{
COutPoint prevout = txin.prevout;
}
// ppcoin: clean up wallet after disconnecting coinstake
- BOOST_FOREACH(CTransaction& tx, vtx)
+ for (CTransaction& tx : vtx)
SyncWithWallets(tx, this, false, false);
return true;
int64_t nValueIn = 0;
int64_t nValueOut = 0;
unsigned int nSigOps = 0;
- BOOST_FOREACH(CTransaction& tx, vtx)
+ for (CTransaction& tx : vtx)
{
uint256 hashTx = tx.GetHash();
if (fEnforceBIP30) {
CTxIndex txindexOld;
if (txdb.ReadTxIndex(hashTx, txindexOld)) {
- BOOST_FOREACH(CDiskTxPos &pos, txindexOld.vSpent)
+ for (CDiskTxPos &pos : txindexOld.vSpent)
if (pos.IsNull())
return false;
}
}
// Watch for transactions paying to me
- BOOST_FOREACH(CTransaction& tx, vtx)
+ for (CTransaction& tx : vtx)
SyncWithWallets(tx, this, true);
// Disconnect shorter branch
vector<CTransaction> vResurrect;
- BOOST_FOREACH(CBlockIndex* pindex, vDisconnect)
+ for (CBlockIndex* pindex : vDisconnect)
{
CBlock block;
if (!block.ReadFromDisk(pindex))
return error("Reorganize() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str());
// Queue memory transactions to resurrect
- BOOST_FOREACH(const CTransaction& tx, block.vtx)
+ for (const CTransaction& tx : block.vtx)
if (!(tx.IsCoinBase() || tx.IsCoinStake()))
vResurrect.push_back(tx);
}
}
// Queue memory transactions to delete
- BOOST_FOREACH(const CTransaction& tx, block.vtx)
+ for (const CTransaction& tx : block.vtx)
vDelete.push_back(tx);
}
if (!txdb.WriteHashBestChain(pindexNew->GetBlockHash()))
return error("Reorganize() : TxnCommit failed");
// Disconnect shorter branch
- BOOST_FOREACH(CBlockIndex* pindex, vDisconnect)
+ for (CBlockIndex* pindex : vDisconnect)
if (pindex->pprev)
pindex->pprev->pnext = NULL;
// Connect longer branch
- BOOST_FOREACH(CBlockIndex* pindex, vConnect)
+ for (CBlockIndex* pindex : vConnect)
if (pindex->pprev)
pindex->pprev->pnext = pindex;
// Resurrect memory transactions that were in the disconnected branch
- BOOST_FOREACH(CTransaction& tx, vResurrect)
+ for (CTransaction& tx : vResurrect)
tx.AcceptToMemoryPool(txdb, false);
// Delete redundant memory transactions that are in the connected branch
- BOOST_FOREACH(CTransaction& tx, vDelete)
+ for (CTransaction& tx : vDelete)
mempool.remove(tx);
printf("REORGANIZE: done\n");
pindexNew->pprev->pnext = pindexNew;
// Delete redundant memory transactions
- BOOST_FOREACH(CTransaction& tx, vtx)
+ for (CTransaction& tx : vtx)
mempool.remove(tx);
return true;
if (IsCoinBase())
return true;
- BOOST_FOREACH(const CTxIn& txin, vin)
+ for (const CTxIn& txin : vin)
{
// First try finding the previous transaction in database
CTransaction txPrev;
nCoinAge = 0;
CTxDB txdb("r");
- BOOST_FOREACH(const CTransaction& tx, vtx)
+ for (const CTransaction& tx : vtx)
{
uint64_t nTxCoinAge;
if (tx.GetCoinAge(txdb, nTxCoinAge))
return error("AcceptBlock() : block's timestamp is too far in the future");
// Check that all transactions are finalized
- BOOST_FOREACH(const CTransaction& tx, vtx)
+ for (const CTransaction& tx : vtx)
if (!tx.IsFinal(nHeight, GetBlockTime()))
return DoS(10, error("AcceptBlock() : contains a non-final transaction"));
if (hashBestChain == hash)
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate))
pnode->PushInventory(CInv(MSG_BLOCK, hash));
}
// Alerts
{
LOCK(cs_mapAlerts);
- BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
+ for (auto& item : mapAlerts)
{
const CAlert& alert = item.second;
if (alert.AppliesToMe() && alert.nPriority > nPriority)
// Relay alerts
{
LOCK(cs_mapAlerts);
- BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
+ for (auto& item : mapAlerts)
item.second.RelayTo(pfrom);
}
vector<CAddress> vAddrOk;
int64_t nNow = GetAdjustedTime();
int64_t nSince = nNow - 10 * 60;
- BOOST_FOREACH(CAddress& addr, vAddr)
+ for (CAddress& addr : vAddr)
{
if (fShutdown)
return true;
uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/nOneDay);
hashRand = Hash(BEGIN(hashRand), END(hashRand));
multimap<uint256, CNode*> mapMix;
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
{
if (pnode->nVersion < CADDR_TIME_VERSION)
continue;
if (fDebugNet || (vInv.size() != 1))
printf("received getdata (%" PRIszu " invsz)\n", vInv.size());
- BOOST_FOREACH(const CInv& inv, vInv)
+ for (const CInv& inv : vInv)
{
if (fShutdown)
return true;
// Relay
pfrom->hashCheckpointKnown = checkpoint.hashCheckpoint;
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
checkpoint.RelayTo(pnode);
}
}
}
}
- BOOST_FOREACH(uint256 hash, vEraseQueue)
+ for (uint256 hash : vEraseQueue)
EraseOrphanTx(hash);
}
else if (fMissingInputs)
int64_t nCutOff = GetTime() - (nNodeLifespan * nOneDay);
pfrom->vAddrToSend.clear();
vector<CAddress> vAddr = addrman.GetAddr();
- BOOST_FOREACH(const CAddress &addr, vAddr)
+ for (const CAddress &addr : vAddr)
if(addr.nTime > nCutOff)
pfrom->PushAddress(addr);
}
pfrom->setKnown.insert(alertHash);
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
alert.RelayTo(pnode);
}
}
pto->nNextAddrSend = PoissonNextSend(nNow, 30);
vector<CAddress> vAddr;
vAddr.reserve(pto->vAddrToSend.size());
- BOOST_FOREACH(const CAddress& addr, pto->vAddrToSend)
+ for (const CAddress& addr : pto->vAddrToSend)
{
if (pto->setAddrKnown.insert(addr).second)
{
LOCK(pto->cs_inventory);
vInv.reserve(pto->vInventoryToSend.size());
vInvWait.reserve(pto->vInventoryToSend.size());
- BOOST_FOREACH(const CInv& inv, pto->vInventoryToSend)
+ for (const CInv& inv : pto->vInventoryToSend)
{
if (pto->setInventoryKnown.count(inv))
continue;
nBlockTime = GetAdjustedTime();
if ((int64_t)nLockTime < ((int64_t)nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
return true;
- BOOST_FOREACH(const CTxIn& txin, vin)
+ for (const CTxIn& txin : vin)
if (!txin.IsFinal())
return false;
return true;
int64_t GetValueOut() const
{
int64_t nValueOut = 0;
- BOOST_FOREACH(const CTxOut& txout, vout)
+ for (const CTxOut& txout : vout)
{
nValueOut += txout.nValue;
if (!MoneyRange(txout.nValue) || !MoneyRange(nValueOut))
int64_t GetMaxTransactionTime() const
{
int64_t maxTransactionTime = 0;
- BOOST_FOREACH(const CTransaction& tx, vtx)
+ for (const CTransaction& tx : vtx)
maxTransactionTime = std::max(maxTransactionTime, (int64_t)tx.nTime);
return maxTransactionTime;
}
uint256 BuildMerkleTree() const
{
vMerkleTree.clear();
- BOOST_FOREACH(const CTransaction& tx, vtx)
+ for (const CTransaction& tx : vtx)
vMerkleTree.push_back(tx.GetHash());
int j = 0;
for (int nSize = (int)vtx.size(); nSize > 1; nSize = (nSize + 1) / 2)
{
if (nIndex == -1)
return 0;
- BOOST_FOREACH(const uint256& otherside, vMerkleBranch)
+ for (const uint256& otherside : vMerkleBranch)
{
if (nIndex & 1)
hash = Hash(BEGIN(otherside), END(otherside), BEGIN(hash), END(hash));
// Retrace how far back it was in the sender's branch
int nDistance = 0;
int nStep = 1;
- BOOST_FOREACH(const uint256& hash, vHave)
+ for (const uint256& hash : vHave)
{
std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end())
CBlockIndex* GetBlockIndex()
{
// Find the first block the caller has in the main chain
- BOOST_FOREACH(const uint256& hash, vHave)
+ for (const uint256& hash : vHave)
{
std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end())
uint256 GetBlockHash()
{
// Find the first block the caller has in the main chain
- BOOST_FOREACH(const uint256& hash, vHave)
+ for (const uint256& hash : vHave)
{
std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end())
double dPriority = 0;
int64_t nTotalIn = 0;
bool fMissingInputs = false;
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
{
// Read prev transaction
CTransaction txPrev;
uint256 hash = tx.GetHash();
if (mapDependers.count(hash))
{
- BOOST_FOREACH(COrphan* porphan, mapDependers[hash])
+ for (COrphan* porphan : mapDependers[hash])
{
if (!porphan->setDependsOn.empty())
{
void static AdvertizeLocal()
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
{
if (pnode->fSuccessfullyConnected)
{
CNode* FindNode(const CNetAddr& ip)
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
if ((CNetAddr)pnode->addr == ip)
return (pnode);
return NULL;
CNode* FindNode(std::string addrName)
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
if (pnode->addrName == addrName)
return (pnode);
return NULL;
CNode* FindNode(const CService& addr)
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
if ((CService)pnode->addr == addr)
return (pnode);
return NULL;
LOCK(cs_vNodes);
// Disconnect unused nodes
vector<CNode*> vNodesCopy = vNodes;
- BOOST_FOREACH(CNode* pnode, vNodesCopy)
+ for (CNode* pnode : vNodesCopy)
{
if (pnode->fDisconnect ||
(pnode->GetRefCount() <= 0 && pnode->vRecv.empty() && pnode->vSend.empty()))
// Delete disconnected nodes
list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected;
- BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy)
+ for (CNode* pnode : vNodesDisconnectedCopy)
{
// wait until threads are done using it
if (pnode->GetRefCount() <= 0)
SOCKET hSocketMax = 0;
bool have_fds = false;
- BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket) {
+ for (SOCKET hListenSocket : vhListenSocket) {
FD_SET(hListenSocket, &fdsetRecv);
hSocketMax = max(hSocketMax, hListenSocket);
have_fds = true;
}
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
{
if (pnode->hSocket == INVALID_SOCKET)
continue;
//
// Accept new connections
//
- BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket)
+ for (SOCKET hListenSocket : vhListenSocket)
if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv))
{
#ifdef USE_IPV6
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
if (pnode->fInbound)
nInbound++;
}
{
LOCK(cs_vNodes);
vNodesCopy = vNodes;
- BOOST_FOREACH(CNode* pnode, vNodesCopy)
+ for (CNode* pnode : vNodesCopy)
pnode->AddRef();
}
- BOOST_FOREACH(CNode* pnode, vNodesCopy)
+ for (CNode* pnode : vNodesCopy)
{
if (fShutdown)
return;
vector<CAddress> vAdd;
if (LookupHost(strDNSSeed[seed_idx][1], vaddr))
{
- BOOST_FOREACH(CNetAddr& ip, vaddr)
+ for (CNetAddr& ip : vaddr)
{
CAddress addr = CAddress(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - 3*nOneDay - GetRand(4*nOneDay); // use a random age between 3 and 7 days old
for (int64_t nLoop = 0;; nLoop++)
{
ProcessOneShot();
- BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
+ for (string strAddr : mapMultiArgs["-connect"])
{
CAddress addr;
OpenNetworkConnection(addr, NULL, strAddr.c_str());
set<vector<unsigned char> > setConnected;
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes) {
+ for (CNode* pnode : vNodes) {
if (!pnode->fInbound) {
setConnected.insert(pnode->addr.GetGroup());
nOutbound++;
list<string> lAddresses(0);
{
LOCK(cs_vAddedNodes);
- BOOST_FOREACH(string& strAddNode, vAddedNodes)
+ for (string& strAddNode : vAddedNodes)
lAddresses.push_back(strAddNode);
}
- BOOST_FOREACH(string& strAddNode, lAddresses) {
+ for (string& strAddNode : lAddresses) {
CAddress addr;
CSemaphoreGrant grant(*semOutbound);
OpenNetworkConnection(addr, &grant, strAddNode.c_str());
list<string> lAddresses(0);
{
LOCK(cs_vAddedNodes);
- BOOST_FOREACH(string& strAddNode, vAddedNodes)
+ for (string& strAddNode : vAddedNodes)
lAddresses.push_back(strAddNode);
}
list<vector<CService> > lservAddressesToAdd(0);
- BOOST_FOREACH(string& strAddNode, lAddresses)
+ for (string& strAddNode : lAddresses)
{
vector<CService> vservNode(0);
if (Lookup(strAddNode.c_str(), vservNode, GetDefaultPort(), fNameLookup, 0))
lservAddressesToAdd.push_back(vservNode);
{
LOCK(cs_setservAddNodeAddresses);
- BOOST_FOREACH(CService& serv, vservNode)
+ for (CService& serv : vservNode)
setservAddNodeAddresses.insert(serv);
}
}
// (keeping in mind that addnode entries can have many IPs if fNameLookup)
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
for (list<vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++)
{
- BOOST_FOREACH(CService& addrNode, *(it))
+ for (CService& addrNode : *(it))
if (pnode->addr == addrNode)
{
it = lservAddressesToAdd.erase(it);
break;
}
}
- BOOST_FOREACH(vector<CService>& vserv, lservAddressesToAdd)
+ for (vector<CService>& vserv : lservAddressesToAdd)
{
if (vserv.size() == 0)
continue;
int64_t nBestScore = 0;
// Iterate over all nodes
- BOOST_FOREACH(CNode* pnode, vNodes) {
+ for (CNode* pnode : vNodes) {
// check preconditions for allowing a sync
if (!pnode->fClient && !pnode->fOneShot &&
!pnode->fDisconnect && pnode->fSuccessfullyConnected &&
{
LOCK(cs_vNodes);
vNodesCopy = vNodes;
- BOOST_FOREACH(CNode* pnode, vNodesCopy) {
+ for (CNode* pnode : vNodesCopy) {
pnode->AddRef();
if (pnode == pnodeSync)
fHaveSyncNode = true;
StartSync(vNodesCopy);
// Poll the connected nodes for messages
- BOOST_FOREACH(CNode* pnode, vNodesCopy)
+ for (CNode* pnode : vNodesCopy)
{
// Receive messages
{
vector<CNetAddr> vaddr;
if (LookupHost(pszHostName, vaddr))
{
- BOOST_FOREACH (const CNetAddr &addr, vaddr)
+ for (const CNetAddr &addr : vaddr)
{
AddLocal(addr, LOCAL_IF);
}
~CNetCleanup()
{
// Close sockets
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
if (pnode->hSocket != INVALID_SOCKET)
CloseSocket(pnode->hSocket);
- BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket)
+ for (SOCKET hListenSocket : vhListenSocket)
if (hListenSocket != INVALID_SOCKET)
if (!CloseSocket(hListenSocket))
printf("CloseSocket(hListenSocket) failed with error %d\n", WSAGetLastError());
// clean up some globals (to help leak detection)
- BOOST_FOREACH(CNode *pnode, vNodes)
+ for (CNode *pnode : vNodes)
delete pnode;
- BOOST_FOREACH(CNode *pnode, vNodesDisconnected)
+ for (CNode *pnode : vNodesDisconnected)
delete pnode;
vNodes.clear();
vNodesDisconnected.clear();
#include <deque>
#ifndef Q_MOC_RUN
#include <boost/array.hpp>
-#include <boost/foreach.hpp>
#endif
#include <openssl/rand.h>
// Put on lists to offer to the other nodes
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
pnode->PushInventory(inv);
}
}
cachedAddressTable.clear();
{
LOCK(wallet->cs_wallet);
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, std::string)& item, wallet->mapAddressBook)
+ for (const auto& item : wallet->mapAddressBook)
{
const CBitcoinAddress& address = item.first;
const std::string& strName = item.second;
return (int)(vNodes.size());
int nNum = 0;
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT))
nNum++;
coinControl->ListSelected(vCoinControl);
model->getOutputs(vCoinControl, vOutputs);
- BOOST_FOREACH(const COutput& out, vOutputs)
+ for (const COutput& out : vOutputs)
{
// Quantity
nQuantity++;
map<QString, vector<COutput> > mapCoins;
model->listCoins(mapCoins);
- BOOST_FOREACH(PAIRTYPE(QString, vector<COutput>) coins, mapCoins)
+ for (auto coins : mapCoins)
{
QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem();
QString sWalletAddress = coins.first;
int nChildren = 0;
int nInputSum = 0;
uint64_t nTxWeight = 0, nTxWeightSum = 0;
- BOOST_FOREACH(const COutput& out, coins.second)
+ for (const COutput& out : coins.second)
{
int nInputSize = 148; // 180 if uncompressed public key
nSum += out.tx->vout[out.i].nValue;
for(std::map<uint256, CWalletTx>::iterator it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it)
{
std::vector<KernelRecord> txList = KernelRecord::decomposeOutput(wallet, it->second);
- BOOST_FOREACH(KernelRecord& kr, txList) {
+ for (KernelRecord& kr : txList) {
if(!kr.spent) {
cachedWallet.append(kr);
}
if(!toInsert.empty()) /* only if something to insert */
{
int insert_idx = lowerIndex;
- BOOST_FOREACH(const KernelRecord &rec, toInsert)
+ for (const KernelRecord &rec : toInsert)
{
if(!rec.spent)
{
{
// Updated -- remove spent coins from table
std::vector<KernelRecord> toCheck = KernelRecord::decomposeOutput(wallet, mi->second);
- BOOST_FOREACH(const KernelRecord &rec, toCheck)
+ for (const KernelRecord &rec : toCheck)
{
if(rec.spent)
{
TRY_LOCK(wallet->cs_wallet, lockWallet);
if (lockWallet && !wallet->vMintingWalletUpdated.empty())
{
- BOOST_FOREACH(uint256 hash, wallet->vMintingWalletUpdated)
+ for (uint256 hash : wallet->vMintingWalletUpdated)
{
updated.append(hash);
CWalletTx wtx;
if(wallet->GetTransaction(hash, wtx))
{
- BOOST_FOREACH(const CTxIn& txin, wtx.vin)
+ for (const CTxIn& txin : wtx.vin)
{
updated.append(txin.prevout.hash);
}
// Fill input list
int index = -1;
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
{
uint256 prevoutHash = txin.prevout.hash;
addInput();
// Fill output list
index = -1;
- BOOST_FOREACH(const CTxOut& txout, tx.vout)
+ for (const CTxOut& txout : tx.vout)
{
CScript scriptPubKey = txout.scriptPubKey;
CTxDestination addr;
tempTx.vin.push_back(mergedTx.vin[i]);
tempTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid);
- BOOST_FOREACH(const CTxIn& txin, tempTx.vin)
+ for (const CTxIn& txin : tempTx.vin)
{
const uint256& prevHash = txin.prevout.hash;
if(mapPrevTx.count(prevHash) && mapPrevTx[prevHash].second.vout.size() > txin.prevout.n)
#include "transactiondesc.h"
-
#include "guiutil.h"
#include "bitcoinunits.h"
-
#include "main.h"
#include "wallet.h"
#include "txdb-leveldb.h"
if (nNet > 0)
{
// Credit
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
{
if (wallet->IsMine(txout))
{
// Coinbase
//
int64_t nUnmatured = 0;
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
nUnmatured += wallet->GetCredit(txout, MINE_ALL);
strHTML += "<b>" + tr("Credit") + ":</b> ";
if (wtx.IsInMainChain())
else
{
bool fAllFromMe = true;
- BOOST_FOREACH(const CTxIn& txin, wtx.vin)
+ for (const CTxIn& txin : wtx.vin)
fAllFromMe = fAllFromMe && wallet->IsMine(txin);
bool fAllToMe = true;
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
fAllToMe = fAllToMe && wallet->IsMine(txout);
if (fAllFromMe)
//
// Debit
//
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
{
if (wallet->IsMine(txout))
continue;
//
// Mixed debit transaction
//
- BOOST_FOREACH(const CTxIn& txin, wtx.vin)
+ for (const CTxIn& txin : wtx.vin)
if (wallet->IsMine(txin))
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -wallet->GetDebit(txin, MINE_ALL)) + "<br>";
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
if (wallet->IsMine(txout))
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, wallet->GetCredit(txout, MINE_ALL)) + "<br>";
}
if (fDebug)
{
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
- BOOST_FOREACH(const CTxIn& txin, wtx.vin)
+ for (const CTxIn& txin : wtx.vin)
if(wallet->IsMine(txin))
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -wallet->GetDebit(txin, MINE_ALL)) + "<br>";
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
if(wallet->IsMine(txout))
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, wallet->GetCredit(txout, MINE_ALL)) + "<br>";
{
LOCK(wallet->cs_wallet);
- BOOST_FOREACH(const CTxIn& txin, wtx.vin)
+ for (const CTxIn& txin : wtx.vin)
{
COutPoint prevout = txin.prevout;
//
// Credit
//
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
{
if(wallet->IsMine(txout))
{
else
{
bool fAllFromMe = true;
- BOOST_FOREACH(const CTxIn& txin, wtx.vin)
+ for (const CTxIn& txin : wtx.vin)
fAllFromMe = fAllFromMe && wallet->IsMine(txin);
bool fAllToMe = true;
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
fAllToMe = fAllToMe && wallet->IsMine(txout);
if (fAllFromMe && fAllToMe)
std::vector<COutput> vCoins;
wallet->AvailableCoins(vCoins, true, coinControl);
- BOOST_FOREACH(const COutput& out, vCoins)
+ for (const COutput& out : vCoins)
if(out.fSpendable)
nBalance += out.tx->vout[out.i].nValue;
// returns a list of COutputs from COutPoints
void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs)
{
- BOOST_FOREACH(const COutPoint& outpoint, vOutpoints)
+ for (const COutPoint& outpoint : vOutpoints)
{
if (!wallet->mapWallet.count(outpoint.hash)) continue;
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, wallet->mapWallet[outpoint.hash].GetDepthInMainChain(), true);
std::vector<COutPoint> vLockedCoins;
// add locked coins
- BOOST_FOREACH(const COutPoint& outpoint, vLockedCoins)
+ for (const COutPoint& outpoint : vLockedCoins)
{
if (!wallet->mapWallet.count(outpoint.hash)) continue;
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, wallet->mapWallet[outpoint.hash].GetDepthInMainChain(), true);
vCoins.push_back(out);
}
- BOOST_FOREACH(const COutput& out, vCoins)
+ for (const COutput& out : vCoins)
{
COutput cout = out;
result.push_back(Pair("modifier", strprintf("%016" PRIx64, blockindex->nStakeModifier)));
result.push_back(Pair("modifierchecksum", strprintf("%08x", blockindex->nStakeModifierChecksum)));
Array txinfo;
- BOOST_FOREACH (const CTransaction& tx, block.vtx)
+ for (const CTransaction& tx : block.vtx)
{
if (fPrintTransactionDetail)
{
mempool.queryHashes(vtxid);
Array a;
- BOOST_FOREACH(const uint256& hash, vtxid)
+ for (const uint256& hash : vtxid)
a.push_back(hash.ToString());
return a;
if (inputs_v.type() == array_type)
{
Array inputs = inputs_v.get_array();
- BOOST_FOREACH(const Value &v_out, inputs)
+ for (const Value &v_out : inputs)
{
int nOut = v_out.get_int();
if (nOut < 0 || nOut > (int)tx.vout.size() - 1)
interval.second = interval.first + nDays * nOneDay;
Array results;
- BOOST_FOREACH(const int &nOut, vInputs)
+ for (const int &nOut : vInputs)
{
// Check for spent flag
// It doesn't make sense to scan spent inputs.
std::vector<std::pair<uint256, uint32_t> > result;
if (ScanKernelForward((unsigned char *)&itK[0], nBits, tx.nTime, tx.vout[nOut].nValue, interval, result))
{
- BOOST_FOREACH(const PAIRTYPE(uint256, uint32_t) solution, result)
+ for (const auto &solution : result)
{
Object item;
item.push_back(Pair("nout", nOut));
Array merkle_arr;
- BOOST_FOREACH(uint256 merkleh, merkle) {
+ for (uint256 merkleh : merkle) {
merkle_arr.push_back(HexStr(BEGIN(merkleh), END(merkleh)));
}
map<uint256, int64_t> setTxIndex;
int i = 0;
CTxDB txdb("r");
- BOOST_FOREACH (CTransaction& tx, pblock->vtx)
+ for (CTransaction& tx : pblock->vtx)
{
uint256 txHash = tx.GetHash();
setTxIndex[txHash] = i++;
entry.push_back(Pair("fee", (int64_t)(tx.GetValueIn(mapInputs) - tx.GetValueOut())));
Array deps;
- BOOST_FOREACH (MapPrevTx::value_type& inp, mapInputs)
+ for (MapPrevTx::value_type& inp : mapInputs)
{
if (setTxIndex.count(inp.first))
deps.push_back(setTxIndex[inp.first]);
LOCK(cs_vNodes);
vstats.reserve(vNodes.size());
- BOOST_FOREACH(CNode* pnode, vNodes) {
+ for (CNode* pnode : vNodes) {
CNodeStats stats;
pnode->copyStats(stats);
vstats.push_back(stats);
strFilterNetType = params[0].get_str();
Array ret;
- BOOST_FOREACH(const CAddrInfo &addr, vAddr) {
+ for (const CAddrInfo &addr : vAddr) {
if (!addr.IsRoutable() || addr.IsLocal())
continue;
Array ret;
- BOOST_FOREACH(const CNodeStats& stats, vstats) {
+ for (const CNodeStats& stats : vstats) {
Object obj;
obj.push_back(Pair("addr", stats.addrName));
if (params.size() == 1)
{
LOCK(cs_vAddedNodes);
- BOOST_FOREACH(string& strAddNode, vAddedNodes)
+ for (string& strAddNode : vAddedNodes)
laddedNodes.push_back(strAddNode);
}
else
{
string strNode = params[1].get_str();
LOCK(cs_vAddedNodes);
- BOOST_FOREACH(string& strAddNode, vAddedNodes)
+ for (string& strAddNode : vAddedNodes)
if (strAddNode == strNode)
{
laddedNodes.push_back(strAddNode);
if (!fDns)
{
Object ret;
- BOOST_FOREACH(string& strAddNode, laddedNodes)
+ for (string& strAddNode : laddedNodes)
ret.push_back(Pair("addednode", strAddNode));
return ret;
}
Array ret;
list<pair<string, vector<CService> > > laddedAddreses(0);
- BOOST_FOREACH(string& strAddNode, laddedNodes)
+ for (string& strAddNode : laddedNodes)
{
vector<CService> vservNode(0);
if(Lookup(strAddNode.c_str(), vservNode, GetDefaultPort(), fNameLookup, 0))
Array addresses;
bool fConnected = false;
- BOOST_FOREACH(CService& addrNode, it->second)
+ for (CService& addrNode : it->second)
{
bool fFound = false;
Object node;
node.push_back(Pair("address", addrNode.ToString()));
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
if (pnode->addr == addrNode)
{
fFound = true;
// Relay alert
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
+ for (CNode* pnode : vNodes)
alert.RelayTo(pnode);
}
else
{
Array a;
- BOOST_FOREACH(const CTxDestination& addr, addresses)
+ for (const CTxDestination& addr : addresses)
a.push_back(CBitcoinAddress(addr).ToString());
out.push_back(Pair("addresses", a));
}
entry.push_back(Pair("time", (int64_t)tx.nTime));
entry.push_back(Pair("locktime", (int64_t)tx.nLockTime));
Array vin;
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
{
Object in;
if (tx.IsCoinBase())
if (params.size() > 2)
{
Array inputs = params[2].get_array();
- BOOST_FOREACH(Value& input, inputs)
+ for (Value& input : inputs)
{
CBitcoinAddress address(input.get_str());
if (!address.IsValid())
Array results;
vector<COutput> vecOutputs;
pwalletMain->AvailableCoins(vecOutputs, false);
- BOOST_FOREACH(const COutput& out, vecOutputs)
+ for (const COutput& out : vecOutputs)
{
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
continue;
CTransaction rawTx;
- BOOST_FOREACH(Value& input, inputs)
+ for (Value& input : inputs)
{
const Object& o = input.get_obj();
}
set<CBitcoinAddress> setAddress;
- BOOST_FOREACH(const Pair& s, sendTo)
+ for (const Pair& s : sendTo)
{
// Create output destination script
CScript scriptPubKey;
tempTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid);
// Copy results into mapPrevOut:
- BOOST_FOREACH(const CTxIn& txin, tempTx.vin)
+ for (const CTxIn& txin : tempTx.vin)
{
const uint256& prevHash = txin.prevout.hash;
if (mapPrevTx.count(prevHash) && mapPrevTx[prevHash].second.vout.size()>txin.prevout.n)
{
fGivenKeys = true;
Array keys = params[2].get_array();
- BOOST_FOREACH(Value k, keys)
+ for (Value k : keys)
{
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(k.get_str());
if (params.size() > 1 && params[1].type() != null_type)
{
Array prevTxs = params[1].get_array();
- BOOST_FOREACH(Value& p, prevTxs)
+ for (Value& p : prevTxs)
{
if (p.type() != obj_type)
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}");
SignSignature(keystore, prevPubKey, mergedTx, i, nHashType);
// ... and merge in other signatures:
- BOOST_FOREACH(const CTransaction& txv, txVariants)
+ for (const CTransaction& txv : txVariants)
{
txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig);
}
entry.push_back(Pair("txid", wtx.GetHash().GetHex()));
entry.push_back(Pair("time", (int64_t)wtx.GetTxTime()));
entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived));
- BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)
+ for (const auto& item : wtx.mapValue)
entry.push_back(Pair(item.first, item.second));
}
++it)
{
const CWalletTx& wtx = (*it).second;
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
if (txout.scriptPubKey == scriptPubKey)
bKeyUsed = true;
}
// Find all addresses that have the given account
Array ret;
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook)
+ for (const auto& item : pwalletMain->mapAddressBook)
{
const CBitcoinAddress& address = item.first;
const string& strName = item.second;
return Value::null;
Array mergedHashes;
- BOOST_FOREACH(const uint256 txHash, listMerged)
+ for (const uint256 txHash : listMerged)
mergedHashes.push_back(txHash.GetHex());
return mergedHashes;
Array jsonGroupings;
map<CBitcoinAddress, int64_t> balances = pwalletMain->GetAddressBalances();
- BOOST_FOREACH(set<CBitcoinAddress> grouping, pwalletMain->GetAddressGroupings())
+ for (set<CBitcoinAddress> grouping : pwalletMain->GetAddressGroupings())
{
Array jsonGrouping;
- BOOST_FOREACH(CBitcoinAddress address, grouping)
+ for (CBitcoinAddress address : grouping)
{
Array addressInfo;
addressInfo.push_back(address.ToString());
const CWalletTx& wtx = (*it).second;
if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal())
continue;
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
{
CBitcoinAddress addressRet;
if (!ExtractAddress(*pwalletMain, txout.scriptPubKey, addressRet))
void GetAccountAddresses(string strAccount, set<CBitcoinAddress>& setAddress)
{
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook)
+ for (const auto& item : pwalletMain->mapAddressBook)
{
const CBitcoinAddress& address = item.first;
const string& strName = item.second;
if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal())
continue;
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
{
CBitcoinAddress address;
if (ExtractAddress(*pwalletMain, txout.scriptPubKey, address) && IsMine(*pwalletMain, address) && setAddress.count(address))
wtx.GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount, filter);
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& r, listReceived)
+ for (const auto& r : listReceived)
nBalance += r.second;
}
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& r, listSent)
+ for (const auto& r : listSent)
nBalance -= r.second;
nBalance -= allFee;
nBalance += allGeneratedMature;
vector<pair<CScript, int64_t> > vecSend;
int64_t totalAmount = 0;
- BOOST_FOREACH(const Pair& s, sendTo)
+ for (const Pair& s : sendTo)
{
CBitcoinAddress address(s.name_);
if (!address.IsValid())
if (nDepth < nMinDepth)
continue;
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
{
CTxDestination address;
if (!ExtractDestination(txout.scriptPubKey, address) || !IsMine(*pwalletMain, address))
// Reply
Array ret;
map<string, tallyitem> mapAccountTally;
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook)
+ for (const auto& item : pwalletMain->mapAddressBook)
{
const CBitcoinAddress& address = item.first;
const string& strAccount = item.second;
// Sent
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
{
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64_t)& s, listSent)
+ for (const auto& s : listSent)
{
Object entry;
entry.push_back(Pair("account", strSentAccount));
// Received
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
{
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64_t)& r, listReceived)
+ for (const auto& r : listReceived)
{
string account;
if (pwalletMain->mapAddressBook.count(r.first))
map<string, int64_t> mapAccountBalances;
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& entry, pwalletMain->mapAddressBook) {
+ for (const auto& entry : pwalletMain->mapAddressBook) {
if (IsMine(*pwalletMain, entry.first)) // This address belongs to me
mapAccountBalances[entry.second] = 0;
}
list<pair<CBitcoinAddress, int64_t> > listSent;
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount, includeWatchonly);
mapAccountBalances[strSentAccount] -= nFee;
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64_t)& s, listSent)
+ for (const auto& s : listSent)
mapAccountBalances[strSentAccount] -= s.second;
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
mapAccountBalances[""] += nGeneratedMature;
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64_t)& r, listReceived)
+ for (const auto& r : listReceived)
if (pwalletMain->mapAddressBook.count(r.first))
mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second;
else
list<CAccountingEntry> acentries;
CWalletDB(pwalletMain->strWalletFile).ListAccountCreditDebit("*", acentries);
- BOOST_FOREACH(const CAccountingEntry& entry, acentries)
+ for (const CAccountingEntry& entry : acentries)
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
Object ret;
- BOOST_FOREACH(const PAIRTYPE(string, int64_t)& accountBalance, mapAccountBalances) {
+ for (const auto& accountBalance : mapAccountBalances) {
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
}
return ret;
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
Array a;
- BOOST_FOREACH(const CTxDestination& addr, addresses)
+ for (const CTxDestination& addr : addresses)
a.push_back(CBitcoinAddress(addr).ToString());
obj.push_back(Pair("addresses", a));
if (whichType == TX_MULTISIG)
std::vector<uint256> txids = pwalletMain->ResendWalletTransactionsBefore(GetTime());
Array result;
- BOOST_FOREACH(const uint256& txid, txids)
+ for (const uint256& txid : txids)
{
result.push_back(txid.ToString());
}
pwalletMain->ListMalleableViews(keyViewList);
Array result;
- BOOST_FOREACH(const CMalleableKeyView &keyView, keyViewList)
+ for (const CMalleableKeyView &keyView : keyViewList)
{
result.push_back(keyView.ToString());
}
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <boost/foreach.hpp>
-#include <boost/tuple/tuple.hpp>
using namespace std;
-using namespace boost;
#include "script.h"
#include "keystore.h"
// Scan templates
const CScript& script1 = scriptPubKey;
- BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates)
+ for (const auto& tplate : mTemplates)
{
const CScript& script2 = tplate.second;
vSolutionsRet.clear();
unsigned int HaveKeys(const vector<valtype>& pubkeys, const CKeyStore& keystore)
{
unsigned int nResult = 0;
- BOOST_FOREACH(const valtype& pubkey, pubkeys)
+ for (const valtype& pubkey : pubkeys)
{
CKeyID keyID = CPubKey(pubkey).GetID();
if (keystore.HaveKey(keyID))
std::vector<CTxDestination> vDest;
int nRequired;
if (ExtractDestinations(script, type, vDest, nRequired)) {
- BOOST_FOREACH(const CTxDestination &dest, vDest)
+ for (const CTxDestination &dest : vDest)
boost::apply_visitor(*this, dest);
}
}
static CScript PushAll(const vector<valtype>& values)
{
CScript result;
- BOOST_FOREACH(const valtype& v, values)
+ for (const valtype& v : values)
result << v;
return result;
}
{
// Combine all the signatures we've got:
set<valtype> allsigs;
- BOOST_FOREACH(const valtype& v, sigs1)
+ for (const valtype& v : sigs1)
{
if (!v.empty())
allsigs.insert(v);
}
- BOOST_FOREACH(const valtype& v, sigs2)
+ for (const valtype& v : sigs2)
{
if (!v.empty())
allsigs.insert(v);
unsigned int nSigsRequired = vSolutions.front()[0];
unsigned int nPubKeys = (unsigned int)(vSolutions.size()-2);
map<valtype, valtype> sigs;
- BOOST_FOREACH(const valtype& sig, allsigs)
+ for (const valtype& sig : allsigs)
{
for (unsigned int i = 0; i < nPubKeys; i++)
{
this->clear();
*this << EncodeOP_N(nRequired);
- BOOST_FOREACH(const CPubKey& key, keys)
+ for (const CPubKey& key : keys)
*this << key;
*this << EncodeOP_N((int)(keys.size())) << OP_CHECKMULTISIG;
}
#include <string>
#include <vector>
-#include <boost/foreach.hpp>
-
#include "keystore.h"
#include "bignum.h"
#include "base58.h"
inline std::string StackString(const std::vector<std::vector<unsigned char> >& vStack)
{
std::string str;
- BOOST_FOREACH(const std::vector<unsigned char>& vch, vStack)
+ for (const std::vector<unsigned char>& vch : vStack)
{
if (!str.empty())
str += " ";
#include "sync.h"
#include "util.h"
-#include <boost/foreach.hpp>
#ifdef DEBUG_LOCKCONTENTION
void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
{
printf("POTENTIAL DEADLOCK DETECTED\n");
printf("Previous lock order was:\n");
- BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, s2)
+ for (const auto& i : s2)
{
if (i.first == mismatch.first) printf(" (1)");
if (i.first == mismatch.second) printf(" (2)");
printf(" %s\n", i.second.ToString().c_str());
}
printf("Current lock order is:\n");
- BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, s1)
+ for (const auto& i : s1)
{
if (i.first == mismatch.first) printf(" (1)");
if (i.first == mismatch.second) printf(" (2)");
(*lockstack).push_back(std::make_pair(c, locklocation));
if (!fTry) {
- BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack)) {
+ for (const auto& i : (*lockstack)) {
if (i.first == c) break;
std::pair<void*, void*> p1 = std::make_pair(i.first, c);
// Calculate nChainTrust
vector<pair<int, CBlockIndex*> > vSortedByHeight;
vSortedByHeight.reserve(mapBlockIndex.size());
- BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex)
+ for (const auto& item : mapBlockIndex)
{
CBlockIndex* pindex = item.second;
vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));
}
sort(vSortedByHeight.begin(), vSortedByHeight.end());
- BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
+ for (const auto& item : vSortedByHeight)
{
CBlockIndex* pindex = item.second;
pindex->nChainTrust = (pindex->pprev ? pindex->pprev->nChainTrust : 0) + pindex->GetBlockTrust();
{
pair<unsigned int, unsigned int> pos = make_pair(pindex->nFile, pindex->nBlockPos);
mapBlockPos[pos] = pindex;
- BOOST_FOREACH(const CTransaction &tx, block.vtx)
+ for (const CTransaction &tx : block.vtx)
{
uint256 hashTx = tx.GetHash();
CTxIndex txindex;
unsigned int nOutput = 0;
if (nCheckLevel>3)
{
- BOOST_FOREACH(const CDiskTxPos &txpos, txindex.vSpent)
+ for (const CDiskTxPos &txpos : txindex.vSpent)
{
if (!txpos.IsNull())
{
else
{
bool fFound = false;
- BOOST_FOREACH(const CTxIn &txin, txSpend.vin)
+ for (const CTxIn &txin : txSpend.vin)
if (txin.prevout.hash == hashTx && txin.prevout.n == nOutput)
fFound = true;
if (!fFound)
// check level 5: check whether all prevouts are marked spent
if (nCheckLevel>4)
{
- BOOST_FOREACH(const CTxIn &txin, tx.vin)
+ for (const CTxIn &txin : tx.vin)
{
CTxIndex txindex;
if (ReadTxIndex(txin.prevout.hash, txindex))
#include "sync.h"
#include "version.h"
#include "interface.h"
+
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
#include <boost/program_options/parsers.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
-
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/foreach.hpp>
#include <boost/thread.hpp>
#include <openssl/crypto.h>
#include <openssl/rand.h>
bool IsHex(const string& str)
{
- BOOST_FOREACH(unsigned char c, str)
+ for (unsigned char c : str)
{
if (phexdigit[c] < 0)
return false;
}
// New 0.6 features:
- BOOST_FOREACH(const PAIRTYPE(string,string)& entry, mapArgs)
+ for (const auto& entry : mapArgs)
{
string name = entry.first;
std::string EncodeDumpString(const std::string &str) {
std::stringstream ret;
- BOOST_FOREACH(unsigned char c, str) {
+ for (unsigned char c : str) {
if (c <= 32 || c >= 128 || c == '%') {
ret << '%' << HexStr(&c, &c + 1);
} else {
bool fMatch = false;
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
- BOOST_FOREACH(int64_t nOffset, vSorted)
+ for (int64_t nOffset : vSorted)
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
fMatch = true;
}
}
if (fDebug) {
- BOOST_FOREACH(int64_t n, vSorted)
+ for (int64_t n : vSorted)
printf("%+" PRId64 " ", n);
printf("| ");
}
{
LOCK(cs_wallet);
- BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys)
+ for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
{
if(!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
return false;
CCrypter crypter;
CKeyingMaterial vMasterKey;
- BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys)
+ for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
{
if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
return false;
{
LOCK(cs_wallet);
- BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys)
+ for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
{
if(!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
return false;
// Note: maintaining indices in the database of (account,time) --> txid and (account, time) --> acentry
// would make this much faster for applications that do this a lot.
- for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
+ for (auto & it : mapWallet)
{
- CWalletTx* wtx = &((*it).second);
- txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0)));
+ CWalletTx* wtx = &(it.second);
+ txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)nullptr)));
}
acentries.clear();
walletdb.ListAccountCreditDebit(strAccount, acentries);
- BOOST_FOREACH(CAccountingEntry& entry, acentries)
+ for (CAccountingEntry& entry : acentries)
{
- txOrdered.insert(make_pair(entry.nOrderPos, TxPair((CWalletTx*)0, &entry)));
+ txOrdered.insert(make_pair(entry.nOrderPos, TxPair((CWalletTx*)nullptr, &entry)));
}
return txOrdered;
// restored from backup or the user making copies of wallet.dat.
{
LOCK(cs_wallet);
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
{
map<uint256, CWalletTx>::iterator mi = mapWallet.find(txin.prevout.hash);
if (mi != mapWallet.end())
map<uint256, CWalletTx>::iterator mi = mapWallet.find(hash);
CWalletTx& wtx = (*mi).second;
- BOOST_FOREACH(const CTxOut& txout, tx.vout)
+ for (const CTxOut& txout : tx.vout)
{
if (IsMine(txout))
{
{
{
LOCK(cs_wallet);
- BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
+ for (auto& item : mapWallet)
item.second.MarkDirty();
}
}
// If default receiving address gets used, replace it with a new one
CScript scriptDefaultKey;
scriptDefaultKey.SetDestination(vchDefaultKey.GetID());
- BOOST_FOREACH(const CTxOut& txout, wtx.vout)
+ for (const CTxOut& txout : wtx.vout)
{
if (txout.scriptPubKey == scriptDefaultKey)
{
bool CWallet::IsMine(const CTransaction& tx) const
{
- BOOST_FOREACH(const CTxOut& txout, tx.vout)
+ for (const CTxOut& txout : tx.vout)
if (IsMine(txout) && txout.nValue >= nMinimumInputValue)
return true;
return false;
int64_t CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) const
{
int64_t nDebit = 0;
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
{
nDebit += GetDebit(txin, filter);
if (!MoneyRange(nDebit))
int64_t CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) const
{
int64_t nCredit = 0;
- BOOST_FOREACH(const CTxOut& txout, tx.vout)
+ for (const CTxOut& txout : tx.vout)
{
nCredit += GetCredit(txout, filter);
if (!MoneyRange(nCredit))
int64_t CWallet::GetChange(const CTransaction& tx) const
{
int64_t nChange = 0;
- BOOST_FOREACH(const CTxOut& txout, tx.vout)
+ for (const CTxOut& txout : tx.vout)
{
nChange += GetChange(txout);
if (!MoneyRange(nChange))
return false;
// Trusted if all inputs are from us and are in the mempool:
- BOOST_FOREACH(const CTxIn& txin, vin)
+ for (const CTxIn& txin : vin)
{
// Transactions not sent by us: not trusted
const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash);
}
// Sent/received.
- BOOST_FOREACH(const CTxOut& txout, vout)
+ for (const CTxOut& txout : vout)
{
isminetype fIsMine = pwallet->IsMine(txout);
// Only need to handle txouts if AT LEAST one of these is true:
nGenerated = allGeneratedMature;
if (strAccount == strSentAccount)
{
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& s, listSent)
+ for (const auto& s : listSent)
nSent += s.second;
nFee = allFee;
}
{
LOCK(pwallet->cs_wallet);
- BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& r, listReceived)
+ for (const auto& r : listReceived)
{
if (pwallet->mapAddressBook.count(r.first))
{
if (SetMerkleBranch() < COPY_DEPTH)
{
vector<uint256> vWorkQueue;
- BOOST_FOREACH(const CTxIn& txin, vin)
+ for (const CTxIn& txin : vin)
vWorkQueue.push_back(txin.prevout.hash);
// This critsect is OK because txdb is already open
if (mi != pwallet->mapWallet.end())
{
tx = (*mi).second;
- BOOST_FOREACH(const CMerkleTx& txWalletPrev, (*mi).second.vtxPrev)
+ for (const CMerkleTx& txWalletPrev : (*mi).second.vtxPrev)
mapWalletPrev[txWalletPrev.GetHash()] = &txWalletPrev;
}
else if (mapWalletPrev.count(hash))
if (nDepth < COPY_DEPTH)
{
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
vWorkQueue.push_back(txin.prevout.hash);
}
}
{
CBlock block;
block.ReadFromDisk(pindex, true);
- BOOST_FOREACH(CTransaction& tx, block.vtx)
+ for (CTransaction& tx : block.vtx)
{
if (AddToWalletIfInvolvingMe(tx, &block, fUpdate))
ret++;
LOCK(cs_wallet);
fRepeat = false;
vector<CDiskTxPos> vMissingTx;
- BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
+ for (auto& item : mapWallet)
{
CWalletTx& wtx = item.second;
if ((wtx.IsCoinBase() && wtx.IsSpent(0)) || (wtx.IsCoinStake() && wtx.IsSpent(1)))
LOCK(cs_wallet);
// Sort them in chronological order
map<unsigned int, CWalletTx*> mapSorted;
- BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
+ for (auto& item : mapWallet)
{
CWalletTx& wtx = item.second;
// Don't rebroadcast if newer than nTime:
continue;
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
}
- BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
+ for (auto& item : mapSorted)
{
CWalletTx& wtx = *item.second;
if (wtx.RelayWalletTransaction())
std::mt19937 g(rd());
shuffle(vCoins.begin(), vCoins.end(), g);
- BOOST_FOREACH(const COutput &output, vCoins)
+ for (const COutput &output : vCoins)
{
if (!output.fSpendable)
continue;
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
if (coinControl && coinControl->HasSelected())
{
- BOOST_FOREACH(const COutput& out, vCoins)
+ for (const COutput& out : vCoins)
{
if(!out.fSpendable)
continue;
setCoinsRet.clear();
nValueRet = 0;
- BOOST_FOREACH(COutput output, vCoins)
+ for (COutput output : vCoins)
{
if(!output.fSpendable)
continue;
bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl)
{
int64_t nValue = 0;
- BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
+ for (const auto& s : vecSend)
{
if (nValue < 0)
return false;
int64_t nTotalValue = nValue + nFeeRet;
double dPriority = 0;
// vouts to the payees
- BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
+ for (const auto& s : vecSend)
wtxNew.vout.push_back(CTxOut(s.second, s.first));
// Choose coins to use
int64_t nValueIn = 0;
if (!SelectCoins(nTotalValue, wtxNew.nTime, setCoins, nValueIn, coinControl))
return false;
- BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
+ for (auto pcoin : setCoins)
{
int64_t nCredit = pcoin.first->vout[pcoin.second].nValue;
dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain();
reservekey.ReturnKey();
// Fill vin
- BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
+ for (const auto& coin : setCoins)
wtxNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second));
// Sign
int nIn = 0;
- BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
+ for (const auto& coin : setCoins)
if (!SignSignature(*this, *coin.first, wtxNew, nIn++))
return false;
wtxNew.vout.push_back(CTxOut(0, scriptOutput));
double dWeight = 0;
- BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
+ for (auto pcoin : setCoins)
{
int64_t nCredit = pcoin.first->vout[pcoin.second].nValue;
// Sign
int nIn = 0;
- BOOST_FOREACH(const CWalletTx* pcoin, vwtxPrev)
+ for (const CWalletTx* pcoin : vwtxPrev)
{
if (!SignSignature(*this, *pcoin, txNew, nIn++))
return error("CreateCoinStake : failed to sign coinstake\n");
AddToWallet(wtxNew);
// Mark old coins as spent
- BOOST_FOREACH(const CTxIn& txin, wtxNew.vin)
+ for (const CTxIn& txin : wtxNew.vin)
{
CWalletTx &coin = mapWallet[txin.prevout.hash];
coin.BindWallet(this);
{
LOCK(cs_wallet);
CWalletDB walletdb(strWalletFile);
- BOOST_FOREACH(int64_t nIndex, setKeyPool)
+ for (int64_t nIndex : setKeyPool)
walletdb.ErasePool(nIndex);
setKeyPool.clear();
{
LOCK(cs_wallet);
- BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet)
+ for (auto walletEntry : mapWallet)
{
CWalletTx *pcoin = &walletEntry.second;
set< set<CBitcoinAddress> > groupings;
set<CBitcoinAddress> grouping;
- BOOST_FOREACH(PAIRTYPE(uint256, CWalletTx) walletEntry, mapWallet)
+ for (auto& walletEntry : mapWallet)
{
CWalletTx *pcoin = &walletEntry.second;
{
bool any_mine = false;
// group all input addresses with each other
- BOOST_FOREACH(CTxIn txin, pcoin->vin)
+ for (CTxIn txin : pcoin->vin)
{
CBitcoinAddress address;
if(!IsMine(txin)) // If this input isn't mine, ignore it
// group change with input addresses
if (any_mine)
{
- BOOST_FOREACH(CTxOut txout, pcoin->vout)
+ for (CTxOut txout : pcoin->vout)
if (IsChange(txout))
{
CBitcoinAddress txoutAddr;
set< set<CBitcoinAddress>* > uniqueGroupings; // a set of pointers to groups of addresses
map< CBitcoinAddress, set<CBitcoinAddress>* > setmap; // map addresses to the unique group containing it
- BOOST_FOREACH(set<CBitcoinAddress> grouping, groupings)
+ for (set<CBitcoinAddress> grouping : groupings)
{
// make a set of all the groups hit by this new group
set< set<CBitcoinAddress>* > hits;
map< CBitcoinAddress, set<CBitcoinAddress>* >::iterator it;
- BOOST_FOREACH(CBitcoinAddress address, grouping)
+ for (CBitcoinAddress address : grouping)
if ((it = setmap.find(address)) != setmap.end())
hits.insert((*it).second);
// merge all hit groups into a new single group and delete old groups
set<CBitcoinAddress>* merged = new set<CBitcoinAddress>(grouping);
- BOOST_FOREACH(set<CBitcoinAddress>* hit, hits)
+ for (set<CBitcoinAddress>* hit : hits)
{
merged->insert(hit->begin(), hit->end());
uniqueGroupings.erase(hit);
uniqueGroupings.insert(merged);
// update setmap
- BOOST_FOREACH(CBitcoinAddress element, *merged)
+ for (CBitcoinAddress element : *merged)
setmap[element] = merged;
}
set< set<CBitcoinAddress> > ret;
- BOOST_FOREACH(set<CBitcoinAddress>* uniqueGrouping, uniqueGroupings)
+ for (set<CBitcoinAddress>* uniqueGrouping : uniqueGroupings)
{
ret.insert(*uniqueGrouping);
delete uniqueGrouping;
vCoins.push_back(&(*it).second);
CTxDB txdb("r");
- BOOST_FOREACH(CWalletTx* pcoin, vCoins)
+ for (CWalletTx* pcoin : vCoins)
{
// Find the corresponding transaction index
CTxIndex txindex;
return; // only disconnecting coinstake requires marking input unspent
LOCK(cs_wallet);
- BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ for (const CTxIn& txin : tx.vin)
{
map<uint256, CWalletTx>::iterator mi = mapWallet.find(txin.prevout.hash);
if (mi != mapWallet.end())
CWalletDB walletdb(strWalletFile);
LOCK2(cs_main, cs_wallet);
- BOOST_FOREACH(const int64_t& id, setKeyPool)
+ for (const int64_t& id : setKeyPool)
{
CKeyPool keypool;
if (!walletdb.ReadPool(id, keypool))
pthis->mapValue["fromaccount"] = pthis->strFromAccount;
std::string str;
- BOOST_FOREACH(char f, vfSpent)
+ for (char f : vfSpent)
{
str += (f ? '1' : '0');
if (f)
pthis->strFromAccount = pthis->mapValue["fromaccount"];
if (mapValue.count("spent"))
- BOOST_FOREACH(char c, pthis->mapValue["spent"])
+ for (char c : pthis->mapValue["spent"])
pthis->vfSpent.push_back(c != '0');
else
pthis->vfSpent.assign(vout.size(), fSpent);
ListAccountCreditDebit(strAccount, entries);
int64_t nCreditDebit = 0;
- BOOST_FOREACH (const CAccountingEntry& entry, entries)
+ for (const CAccountingEntry& entry : entries)
nCreditDebit += entry.nCreditDebit;
return nCreditDebit;
}
list<CAccountingEntry> acentries;
ListAccountCreditDebit("", acentries);
- BOOST_FOREACH(CAccountingEntry& entry, acentries)
+ for (CAccountingEntry& entry : acentries)
{
txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));
}
else
{
int64_t nOrderPosOff = 0;
- BOOST_FOREACH(const int64_t& nOffsetStart, nOrderPosOffsets)
+ for (const int64_t& nOffsetStart : nOrderPosOffsets)
{
if (nOrderPos >= nOffsetStart)
++nOrderPosOff;
pwallet->nTimeFirstKey = 1; // 0 would be considered 'no value'
- BOOST_FOREACH(uint256 hash, wss.vWalletUpgrade)
+ for (uint256 hash : wss.vWalletUpgrade)
WriteTx(hash, pwallet->mapWallet[hash]);
// Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
return err;
// erase each wallet TX
- BOOST_FOREACH (uint256& hash, vTxHash) {
+ for (uint256& hash : vTxHash) {
if (!EraseTx(hash))
return DB_CORRUPT;
}
CWalletScanState wss;
DbTxn* ptxn = dbenv.TxnBegin();
- BOOST_FOREACH(CDBEnv::KeyValPair& row, salvagedData)
+ for (CDBEnv::KeyValPair& row : salvagedData)
{
if (fOnlyKeys)
{