From 107e81071c7e60157fb3d00f90e3e3258c213aff Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Mon, 17 Mar 2025 08:00:01 +0100 Subject: [PATCH] lianad; update docs & tests for getinfo command --- doc/API.md | 2 ++ tests/test_rpc.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/doc/API.md b/doc/API.md index 0be165b2..c7f3d754 100644 --- a/doc/API.md +++ b/doc/API.md @@ -63,6 +63,8 @@ This command does not take any parameter for now. | `rescan_progress` | float or null | Progress of an ongoing rescan as a percentage (between 0 and 1) if there is any | | `timestamp` | integer | Unix timestamp of wallet creation date | | `last_poll_timestamp`| integer or null | Unix timestamp of last poll (if any) of the blockchain | +| `receive_index` | integer | Last index used to generate a receive address | +| `change_index` | integer | Last index used to generate a change address | ### `getnewaddress` diff --git a/tests/test_rpc.py b/tests/test_rpc.py index 4ba57726..c46e5a9a 100644 --- a/tests/test_rpc.py +++ b/tests/test_rpc.py @@ -36,6 +36,8 @@ def test_getinfo(lianad): time.sleep(lianad.poll_interval_secs + 1) res = lianad.rpc.getinfo() assert res["last_poll_timestamp"] > last_poll_timestamp + assert res["receive_index"] == 0 + assert res["change_index"] == 0 def test_getaddress(lianad): @@ -45,6 +47,9 @@ def test_getaddress(lianad): assert res["address"] != lianad.rpc.getnewaddress()["address"] # new address has derivation_index higher than the previous one assert lianad.rpc.getnewaddress()["derivation_index"] == res["derivation_index"] + 2 + info = lianad.rpc.getinfo() + assert info["receive_index"] == res["derivation_index"] + 3 + assert info["change_index"] == 0 def test_listaddresses(lianad): @@ -420,6 +425,8 @@ def test_create_spend(lianad, bitcoind): assert len(spend_psbt.o) == 4 assert len(spend_psbt.tx.vout) == 4 + assert lianad.rpc.getinfo()["change_index"] == 15 + # The transaction must contain the spent transaction for each input for P2WSH. But not for Taproot. # We don't make assumptions about the ordering of PSBT inputs. if USE_TAPROOT: