Skip to content

Commit 84eba47

Browse files
committed
Merge pull request #5540
12d927a RPC test for immature balance (Jonas Schnelli) 8024d67 Add immature balances to getwalletinfo. (Gregory Maxwell) d44c545 Add unconfirmedbalance field to getwalletinfo (azeteki)
2 parents 9a5cabf + 12d927a commit 84eba47

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

qa/rpc-tests/wallet.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def run_test (self):
4141

4242
self.nodes[0].setgenerate(True, 1)
4343

44+
walletinfo = self.nodes[0].getwalletinfo()
45+
assert_equal(walletinfo['immature_balance'], 50)
46+
assert_equal(walletinfo['balance'], 0)
47+
4448
self.sync_all()
4549
self.nodes[1].setgenerate(True, 101)
4650
self.sync_all()
@@ -54,6 +58,9 @@ def run_test (self):
5458
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
5559
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
5660

61+
walletinfo = self.nodes[0].getwalletinfo()
62+
assert_equal(walletinfo['immature_balance'], 0)
63+
5764
# Have node0 mine a block, thus he will collect his own fee.
5865
self.nodes[0].setgenerate(True, 1)
5966
self.sync_all()

src/rpcwallet.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,9 @@ Value getwalletinfo(const Array& params, bool fHelp)
19901990
"\nResult:\n"
19911991
"{\n"
19921992
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
1993-
" \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n"
1993+
" \"balance\": xxxxxxx, (numeric) the total confirmed bitcoin balance of the wallet\n"
1994+
" \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed bitcoin balance of the wallet\n"
1995+
" \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet\n"
19941996
" \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n"
19951997
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n"
19961998
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
@@ -2004,6 +2006,8 @@ Value getwalletinfo(const Array& params, bool fHelp)
20042006
Object obj;
20052007
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
20062008
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
2009+
obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance())));
2010+
obj.push_back(Pair("immature_balance", ValueFromAmount(pwalletMain->GetImmatureBalance())));
20072011
obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size()));
20082012
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
20092013
obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize()));

0 commit comments

Comments
 (0)