From 2dc70b50dc93d0ccea71cc75ded02b7081e360f4 Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Tue, 17 Jan 2023 09:11:34 +0100 Subject: [PATCH] doc-schema: make address field in getinfo response required There were cases where address it's empty, and this cases are not right if the field is considered optional. This makes it required and add the field also when `--offline` is set. --- cln-grpc/src/convert.rs | 2 +- cln-rpc/src/model.rs | 4 ++-- doc/lightning-getinfo.7.md | 14 +++++++------- doc/schemas/getinfo.schema.json | 3 ++- lightningd/peer_control.c | 5 +++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index c8096ae28a3d..d86fa7c4cd96 100644 --- a/cln-grpc/src/convert.rs +++ b/cln-grpc/src/convert.rs @@ -65,7 +65,7 @@ impl From for pb::GetinfoResponse { network: c.network, // Rule #2 for type string msatoshi_fees_collected: c.msatoshi_fees_collected, // Rule #2 for type u64? fees_collected_msat: Some(c.fees_collected_msat.into()), // Rule #2 for type msat - address: c.address.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 + address: c.address.into_iter().map(|i| i.into()).collect(), // Rule #3 for type GetinfoAddress binding: c.binding.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 warning_bitcoind_sync: c.warning_bitcoind_sync, // Rule #2 for type string? warning_lightningd_sync: c.warning_lightningd_sync, // Rule #2 for type string? diff --git a/cln-rpc/src/model.rs b/cln-rpc/src/model.rs index 3c7124b5fb36..9aae1d724eee 100644 --- a/cln-rpc/src/model.rs +++ b/cln-rpc/src/model.rs @@ -1465,8 +1465,8 @@ pub mod responses { pub msatoshi_fees_collected: Option, #[serde(alias = "fees_collected_msat")] pub fees_collected_msat: Amount, - #[serde(alias = "address", skip_serializing_if = "crate::is_none_or_empty")] - pub address: Option>, + #[serde(alias = "address")] + pub address: Vec, #[serde(alias = "binding", skip_serializing_if = "crate::is_none_or_empty")] pub binding: Option>, #[serde(alias = "warning_bitcoind_sync", skip_serializing_if = "Option::is_none")] diff --git a/doc/lightning-getinfo.7.md b/doc/lightning-getinfo.7.md index eb60aee6c789..6340fa96d174 100644 --- a/doc/lightning-getinfo.7.md +++ b/doc/lightning-getinfo.7.md @@ -40,18 +40,18 @@ On success, an object is returned, containing: - **blockheight** (u32): The highest block height we've learned - **network** (string): represents the type of network on the node are working (e.g: `bitcoin`, `testnet`, or `regtest`) - **fees\_collected\_msat** (msat): Total routing fees collected by this node -- **our\_features** (object, optional): Our BOLT #9 feature bits (as hexstring) for various contexts: - - **init** (hex): features (incl. globalfeatures) in our init message, these also restrict what we offer in open\_channel or accept in accept\_channel - - **node** (hex): features in our node\_announcement message - - **channel** (hex): negotiated channel features we (as channel initiator) publish in the channel\_announcement message - - **invoice** (hex): features in our BOLT11 invoices -- **address** (array of objects, optional): The addresses we announce to the world: +- **address** (array of objects): The addresses we announce to the world: - **type** (string): Type of connection (one of "dns", "ipv4", "ipv6", "torv2", "torv3", "websocket") - **port** (u16): port number If **type** is "dns", "ipv4", "ipv6", "torv2" or "torv3": - **address** (string): address in expected format for **type** +- **our\_features** (object, optional): Our BOLT #9 feature bits (as hexstring) for various contexts: + - **init** (hex): features (incl. globalfeatures) in our init message, these also restrict what we offer in open\_channel or accept in accept\_channel + - **node** (hex): features in our node\_announcement message + - **channel** (hex): negotiated channel features we (as channel initiator) publish in the channel\_announcement message + - **invoice** (hex): features in our BOLT11 invoices - **binding** (array of objects, optional): The addresses we are listening on: - **type** (string): Type of connection (one of "local socket", "ipv4", "ipv6", "torv2", "torv3") - **address** (string, optional): address in expected format for **type** @@ -132,4 +132,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:d458c44f03d1c242c484627d514b373bf14eca600a0a8390787d370a2ffd2559) +[comment]: # ( SHA256STAMP:7b6d1c38547958041c1b746d78e9172a183345c2cb2a5743d6df530e45471e78) diff --git a/doc/schemas/getinfo.schema.json b/doc/schemas/getinfo.schema.json index 21001d0c78dd..5fbbf516a7d3 100644 --- a/doc/schemas/getinfo.schema.json +++ b/doc/schemas/getinfo.schema.json @@ -14,7 +14,8 @@ "blockheight", "network", "fees_collected_msat", - "lightning-dir" + "lightning-dir", + "address" ], "properties": { "id": { diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index dee6f83ca97b..4b33ec1bb5f7 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -2341,10 +2341,10 @@ static struct command_result *json_getinfo(struct command *cmd, json_add_num(response, "num_inactive_channels", inactive_channels); /* Add network info */ + json_array_start(response, "address"); if (cmd->ld->listen) { /* These are the addresses we're announcing */ count_announceable = tal_count(cmd->ld->announceable); - json_array_start(response, "address"); for (size_t i = 0; i < count_announceable; i++) json_add_address(response, NULL, cmd->ld->announceable+i); @@ -2372,8 +2372,9 @@ static struct command_result *json_getinfo(struct command *cmd, for (size_t i = 0; i < tal_count(cmd->ld->binding); i++) json_add_address_internal(response, NULL, cmd->ld->binding+i); - json_array_end(response); } + json_array_end(response); + json_add_string(response, "version", version()); json_add_num(response, "blockheight", cmd->ld->blockheight); json_add_string(response, "network", chainparams->network_name);