mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
[wallet] Remove unneeded legacy getbalance code
This commit is contained in:
@@ -1457,41 +1457,6 @@ void CWalletTx::GetAmounts(std::list<COutputEntry>& listReceived,
|
||||
|
||||
}
|
||||
|
||||
void CWalletTx::GetAccountAmounts(const std::string& strAccount, CAmount& nReceived,
|
||||
CAmount& nSent, CAmount& nFee, const isminefilter& filter) const
|
||||
{
|
||||
nReceived = nSent = nFee = 0;
|
||||
|
||||
CAmount allFee;
|
||||
std::string strSentAccount;
|
||||
std::list<COutputEntry> listReceived;
|
||||
std::list<COutputEntry> listSent;
|
||||
GetAmounts(listReceived, listSent, allFee, strSentAccount, filter);
|
||||
|
||||
if (strAccount == strSentAccount)
|
||||
{
|
||||
BOOST_FOREACH(const COutputEntry& s, listSent)
|
||||
nSent += s.amount;
|
||||
nFee = allFee;
|
||||
}
|
||||
{
|
||||
LOCK(pwallet->cs_wallet);
|
||||
BOOST_FOREACH(const COutputEntry& r, listReceived)
|
||||
{
|
||||
if (pwallet->mapAddressBook.count(r.destination))
|
||||
{
|
||||
std::map<CTxDestination, CAddressBookData>::const_iterator mi = pwallet->mapAddressBook.find(r.destination);
|
||||
if (mi != pwallet->mapAddressBook.end() && (*mi).second.name == strAccount)
|
||||
nReceived += r.amount;
|
||||
}
|
||||
else if (strAccount.empty())
|
||||
{
|
||||
nReceived += r.amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan the block chain (starting in pindexStart) for transactions
|
||||
* from or to us. If fUpdate is true, found transactions that already
|
||||
@@ -3315,37 +3280,6 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||
return ret;
|
||||
}
|
||||
|
||||
CAmount CWallet::GetAccountBalance(const std::string& strAccount, int nMinDepth, const isminefilter& filter)
|
||||
{
|
||||
CWalletDB walletdb(*dbw);
|
||||
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
|
||||
}
|
||||
|
||||
CAmount CWallet::GetAccountBalance(CWalletDB& walletdb, const std::string& strAccount, int nMinDepth, const isminefilter& filter)
|
||||
{
|
||||
CAmount nBalance = 0;
|
||||
|
||||
// Tally wallet transactions
|
||||
for (std::map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 0)
|
||||
continue;
|
||||
|
||||
CAmount nReceived, nSent, nFee;
|
||||
wtx.GetAccountAmounts(strAccount, nReceived, nSent, nFee, filter);
|
||||
|
||||
if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)
|
||||
nBalance += nReceived;
|
||||
nBalance -= nSent + nFee;
|
||||
}
|
||||
|
||||
// Tally internal accounting entries
|
||||
nBalance += walletdb.GetAccountCreditDebit(strAccount);
|
||||
|
||||
return nBalance;
|
||||
}
|
||||
|
||||
std::set<CTxDestination> CWallet::GetAccountAddresses(const std::string& strAccount) const
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
|
||||
Reference in New Issue
Block a user