mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
Fix getbalance discrepency
Two changes: Use IsConfirmed() instead of IsFinal(), so 'getbalance "*" 0' uses the same 'is this output spendable' criteria as 'getbalance'. Fixes issue #172. And a tiny refactor to CWallet::GetBalance() (redundant call to IsFinal -- IsConfirmed calls IsFinal). getbalance with no arguments and 'getbalance "*" 0' could return different different results,
This commit is contained in:
parent
77052ab0f3
commit
d28bd8b7ca
@ -519,12 +519,12 @@ Value getbalance(const Array& params, bool fHelp)
|
|||||||
if (params[0].get_str() == "*") {
|
if (params[0].get_str() == "*") {
|
||||||
// Calculate total balance a different way from GetBalance()
|
// Calculate total balance a different way from GetBalance()
|
||||||
// (GetBalance() sums up all unspent TxOuts)
|
// (GetBalance() sums up all unspent TxOuts)
|
||||||
// getbalance and getbalance '*' should always return the same number.
|
// getbalance and getbalance '*' 0 should return the same number
|
||||||
int64 nBalance = 0;
|
int64 nBalance = 0;
|
||||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||||
{
|
{
|
||||||
const CWalletTx& wtx = (*it).second;
|
const CWalletTx& wtx = (*it).second;
|
||||||
if (!wtx.IsFinal())
|
if (!wtx.IsConfirmed())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int64 allFee;
|
int64 allFee;
|
||||||
|
@ -899,7 +899,7 @@ int64 CWallet::GetBalance() const
|
|||||||
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||||
{
|
{
|
||||||
const CWalletTx* pcoin = &(*it).second;
|
const CWalletTx* pcoin = &(*it).second;
|
||||||
if (pcoin->IsFinal() && pcoin->IsConfirmed())
|
if (pcoin->IsConfirmed())
|
||||||
nTotal += pcoin->GetAvailableCredit();
|
nTotal += pcoin->GetAvailableCredit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user