From 40c08d350f64728a84d0160d4e888035bec8ed97 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Sun, 27 Aug 2023 11:48:19 +0200 Subject: [PATCH] trampoline: fix two bugs preventing legacy payments to Electrum clients that have non-trampoline channels. - if an invoice supports trampoline, but provides only non-trampoline nodes in its routing hints, we must use a legacy trampoline payment - when we create a trampoline onion for a legacy payment, the invoice_features field is a u64, so we need to remove high feature bits. --- electrum/trampoline.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/electrum/trampoline.py b/electrum/trampoline.py index e9ea251dc..fb753df2a 100644 --- a/electrum/trampoline.py +++ b/electrum/trampoline.py @@ -121,7 +121,8 @@ def is_legacy_relay(invoice_features, r_tags) -> Tuple[bool, Set[bytes]]: singlehop_r_tags = [x for x in r_tags if len(x) == 1] invoice_trampolines = [x[0][0] for x in singlehop_r_tags if is_hardcoded_trampoline(x[0][0])] invoice_trampolines = set(invoice_trampolines) - return False, invoice_trampolines + if invoice_trampolines: + return False, invoice_trampolines # if trampoline receiving is not supported or the forwarder is not known as a trampoline, # we send a legacy payment return True, set() @@ -212,6 +213,8 @@ def create_trampoline_route( # the last trampoline onion must contain routing hints for the last trampoline # node to find the recipient invoice_routing_info = encode_routing_info(r_tags) + # lnwire invoice_features for trampoline is u64 + invoice_features = invoice_features & 0xffffffffffffffff route[-1].invoice_routing_info = invoice_routing_info route[-1].invoice_features = invoice_features route[-1].outgoing_node_id = invoice_pubkey