Browse Source

lnpeer: remove recursve call in maybe_fulfill_htlc

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

33
electrum/lnpeer.py

@ -1540,21 +1540,9 @@ class Peer(Logger):
code=OnionFailureCode.FINAL_INCORRECT_HTLC_AMOUNT, code=OnionFailureCode.FINAL_INCORRECT_HTLC_AMOUNT,
data=total_msat.to_bytes(8, byteorder="big")) 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 there is a trampoline_onion, perform the above checks on it
if processed_onion.trampoline_onion_packet: if processed_onion.trampoline_onion_packet:
trampoline_onion = process_onion_packet( return
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)
info = self.lnworker.get_payment_info(htlc.payment_hash) info = self.lnworker.get_payment_info(htlc.payment_hash)
if info is None: if info is None:
@ -1877,12 +1865,19 @@ class Peer(Logger):
htlc.payment_hash, htlc.payment_hash,
onion_packet_bytes, onion_packet_bytes,
is_trampoline=True) is_trampoline=True)
self.maybe_forward_trampoline( if trampoline_onion.are_we_final:
chan=chan, preimage = self.maybe_fulfill_htlc(
htlc=htlc, chan=chan,
trampoline_onion=trampoline_onion) htlc=htlc,
# we return True so that this code gets executed only once processed_onion=trampoline_onion,
return None, True, None 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: else:
preimage = self.lnworker.get_preimage(payment_hash) preimage = self.lnworker.get_preimage(payment_hash)
error_reason = self.lnworker.trampoline_forwarding_failures.pop(payment_hash, None) error_reason = self.lnworker.trampoline_forwarding_failures.pop(payment_hash, None)

Loading…
Cancel
Save