{
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))