Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://docs.rs/ldk-node/latest/ldk_node/payment/struct.OnchainPayment.html#method.new_address>
Expand Down
6 changes: 6 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 14 additions & 3 deletions ldk-server/src/api/get_node_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,32 @@ pub(crate) fn handle_get_node_info_request(
height: node_status.current_best_block.height,
};

let listening_addresses = context
let listening_addresses: Vec<String> = 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<String> = context
.node
.announcement_addresses()
.map(|addrs| addrs.into_iter().map(|a| a.to_string()).collect())
.unwrap_or_default();

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,
Expand All @@ -49,6 +59,7 @@ pub(crate) fn handle_get_node_info_request(
listening_addresses,
announcement_addresses,
node_alias,
node_uris,
};
Ok(response)
}
11 changes: 8 additions & 3 deletions ldk-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down