Skip to content

Commit 07421cf

Browse files
committed
Merge #9613: [wallet] Clarify getbalance help string to explain interaction with bumpfee
5a00659 [wallet] Clarify getbalance help string to explain interaction with bumpfee (Russell Yanofsky)
2 parents 3f9f962 + 5a00659 commit 07421cf

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,19 @@ UniValue getbalance(const JSONRPCRequest& request)
668668
"Note that the account \"\" is not the same as leaving the parameter out.\n"
669669
"The server total may be different to the balance in the default \"\" account.\n"
670670
"\nArguments:\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"
673684
"3. include_watchonly (bool, optional, default=false) Also include balance in watch-only addresses (see 'importaddress')\n"
674685
"\nResult:\n"
675686
"amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n"
@@ -696,9 +707,12 @@ UniValue getbalance(const JSONRPCRequest& request)
696707
filter = filter | ISMINE_WATCH_ONLY;
697708

698709
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.
702716
CAmount nBalance = 0;
703717
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
704718
{

0 commit comments

Comments
 (0)