[Buildroot] [PATCH 1/1] support/testing: package: bitcoin: replace deprecated wallet rpc calls

Julien Olivain ju.o at free.fr
Sun Oct 26 13:35:51 UTC 2025


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 <bernd at kuhls.net>
Signed-off-by: Julien Olivain <ju.o at free.fr>
---
Patch tested with:
bitcoin v28.0, current Buildroot version, in:
https://gitlab.com/jolivain/buildroot/-/jobs/11855409507

bitcoin v30.0, with Bernd patch from:
https://patchwork.ozlabs.org/project/buildroot/patch/20251020200539.2656292-1-bernd@kuhls.net/
in:
https://gitlab.com/jolivain/buildroot/-/jobs/11855410715
---
 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_balance(self, wallet):
-        """Return the (confirmed) balance of a wallet."""
-        cmd = f"{self.cli_cmd} -rpcwallet={wallet} getbalance"
+    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)
-        return float(out[0])
+        balances = json.loads("".join(out))
+        return balances
+
+    def get_wallet_balance(self, wallet):
+        """Return the (confirmed) balance of a wallet."""
+        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."""
-- 
2.51.1



More information about the buildroot mailing list