Browse Source

lnpeer: remove recursve call in maybe_fulfill_htlc

patch-4
ThomasV 4 years ago
parent
commit
3a40d48a6e
  1. 23
      electrum/lnpeer.py

23
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,11 +1865,18 @@ class Peer(Logger):
htlc.payment_hash,
onion_packet_bytes,
is_trampoline=True)
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)
# we return True so that this code gets executed only once
# return True so that this code gets executed only once
return None, True, None
else:
preimage = self.lnworker.get_preimage(payment_hash)

Loading…
Cancel
Save