commit 3a40d48a6e5add78a67a1fb5916428d604de4612
parent 9b7f9219a36e1dab39385345270643479a5c0334
Author: ThomasV <thomasv@electrum.org>
Date: Sat, 20 Feb 2021 14:20:55 +0100
lnpeer: remove recursve call in maybe_fulfill_htlc
Diffstat:
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
@@ -1540,21 +1540,9 @@ class Peer(Logger):
code=OnionFailureCode.FINAL_INCORRECT_HTLC_AMOUNT,
data=total_msat.to_bytes(8, byteorder="big"))
- outgoing_node_id = processed_onion.hop_data.payload.get("outgoing_node_id")
- if is_trampoline and outgoing_node_id:
- return
-
# if there is a trampoline_onion, perform the above checks on it
if processed_onion.trampoline_onion_packet:
- trampoline_onion = process_onion_packet(
- processed_onion.trampoline_onion_packet,
- associated_data=htlc.payment_hash,
- our_onion_private_key=self.privkey)
- return self.maybe_fulfill_htlc(
- chan=chan,
- htlc=htlc,
- processed_onion=trampoline_onion,
- is_trampoline=True)
+ return
info = self.lnworker.get_payment_info(htlc.payment_hash)
if info is None:
@@ -1877,12 +1865,19 @@ class Peer(Logger):
htlc.payment_hash,
onion_packet_bytes,
is_trampoline=True)
- self.maybe_forward_trampoline(
- chan=chan,
- htlc=htlc,
- trampoline_onion=trampoline_onion)
- # we return True so that this code gets executed only once
- return None, True, None
+ if trampoline_onion.are_we_final:
+ preimage = self.maybe_fulfill_htlc(
+ chan=chan,
+ htlc=htlc,
+ processed_onion=trampoline_onion,
+ is_trampoline=True)
+ else:
+ self.maybe_forward_trampoline(
+ chan=chan,
+ htlc=htlc,
+ trampoline_onion=trampoline_onion)
+ # return True so that this code gets executed only once
+ return None, True, None
else:
preimage = self.lnworker.get_preimage(payment_hash)
error_reason = self.lnworker.trampoline_forwarding_failures.pop(payment_hash, None)