@@ -668,8 +668,19 @@ UniValue getbalance(const JSONRPCRequest& request)
668
668
" Note that the account \"\" is not the same as leaving the parameter out.\n "
669
669
" The server total may be different to the balance in the default \"\" account.\n "
670
670
" \n Arguments:\n "
671
- " 1. \" account\" (string, optional) DEPRECATED. The selected account, or \" *\" for entire wallet. It may be the default account using \"\" .\n "
672
- " 2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n "
671
+ " 1. \" account\" (string, optional) DEPRECATED. The account string may be given as a\n "
672
+ " specific account name to find the balance associated with wallet keys in\n "
673
+ " a named account, or as the empty string (\"\" ) to find the balance\n "
674
+ " associated with wallet keys not in any named account, or as \" *\" to find\n "
675
+ " the balance associated with all wallet keys regardless of account.\n "
676
+ " When this option is specified, it calculates the balance in a different\n "
677
+ " way than when it is not specified, and which can count spends twice when\n "
678
+ " there are conflicting pending transactions (such as those created by\n "
679
+ " the bumpfee command), temporarily resulting in low or even negative\n "
680
+ " balances. In general, account balance calculation is not considered\n "
681
+ " reliable and has resulted in confusing outcomes, so it is recommended to\n "
682
+ " avoid passing this argument.\n "
683
+ " 2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n "
673
684
" 3. include_watchonly (bool, optional, default=false) Also include balance in watch-only addresses (see 'importaddress')\n "
674
685
" \n Result:\n "
675
686
" amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n "
@@ -696,9 +707,12 @@ UniValue getbalance(const JSONRPCRequest& request)
696
707
filter = filter | ISMINE_WATCH_ONLY;
697
708
698
709
if (request.params [0 ].get_str () == " *" ) {
699
- // Calculate total balance a different way from GetBalance()
700
- // (GetBalance() sums up all unspent TxOuts)
701
- // getbalance and "getbalance * 1 true" should return the same number
710
+ // Calculate total balance in a very different way from GetBalance().
711
+ // The biggest difference is that GetBalance() sums up all unspent
712
+ // TxOuts paying to the wallet, while this sums up both spent and
713
+ // unspent TxOuts paying to the wallet, and then subtracts the values of
714
+ // TxIns spending from the wallet. This also has fewer restrictions on
715
+ // which unconfirmed transactions are considered trusted.
702
716
CAmount nBalance = 0 ;
703
717
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet .begin (); it != pwalletMain->mapWallet .end (); ++it)
704
718
{
0 commit comments