Skip to content

Commit 22dded7

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 18981a0 commit 22dded7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lightning/src/ln/features.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ mod sealed {
236236
"Feature flags for `option_upfront_shutdown_script`.");
237237
define_feature!(9, VariableLengthOnion, [InitContext, NodeContext],
238238
"Feature flags for `var_onion_optin`.");
239+
define_feature!(13, StaticRemoteKey, [InitContext, NodeContext],
240+
"Feature flags for `option_static_remotekey`.");
239241
define_feature!(15, PaymentSecret, [InitContext, NodeContext],
240242
"Feature flags for `payment_secret`.");
241243
define_feature!(17, BasicMPP, [InitContext, NodeContext],
@@ -470,6 +472,16 @@ impl<T: sealed::VariableLengthOnion> Features<T> {
470472
}
471473
}
472474

475+
impl<T: sealed::StaticRemoteKey> Features<T> {
476+
pub(crate) fn supports_static_remote_key(&self) -> bool {
477+
<T as sealed::StaticRemoteKey>::supports_feature(&self.flags)
478+
}
479+
#[cfg(test)]
480+
pub(crate) fn requires_static_remote_key(&self) -> bool {
481+
<T as sealed::StaticRemoteKey>::requires_feature(&self.flags)
482+
}
483+
}
484+
473485
impl<T: sealed::InitialRoutingSync> Features<T> {
474486
pub(crate) fn initial_routing_sync(&self) -> bool {
475487
<T as sealed::InitialRoutingSync>::supports_feature(&self.flags)
@@ -555,6 +567,11 @@ mod tests {
555567
assert!(!InitFeatures::known().requires_variable_length_onion());
556568
assert!(!NodeFeatures::known().requires_variable_length_onion());
557569

570+
assert!(!InitFeatures::known().supports_static_remote_key());
571+
assert!(!NodeFeatures::known().supports_static_remote_key());
572+
assert!(!InitFeatures::known().requires_static_remote_key());
573+
assert!(!NodeFeatures::known().requires_static_remote_key());
574+
558575
assert!(InitFeatures::known().supports_payment_secret());
559576
assert!(NodeFeatures::known().supports_payment_secret());
560577
assert!(!InitFeatures::known().requires_payment_secret());

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)