From 16623076080e8ab3d1d2af3717b82b685dd6dee2 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Tue, 24 Feb 2026 20:30:07 -0600 Subject: [PATCH 1/2] Add node_uris to GetNodeInfo response Constructs connection URIs in the node_id@address format from the announcement addresses, making it easy for clients to get ready-to-use connection strings. Co-Authored-By: Claude Opus 4.6 (1M context) --- ldk-server-protos/src/api.rs | 6 ++++++ ldk-server-protos/src/proto/api.proto | 6 ++++++ ldk-server/src/api/get_node_info.rs | 17 ++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ldk-server-protos/src/api.rs b/ldk-server-protos/src/api.rs index 9bfb1321..b8d23a75 100644 --- a/ldk-server-protos/src/api.rs +++ b/ldk-server-protos/src/api.rs @@ -74,6 +74,12 @@ pub struct GetNodeInfoResponse { /// Will be `None` if no alias is configured. #[prost(string, optional, tag = "11")] pub node_alias: ::core::option::Option<::prost::alloc::string::String>, + /// The node URIs that can be used to connect to this node, in the format `node_id@address`. + /// + /// These are constructed from the announcement addresses and the node's public key. + /// Will be empty if no announcement addresses are configured. + #[prost(string, repeated, tag = "12")] + pub node_uris: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } /// Retrieve a new on-chain funding address. /// See more: diff --git a/ldk-server-protos/src/proto/api.proto b/ldk-server-protos/src/proto/api.proto index c982342a..57c7b2fe 100644 --- a/ldk-server-protos/src/proto/api.proto +++ b/ldk-server-protos/src/proto/api.proto @@ -64,6 +64,12 @@ message GetNodeInfoResponse { // // Will be `None` if no alias is configured. optional string node_alias = 11; + + // The node URIs that can be used to connect to this node, in the format `node_id@address`. + // + // These are constructed from the announcement addresses and the node's public key. + // Will be empty if no announcement addresses are configured. + repeated string node_uris = 12; } // Retrieve a new on-chain funding address. diff --git a/ldk-server/src/api/get_node_info.rs b/ldk-server/src/api/get_node_info.rs index da85c727..c1b81279 100644 --- a/ldk-server/src/api/get_node_info.rs +++ b/ldk-server/src/api/get_node_info.rs @@ -23,13 +23,13 @@ pub(crate) fn handle_get_node_info_request( height: node_status.current_best_block.height, }; - let listening_addresses = context + let listening_addresses: Vec = context .node .listening_addresses() .map(|addrs| addrs.into_iter().map(|a| a.to_string()).collect()) .unwrap_or_default(); - let announcement_addresses = context + let announcement_addresses: Vec = context .node .announcement_addresses() .map(|addrs| addrs.into_iter().map(|a| a.to_string()).collect()) @@ -37,8 +37,18 @@ pub(crate) fn handle_get_node_info_request( let node_alias = context.node.node_alias().map(|alias| alias.to_string()); + let node_id = context.node.node_id().to_string(); + + let node_uris = { + let addrs = if announcement_addresses.is_empty() { + listening_addresses.clone() + } else { + announcement_addresses.clone() + }; + addrs.into_iter().map(|a| format!("{node_id}@{a}")).collect() + }; let response = GetNodeInfoResponse { - node_id: context.node.node_id().to_string(), + node_id, current_best_block: Some(best_block), latest_lightning_wallet_sync_timestamp: node_status.latest_lightning_wallet_sync_timestamp, latest_onchain_wallet_sync_timestamp: node_status.latest_onchain_wallet_sync_timestamp, @@ -49,6 +59,7 @@ pub(crate) fn handle_get_node_info_request( listening_addresses, announcement_addresses, node_alias, + node_uris, }; Ok(response) } From 63e93022e7f2e4c3142b3bb74bd6f7791bfd7ad2 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Tue, 24 Feb 2026 20:31:24 -0600 Subject: [PATCH 2/2] Log node URIs on startup using announcement addresses Co-Authored-By: Claude Opus 4.6 (1M context) --- ldk-server/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ldk-server/src/main.rs b/ldk-server/src/main.rs index 5f7b660d..c8bc5e3a 100644 --- a/ldk-server/src/main.rs +++ b/ldk-server/src/main.rs @@ -232,9 +232,14 @@ fn main() { }, } - if let Some(addresses) = node.config().listening_addresses { - if !addresses.is_empty() { - info!("CONNECTION_STRING: {}@{}", node.node_id(), addresses.first().unwrap()); + let addrs = node + .config() + .announcement_addresses + .filter(|a| !a.is_empty()) + .or(node.config().listening_addresses); + if let Some(addresses) = addrs { + for address in &addresses { + info!("NODE_URI: {}@{}", node.node_id(), address); } }