From d44c545673c0d75d1a2febe69685904787f8b21c Mon Sep 17 00:00:00 2001 From: azeteki Date: Sun, 21 Dec 2014 05:28:14 +0000 Subject: [PATCH 1/3] Add unconfirmedbalance field to getwalletinfo --- src/rpcwallet.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 63da8a20b..7c371ae2e 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -1990,7 +1990,8 @@ Value getwalletinfo(const Array& params, bool fHelp) "\nResult:\n" "{\n" " \"walletversion\": xxxxx, (numeric) the wallet version\n" - " \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n" + " \"balance\": xxxxxxx, (numeric) the total confirmed bitcoin balance of the wallet\n" + " \"unconfirmedbalance\": xxxx, (numeric) the total unconfirmed bitcoin balance of the wallet\n" " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n" " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n" @@ -2004,6 +2005,7 @@ Value getwalletinfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); + obj.push_back(Pair("unconfirmedbalance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()))); obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size())); obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); From 8024d67dae9da4a5259cddc0fa713146272f7aad Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Wed, 24 Dec 2014 21:10:59 -0800 Subject: [PATCH 2/3] Add immature balances to getwalletinfo. --- src/rpcwallet.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 7c371ae2e..8366430f1 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -1991,7 +1991,8 @@ Value getwalletinfo(const Array& params, bool fHelp) "{\n" " \"walletversion\": xxxxx, (numeric) the wallet version\n" " \"balance\": xxxxxxx, (numeric) the total confirmed bitcoin balance of the wallet\n" - " \"unconfirmedbalance\": xxxx, (numeric) the total unconfirmed bitcoin balance of the wallet\n" + " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed bitcoin balance of the wallet\n" + " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet\n" " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n" " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n" @@ -2005,7 +2006,8 @@ Value getwalletinfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); - obj.push_back(Pair("unconfirmedbalance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()))); + obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()))); + obj.push_back(Pair("immature_balance", ValueFromAmount(pwalletMain->GetImmatureBalance()))); obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size())); obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); From 12d927a391b83041479f06e72051d37cc4e66655 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Thu, 25 Dec 2014 08:57:16 +0100 Subject: [PATCH 3/3] RPC test for immature balance --- qa/rpc-tests/wallet.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py index d99540b58..f280ac380 100755 --- a/qa/rpc-tests/wallet.py +++ b/qa/rpc-tests/wallet.py @@ -41,6 +41,10 @@ class WalletTest (BitcoinTestFramework): self.nodes[0].setgenerate(True, 1) + walletinfo = self.nodes[0].getwalletinfo() + assert_equal(walletinfo['immature_balance'], 50) + assert_equal(walletinfo['balance'], 0) + self.sync_all() self.nodes[1].setgenerate(True, 101) self.sync_all() @@ -54,6 +58,9 @@ class WalletTest (BitcoinTestFramework): self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10) + walletinfo = self.nodes[0].getwalletinfo() + assert_equal(walletinfo['immature_balance'], 0) + # Have node0 mine a block, thus he will collect his own fee. self.nodes[0].setgenerate(True, 1) self.sync_all()