Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,347 Lines • ▼ Show 20 Lines | void MaybeResendWalletTxs() { | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* @defgroup Actions | * @defgroup Actions | ||||
* | * | ||||
* @{ | * @{ | ||||
*/ | */ | ||||
Amount CWallet::GetBalance(const isminefilter &filter, | CWallet::Balance CWallet::GetBalance(const int min_depth) const { | ||||
const int min_depth) const { | Balance ret; | ||||
auto locked_chain = chain().lock(); | auto locked_chain = chain().lock(); | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
Amount nTotal = Amount::zero(); | |||||
for (const auto &entry : mapWallet) { | |||||
const CWalletTx &wtx = entry.second; | |||||
if (wtx.IsTrusted(*locked_chain) && | |||||
wtx.GetDepthInMainChain(*locked_chain) >= min_depth) { | |||||
nTotal += wtx.GetAvailableCredit(*locked_chain, true, filter); | |||||
} | |||||
} | |||||
return nTotal; | |||||
} | |||||
Amount CWallet::GetUnconfirmedBalance() const { | |||||
auto locked_chain = chain().lock(); | |||||
LOCK(cs_wallet); | |||||
Amount nTotal = Amount::zero(); | |||||
for (const auto &entry : mapWallet) { | |||||
const CWalletTx &wtx = entry.second; | |||||
if (!wtx.IsTrusted(*locked_chain) && | |||||
wtx.GetDepthInMainChain(*locked_chain) == 0 && wtx.InMempool()) { | |||||
nTotal += wtx.GetAvailableCredit(*locked_chain); | |||||
} | |||||
} | |||||
return nTotal; | |||||
} | |||||
Amount CWallet::GetImmatureBalance() const { | |||||
auto locked_chain = chain().lock(); | |||||
LOCK(cs_wallet); | |||||
Amount nTotal = Amount::zero(); | |||||
for (const auto &entry : mapWallet) { | for (const auto &entry : mapWallet) { | ||||
const CWalletTx &wtx = entry.second; | const CWalletTx &wtx = entry.second; | ||||
nTotal += wtx.GetImmatureCredit(*locked_chain); | const bool is_trusted{wtx.IsTrusted(*locked_chain)}; | ||||
const int tx_depth{wtx.GetDepthInMainChain(*locked_chain)}; | |||||
const Amount tx_credit_mine{wtx.GetAvailableCredit( | |||||
*locked_chain, /* fUseCache */ true, ISMINE_SPENDABLE)}; | |||||
const Amount tx_credit_watchonly{wtx.GetAvailableCredit( | |||||
*locked_chain, /* fUseCache */ true, ISMINE_WATCH_ONLY)}; | |||||
if (is_trusted && tx_depth >= min_depth) { | |||||
ret.m_mine_trusted += tx_credit_mine; | |||||
ret.m_watchonly_trusted += tx_credit_watchonly; | |||||
} | |||||
if (!is_trusted && tx_depth == 0 && wtx.InMempool()) { | |||||
ret.m_mine_untrusted_pending += tx_credit_mine; | |||||
ret.m_watchonly_untrusted_pending += tx_credit_watchonly; | |||||
} | |||||
ret.m_mine_immature += wtx.GetImmatureCredit(*locked_chain); | |||||
ret.m_watchonly_immature += | |||||
wtx.GetImmatureWatchOnlyCredit(*locked_chain); | |||||
} | } | ||||
return ret; | |||||
return nTotal; | |||||
} | |||||
Amount CWallet::GetUnconfirmedWatchOnlyBalance() const { | |||||
auto locked_chain = chain().lock(); | |||||
LOCK(cs_wallet); | |||||
Amount nTotal = Amount::zero(); | |||||
for (const auto &entry : mapWallet) { | |||||
const CWalletTx &wtx = entry.second; | |||||
if (!wtx.IsTrusted(*locked_chain) && | |||||
wtx.GetDepthInMainChain(*locked_chain) == 0 && wtx.InMempool()) { | |||||
nTotal += | |||||
wtx.GetAvailableCredit(*locked_chain, true, ISMINE_WATCH_ONLY); | |||||
} | |||||
} | |||||
return nTotal; | |||||
} | |||||
Amount CWallet::GetImmatureWatchOnlyBalance() const { | |||||
auto locked_chain = chain().lock(); | |||||
LOCK(cs_wallet); | |||||
Amount nTotal = Amount::zero(); | |||||
for (const auto &entry : mapWallet) { | |||||
const CWalletTx &wtx = entry.second; | |||||
nTotal += wtx.GetImmatureWatchOnlyCredit(*locked_chain); | |||||
} | |||||
return nTotal; | |||||
} | } | ||||
Amount CWallet::GetAvailableBalance(const CCoinControl *coinControl) const { | Amount CWallet::GetAvailableBalance(const CCoinControl *coinControl) const { | ||||
auto locked_chain = chain().lock(); | auto locked_chain = chain().lock(); | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
Amount balance = Amount::zero(); | Amount balance = Amount::zero(); | ||||
std::vector<COutput> vCoins; | std::vector<COutput> vCoins; | ||||
▲ Show 20 Lines • Show All 2,537 Lines • Show Last 20 Lines |