Skip to content

Commit 610dc33

Browse files
committed
Rename starting_htlc_offset cur_block_height in onion building
Now that we are consistently using the `RouteHop::cltv_expiry_delta` as the last hop's starting CLTV rather than summing trampoline hops, `starting_htlc_offset` is a bit confusing - its actually always the current block height. Thus, here we rename it.
1 parent 3c94d81 commit 610dc33

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ pub(super) fn construct_trampoline_onion_keys<T: secp256k1::Signing>(
415415

416416
pub(super) fn build_trampoline_onion_payloads<'a>(
417417
blinded_tail: &'a BlindedTail, recipient_onion: &'a RecipientOnionFields,
418-
starting_htlc_offset: u32, keysend_preimage: &Option<PaymentPreimage>,
418+
cur_block_height: u32, keysend_preimage: &Option<PaymentPreimage>,
419419
) -> Result<(Vec<msgs::OutboundTrampolinePayload<'a>>, u64), APIError> {
420420
let mut res: Vec<msgs::OutboundTrampolinePayload> =
421421
Vec::with_capacity(blinded_tail.trampoline_hops.len() + blinded_tail.hops.len());
@@ -430,7 +430,7 @@ pub(super) fn build_trampoline_onion_payloads<'a>(
430430
blinded_tail.trampoline_hops.iter(),
431431
Some(blinded_tail_with_hop_iter),
432432
recipient_onion,
433-
starting_htlc_offset,
433+
cur_block_height,
434434
keysend_preimage,
435435
None,
436436
|action, payload| match action {
@@ -444,14 +444,14 @@ pub(super) fn build_trampoline_onion_payloads<'a>(
444444
/// returns the hop data, as well as the first-hop value_msat and CLTV value we should send.
445445
#[cfg(any(test, feature = "_externalize_tests"))]
446446
pub(crate) fn test_build_onion_payloads<'a>(
447-
path: &'a Path, recipient_onion: &'a RecipientOnionFields, starting_htlc_offset: u32,
447+
path: &'a Path, recipient_onion: &'a RecipientOnionFields, cur_block_height: u32,
448448
keysend_preimage: &Option<PaymentPreimage>, invoice_request: Option<&'a InvoiceRequest>,
449449
trampoline_packet: Option<msgs::TrampolineOnionPacket>,
450450
) -> Result<(Vec<msgs::OutboundOnionPayload<'a>>, u64, u32), APIError> {
451451
build_onion_payloads(
452452
path,
453453
recipient_onion,
454-
starting_htlc_offset,
454+
cur_block_height,
455455
keysend_preimage,
456456
invoice_request,
457457
trampoline_packet,
@@ -460,7 +460,7 @@ pub(crate) fn test_build_onion_payloads<'a>(
460460

461461
/// returns the hop data, as well as the first-hop value_msat and CLTV value we should send.
462462
fn build_onion_payloads<'a>(
463-
path: &'a Path, recipient_onion: &'a RecipientOnionFields, starting_htlc_offset: u32,
463+
path: &'a Path, recipient_onion: &'a RecipientOnionFields, cur_block_height: u32,
464464
keysend_preimage: &Option<PaymentPreimage>, invoice_request: Option<&'a InvoiceRequest>,
465465
trampoline_packet: Option<msgs::TrampolineOnionPacket>,
466466
) -> Result<(Vec<msgs::OutboundOnionPayload<'a>>, u64, u32), APIError> {
@@ -490,7 +490,7 @@ fn build_onion_payloads<'a>(
490490
path.hops.iter(),
491491
blinded_tail_with_hop_iter,
492492
recipient_onion,
493-
starting_htlc_offset,
493+
cur_block_height,
494494
keysend_preimage,
495495
invoice_request,
496496
|action, payload| match action {
@@ -520,7 +520,7 @@ enum PayloadCallbackAction {
520520
}
521521
fn build_onion_payloads_callback<'a, 'b, H, B, F, OP>(
522522
hops: H, mut blinded_tail: Option<BlindedTailDetails<'a, B>>,
523-
recipient_onion: &'a RecipientOnionFields, starting_htlc_offset: u32,
523+
recipient_onion: &'a RecipientOnionFields, cur_block_height: u32,
524524
keysend_preimage: &Option<PaymentPreimage>, invoice_request: Option<&'a InvoiceRequest>,
525525
mut callback: F,
526526
) -> Result<(u64, u32), APIError>
@@ -531,7 +531,7 @@ where
531531
OP: OnionPayload<'a, 'b, ReceiveType = OP>,
532532
{
533533
let mut cur_value_msat = 0u64;
534-
let mut cur_cltv = starting_htlc_offset;
534+
let mut cur_cltv = cur_block_height;
535535
let mut last_hop_id = None;
536536

537537
for (idx, hop) in hops.rev().enumerate() {
@@ -559,7 +559,7 @@ where
559559
OP::new_blinded_receive(
560560
final_value_msat,
561561
recipient_onion.total_mpp_amount_msat,
562-
starting_htlc_offset + excess_final_cltv_expiry_delta,
562+
cur_block_height + excess_final_cltv_expiry_delta,
563563
&blinded_hop.encrypted_payload,
564564
blinding_point.take(),
565565
*keysend_preimage,

0 commit comments

Comments
 (0)