From 632aade2c5830b2d07df7d81f978ffa17a06a0f4 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sun, 26 Oct 2025 14:35:51 +0100 Subject: [PATCH] support/testing: package: bitcoin: replace deprecated wallet rpc calls The getunconfirmedbalance rpc call was marked as deprecated in [1] (included in v0.19.0, released on 2019-11-08) and removed in [2] (included in v30.0, released on 2025-10-09). This commit replaces the old getbalance/getunconfirmedbalance rpc calls with the new call getbalances (plural) returning a json object containing all the data. This commit is needed before updating bitcoin to v30.0. [1] https://github.com/bitcoin/bitcoin/commit/facfb4111d14a3b06c46690a2cca7ca91cea8a96 [2] https://github.com/bitcoin/bitcoin/commit/c3fe85e2d6dd4f251a62a99fd891b0fa370f9712 Cc: Bernd Kuhls Signed-off-by: Julien Olivain --- support/testing/tests/package/test_bitcoin.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/support/testing/tests/package/test_bitcoin.py b/support/testing/tests/package/test_bitcoin.py index 1f00345a12..a942504af4 100644 --- a/support/testing/tests/package/test_bitcoin.py +++ b/support/testing/tests/package/test_bitcoin.py @@ -1,3 +1,4 @@ +import json import os import time @@ -47,19 +48,25 @@ class TestBitcoin(infra.basetest.BRTest): self.create_btc_wallet(wallet_name) return self.gen_btc_address(wallet_name) + def get_wallet_balances(self, wallet): + """Return the balances of a wallet.""" + cmd = f"{self.cli_cmd} -rpcwallet={wallet} getbalances" + out, ret = self.emulator.run(cmd) + self.assertEqual(ret, 0) + balances = json.loads("".join(out)) + return balances + def get_wallet_balance(self, wallet): """Return the (confirmed) balance of a wallet.""" - cmd = f"{self.cli_cmd} -rpcwallet={wallet} getbalance" - out, ret = self.emulator.run(cmd) - self.assertEqual(ret, 0) - return float(out[0]) + balances = self.get_wallet_balances(wallet) + balance = balances["mine"]["trusted"] + return balance def get_wallet_unconfirmed_balance(self, wallet): - """Return the unconfirmed balance of a wallet.""" - cmd = f"{self.cli_cmd} -rpcwallet={wallet} getunconfirmedbalance" - out, ret = self.emulator.run(cmd) - self.assertEqual(ret, 0) - return float(out[0]) + """Return the untrusted pending (unconfirmed) balance of a wallet.""" + balances = self.get_wallet_balances(wallet) + untrusted_balance = balances["mine"]["untrusted_pending"] + return untrusted_balance def get_block_count(self): """Returns the height of the most-work fully-validated chain."""