Skip to content

Commit b6c92e1

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 b6c92e1

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lightning/src/ln/features.rs

+12-4
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
],
@@ -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,12 @@ 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+
}
480+
473481
impl<T: sealed::InitialRoutingSync> Features<T> {
474482
pub(crate) fn initial_routing_sync(&self) -> bool {
475483
<T as sealed::InitialRoutingSync>::supports_feature(&self.flags)
@@ -600,11 +608,11 @@ mod tests {
600608
{
601609
// Check that the flags are as expected:
602610
// - option_data_loss_protect
603-
// - var_onion_optin | payment_secret
611+
// - var_onion_optin | static_remote_key | payment_secret
604612
// - basic_mpp
605613
assert_eq!(node_features.flags.len(), 3);
606614
assert_eq!(node_features.flags[0], 0b00000010);
607-
assert_eq!(node_features.flags[1], 0b10000010);
615+
assert_eq!(node_features.flags[1], 0b10100010);
608616
assert_eq!(node_features.flags[2], 0b00000010);
609617
}
610618

lightning/src/ln/peer_handler.rs

+2-1
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)