if (fCompressed)
SetMinVersion(FEATURE_COMPRPUBKEY);
- CPubKey pubkey = key.GetPubKey();
+ auto pubkey = key.GetPubKey();
// Create new metadata
int64_t nCreationTime = GetTime();
bool CWallet::AddKey(const CKey& key)
{
- CPubKey pubkey = key.GetPubKey();
+ auto pubkey = key.GetPubKey();
if (!CCryptoKeyStore::AddKey(key))
return false;
if (!fFileBacked)
bool CWallet::AddKey(const CMalleableKey& mKey)
{
- CMalleableKeyView keyView = CMalleableKeyView(mKey);
- CSecret vchSecretH = mKey.GetSecretH();
+ auto keyView = CMalleableKeyView(mKey);
+ auto vchSecretH = mKey.GetSecretH();
if (!CCryptoKeyStore::AddMalleableKey(keyView, vchSecretH))
return false;
if (!fFileBacked)
// restored from backup or the user making copies of wallet.dat.
{
LOCK(cs_wallet);
- for(const CTxIn& txin : tx.vin)
+ for(const auto& txin : tx.vin)
{
- map<uint256, CWalletTx>::iterator mi = mapWallet.find(txin.prevout.hash);
+ auto mi = mapWallet.find(txin.prevout.hash);
if (mi != mapWallet.end())
{
- CWalletTx& wtx = (*mi).second;
+ auto& wtx = (*mi).second;
if (txin.prevout.n >= wtx.vout.size())
printf("WalletUpdateSpent: bad wtx %s\n", wtx.GetHash().ToString().c_str());
else if (!wtx.IsSpent(txin.prevout.n) && IsMine(wtx.vout[txin.prevout.n]))
if (fBlock)
{
- uint256 hash = tx.GetHash();
- map<uint256, CWalletTx>::iterator mi = mapWallet.find(hash);
- CWalletTx& wtx = (*mi).second;
+ auto hash = tx.GetHash();
+ auto mi = mapWallet.find(hash);
+ auto& wtx = (*mi).second;
for(const CTxOut& txout : tx.vout)
{
{
LOCK(cs_wallet);
// Inserts only if not already there, returns tx inserted or tx found
- pair<map<uint256, CWalletTx>::iterator, bool> ret = mapWallet.insert(make_pair(hash, wtxIn));
- CWalletTx& wtx = (*ret.first).second;
+ auto ret = mapWallet.insert(make_pair(hash, wtxIn));
+ auto& wtx = (*ret.first).second;
wtx.BindWallet(this);
bool fInsertedNew = ret.second;
if (fInsertedNew)
// Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future
int64_t latestTolerated = latestNow + 300;
std::list<CAccountingEntry> acentries;
- TxItems txOrdered = OrderedTxItems(acentries);
+ auto txOrdered = OrderedTxItems(acentries);
for (auto it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
{
CWalletTx *const pwtx = (*it).second.first;
// Sent/received.
for(const CTxOut& txout : vout)
{
- isminetype fIsMine = pwallet->IsMine(txout);
+ auto fIsMine = pwallet->IsMine(txout);
// Only need to handle txouts if AT LEAST one of these is true:
// 1) they debit from us (sent)
// 2) the output is to us (received)
vector<CDiskTxPos> vMissingTx;
for(auto& item : mapWallet)
{
- CWalletTx& wtx = item.second;
+ auto& wtx = item.second;
if ((wtx.IsCoinBase() && wtx.IsSpent(0)) || (wtx.IsCoinStake() && wtx.IsSpent(1)))
continue;
map<unsigned int, CWalletTx*> mapSorted;
for(auto& item : mapWallet)
{
- CWalletTx& wtx = item.second;
+ auto& wtx = item.second;
// Don't rebroadcast if newer than nTime:
if (wtx.nTimeReceived > nTime)
continue;
}
for(auto& item : mapSorted)
{
- CWalletTx& wtx = *item.second;
+ auto& wtx = *item.second;
if (wtx.RelayWalletTransaction())
result.push_back(wtx.GetHash());
}
continue;
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
- isminetype mine = IsMine(pcoin->vout[i]);
+ auto mine = IsMine(pcoin->vout[i]);
if (!(pcoin->IsSpent(i)) && mine != MINE_NO &&
pcoin->vout[i].nValue >= nMinimumInputValue &&
(!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i)))
continue;
for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
- isminetype mine = IsMine(pcoin->vout[i]);
+ auto mine = IsMine(pcoin->vout[i]);
// ignore coin if it was already spent or we don't own it
if (pcoin->IsSpent(i) || mine == MINE_NO)
// post-backup change.
// Reserve a new key pair from key pool
- CPubKey vchPubKey = reservekey.GetReservedKey();
+ auto vchPubKey = reservekey.GetReservedKey();
scriptChange.SetDestination(vchPubKey.GetID());
}
// Insert change txn at random position:
- vector<CTxOut>::iterator position = wtxNew.vout.begin()+GetRandInt(wtxNew.vout.size());
+ auto position = wtxNew.vout.begin()+GetRandInt(wtxNew.vout.size());
wtxNew.vout.insert(position, CTxOut(nChange, scriptChange));
}
else
return;
}
- CBigNum bnCoinDayWeight = CBigNum(nValue) * nTimeWeight / COIN / nOneDay;
+ auto bnCoinDayWeight = CBigNum(nValue) * nTimeWeight / COIN / nOneDay;
nWeight = bnCoinDayWeight.getuint64();
}
// Reserve a new key pair from key pool
CReserveKey reservekey(this);
- CPubKey vchPubKey = reservekey.GetReservedKey();
+ auto vchPubKey = reservekey.GetReservedKey();
// Output script
CScript scriptOutput;
vector<valtype> vSolutions;
txnouttype whichType;
CScript scriptPubKeyOut;
- CScript scriptPubKeyKernel = wtx.vout[nOut].scriptPubKey;
+ auto scriptPubKeyKernel = wtx.vout[nOut].scriptPubKey;
if (!Solver(scriptPubKeyKernel, whichType, vSolutions))
return error("CreateCoinStake : failed to parse kernel\n");
// * Value is higher than 0.01 NVC;
// * Only add inputs of the same key/address as kernel;
// * Input hash and kernel parent hash should be different.
- for(CoinsSet::iterator pcoin = setCoins.begin(); pcoin != setCoins.end(); pcoin++)
+ for(auto pcoin = setCoins.begin(); pcoin != setCoins.end(); pcoin++)
{
// Stop adding more inputs if already too many inputs
if (txNew.vin.size() >= 100)
bool CWallet::SetAddressBookName(const CBitcoinAddress& address, const string& strName)
{
- std::map<CBitcoinAddress, string>::iterator mi = mapAddressBook.find(address);
+ auto mi = mapAddressBook.find(address);
mapAddressBook[address] = strName;
NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address) != MINE_NO, (mi == mapAddressBook.end()) ? CT_NEW : CT_UPDATED);
if (!fFileBacked)
LOCK(cs_wallet);
if (block.IsProofOfStake() && mapWallet.count(block.vtx[1].GetHash()))
{
- CWalletTx& wtx = mapWallet[block.vtx[1].GetHash()];
+ auto& wtx = mapWallet[block.vtx[1].GetHash()];
printf(" PoS: %d %d %" PRId64 "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit(MINE_ALL));
}
else if (mapWallet.count(block.vtx[0].GetHash()))
{
- CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()];
+ auto& wtx = mapWallet[block.vtx[0].GetHash()];
printf(" PoW: %d %d %" PRId64 "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit(MINE_ALL));
}
}
{
{
LOCK(cs_wallet);
- map<uint256, CWalletTx>::iterator mi = mapWallet.find(hashTx);
+ auto mi = mapWallet.find(hashTx);
if (mi != mapWallet.end())
{
wtx = (*mi).second;
for(CTxOut txout : pcoin->vout)
if (IsChange(txout))
{
- CWalletTx tx = mapWallet[pcoin->vin[0].prevout.hash];
+ auto tx = mapWallet[pcoin->vin[0].prevout.hash];
CBitcoinAddress txoutAddr;
if(!ExtractAddress(*this, txout.scriptPubKey, txoutAddr))
continue;
return; // only disconnecting coinstake requires marking input unspent
LOCK(cs_wallet);
- for(const CTxIn& txin : tx.vin)
+ for(const auto& txin : tx.vin)
{
- map<uint256, CWalletTx>::iterator mi = mapWallet.find(txin.prevout.hash);
+ auto mi = mapWallet.find(txin.prevout.hash);
if (mi != mapWallet.end())
{
- CWalletTx& prev = (*mi).second;
+ auto& prev = (*mi).second;
if (txin.prevout.n < prev.vout.size() && IsMine(prev.vout[txin.prevout.n]))
{
prev.MarkUnspent(txin.prevout.n);