Skip to content

Commit 0ec2551

Browse files
committed
wallet, rpc: Remove deprecated balances from getwalletinfo
1 parent 011a8c5 commit 0ec2551

File tree

5 files changed

+10
-22
lines changed

5 files changed

+10
-22
lines changed

src/wallet/rpc/wallet.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ static RPCHelpMan getwalletinfo()
4242
{RPCResult::Type::STR, "walletname", "the wallet name"},
4343
{RPCResult::Type::NUM, "walletversion", "the wallet version"},
4444
{RPCResult::Type::STR, "format", "the database format (only sqlite)"},
45-
{RPCResult::Type::STR_AMOUNT, "balance", "DEPRECATED. Identical to getbalances().mine.trusted"},
46-
{RPCResult::Type::STR_AMOUNT, "unconfirmed_balance", "DEPRECATED. Identical to getbalances().mine.untrusted_pending"},
47-
{RPCResult::Type::STR_AMOUNT, "immature_balance", "DEPRECATED. Identical to getbalances().mine.immature"},
4845
{RPCResult::Type::NUM, "txcount", "the total number of transactions in the wallet"},
4946
{RPCResult::Type::NUM, "keypoolsize", "how many new keys are pre-generated (only counts external keys)"},
5047
{RPCResult::Type::NUM, "keypoolsize_hd_internal", /*optional=*/true, "how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)"},
@@ -82,13 +79,9 @@ static RPCHelpMan getwalletinfo()
8279
UniValue obj(UniValue::VOBJ);
8380

8481
size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
85-
const auto bal = GetBalance(*pwallet);
8682
obj.pushKV("walletname", pwallet->GetName());
8783
obj.pushKV("walletversion", pwallet->GetVersion());
8884
obj.pushKV("format", pwallet->GetDatabase().Format());
89-
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
90-
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
91-
obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));
9285
obj.pushKV("txcount", (int)pwallet->mapWallet.size());
9386
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
9487

test/functional/wallet_balance.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ def test_balances(*, fee_node_1=0):
170170
# getunconfirmedbalance
171171
assert_equal(self.nodes[0].getunconfirmedbalance(), Decimal('60')) # output of node 1's spend
172172
assert_equal(self.nodes[1].getunconfirmedbalance(), Decimal('30') - fee_node_1) # Doesn't include output of node 0's send since it was spent
173-
# getwalletinfo.unconfirmed_balance
174-
assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], Decimal('60'))
175-
assert_equal(self.nodes[1].getwalletinfo()["unconfirmed_balance"], Decimal('30') - fee_node_1)
176173

177174
test_balances(fee_node_1=Decimal('0.01'))
178175

test/functional/wallet_basic.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ def run_test(self):
6969

7070
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
7171

72-
walletinfo = self.nodes[0].getwalletinfo()
73-
assert_equal(walletinfo['immature_balance'], 50)
74-
assert_equal(walletinfo['balance'], 0)
72+
balances = self.nodes[0].getbalances()
73+
assert_equal(balances["mine"]["immature"], 50)
74+
assert_equal(balances["mine"]["trusted"], 0)
7575

7676
self.sync_all(self.nodes[0:3])
7777
self.generate(self.nodes[1], COINBASE_MATURITY + 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
@@ -118,8 +118,7 @@ def run_test(self):
118118
# but 10 will go to node2 and the rest will go to node0
119119
balance = self.nodes[0].getbalance()
120120
assert_equal(set([txout1['value'], txout2['value']]), set([10, balance]))
121-
walletinfo = self.nodes[0].getwalletinfo()
122-
assert_equal(walletinfo['immature_balance'], 0)
121+
assert_equal(self.nodes[0].getbalances()["mine"]["immature"], 0)
123122

124123
# Have node0 mine a block, thus it will collect its own fee.
125124
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))

test/functional/wallet_multiwallet.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ def wallet_file(name):
185185
self.nodes[0].loadwallet("w5")
186186
assert_equal(set(node.listwallets()), {"w4", "w5"})
187187
w5 = wallet("w5")
188-
w5_info = w5.getwalletinfo()
189-
assert_equal(w5_info['immature_balance'], 50)
188+
assert_equal(w5.getbalances()["mine"]["immature"], 50)
190189

191190
competing_wallet_dir = os.path.join(self.options.tmpdir, 'competing_walletdir')
192191
os.mkdir(competing_wallet_dir)
@@ -208,7 +207,7 @@ def wallet_file(name):
208207
self.generatetoaddress(node, nblocks=1, address=wallets[0].getnewaddress(), sync_fun=self.no_op)
209208
for wallet_name, wallet in zip(wallet_names, wallets):
210209
info = wallet.getwalletinfo()
211-
assert_equal(info['immature_balance'], 50 if wallet is wallets[0] else 0)
210+
assert_equal(wallet.getbalances()["mine"]["immature"], 50 if wallet is wallets[0] else 0)
212211
assert_equal(info['walletname'], wallet_name)
213212

214213
# accessing invalid wallet fails

test/functional/wallet_reorgsrestore.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ def test_reorg_handling_during_unclean_shutdown(self):
100100
# Restart to ensure node and wallet are flushed
101101
self.restart_node(0)
102102
wallet = node.get_wallet_rpc("reorg_crash")
103-
assert_greater_than(wallet.getwalletinfo()['immature_balance'], 0)
103+
assert_greater_than(wallet.getbalances()["mine"]["immature"], 0)
104104

105105
# Disconnect tip and sync wallet state
106106
tip = wallet.getbestblockhash()
107107
wallet.invalidateblock(tip)
108108
wallet.syncwithvalidationinterfacequeue()
109109

110110
# Tip was disconnected, ensure coinbase has been abandoned
111-
assert_equal(wallet.getwalletinfo()['immature_balance'], 0)
111+
assert_equal(wallet.getbalances()["mine"]["immature"], 0)
112112
coinbase_tx_id = wallet.getblock(tip, verbose=1)["tx"][0]
113113
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], True)
114114

@@ -131,12 +131,12 @@ def test_reorg_handling_during_unclean_shutdown(self):
131131
assert(node.getbestblockhash() != tip)
132132
# Ensure wallet state is consistent now
133133
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], True)
134-
assert_equal(wallet.getwalletinfo()['immature_balance'], 0)
134+
assert_equal(wallet.getbalances()["mine"]["immature"], 0)
135135

136136
# And finally, verify the state if the block ends up being into the best chain again
137137
node.reconsiderblock(tip)
138138
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], False)
139-
assert_greater_than(wallet.getwalletinfo()['immature_balance'], 0)
139+
assert_greater_than(wallet.getbalances()["mine"]["immature"], 0)
140140

141141
def run_test(self):
142142
# Send a tx from which to conflict outputs later

0 commit comments

Comments
 (0)