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
1 change: 1 addition & 0 deletions e2e-tests/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ async fn test_cli_list_channels() {
// configured, so the reserve type is deterministically Adaptive.
assert_eq!(channel["reserve_type"].as_i64(), Some(ReserveType::Adaptive as i64));
assert!(!channel["channel_type"].as_object().unwrap().is_empty());
assert!(!channel["counterparty_features"].as_object().unwrap().is_empty());
}

#[tokio::test]
Expand Down
1 change: 1 addition & 0 deletions ldk-server-grpc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ fn generate_protos() {
"api.DecodeInvoiceResponse.features",
"api.DecodeOfferResponse.features",
"types.Channel.channel_type",
"types.Channel.counterparty_features",
"types.GraphNodeAnnouncement.features",
])
.type_attribute(
Expand Down
7 changes: 7 additions & 0 deletions ldk-server-grpc/src/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ message Channel {
// The negotiated channel-type features, keyed by the signaled BOLT feature bit.
// This map is empty until channel negotiation determines the channel type.
map<uint32, Feature> channel_type = 33;

// The features our counterparty provided upon last connection, keyed by the signaled BOLT
// feature bit.
//
// Useful for routing, as it is the most up-to-date copy of the counterparty's features and
// many routing-relevant features are present in the init context.
map<uint32, Feature> counterparty_features = 34;
}

// ChannelConfig represents the configuration settings for a channel in a Lightning Network node.
Expand Down
7 changes: 7 additions & 0 deletions ldk-server-grpc/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,13 @@ pub struct Channel {
/// This map is empty until channel negotiation determines the channel type.
#[prost(btree_map = "uint32, message", tag = "33")]
pub channel_type: ::prost::alloc::collections::BTreeMap<u32, Feature>,
/// The features our counterparty provided upon last connection, keyed by the signaled BOLT
/// feature bit.
///
/// Useful for routing, as it is the most up-to-date copy of the counterparty's features and
/// many routing-relevant features are present in the init context.
#[prost(btree_map = "uint32, message", tag = "34")]
pub counterparty_features: ::prost::alloc::collections::BTreeMap<u32, Feature>,
}
/// ChannelConfig represents the configuration settings for a channel in a Lightning Network node.
/// See more: <https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html>
Expand Down
6 changes: 5 additions & 1 deletion ldk-server/src/util/proto_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use ldk_node::lightning::routing::gossip::{
ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo, RoutingFees,
};
use ldk_node::lightning_invoice::{Bolt11InvoiceDescription, Description, Sha256};
use ldk_node::lightning_types::features::{ChannelTypeFeatures, NodeFeatures};
use ldk_node::lightning_types::features::{ChannelTypeFeatures, InitFeatures, NodeFeatures};
use ldk_node::payment::{
Channel as LdkTransactionChannel, ConfirmationStatus, PaymentDetails, PaymentDirection,
PaymentKind, PaymentStatus, TransactionType as LdkTransactionType,
Expand Down Expand Up @@ -96,6 +96,9 @@ pub(crate) fn channel_to_proto(channel: ChannelDetails) -> Channel {
})
.unwrap_or_default();
let counterparty = channel.counterparty;
let counterparty_features = features_to_proto(counterparty.features.le_flags(), |bytes| {
InitFeatures::from_le_bytes(bytes).to_string()
});

Channel {
channel_id: channel.channel_id.0.to_lower_hex_string(),
Expand Down Expand Up @@ -145,6 +148,7 @@ pub(crate) fn channel_to_proto(channel: ChannelDetails) -> Channel {
.map(|s| channel_shutdown_state_to_proto(s) as i32),
reserve_type: channel.reserve_type.as_ref().map(|r| reserve_type_to_proto(r) as i32),
channel_type,
counterparty_features,
}
}

Expand Down