URI: 
       tfix confusion re max path length - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 7edbd5682ae2de059e7608b00ff7b6184c122e10
   DIR parent 2fafd01945569cb0ef1cad9320e426874fb40f7d
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Sat, 20 Oct 2018 16:50:43 +0200
       
       fix confusion re max path length
       
       Diffstat:
         M electrum/lnonion.py                 |       6 +++---
         M electrum/lnrouter.py                |       6 +++---
         M electrum/lnutil.py                  |       1 +
         M electrum/lnworker.py                |       4 ++--
       
       4 files changed, 9 insertions(+), 8 deletions(-)
       ---
   DIR diff --git a/electrum/lnonion.py b/electrum/lnonion.py
       t@@ -33,7 +33,7 @@ from cryptography.hazmat.backends import default_backend
        from . import ecc
        from .crypto import sha256, hmac_oneshot
        from .util import bh2u, profiler, xor_bytes, bfh
       -from .lnutil import get_ecdh, PaymentFailure, NUM_MAX_HOPS_IN_PAYMENT_PATH
       +from .lnutil import get_ecdh, PaymentFailure, NUM_MAX_HOPS_IN_PAYMENT_PATH, NUM_MAX_EDGES_IN_PAYMENT_PATH
        from .lnrouter import RouteEdge
        
        
       t@@ -191,8 +191,8 @@ def calc_hops_data_for_payment(route: List[RouteEdge], amount_msat: int, final_c
            """Returns the hops_data to be used for constructing an onion packet,
            and the amount_msat and cltv to be used on our immediate channel.
            """
       -    if len(route) > NUM_MAX_HOPS_IN_PAYMENT_PATH:
       -        raise PaymentFailure(f"too long route ({len(route)} hops)")
       +    if len(route) > NUM_MAX_EDGES_IN_PAYMENT_PATH:
       +        raise PaymentFailure(f"too long route ({len(route)} edges)")
        
            amt = amount_msat
            cltv = final_cltv
   DIR diff --git a/electrum/lnrouter.py b/electrum/lnrouter.py
       t@@ -39,7 +39,7 @@ from .storage import JsonDB
        from .lnchannelverifier import LNChannelVerifier, verify_sig_for_channel_update
        from .crypto import Hash
        from . import ecc
       -from .lnutil import LN_GLOBAL_FEATURES_KNOWN_SET, LNPeerAddr, NUM_MAX_HOPS_IN_PAYMENT_PATH
       +from .lnutil import LN_GLOBAL_FEATURES_KNOWN_SET, LNPeerAddr, NUM_MAX_EDGES_IN_PAYMENT_PATH
        
        
        class UnknownEvenFeatureBits(Exception): pass
       t@@ -535,7 +535,7 @@ def is_route_sane_to_use(route: List[RouteEdge], invoice_amount_msat: int, min_f
            """Run some sanity checks on the whole route, before attempting to use it.
            called when we are paying; so e.g. lower cltv is better
            """
       -    if len(route) > NUM_MAX_HOPS_IN_PAYMENT_PATH:
       +    if len(route) > NUM_MAX_EDGES_IN_PAYMENT_PATH:
                return False
            amt = invoice_amount_msat
            cltv = min_final_cltv_expiry
       t@@ -606,7 +606,7 @@ class LNPathFinder(PrintError):
                unable_channels = set(map(lambda x: x.short_channel_id, filter(lambda x: not x.can_pay(amount_msat), my_channels)))
        
                # TODO find multiple paths??
       -        # FIXME paths cannot be longer than 20 (onion packet)...
       +        # FIXME paths cannot be longer than 21 edges (onion packet)...
        
                # run Dijkstra
                distance_from_start = defaultdict(lambda: float('inf'))
   DIR diff --git a/electrum/lnutil.py b/electrum/lnutil.py
       t@@ -614,4 +614,5 @@ class EncumberedTransaction(NamedTuple("EncumberedTransaction", [('tx', Transact
        
        
        NUM_MAX_HOPS_IN_PAYMENT_PATH = 20
       +NUM_MAX_EDGES_IN_PAYMENT_PATH = NUM_MAX_HOPS_IN_PAYMENT_PATH + 1
        
   DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -26,7 +26,7 @@ from .lnutil import (Outpoint, calc_short_channel_id, LNPeerAddr,
                             PaymentFailure, split_host_port, ConnStringFormatError,
                             generate_keypair, LnKeyFamily, LOCAL, REMOTE,
                             UnknownPaymentHash, MIN_FINAL_CLTV_EXPIRY_FOR_INVOICE,
       -                     NUM_MAX_HOPS_IN_PAYMENT_PATH)
       +                     NUM_MAX_EDGES_IN_PAYMENT_PATH)
        from .lnaddr import lndecode
        from .i18n import _
        from .lnrouter import RouteEdge, is_route_sane_to_use
       t@@ -286,7 +286,7 @@ class LNWorker(PrintError):
                    channels = list(self.channels.values())
                for private_route in r_tags:
                    if len(private_route) == 0: continue
       -            if len(private_route) > NUM_MAX_HOPS_IN_PAYMENT_PATH: continue
       +            if len(private_route) > NUM_MAX_EDGES_IN_PAYMENT_PATH: continue
                    border_node_pubkey = private_route[0][0]
                    path = self.network.path_finder.find_path_for_payment(self.node_keypair.pubkey, border_node_pubkey, amount_msat, channels)
                    if not path: continue