When I run:
bitcoind getbalance '*' 1
I expect to see the sum of all the inputs in my wallet with at least 1 confirmation. The 1 is the 'minconf' parameter.
But the figure returned also includes unconfirmed change inputs.
When I specify minconf to be 1, it seems only right to sum inputs with a minimum of 1 confirmation, and no unconfirmed inputs at all.
The following change gives the result I expect in this case, but doesn't change anything if the first parameter is anything other than '*':
/* ------------------------------------------------------------------------
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 90a68f5..d069467 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -527,19 +527,8 @@ Value getbalance(const Array& params, bool fHelp)
if (!wtx.IsFinal())
continue;
- int64 allFee;
- string strSentAccount;
- list<pair<CTxDestination, int64> > listReceived;
- list<pair<CTxDestination, int64> > listSent;
- wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount);
if (wtx.GetDepthInMainChain() >= nMinDepth)
- {
- BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listReceived)
- nBalance += r.second;
- }
- BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listSent)
- nBalance -= r.second;
- nBalance -= allFee;
+ nBalance += wtx.GetAvailableCredit();
}
return ValueFromAmount(nBalance);
}
* ------------------------------------------------------------------------ */