From 04bc7fd28fe62cf83e0eedf41fe00d6a6f90cbbe Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 2 Jul 2021 19:42:58 +0200 Subject: [PATCH] trampoline: fix "pay-to-legacy" workaround when using ACINQ node It is the last Trampoline Forwarder that should be checked, not the first one. Consider route (of Trampolines only): Alice-electrum -> T_ACINQ -> T_Hodlister -> Bob-electrum Even if Bob has a transport open with ACINQ or even if Bob has a channel open with ACINQ, Alice can safely use end-to-end trampoline for this route: ACINQ will not know who the recipient is, so they will not try to do pay-to-open (and hold up the payment for minutes...). related: https://github.com/ACINQ/lightning-kmp/pull/237 --- electrum/trampoline.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/electrum/trampoline.py b/electrum/trampoline.py index d5c92e11a..931245cf7 100644 --- a/electrum/trampoline.py +++ b/electrum/trampoline.py @@ -105,7 +105,7 @@ def create_trampoline_route( invoice_pubkey:bytes, invoice_features:int, my_pubkey: bytes, - trampoline_node_id, + trampoline_node_id: bytes, # the first trampoline in the path; which we are directly connected to r_tags, trampoline_fee_level: int, use_two_trampolines: bool) -> LNPaymentRoute: @@ -118,6 +118,7 @@ def create_trampoline_route( or invoice_features.supports(LnFeatures.OPTION_TRAMPOLINE_ROUTING_OPT_ECLAIR)): if not r_tags: # presumably the recipient has public channels is_legacy = False + pubkey = trampoline_node_id else: # - We choose one routing hint at random, and # use end-to-end trampoline if that node is a trampoline-forwarder (TF). @@ -130,16 +131,20 @@ def create_trampoline_route( r_tag_chosen_for_e2e_trampoline = random.choice(singlehop_r_tags)[0] pubkey, scid, feebase, feerate, cltv = r_tag_chosen_for_e2e_trampoline is_legacy = not is_hardcoded_trampoline(pubkey) + # Temporary fix: until ACINQ uses a proper feature bit to detect Phoenix, + # they might try to open channels when payments fail. The ACINQ node does this + # if it is directly connected to the recipient but without enough sending capacity. + # They send a custom "pay-to-open-request", and wait 60+ sec for the recipient to respond. + # Effectively, they hold the HTLC for minutes before failing it. + # see: https://github.com/ACINQ/lightning-kmp/pull/237 + if pubkey == TRAMPOLINE_NODES_MAINNET['ACINQ'].pubkey: + is_legacy = True + use_two_trampolines = False # fee level. the same fee is used for all trampolines if trampoline_fee_level < len(TRAMPOLINE_FEES): params = TRAMPOLINE_FEES[trampoline_fee_level] else: raise NoPathFound() - # temporary fix: until ACINQ uses a proper feature bit to detect - # Phoenix, they might try to open channels when payments fail - if trampoline_node_id == TRAMPOLINE_NODES_MAINNET['ACINQ'].pubkey: - is_legacy = True - use_two_trampolines = False # add optional second trampoline trampoline2 = None if is_legacy and use_two_trampolines: