Skip to content

Commit 7d6a85a

Browse files
committed
Fix getbalance *
Chance "getbalance *" not to use IsTrusted. The method and result now match the "getbalance <specific-account>" behavior. In particular, "getbalance * 0" now works. Also fixed a comment -- GetGalance has required 1 confirmation for many years, and the default "getbalance *" behavior matches that.
1 parent ab0ec67 commit 7d6a85a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,12 +733,12 @@ UniValue getbalance(const UniValue& params, bool fHelp)
733733
if (params[0].get_str() == "*") {
734734
// Calculate total balance a different way from GetBalance()
735735
// (GetBalance() sums up all unspent TxOuts)
736-
// getbalance and getbalance '*' 0 should return the same number
736+
// getbalance and "getbalance * 1 true" should return the same number
737737
CAmount nBalance = 0;
738738
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
739739
{
740740
const CWalletTx& wtx = (*it).second;
741-
if (!wtx.IsTrusted() || wtx.GetBlocksToMaturity() > 0)
741+
if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 0)
742742
continue;
743743

744744
CAmount allFee;

0 commit comments

Comments
 (0)