wallet, rpc: Remove deprecated balances from getwalletinfo

This commit is contained in:
Ava Chow 2025-06-10 12:10:19 -07:00
parent 011a8c5f01
commit 0ec255139b
5 changed files with 10 additions and 22 deletions

View File

@ -42,9 +42,6 @@ static RPCHelpMan getwalletinfo()
{RPCResult::Type::STR, "walletname", "the wallet name"},
{RPCResult::Type::NUM, "walletversion", "the wallet version"},
{RPCResult::Type::STR, "format", "the database format (only sqlite)"},
{RPCResult::Type::STR_AMOUNT, "balance", "DEPRECATED. Identical to getbalances().mine.trusted"},
{RPCResult::Type::STR_AMOUNT, "unconfirmed_balance", "DEPRECATED. Identical to getbalances().mine.untrusted_pending"},
{RPCResult::Type::STR_AMOUNT, "immature_balance", "DEPRECATED. Identical to getbalances().mine.immature"},
{RPCResult::Type::NUM, "txcount", "the total number of transactions in the wallet"},
{RPCResult::Type::NUM, "keypoolsize", "how many new keys are pre-generated (only counts external keys)"},
{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()
UniValue obj(UniValue::VOBJ);
size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
const auto bal = GetBalance(*pwallet);
obj.pushKV("walletname", pwallet->GetName());
obj.pushKV("walletversion", pwallet->GetVersion());
obj.pushKV("format", pwallet->GetDatabase().Format());
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));
obj.pushKV("txcount", (int)pwallet->mapWallet.size());
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);

View File

@ -170,9 +170,6 @@ class WalletTest(BitcoinTestFramework):
# getunconfirmedbalance
assert_equal(self.nodes[0].getunconfirmedbalance(), Decimal('60')) # output of node 1's spend
assert_equal(self.nodes[1].getunconfirmedbalance(), Decimal('30') - fee_node_1) # Doesn't include output of node 0's send since it was spent
# getwalletinfo.unconfirmed_balance
assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], Decimal('60'))
assert_equal(self.nodes[1].getwalletinfo()["unconfirmed_balance"], Decimal('30') - fee_node_1)
test_balances(fee_node_1=Decimal('0.01'))

View File

@ -69,9 +69,9 @@ class WalletTest(BitcoinTestFramework):
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 50)
assert_equal(walletinfo['balance'], 0)
balances = self.nodes[0].getbalances()
assert_equal(balances["mine"]["immature"], 50)
assert_equal(balances["mine"]["trusted"], 0)
self.sync_all(self.nodes[0:3])
self.generate(self.nodes[1], COINBASE_MATURITY + 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
@ -118,8 +118,7 @@ class WalletTest(BitcoinTestFramework):
# but 10 will go to node2 and the rest will go to node0
balance = self.nodes[0].getbalance()
assert_equal(set([txout1['value'], txout2['value']]), set([10, balance]))
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 0)
assert_equal(self.nodes[0].getbalances()["mine"]["immature"], 0)
# Have node0 mine a block, thus it will collect its own fee.
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))

View File

@ -185,8 +185,7 @@ class MultiWalletTest(BitcoinTestFramework):
self.nodes[0].loadwallet("w5")
assert_equal(set(node.listwallets()), {"w4", "w5"})
w5 = wallet("w5")
w5_info = w5.getwalletinfo()
assert_equal(w5_info['immature_balance'], 50)
assert_equal(w5.getbalances()["mine"]["immature"], 50)
competing_wallet_dir = os.path.join(self.options.tmpdir, 'competing_walletdir')
os.mkdir(competing_wallet_dir)
@ -208,7 +207,7 @@ class MultiWalletTest(BitcoinTestFramework):
self.generatetoaddress(node, nblocks=1, address=wallets[0].getnewaddress(), sync_fun=self.no_op)
for wallet_name, wallet in zip(wallet_names, wallets):
info = wallet.getwalletinfo()
assert_equal(info['immature_balance'], 50 if wallet is wallets[0] else 0)
assert_equal(wallet.getbalances()["mine"]["immature"], 50 if wallet is wallets[0] else 0)
assert_equal(info['walletname'], wallet_name)
# accessing invalid wallet fails

View File

@ -100,7 +100,7 @@ class ReorgsRestoreTest(BitcoinTestFramework):
# Restart to ensure node and wallet are flushed
self.restart_node(0)
wallet = node.get_wallet_rpc("reorg_crash")
assert_greater_than(wallet.getwalletinfo()['immature_balance'], 0)
assert_greater_than(wallet.getbalances()["mine"]["immature"], 0)
# Disconnect tip and sync wallet state
tip = wallet.getbestblockhash()
@ -108,7 +108,7 @@ class ReorgsRestoreTest(BitcoinTestFramework):
wallet.syncwithvalidationinterfacequeue()
# Tip was disconnected, ensure coinbase has been abandoned
assert_equal(wallet.getwalletinfo()['immature_balance'], 0)
assert_equal(wallet.getbalances()["mine"]["immature"], 0)
coinbase_tx_id = wallet.getblock(tip, verbose=1)["tx"][0]
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], True)
@ -131,12 +131,12 @@ class ReorgsRestoreTest(BitcoinTestFramework):
assert(node.getbestblockhash() != tip)
# Ensure wallet state is consistent now
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], True)
assert_equal(wallet.getwalletinfo()['immature_balance'], 0)
assert_equal(wallet.getbalances()["mine"]["immature"], 0)
# And finally, verify the state if the block ends up being into the best chain again
node.reconsiderblock(tip)
assert_equal(wallet.gettransaction(coinbase_tx_id)['details'][0]['abandoned'], False)
assert_greater_than(wallet.getwalletinfo()['immature_balance'], 0)
assert_greater_than(wallet.getbalances()["mine"]["immature"], 0)
def run_test(self):
# Send a tx from which to conflict outputs later