diff --git a/doc/API.md b/doc/API.md index 68b0094b..c89d206a 100644 --- a/doc/API.md +++ b/doc/API.md @@ -53,15 +53,16 @@ This command does not take any parameter for now. #### Response -| Field | Type | Description | -| -------------------- | ------------- | -------------------------------------------------------------------------------------------- | -| `version` | string | Version following the [SimVer](http://www.simver.org/) format | -| `network` | string | Answer can be `mainnet`, `testnet`, `regtest` | -| `block_height` | integer | The block height we are synced at. | -| `sync` | float | The synchronization progress as percentage (`0 < sync < 1`) | -| `descriptors` | object | Object with the name of the descriptor as key and the descriptor string as value | -| `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 | +| Field | Type | Description | +| -------------------- | --------------- | -------------------------------------------------------------------------------------------- | +| `version` | string | Version following the [SimVer](http://www.simver.org/) format | +| `network` | string | Answer can be `mainnet`, `testnet`, `regtest` | +| `block_height` | integer | The block height we are synced at. | +| `sync` | float | The synchronization progress as percentage (`0 < sync < 1`) | +| `descriptors` | object | Object with the name of the descriptor as key and the descriptor string as value | +| `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 | ### `getnewaddress` diff --git a/src/commands/mod.rs b/src/commands/mod.rs index f678e44d..7c9e002c 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -324,6 +324,7 @@ impl DaemonControl { }, rescan_progress, timestamp: db_conn.timestamp(), + last_poll_timestamp: db_conn.last_poll_timestamp(), } } @@ -1127,6 +1128,8 @@ pub struct GetInfoResult { pub rescan_progress: Option, /// Timestamp at wallet creation date pub timestamp: u32, + /// Timestamp of last poll, if any. + pub last_poll_timestamp: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/tests/test_rpc.py b/tests/test_rpc.py index 66c94d5a..28e09007 100644 --- a/tests/test_rpc.py +++ b/tests/test_rpc.py @@ -31,6 +31,11 @@ def test_getinfo(lianad): assert res["sync"] == 1.0 assert "main" in res["descriptors"] assert res["rescan_progress"] is None + last_poll_timestamp = res["last_poll_timestamp"] + assert last_poll_timestamp is not None + time.sleep(lianad.poll_interval_secs + 1) + res = lianad.rpc.getinfo() + assert res["last_poll_timestamp"] > last_poll_timestamp def test_getaddress(lianad):