From 6c0b9b0c789a5bc024d62ab200f9456525f5e523 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Thu, 12 Jan 2023 11:55:58 +1030 Subject: [PATCH] lightningd: deprecate listpeers.channels Changelog-Deprecated: JSON-RPC: `listpeers` `channels` array: use `listpeerchannels` Signed-off-by: Vincenzo Palazzo --- cln-grpc/src/convert.rs | 2 +- cln-rpc/src/model.rs | 5 ++-- doc/lightning-listpeers.7.md | 46 +++++++++++++++---------------- doc/schemas/listpeers.schema.json | 4 +-- lightningd/peer_control.c | 20 ++++++++------ 5 files changed, 40 insertions(+), 37 deletions(-) diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index da276661b9d7..c8096ae28a3d 100644 --- a/cln-grpc/src/convert.rs +++ b/cln-grpc/src/convert.rs @@ -216,7 +216,7 @@ impl From for pb::ListpeersPeers { id: c.id.serialize().to_vec(), // Rule #2 for type pubkey connected: c.connected, // Rule #2 for type boolean log: c.log.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 - channels: c.channels.into_iter().map(|i| i.into()).collect(), // Rule #3 for type ListpeersPeersChannels + channels: c.channels.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 netaddr: c.netaddr.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 remote_addr: c.remote_addr, // Rule #2 for type string? features: c.features.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? diff --git a/cln-rpc/src/model.rs b/cln-rpc/src/model.rs index 01759b177ebd..9d8150536759 100644 --- a/cln-rpc/src/model.rs +++ b/cln-rpc/src/model.rs @@ -1808,8 +1808,9 @@ pub mod responses { pub connected: bool, #[serde(alias = "log", skip_serializing_if = "crate::is_none_or_empty")] pub log: Option>, - #[serde(alias = "channels")] - pub channels: Vec, + #[deprecated] + #[serde(alias = "channels", skip_serializing_if = "crate::is_none_or_empty")] + pub channels: Option>, #[serde(alias = "netaddr", skip_serializing_if = "crate::is_none_or_empty")] pub netaddr: Option>, #[serde(alias = "remote_addr", skip_serializing_if = "Option::is_none")] diff --git a/doc/lightning-listpeers.7.md b/doc/lightning-listpeers.7.md index d4732be50298..dedf608603a8 100644 --- a/doc/lightning-listpeers.7.md +++ b/doc/lightning-listpeers.7.md @@ -43,7 +43,28 @@ On success, an object containing **peers** is returned. It is an array of objec - **id** (pubkey): the public key of the peer - **connected** (boolean): True if the peer is currently connected -- **channels** (array of objects): +- **log** (array of objects, optional): if *level* is specified, logs for this peer: + - **type** (string) (one of "SKIPPED", "BROKEN", "UNUSUAL", "INFO", "DEBUG", "IO\_IN", "IO\_OUT") + + If **type** is "SKIPPED": + + - **num\_skipped** (u32): number of deleted/omitted entries + + If **type** is "BROKEN", "UNUSUAL", "INFO" or "DEBUG": + + - **time** (string): UNIX timestamp with 9 decimal places + - **source** (string): The particular logbook this was found in + - **log** (string): The actual log message + - **node\_id** (pubkey): The peer this is associated with + + If **type** is "IO\_IN" or "IO\_OUT": + + - **time** (string): UNIX timestamp with 9 decimal places + - **source** (string): The particular logbook this was found in + - **log** (string): The actual log message + - **node\_id** (pubkey): The peer this is associated with + - **data** (hex): The IO which occurred +- **channels** (array of objects, optional) **deprecated, removal in v23.11**: - **state** (string): the channel state, in particular "CHANNELD\_NORMAL" means the channel can be used normally (one of "OPENINGD", "CHANNELD\_AWAITING\_LOCKIN", "CHANNELD\_NORMAL", "CHANNELD\_SHUTTING\_DOWN", "CLOSINGD\_SIGEXCHANGE", "CLOSINGD\_COMPLETE", "AWAITING\_UNILATERAL", "FUNDING\_SPEND\_SEEN", "ONCHAIN", "DUALOPEND\_OPEN\_INIT", "DUALOPEND\_AWAITING\_LOCKIN") - **opener** (string): Who initiated the channel (one of "local", "remote") - **features** (array of strings): @@ -150,27 +171,6 @@ On success, an object containing **peers** is returned. It is an array of objec - **initial\_feerate** (string): The feerate for the initial funding transaction in per-1000-weight, with "kpw" appended - **last\_feerate** (string): The feerate for the latest funding transaction in per-1000-weight, with "kpw" appended - **next\_feerate** (string): The minimum feerate for the next funding transaction in per-1000-weight, with "kpw" appended -- **log** (array of objects, optional): if *level* is specified, logs for this peer: - - **type** (string) (one of "SKIPPED", "BROKEN", "UNUSUAL", "INFO", "DEBUG", "IO\_IN", "IO\_OUT") - - If **type** is "SKIPPED": - - - **num\_skipped** (u32): number of deleted/omitted entries - - If **type** is "BROKEN", "UNUSUAL", "INFO" or "DEBUG": - - - **time** (string): UNIX timestamp with 9 decimal places - - **source** (string): The particular logbook this was found in - - **log** (string): The actual log message - - **node\_id** (pubkey): The peer this is associated with - - If **type** is "IO\_IN" or "IO\_OUT": - - - **time** (string): UNIX timestamp with 9 decimal places - - **source** (string): The particular logbook this was found in - - **log** (string): The actual log message - - **node\_id** (pubkey): The peer this is associated with - - **data** (hex): The IO which occurred If **connected** is *true*: @@ -399,4 +399,4 @@ Main web site: Lightning RFC site (BOLT \#9): -[comment]: # ( SHA256STAMP:c84136fcca3d0295cd1612873a54a074f3e8b6ae9cc643489cab6fb7376d66f6) +[comment]: # ( SHA256STAMP:a063a4a4fb1e6af4138d19ccbdc8d1539712c6eb6ed8a4b1b7f7c4fe12e0907b) diff --git a/doc/schemas/listpeers.schema.json b/doc/schemas/listpeers.schema.json index b16b57f7667d..4087cfc02a8a 100644 --- a/doc/schemas/listpeers.schema.json +++ b/doc/schemas/listpeers.schema.json @@ -13,8 +13,7 @@ "additionalProperties": true, "required": [ "id", - "connected", - "channels" + "connected" ], "properties": { "id": { @@ -167,6 +166,7 @@ } }, "channels": { + "deprecated": "v23.02", "type": "array", "items": { "type": "object", diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 437469d6a5fd..dee6f83ca97b 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1941,16 +1941,18 @@ static void json_add_peer(struct lightningd *ld, json_add_hex_talarr(response, "features", p->their_features); } - json_array_start(response, "channels"); - json_add_uncommitted_channel(response, p->uncommitted_channel, NULL); - - list_for_each(&p->channels, channel, list) { - if (channel_unsaved(channel)) - json_add_unsaved_channel(response, channel, NULL); - else - json_add_channel(ld, response, NULL, channel, NULL); + if (deprecated_apis) { + json_array_start(response, "channels"); + json_add_uncommitted_channel(response, p->uncommitted_channel, NULL); + + list_for_each(&p->channels, channel, list) { + if (channel_unsaved(channel)) + json_add_unsaved_channel(response, channel, NULL); + else + json_add_channel(ld, response, NULL, channel, NULL); + } + json_array_end(response); } - json_array_end(response); if (ll) json_add_log(response, ld->log_book, &p->id, *ll);