|
|
|
|
@ -602,7 +602,7 @@ class Peer(Logger):
|
|
|
|
|
try: |
|
|
|
|
if self.transport: |
|
|
|
|
self.transport.close() |
|
|
|
|
except: |
|
|
|
|
except Exception: |
|
|
|
|
pass |
|
|
|
|
self.lnworker.peer_closed(self) |
|
|
|
|
self.got_disconnected.set() |
|
|
|
|
@ -1594,7 +1594,7 @@ class Peer(Logger):
|
|
|
|
|
raise OnionRoutingFailure(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'') |
|
|
|
|
try: |
|
|
|
|
next_chan_scid = processed_onion.hop_data.payload["short_channel_id"]["short_channel_id"] |
|
|
|
|
except: |
|
|
|
|
except Exception: |
|
|
|
|
raise OnionRoutingFailure(code=OnionFailureCode.INVALID_ONION_PAYLOAD, data=b'\x00\x00\x00') |
|
|
|
|
next_chan = self.lnworker.get_channel_by_short_id(next_chan_scid) |
|
|
|
|
local_height = chain.height() |
|
|
|
|
@ -1610,14 +1610,14 @@ class Peer(Logger):
|
|
|
|
|
raise OnionRoutingFailure(code=OnionFailureCode.TEMPORARY_CHANNEL_FAILURE, data=outgoing_chan_upd_message) |
|
|
|
|
try: |
|
|
|
|
next_amount_msat_htlc = processed_onion.hop_data.payload["amt_to_forward"]["amt_to_forward"] |
|
|
|
|
except: |
|
|
|
|
except Exception: |
|
|
|
|
raise OnionRoutingFailure(code=OnionFailureCode.INVALID_ONION_PAYLOAD, data=b'\x00\x00\x00') |
|
|
|
|
if not next_chan.can_pay(next_amount_msat_htlc): |
|
|
|
|
self.logger.info(f"cannot forward htlc due to transient errors (likely due to insufficient funds)") |
|
|
|
|
raise OnionRoutingFailure(code=OnionFailureCode.TEMPORARY_CHANNEL_FAILURE, data=outgoing_chan_upd_message) |
|
|
|
|
try: |
|
|
|
|
next_cltv_expiry = processed_onion.hop_data.payload["outgoing_cltv_value"]["outgoing_cltv_value"] |
|
|
|
|
except: |
|
|
|
|
except Exception: |
|
|
|
|
raise OnionRoutingFailure(code=OnionFailureCode.INVALID_ONION_PAYLOAD, data=b'\x00\x00\x00') |
|
|
|
|
if htlc.cltv_expiry - next_cltv_expiry < next_chan.forwarding_cltv_expiry_delta: |
|
|
|
|
data = htlc.cltv_expiry.to_bytes(4, byteorder="big") + outgoing_chan_upd_message |
|
|
|
|
@ -1746,7 +1746,7 @@ class Peer(Logger):
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
amt_to_forward = processed_onion.hop_data.payload["amt_to_forward"]["amt_to_forward"] |
|
|
|
|
except: |
|
|
|
|
except Exception: |
|
|
|
|
log_fail_reason(f"'amt_to_forward' missing from onion") |
|
|
|
|
raise OnionRoutingFailure(code=OnionFailureCode.INVALID_ONION_PAYLOAD, data=b'\x00\x00\x00') |
|
|
|
|
|
|
|
|
|
@ -1766,7 +1766,7 @@ class Peer(Logger):
|
|
|
|
|
raise exc_incorrect_or_unknown_pd |
|
|
|
|
try: |
|
|
|
|
cltv_from_onion = processed_onion.hop_data.payload["outgoing_cltv_value"]["outgoing_cltv_value"] |
|
|
|
|
except: |
|
|
|
|
except Exception: |
|
|
|
|
log_fail_reason(f"'outgoing_cltv_value' missing from onion") |
|
|
|
|
raise OnionRoutingFailure(code=OnionFailureCode.INVALID_ONION_PAYLOAD, data=b'\x00\x00\x00') |
|
|
|
|
|
|
|
|
|
@ -1778,7 +1778,7 @@ class Peer(Logger):
|
|
|
|
|
data=htlc.cltv_expiry.to_bytes(4, byteorder="big")) |
|
|
|
|
try: |
|
|
|
|
total_msat = processed_onion.hop_data.payload["payment_data"]["total_msat"] |
|
|
|
|
except: |
|
|
|
|
except Exception: |
|
|
|
|
total_msat = amt_to_forward # fall back to "amt_to_forward" |
|
|
|
|
|
|
|
|
|
if not is_trampoline and amt_to_forward != htlc.amount_msat: |
|
|
|
|
@ -1789,7 +1789,7 @@ class Peer(Logger):
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
payment_secret_from_onion = processed_onion.hop_data.payload["payment_data"]["payment_secret"] |
|
|
|
|
except: |
|
|
|
|
except Exception: |
|
|
|
|
if total_msat > amt_to_forward: |
|
|
|
|
# payment_secret is required for MPP |
|
|
|
|
log_fail_reason(f"'payment_secret' missing from onion") |
|
|
|
|
|