mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Extend #15747: Remove some Dash Get*Balance
This commit is contained in:
parent
f43b8216b1
commit
fa8300f6cc
@ -812,8 +812,10 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto bal = mixingWallet.GetBalance();
|
||||||
|
|
||||||
// check if there is anything left to do
|
// check if there is anything left to do
|
||||||
CAmount nBalanceAnonymized = mixingWallet.GetAnonymizedBalance();
|
CAmount nBalanceAnonymized = bal.m_anonymized;
|
||||||
nBalanceNeedsAnonymized = CCoinJoinClientOptions::GetAmount() * COIN - nBalanceAnonymized;
|
nBalanceNeedsAnonymized = CCoinJoinClientOptions::GetAmount() * COIN - nBalanceAnonymized;
|
||||||
|
|
||||||
if (nBalanceNeedsAnonymized < 0) {
|
if (nBalanceNeedsAnonymized < 0) {
|
||||||
@ -843,8 +845,8 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr
|
|||||||
// excluding denoms
|
// excluding denoms
|
||||||
CAmount nBalanceAnonimizableNonDenom = mixingWallet.GetAnonymizableBalance(true);
|
CAmount nBalanceAnonimizableNonDenom = mixingWallet.GetAnonymizableBalance(true);
|
||||||
// denoms
|
// denoms
|
||||||
CAmount nBalanceDenominatedConf = mixingWallet.GetDenominatedBalance();
|
CAmount nBalanceDenominatedConf = bal.m_denominated_trusted;
|
||||||
CAmount nBalanceDenominatedUnconf = mixingWallet.GetDenominatedBalance(true);
|
CAmount nBalanceDenominatedUnconf = bal.m_denominated_untrusted_pending;
|
||||||
CAmount nBalanceDenominated = nBalanceDenominatedConf + nBalanceDenominatedUnconf;
|
CAmount nBalanceDenominated = nBalanceDenominatedConf + nBalanceDenominatedUnconf;
|
||||||
CAmount nBalanceToDenominate = CCoinJoinClientOptions::GetAmount() * COIN - nBalanceDenominated;
|
CAmount nBalanceToDenominate = CCoinJoinClientOptions::GetAmount() * COIN - nBalanceDenominated;
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ public:
|
|||||||
result.balance = bal.m_mine_trusted;
|
result.balance = bal.m_mine_trusted;
|
||||||
result.unconfirmed_balance = bal.m_mine_untrusted_pending;
|
result.unconfirmed_balance = bal.m_mine_untrusted_pending;
|
||||||
result.immature_balance = bal.m_mine_immature;
|
result.immature_balance = bal.m_mine_immature;
|
||||||
result.anonymized_balance = m_wallet->GetAnonymizedBalance();
|
result.anonymized_balance = bal.m_anonymized;
|
||||||
result.have_watch_only = m_wallet->HaveWatchOnly();
|
result.have_watch_only = m_wallet->HaveWatchOnly();
|
||||||
if (result.have_watch_only) {
|
if (result.have_watch_only) {
|
||||||
result.watch_only_balance = bal.m_watchonly_trusted;
|
result.watch_only_balance = bal.m_watchonly_trusted;
|
||||||
@ -419,11 +419,16 @@ public:
|
|||||||
}
|
}
|
||||||
CAmount getAnonymizedBalance() override
|
CAmount getAnonymizedBalance() override
|
||||||
{
|
{
|
||||||
return m_wallet->GetAnonymizedBalance();
|
return m_wallet->GetBalance().m_anonymized;
|
||||||
}
|
}
|
||||||
CAmount getDenominatedBalance(bool unconfirmed) override
|
CAmount getDenominatedBalance(bool unconfirmed) override
|
||||||
{
|
{
|
||||||
return m_wallet->GetDenominatedBalance(unconfirmed);
|
const auto bal = m_wallet->GetBalance();
|
||||||
|
if (unconfirmed) {
|
||||||
|
return bal.m_denominated_untrusted_pending;
|
||||||
|
} else {
|
||||||
|
return bal.m_denominated_trusted;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CAmount getNormalizedAnonymizedBalance() override
|
CAmount getNormalizedAnonymizedBalance() override
|
||||||
{
|
{
|
||||||
@ -436,7 +441,7 @@ public:
|
|||||||
CAmount getAvailableBalance(const CCoinControl& coin_control) override
|
CAmount getAvailableBalance(const CCoinControl& coin_control) override
|
||||||
{
|
{
|
||||||
if (coin_control.IsUsingCoinJoin()) {
|
if (coin_control.IsUsingCoinJoin()) {
|
||||||
return m_wallet->GetAnonymizedBalance(&coin_control);
|
return m_wallet->GetBalance(0, false, &coin_control).m_anonymized;
|
||||||
} else {
|
} else {
|
||||||
return m_wallet->GetAvailableBalance(&coin_control);
|
return m_wallet->GetAvailableBalance(&coin_control);
|
||||||
}
|
}
|
||||||
|
@ -2648,7 +2648,7 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
|
|||||||
obj.pushKV("walletname", pwallet->GetName());
|
obj.pushKV("walletname", pwallet->GetName());
|
||||||
obj.pushKV("walletversion", pwallet->GetVersion());
|
obj.pushKV("walletversion", pwallet->GetVersion());
|
||||||
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
|
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
|
||||||
obj.pushKV("coinjoin_balance", ValueFromAmount(pwallet->GetAnonymizedBalance()));
|
obj.pushKV("coinjoin_balance", ValueFromAmount(bal.m_anonymized));
|
||||||
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
|
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
|
||||||
obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));
|
obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));
|
||||||
obj.pushKV("txcount", (int)pwallet->mapWallet.size());
|
obj.pushKV("txcount", (int)pwallet->mapWallet.size());
|
||||||
|
@ -2649,7 +2649,7 @@ std::unordered_set<const CWalletTx*, WalletTxHasher> CWallet::GetSpendableTXs()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CWallet::Balance CWallet::GetBalance(const int min_depth, const bool fAddLocked) const
|
CWallet::Balance CWallet::GetBalance(const int min_depth, const bool fAddLocked, const CCoinControl* coinControl) const
|
||||||
{
|
{
|
||||||
Balance ret;
|
Balance ret;
|
||||||
{
|
{
|
||||||
@ -2669,6 +2669,11 @@ CWallet::Balance CWallet::GetBalance(const int min_depth, const bool fAddLocked)
|
|||||||
}
|
}
|
||||||
ret.m_mine_immature += pcoin->GetImmatureCredit();
|
ret.m_mine_immature += pcoin->GetImmatureCredit();
|
||||||
ret.m_watchonly_immature += pcoin->GetImmatureWatchOnlyCredit();
|
ret.m_watchonly_immature += pcoin->GetImmatureWatchOnlyCredit();
|
||||||
|
if (CCoinJoinClientOptions::IsEnabled()) {
|
||||||
|
ret.m_anonymized += pcoin->GetAnonymizedCredit(coinControl);
|
||||||
|
ret.m_denominated_trusted += pcoin->GetDenominatedCredit(false);
|
||||||
|
ret.m_denominated_untrusted_pending += pcoin->GetDenominatedCredit(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -2696,21 +2701,6 @@ CAmount CWallet::GetAnonymizableBalance(bool fSkipDenominated, bool fSkipUnconfi
|
|||||||
return nTotal;
|
return nTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAmount CWallet::GetAnonymizedBalance(const CCoinControl* coinControl) const
|
|
||||||
{
|
|
||||||
if (!CCoinJoinClientOptions::IsEnabled()) return 0;
|
|
||||||
|
|
||||||
CAmount nTotal = 0;
|
|
||||||
|
|
||||||
LOCK2(cs_main, cs_wallet);
|
|
||||||
|
|
||||||
for (auto pcoin : GetSpendableTXs()) {
|
|
||||||
nTotal += pcoin->GetAnonymizedCredit(coinControl);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: calculated including unconfirmed,
|
// Note: calculated including unconfirmed,
|
||||||
// that's ok as long as we use it for informational purposes only
|
// that's ok as long as we use it for informational purposes only
|
||||||
float CWallet::GetAverageAnonymizedRounds() const
|
float CWallet::GetAverageAnonymizedRounds() const
|
||||||
@ -2757,21 +2747,6 @@ CAmount CWallet::GetNormalizedAnonymizedBalance() const
|
|||||||
return nTotal;
|
return nTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAmount CWallet::GetDenominatedBalance(bool unconfirmed) const
|
|
||||||
{
|
|
||||||
if (!CCoinJoinClientOptions::IsEnabled()) return 0;
|
|
||||||
|
|
||||||
CAmount nTotal = 0;
|
|
||||||
|
|
||||||
LOCK2(cs_main, cs_wallet);
|
|
||||||
|
|
||||||
for (auto pcoin : GetSpendableTXs()) {
|
|
||||||
nTotal += pcoin->GetDenominatedCredit(unconfirmed);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate total balance in a different way from GetBalance. The biggest
|
// Calculate total balance in a different way from GetBalance. The biggest
|
||||||
// difference is that GetBalance sums up all unspent TxOuts paying to the
|
// difference is that GetBalance sums up all unspent TxOuts paying to the
|
||||||
// wallet, while this sums up both spent and unspent TxOuts paying to the
|
// wallet, while this sums up both spent and unspent TxOuts paying to the
|
||||||
|
@ -994,15 +994,16 @@ public:
|
|||||||
CAmount m_watchonly_trusted{0};
|
CAmount m_watchonly_trusted{0};
|
||||||
CAmount m_watchonly_untrusted_pending{0};
|
CAmount m_watchonly_untrusted_pending{0};
|
||||||
CAmount m_watchonly_immature{0};
|
CAmount m_watchonly_immature{0};
|
||||||
|
CAmount m_anonymized{0};
|
||||||
|
CAmount m_denominated_trusted{0};
|
||||||
|
CAmount m_denominated_untrusted_pending{0};
|
||||||
};
|
};
|
||||||
CAmount GetLegacyBalance(const isminefilter& filter, int minDepth, const bool fAddLocked) const;
|
CAmount GetLegacyBalance(const isminefilter& filter, int minDepth, const bool fAddLocked) const;
|
||||||
Balance GetBalance(int min_depth = 0, const bool fAddLocked = false) const;
|
Balance GetBalance(int min_depth = 0, const bool fAddLocked = false, const CCoinControl* coinControl = nullptr) const;
|
||||||
|
|
||||||
CAmount GetAnonymizableBalance(bool fSkipDenominated = false, bool fSkipUnconfirmed = true) const;
|
CAmount GetAnonymizableBalance(bool fSkipDenominated = false, bool fSkipUnconfirmed = true) const;
|
||||||
CAmount GetAnonymizedBalance(const CCoinControl* coinControl = nullptr) const;
|
|
||||||
float GetAverageAnonymizedRounds() const;
|
float GetAverageAnonymizedRounds() const;
|
||||||
CAmount GetNormalizedAnonymizedBalance() const;
|
CAmount GetNormalizedAnonymizedBalance() const;
|
||||||
CAmount GetDenominatedBalance(bool unconfirmed=false) const;
|
|
||||||
|
|
||||||
bool GetBudgetSystemCollateralTX(CTransactionRef& tx, uint256 hash, CAmount amount, const COutPoint& outpoint=COutPoint()/*defaults null*/);
|
bool GetBudgetSystemCollateralTX(CTransactionRef& tx, uint256 hash, CAmount amount, const COutPoint& outpoint=COutPoint()/*defaults null*/);
|
||||||
CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const;
|
CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user