mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
fix confusion re max path length
This commit is contained in:
parent
2fafd01945
commit
7edbd5682a
4 changed files with 9 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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'))
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue