|
|
@ -701,9 +701,9 @@ DBErrors CWallet::ReorderTransactions() |
|
|
|
typedef std::multimap<int64_t, TxPair > TxItems; |
|
|
|
typedef std::multimap<int64_t, TxPair > TxItems; |
|
|
|
TxItems txByTime; |
|
|
|
TxItems txByTime; |
|
|
|
|
|
|
|
|
|
|
|
for (std::map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (auto& entry : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CWalletTx* wtx = &((*it).second); |
|
|
|
CWalletTx* wtx = &entry.second; |
|
|
|
txByTime.insert(std::make_pair(wtx->nTimeReceived, TxPair(wtx, nullptr))); |
|
|
|
txByTime.insert(std::make_pair(wtx->nTimeReceived, TxPair(wtx, nullptr))); |
|
|
|
} |
|
|
|
} |
|
|
|
std::list<CAccountingEntry> acentries; |
|
|
|
std::list<CAccountingEntry> acentries; |
|
|
@ -1966,9 +1966,9 @@ CAmount CWallet::GetBalance() const |
|
|
|
CAmount nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (const auto& entry : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CWalletTx* pcoin = &(*it).second; |
|
|
|
const CWalletTx* pcoin = &entry.second; |
|
|
|
if (pcoin->IsTrusted()) |
|
|
|
if (pcoin->IsTrusted()) |
|
|
|
nTotal += pcoin->GetAvailableCredit(); |
|
|
|
nTotal += pcoin->GetAvailableCredit(); |
|
|
|
} |
|
|
|
} |
|
|
@ -1982,9 +1982,9 @@ CAmount CWallet::GetUnconfirmedBalance() const |
|
|
|
CAmount nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (const auto& entry : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CWalletTx* pcoin = &(*it).second; |
|
|
|
const CWalletTx* pcoin = &entry.second; |
|
|
|
if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && pcoin->InMempool()) |
|
|
|
if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && pcoin->InMempool()) |
|
|
|
nTotal += pcoin->GetAvailableCredit(); |
|
|
|
nTotal += pcoin->GetAvailableCredit(); |
|
|
|
} |
|
|
|
} |
|
|
@ -1997,9 +1997,9 @@ CAmount CWallet::GetImmatureBalance() const |
|
|
|
CAmount nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (const auto& entry : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CWalletTx* pcoin = &(*it).second; |
|
|
|
const CWalletTx* pcoin = &entry.second; |
|
|
|
nTotal += pcoin->GetImmatureCredit(); |
|
|
|
nTotal += pcoin->GetImmatureCredit(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2011,9 +2011,9 @@ CAmount CWallet::GetWatchOnlyBalance() const |
|
|
|
CAmount nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (const auto& entry : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CWalletTx* pcoin = &(*it).second; |
|
|
|
const CWalletTx* pcoin = &entry.second; |
|
|
|
if (pcoin->IsTrusted()) |
|
|
|
if (pcoin->IsTrusted()) |
|
|
|
nTotal += pcoin->GetAvailableWatchOnlyCredit(); |
|
|
|
nTotal += pcoin->GetAvailableWatchOnlyCredit(); |
|
|
|
} |
|
|
|
} |
|
|
@ -2027,9 +2027,9 @@ CAmount CWallet::GetUnconfirmedWatchOnlyBalance() const |
|
|
|
CAmount nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (const auto& entry : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CWalletTx* pcoin = &(*it).second; |
|
|
|
const CWalletTx* pcoin = &entry.second; |
|
|
|
if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && pcoin->InMempool()) |
|
|
|
if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && pcoin->InMempool()) |
|
|
|
nTotal += pcoin->GetAvailableWatchOnlyCredit(); |
|
|
|
nTotal += pcoin->GetAvailableWatchOnlyCredit(); |
|
|
|
} |
|
|
|
} |
|
|
@ -2042,9 +2042,9 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const |
|
|
|
CAmount nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (const auto& entry : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CWalletTx* pcoin = &(*it).second; |
|
|
|
const CWalletTx* pcoin = &entry.second; |
|
|
|
nTotal += pcoin->GetImmatureWatchOnlyCredit(); |
|
|
|
nTotal += pcoin->GetImmatureWatchOnlyCredit(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2118,10 +2118,10 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, const |
|
|
|
|
|
|
|
|
|
|
|
CAmount nTotal = 0; |
|
|
|
CAmount nTotal = 0; |
|
|
|
|
|
|
|
|
|
|
|
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) |
|
|
|
for (const auto& entry : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const uint256& wtxid = it->first; |
|
|
|
const uint256& wtxid = entry.first; |
|
|
|
const CWalletTx* pcoin = &(*it).second; |
|
|
|
const CWalletTx* pcoin = &entry.second; |
|
|
|
|
|
|
|
|
|
|
|
if (!CheckFinalTx(*pcoin)) |
|
|
|
if (!CheckFinalTx(*pcoin)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -2182,10 +2182,10 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, const |
|
|
|
if (pcoin->tx->vout[i].nValue < nMinimumAmount || pcoin->tx->vout[i].nValue > nMaximumAmount) |
|
|
|
if (pcoin->tx->vout[i].nValue < nMinimumAmount || pcoin->tx->vout[i].nValue > nMaximumAmount) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(COutPoint((*it).first, i))) |
|
|
|
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(COutPoint(entry.first, i))) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
if (IsLockedCoin((*it).first, i)) |
|
|
|
if (IsLockedCoin(entry.first, i)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
if (IsSpent(wtxid, i)) |
|
|
|
if (IsSpent(wtxid, i)) |
|
|
@ -3640,9 +3640,9 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) c |
|
|
|
|
|
|
|
|
|
|
|
// find first block that affects those keys, if there are any left
|
|
|
|
// find first block that affects those keys, if there are any left
|
|
|
|
std::vector<CKeyID> vAffected; |
|
|
|
std::vector<CKeyID> vAffected; |
|
|
|
for (std::map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); it++) { |
|
|
|
for (const auto& entry : mapWallet) { |
|
|
|
// iterate over all wallet transactions...
|
|
|
|
// iterate over all wallet transactions...
|
|
|
|
const CWalletTx &wtx = (*it).second; |
|
|
|
const CWalletTx &wtx = entry.second; |
|
|
|
BlockMap::const_iterator blit = mapBlockIndex.find(wtx.hashBlock); |
|
|
|
BlockMap::const_iterator blit = mapBlockIndex.find(wtx.hashBlock); |
|
|
|
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) { |
|
|
|
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) { |
|
|
|
// ... which are already in a block
|
|
|
|
// ... which are already in a block
|
|
|
@ -3662,8 +3662,8 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) c |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Extract block timestamps for those keys
|
|
|
|
// Extract block timestamps for those keys
|
|
|
|
for (std::map<CKeyID, CBlockIndex*>::const_iterator it = mapKeyFirstBlock.begin(); it != mapKeyFirstBlock.end(); it++) |
|
|
|
for (const auto& entry : mapKeyFirstBlock) |
|
|
|
mapKeyBirth[it->first] = it->second->GetBlockTime() - TIMESTAMP_WINDOW; // block times can be 2h off
|
|
|
|
mapKeyBirth[entry.first] = entry.second->GetBlockTime() - TIMESTAMP_WINDOW; // block times can be 2h off
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|