@@ -13,8 +13,8 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1, self};
13
13
14
14
use crate :: blinded_path:: { BlindedHop , BlindedPath , Direction , IntroductionNode } ;
15
15
use crate :: blinded_path:: payment:: { ForwardNode , ForwardTlvs , PaymentConstraints , PaymentRelay , ReceiveTlvs } ;
16
- use crate :: ln:: PaymentHash ;
17
- use crate :: ln:: channelmanager:: { ChannelDetails , PaymentId , MIN_FINAL_CLTV_EXPIRY_DELTA } ;
16
+ use crate :: ln:: { PaymentHash , PaymentPreimage , onion_utils } ;
17
+ use crate :: ln:: channelmanager:: { ChannelDetails , PaymentId , MIN_FINAL_CLTV_EXPIRY_DELTA , RecipientOnionFields } ;
18
18
use crate :: ln:: features:: { BlindedHopFeatures , Bolt11InvoiceFeatures , Bolt12InvoiceFeatures , ChannelFeatures , NodeFeatures } ;
19
19
use crate :: ln:: msgs:: { DecodeError , ErrorAction , LightningError , MAX_VALUE_MSAT } ;
20
20
use crate :: offers:: invoice:: { BlindedPayInfo , Bolt12Invoice } ;
@@ -603,6 +603,17 @@ impl RouteParameters {
603
603
pub fn from_payment_params_and_value ( payment_params : PaymentParameters , final_value_msat : u64 ) -> Self {
604
604
Self { payment_params, final_value_msat, max_total_routing_fee_msat : Some ( final_value_msat / 100 + 50_000 ) }
605
605
}
606
+
607
+ /// Sets the maximum number of hops that can be included in a payment path, based on the provided
608
+ /// [`RecipientOnionFields`] and blinded paths.
609
+ pub fn set_max_path_length (
610
+ & mut self , recipient_onion : & RecipientOnionFields , is_keysend : bool , best_block_height : u32
611
+ ) -> Result < ( ) , ( ) > {
612
+ let keysend_preimage_opt = is_keysend. then ( || PaymentPreimage ( [ 42 ; 32 ] ) ) ;
613
+ onion_utils:: set_max_path_length (
614
+ self , recipient_onion, keysend_preimage_opt, best_block_height
615
+ )
616
+ }
606
617
}
607
618
608
619
impl Writeable for RouteParameters {
0 commit comments