diff --git a/electrum/lnrouter.py b/electrum/lnrouter.py index c89ba7f33..9fd6d329b 100644 --- a/electrum/lnrouter.py +++ b/electrum/lnrouter.py @@ -493,7 +493,7 @@ class LNPathFinder(Logger): # it's ok if we are missing the node_announcement (node_info) for this node, # but if we have it, we enforce that they support var_onion_optin node_features = LnFeatures(node_info.features) - if not node_features.supports(LnFeatures.VAR_ONION_OPT): + if not node_features.supports(LnFeatures.VAR_ONION_OPT): # note: this is kind of slow. could be cached. return float('inf'), 0 route_edge = RouteEdge.from_channel_policy( channel_policy=channel_policy, diff --git a/electrum/lnutil.py b/electrum/lnutil.py index 821b94537..e5fe62009 100644 --- a/electrum/lnutil.py +++ b/electrum/lnutil.py @@ -1250,13 +1250,13 @@ class LnFeatures(IntFlag): you can do: myfeatures.supports(LnFeatures.VAR_ONION_OPT) """ - enabled_bits = list_enabled_bits(feature) - if len(enabled_bits) != 1: + if (1 << (feature.bit_length() - 1)) != feature: raise ValueError(f"'feature' cannot be a combination of features: {feature}") - flag = enabled_bits[0] - our_flags = set(list_enabled_bits(self)) - return (flag in our_flags - or get_ln_flag_pair_of_bit(flag) in our_flags) + if feature.bit_length() % 2 == 0: # feature is OPT + feature_other = feature >> 1 + else: # feature is REQ + feature_other = feature << 1 + return (self & feature != 0) or (self & feature_other != 0) def get_names(self) -> Sequence[str]: r = []