Skip to content
Open
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
37 changes: 15 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions ldk-server-protos/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ pub struct GetNodeInfoResponse {
/// 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>,
/// The init, node announcement, channel, and invoice features.
///
/// Should be always set, will never be `None`.
#[prost(message, optional, tag = "13")]
pub features: ::core::option::Option<super::types::Features>,
/// The bitcoin network the node is running on.
#[prost(string, tag = "14")]
pub network: ::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
8 changes: 8 additions & 0 deletions ldk-server-protos/src/proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ message GetNodeInfoResponse {
// 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;

// The init, node announcement, channel, and invoice features.
//
// Should be always set, will never be `None`.
types.Features features = 13;

// The bitcoin network the node is running on.
string network = 14;
}

// Retrieve a new on-chain funding address.
Expand Down
15 changes: 15 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -704,3 +704,18 @@ message RouteParametersConfig {
// Default value: 2
uint32 max_channel_saturation_power_of_half = 4;
}

// Represents the node's init, node announcement, channel, and invoice features.
message Features {
// Serialized init features.
bytes init = 1;

// Serialized node features.
bytes node = 2;

// Serialized channel features.
bytes channel = 3;

// Serialized invoice features.
bytes invoice = 4;
}
19 changes: 19 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,25 @@ pub struct RouteParametersConfig {
#[prost(uint32, tag = "4")]
pub max_channel_saturation_power_of_half: u32,
}
/// Represents the node's init, node announcement, channel, and invoice features.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Features {
/// Serialized init features.
#[prost(bytes = "bytes", tag = "1")]
pub init: ::prost::bytes::Bytes,
/// Serialized node features.
#[prost(bytes = "bytes", tag = "2")]
pub node: ::prost::bytes::Bytes,
/// Serialized channel features.
#[prost(bytes = "bytes", tag = "3")]
pub channel: ::prost::bytes::Bytes,
/// Serialized invoice features.
#[prost(bytes = "bytes", tag = "4")]
pub invoice: ::prost::bytes::Bytes,
}
/// Represents the direction of a payment.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node", rev = "9e0cfc5fa9b9dd74fefb795580d00b0a46c8f3a3" }
# ldk-node = { git = "https://github.com/lightningdevkit/ldk-node", rev = "9e0cfc5fa9b9dd74fefb795580d00b0a46c8f3a3" }
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node", rev = "refs/pull/810/head" }
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
hyper = { version = "1", default-features = false, features = ["server", "http1"] }
http-body-util = { version = "0.1", default-features = false }
Expand Down
18 changes: 17 additions & 1 deletion ldk-server/src/api/get_node_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use ldk_node::lightning::util::ser::Writeable;
use ldk_server_protos::api::{GetNodeInfoRequest, GetNodeInfoResponse};
use ldk_server_protos::types::BestBlock;
use ldk_server_protos::types::{BestBlock, Features};

use crate::api::error::LdkServerError;
use crate::service::Context;
Expand All @@ -23,6 +24,19 @@ pub(crate) fn handle_get_node_info_request(
height: node_status.current_best_block.height,
};

let network = context.node.config().network.to_string();

let node_features = context.node.node_features();
let init_features = context.node.init_features();
let channel_features = context.node.channel_features();
let invoice_features = context.node.bolt11_invoice_features();
let features = Features {
init: init_features.encode().into(),
node: node_features.encode().into(),
channel: channel_features.encode().into(),
invoice: invoice_features.encode().into(),
};

let listening_addresses: Vec<String> = context
.node
.listening_addresses()
Expand Down Expand Up @@ -60,6 +74,8 @@ pub(crate) fn handle_get_node_info_request(
announcement_addresses,
node_alias,
node_uris,
features: Some(features),
network,
};
Ok(response)
}