From: Matt Corallo Date: Tue, 3 Mar 2020 20:27:45 +0000 (-0500) Subject: Add detection of feature_static_remotekey support and print X-Git-Tag: v0.0.12~67^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=rust-lightning;a=commitdiff_plain;h=22dded737b6771d9de0eb20abac0d20e31ff929a 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. --- diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index b65b9b1b..ad894232 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -236,6 +236,8 @@ mod sealed { "Feature flags for `option_upfront_shutdown_script`."); define_feature!(9, VariableLengthOnion, [InitContext, NodeContext], "Feature flags for `var_onion_optin`."); + define_feature!(13, StaticRemoteKey, [InitContext, NodeContext], + "Feature flags for `option_static_remotekey`."); define_feature!(15, PaymentSecret, [InitContext, NodeContext], "Feature flags for `payment_secret`."); define_feature!(17, BasicMPP, [InitContext, NodeContext], @@ -470,6 +472,16 @@ impl Features { } } +impl Features { + pub(crate) fn supports_static_remote_key(&self) -> bool { + ::supports_feature(&self.flags) + } + #[cfg(test)] + pub(crate) fn requires_static_remote_key(&self) -> bool { + ::requires_feature(&self.flags) + } +} + impl Features { pub(crate) fn initial_routing_sync(&self) -> bool { ::supports_feature(&self.flags) @@ -555,6 +567,11 @@ mod tests { assert!(!InitFeatures::known().requires_variable_length_onion()); assert!(!NodeFeatures::known().requires_variable_length_onion()); + assert!(!InitFeatures::known().supports_static_remote_key()); + assert!(!NodeFeatures::known().supports_static_remote_key()); + assert!(!InitFeatures::known().requires_static_remote_key()); + assert!(!NodeFeatures::known().requires_static_remote_key()); + assert!(InitFeatures::known().supports_payment_secret()); assert!(NodeFeatures::known().supports_payment_secret()); assert!(!InitFeatures::known().requires_payment_secret()); diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 51a546de..02bb2625 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -629,10 +629,11 @@ impl PeerManager where return Err(PeerHandleError{ no_connection_possible: false }); } - log_info!(self, "Received peer Init message: data_loss_protect: {}, initial_routing_sync: {}, upfront_shutdown_script: {}, unkown local flags: {}, unknown global flags: {}", + 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: {}", if msg.features.supports_data_loss_protect() { "supported" } else { "not supported"}, if msg.features.initial_routing_sync() { "requested" } else { "not requested" }, if msg.features.supports_upfront_shutdown_script() { "supported" } else { "not supported"}, + if msg.features.supports_static_remote_key() { "supported" } else { "not supported"}, if msg.features.supports_unknown_bits() { "present" } else { "none" }, if msg.features.supports_unknown_bits() { "present" } else { "none" });