Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions electrum/lnworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3954,10 +3954,13 @@ async def maybe_forward_htlc_set(
min_inc_cltv_abs = min(
mpp_htlc.htlc.cltv_abs
for mpp_htlc in processed_htlc_set.keys()) # take "min" to assume worst-case
total_msat = any_outer_onion.total_msat
sum_inc_amt_msat = sum(mpp_htlc.htlc.amount_msat for mpp_htlc in processed_htlc_set)
assert total_msat <= sum_inc_amt_msat, f"{total_msat=} should be <= {sum_inc_amt_msat=}"
await self._maybe_forward_trampoline(
payment_hash=any_mpp_htlc.htlc.payment_hash,
closest_inc_cltv_abs=min_inc_cltv_abs,
total_msat=any_outer_onion.total_msat,
total_msat=total_msat,
any_trampoline_onion=any_trampoline_onion,
fw_payment_key=payment_key,
)
Expand Down Expand Up @@ -4094,7 +4097,7 @@ async def _maybe_forward_trampoline(
self, *,
payment_hash: bytes,
closest_inc_cltv_abs: int,
total_msat: int, # total_msat of the outer onion
total_msat: int, # total_msat of the outer onion. this is <= sum_inc_amt_msat
any_trampoline_onion: ProcessedOnionPacket, # any trampoline onion of the incoming htlc set, they should be similar
fw_payment_key: str,
) -> None:
Expand Down Expand Up @@ -4134,6 +4137,7 @@ async def _maybe_forward_trampoline(
f"RHASH corresponds to payreq we created. {payment_hash.hex()=}")
raise OnionRoutingFailure(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'')

assert total_msat >= amt_to_forward # sanity check: money_in >= money_out

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add closest_inc_cltv_abs >= out_cltv_abs ?

# these are the fee/cltv paid by the sender
# pay_to_node will raise if they are not sufficient
budget = PaymentFeeBudget(
Expand Down
Loading