@@ -158,6 +158,7 @@ impl<'a> PathHop for &'a RouteHop {
158158 }
159159
160160 fn cltv_expiry_delta ( & self ) -> u32 {
161+ eprintln ! ( "cltv for hop is {}" , self . cltv_expiry_delta) ;
161162 self . cltv_expiry_delta
162163 }
163164}
@@ -180,6 +181,7 @@ impl<'a> PathHop for &'a TrampolineHop {
180181 }
181182
182183 fn cltv_expiry_delta ( & self ) -> u32 {
184+ eprintln ! ( "trampoline hop cltv is {}" , self . cltv_expiry_delta) ;
183185 self . cltv_expiry_delta
184186 }
185187}
@@ -532,18 +534,16 @@ where
532534{
533535 let mut cur_value_msat = 0u64 ;
534536 let mut cur_cltv = starting_htlc_offset;
537+ eprintln ! ( "\n {:?}init'd cltv to {starting_htlc_offset}" , :: backtrace:: Backtrace :: new( ) ) ;
535538 let mut last_hop_id = None ;
536539
537540 for ( idx, hop) in hops. rev ( ) . enumerate ( ) {
541+ eprintln ! ( "\n loop idx {idx}. starting cltv {cur_cltv}" ) ;
538542 // First hop gets special values so that it can check, on receipt, that everything is
539543 // exactly as it should be (and the next hop isn't trying to probe to find out if we're
540544 // the intended recipient).
541545 let value_msat = if cur_value_msat == 0 { hop. fee_msat ( ) } else { cur_value_msat } ;
542- let cltv = if cur_cltv == starting_htlc_offset {
543- hop. cltv_expiry_delta ( ) . saturating_add ( starting_htlc_offset)
544- } else {
545- cur_cltv
546- } ;
546+ let cltv = hop. cltv_expiry_delta ( ) . saturating_add ( starting_htlc_offset) ;
547547 if idx == 0 {
548548 match blinded_tail. take ( ) {
549549 Some ( BlindedTailDetails :: DirectEntry {
@@ -553,6 +553,7 @@ where
553553 excess_final_cltv_expiry_delta,
554554 ..
555555 } ) => {
556+ eprintln ! ( "first hop is bp" ) ;
556557 let mut blinding_point = Some ( blinding_point) ;
557558 let hops_len = hops. len ( ) ;
558559 for ( i, blinded_hop) in hops. enumerate ( ) {
@@ -586,18 +587,20 @@ where
586587 trampoline_packet,
587588 final_value_msat,
588589 } ) => {
590+ eprintln ! ( "first hop is tramp" ) ;
589591 cur_value_msat += final_value_msat;
590592 callback (
591593 PayloadCallbackAction :: PushBack ,
592594 OP :: new_trampoline_entry (
593595 final_value_msat + hop. fee_msat ( ) ,
594- cur_cltv ,
596+ cltv ,
595597 & recipient_onion,
596598 trampoline_packet,
597599 ) ?,
598600 ) ;
599601 } ,
600602 None => {
603+ eprintln ! ( "pushing regular first hop with cltv {cltv}" ) ;
601604 callback (
602605 PayloadCallbackAction :: PushBack ,
603606 OP :: new_receive ( & recipient_onion, * keysend_preimage, value_msat, cltv) ?,
@@ -610,14 +613,15 @@ where
610613 err : "Next hop ID must be known for non-final hops" . to_string ( ) ,
611614 } ) ?,
612615 value_msat,
613- cltv ,
616+ cur_cltv ,
614617 ) ;
615618 callback ( PayloadCallbackAction :: PushFront , payload) ;
616619 }
617620 cur_value_msat += hop. fee_msat ( ) ;
618621 if cur_value_msat >= 21000000 * 100000000 * 1000 {
619622 return Err ( APIError :: InvalidRoute { err : "Channel fees overflowed?" . to_owned ( ) } ) ;
620623 }
624+ eprintln ! ( "cur cltv added {}" , hop. cltv_expiry_delta( ) ) ;
621625 cur_cltv = cur_cltv. saturating_add ( hop. cltv_expiry_delta ( ) as u32 ) ;
622626 if cur_cltv >= 500000000 {
623627 return Err ( APIError :: InvalidRoute { err : "Channel CLTV overflowed?" . to_owned ( ) } ) ;
@@ -2652,6 +2656,7 @@ pub(crate) fn create_payment_onion_internal<T: secp256k1::Signing>(
26522656 if !blinded_tail. trampoline_hops . is_empty ( ) {
26532657 let trampoline_payloads;
26542658 let outer_total_msat;
2659+ eprintln ! ( "building trampoline onion......." ) ;
26552660 ( trampoline_payloads, outer_total_msat, outer_starting_htlc_offset) =
26562661 build_trampoline_onion_payloads (
26572662 & blinded_tail,
@@ -2683,14 +2688,16 @@ pub(crate) fn create_payment_onion_internal<T: secp256k1::Signing>(
26832688 }
26842689 }
26852690
2691+ eprintln ! ( "building real onion......." ) ;
26862692 let ( onion_payloads, htlc_msat, htlc_cltv) = build_onion_payloads (
26872693 & path,
26882694 outer_onion,
2689- outer_starting_htlc_offset ,
2695+ cur_block_height ,
26902696 keysend_preimage,
26912697 invoice_request,
26922698 trampoline_packet_option,
26932699 ) ?;
2700+ debug_assert_eq ! ( htlc_cltv - cur_block_height, path. total_cltv_expiry_delta( ) ) ;
26942701
26952702 let onion_keys = construct_onion_keys ( & secp_ctx, & path, session_priv) ;
26962703 let onion_packet = construct_onion_packet ( onion_payloads, onion_keys, prng_seed, payment_hash)
0 commit comments