electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit cd893de837def1aee792e0b71af24078aa812810
parent 15a6a83107607d99079863bffc65805472376784
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  1 Aug 2018 18:22:23 +0200

lnrouter: use 'disable' flags from channel updates in path finding

Diffstat:
Melectrum/lnrouter.py | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/electrum/lnrouter.py b/electrum/lnrouter.py @@ -107,7 +107,7 @@ class ChannelInfo(PrintError): def on_channel_update(self, msg_payload, trusted=False): assert self.channel_id == msg_payload['short_channel_id'] flags = int.from_bytes(msg_payload['flags'], 'big') - direction = flags & 1 + direction = flags & ChannelInfoDirectedPolicy.FLAG_DIRECTION new_policy = ChannelInfoDirectedPolicy(msg_payload) if direction == 0: old_policy = self.policy_node1 @@ -136,6 +136,9 @@ class ChannelInfo(PrintError): class ChannelInfoDirectedPolicy: + FLAG_DIRECTION = 1 << 0 + FLAG_DISABLE = 1 << 1 + def __init__(self, channel_update_payload): cltv_expiry_delta = channel_update_payload['cltv_expiry_delta'] htlc_minimum_msat = channel_update_payload['htlc_minimum_msat'] @@ -151,6 +154,8 @@ class ChannelInfoDirectedPolicy: self.flags = int.from_bytes(flags, "big") self.timestamp = int.from_bytes(timestamp, "big") + self.disabled = self.flags & self.FLAG_DISABLE + def to_json(self) -> dict: d = {} d['cltv_expiry_delta'] = self.cltv_expiry_delta @@ -495,6 +500,7 @@ class LNPathFinder(PrintError): channel_policy = channel_info.get_policy_for_node(start_node) if channel_policy is None: return float('inf') + if channel_policy.disabled: return float('inf') cltv_expiry_delta = channel_policy.cltv_expiry_delta htlc_minimum_msat = channel_policy.htlc_minimum_msat fee_base_msat = channel_policy.fee_base_msat