diff --git a/e2e-tests/tests/e2e.rs b/e2e-tests/tests/e2e.rs index 05dea885..681416c9 100644 --- a/e2e-tests/tests/e2e.rs +++ b/e2e-tests/tests/e2e.rs @@ -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] diff --git a/ldk-server-grpc/build.rs b/ldk-server-grpc/build.rs index ece88bc3..84616330 100644 --- a/ldk-server-grpc/build.rs +++ b/ldk-server-grpc/build.rs @@ -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( diff --git a/ldk-server-grpc/src/proto/types.proto b/ldk-server-grpc/src/proto/types.proto index cea320b2..6f2bd961 100644 --- a/ldk-server-grpc/src/proto/types.proto +++ b/ldk-server-grpc/src/proto/types.proto @@ -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 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 counterparty_features = 34; } // ChannelConfig represents the configuration settings for a channel in a Lightning Network node. diff --git a/ldk-server-grpc/src/types.rs b/ldk-server-grpc/src/types.rs index 6cef8912..c5a51118 100644 --- a/ldk-server-grpc/src/types.rs +++ b/ldk-server-grpc/src/types.rs @@ -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, + /// 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, } /// ChannelConfig represents the configuration settings for a channel in a Lightning Network node. /// See more: diff --git a/ldk-server/src/util/proto_adapter.rs b/ldk-server/src/util/proto_adapter.rs index f61aebfa..2fa62bfe 100644 --- a/ldk-server/src/util/proto_adapter.rs +++ b/ldk-server/src/util/proto_adapter.rs @@ -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, @@ -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(), @@ -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, } }