1
0

renames: use consistent naming of cltv delta vs cltv abs

to avoid confusing relative vs absolute cltvs
(see b0401a6386)
This commit is contained in:
SomberNight
2023-10-19 16:33:04 +00:00
parent b645da6514
commit 22a8348303
17 changed files with 264 additions and 216 deletions

View File

@@ -212,23 +212,23 @@ def new_onion_packet(
def calc_hops_data_for_payment(
route: 'LNPaymentRoute',
amount_msat: int,
final_cltv: int, *,
amount_msat: int, # that final recipient receives
*,
final_cltv_abs: int,
total_msat: int,
payment_secret: bytes,
) -> Tuple[List[OnionHopsDataSingle], int, int]:
"""Returns the hops_data to be used for constructing an onion packet,
and the amount_msat and cltv to be used on our immediate channel.
and the amount_msat and cltv_abs to be used on our immediate channel.
"""
if len(route) > NUM_MAX_EDGES_IN_PAYMENT_PATH:
raise PaymentFailure(f"too long route ({len(route)} edges)")
# payload that will be seen by the last hop:
amt = amount_msat
cltv = final_cltv
cltv_abs = final_cltv_abs
hop_payload = {
"amt_to_forward": {"amt_to_forward": amt},
"outgoing_cltv_value": {"outgoing_cltv_value": cltv},
"outgoing_cltv_value": {"outgoing_cltv_value": cltv_abs},
}
# for multipart payments we need to tell the receiver about the total and
# partial amounts
@@ -244,19 +244,19 @@ def calc_hops_data_for_payment(
is_trampoline = route_edge.is_trampoline()
if is_trampoline:
amt += route_edge.fee_for_edge(amt)
cltv += route_edge.cltv_expiry_delta
cltv_abs += route_edge.cltv_delta
hop_payload = {
"amt_to_forward": {"amt_to_forward": amt},
"outgoing_cltv_value": {"outgoing_cltv_value": cltv},
"outgoing_cltv_value": {"outgoing_cltv_value": cltv_abs},
"short_channel_id": {"short_channel_id": route_edge.short_channel_id},
}
hops_data.append(
OnionHopsDataSingle(payload=hop_payload))
if not is_trampoline:
amt += route_edge.fee_for_edge(amt)
cltv += route_edge.cltv_expiry_delta
cltv_abs += route_edge.cltv_delta
hops_data.reverse()
return hops_data, amt, cltv
return hops_data, amt, cltv_abs
def _generate_filler(key_type: bytes, hops_data: Sequence[OnionHopsDataSingle],