Skip to content

Commit 75215d9

Browse files
committed
Add detection of feature_static_remotekey support and print
This adds the ability to check for static_remotekey in appropriate feature contexts and prints it at connect time. It is still considered unknown for the purposes of requires_unknown_bits() as we don't yet implement it.
1 parent 194de0c commit 75215d9

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lightning/src/ln/features.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ mod sealed {
9797
// Byte 0
9898
DataLossProtect | InitialRoutingSync | UpfrontShutdownScript,
9999
// Byte 1
100-
VariableLengthOnion | PaymentSecret,
100+
VariableLengthOnion | StaticRemoteKey | PaymentSecret,
101101
// Byte 2
102102
BasicMPP,
103103
],
@@ -115,7 +115,7 @@ mod sealed {
115115
// Byte 0
116116
DataLossProtect | UpfrontShutdownScript,
117117
// Byte 1
118-
VariableLengthOnion | PaymentSecret,
118+
VariableLengthOnion | StaticRemoteKey | PaymentSecret,
119119
// Byte 2
120120
BasicMPP,
121121
],
@@ -215,6 +215,8 @@ mod sealed {
215215
"Feature flags for `option_upfront_shutdown_script`.");
216216
define_feature!(9, VariableLengthOnion, [InitContext, NodeContext],
217217
"Feature flags for `var_onion_optin`.");
218+
define_feature!(13, StaticRemoteKey, [InitContext, NodeContext],
219+
"Feature flags for `option_static_remotekey`.");
218220
define_feature!(15, PaymentSecret, [InitContext, NodeContext],
219221
"Feature flags for `payment_secret`.");
220222
define_feature!(17, BasicMPP, [InitContext, NodeContext],
@@ -418,6 +420,12 @@ impl<T: sealed::VariableLengthOnion> Features<T> {
418420
}
419421
}
420422

423+
impl<T: sealed::StaticRemoteKey> Features<T> {
424+
pub(crate) fn supports_static_remote_key(&self) -> bool {
425+
<T as sealed::StaticRemoteKey>::supports_feature(&self.flags)
426+
}
427+
}
428+
421429
impl<T: sealed::InitialRoutingSync> Features<T> {
422430
pub(crate) fn initial_routing_sync(&self) -> bool {
423431
<T as sealed::InitialRoutingSync>::supports_feature(&self.flags)
@@ -520,11 +528,11 @@ mod tests {
520528
{
521529
// Check that the flags are as expected:
522530
// - option_data_loss_protect
523-
// - var_onion_optin | payment_secret
531+
// - var_onion_optin | static_remote_key | payment_secret
524532
// - basic_mpp
525533
assert_eq!(node_features.flags.len(), 3);
526534
assert_eq!(node_features.flags[0], 0b00000010);
527-
assert_eq!(node_features.flags[1], 0b10000010);
535+
assert_eq!(node_features.flags[1], 0b10100010);
528536
assert_eq!(node_features.flags[2], 0b00000010);
529537
}
530538

lightning/src/ln/peer_handler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,11 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
629629
return Err(PeerHandleError{ no_connection_possible: false });
630630
}
631631

632-
log_info!(self, "Received peer Init message: data_loss_protect: {}, initial_routing_sync: {}, upfront_shutdown_script: {}, unkown local flags: {}, unknown global flags: {}",
632+
log_info!(self, "Received peer Init message: data_loss_protect: {}, initial_routing_sync: {}, upfront_shutdown_script: {}, static_remote_key: {}, unkown local flags: {}, unknown global flags: {}",
633633
if msg.features.supports_data_loss_protect() { "supported" } else { "not supported"},
634634
if msg.features.initial_routing_sync() { "requested" } else { "not requested" },
635635
if msg.features.supports_upfront_shutdown_script() { "supported" } else { "not supported"},
636+
if msg.features.supports_static_remote_key() { "supported" } else { "not supported"},
636637
if msg.features.supports_unknown_bits() { "present" } else { "none" },
637638
if msg.features.supports_unknown_bits() { "present" } else { "none" });
638639

0 commit comments

Comments
 (0)