@@ -17,16 +17,16 @@ use crate::sign::{EntropySource, NodeSigner, Recipient};
17
17
use crate :: events:: { self , PaymentFailureReason } ;
18
18
use crate :: ln:: { PaymentHash , PaymentPreimage , PaymentSecret } ;
19
19
use crate :: ln:: channelmanager:: { ChannelDetails , EventCompletionAction , HTLCSource , PaymentId } ;
20
- use crate :: ln:: msgs ;
20
+ use crate :: ln:: onion_utils ;
21
21
use crate :: ln:: onion_utils:: { DecodedOnionFailure , HTLCFailReason } ;
22
22
use crate :: offers:: invoice:: Bolt12Invoice ;
23
- use crate :: routing:: router:: { BlindedTail , InFlightHtlcs , MAX_PATH_LENGTH_ESTIMATE , Path , Payee , PaymentParameters , Route , RouteParameters , Router } ;
23
+ use crate :: routing:: router:: { BlindedTail , InFlightHtlcs , Path , PaymentParameters , Route , RouteParameters , Router } ;
24
24
use crate :: util:: errors:: APIError ;
25
25
use crate :: util:: logger:: Logger ;
26
26
use crate :: util:: time:: Time ;
27
27
#[ cfg( all( feature = "std" , test) ) ]
28
28
use crate :: util:: time:: tests:: SinceEpoch ;
29
- use crate :: util:: ser:: { ReadableArgs , Writeable } ;
29
+ use crate :: util:: ser:: ReadableArgs ;
30
30
31
31
use core:: fmt:: { self , Display , Formatter } ;
32
32
use core:: ops:: Deref ;
@@ -914,7 +914,7 @@ impl OutboundPayments {
914
914
}
915
915
}
916
916
917
- set_max_path_length (
917
+ onion_utils :: set_max_path_length (
918
918
& mut route_params, & recipient_onion, keysend_preimage, best_block_height
919
919
)
920
920
. map_err ( |( ) | {
@@ -1787,74 +1787,6 @@ impl OutboundPayments {
1787
1787
}
1788
1788
}
1789
1789
1790
- fn set_max_path_length (
1791
- route_params : & mut RouteParameters , recipient_onion : & RecipientOnionFields ,
1792
- keysend_preimage : Option < PaymentPreimage > , best_block_height : u32 ,
1793
- ) -> Result < ( ) , ( ) > {
1794
- const PAYLOAD_HMAC_LEN : usize = 32 ;
1795
- const UNBLINDED_INTERMED_PAYLOAD_LEN : usize = PAYLOAD_HMAC_LEN
1796
- + 1 + 1 + 8 // amt_to_forward
1797
- + 1 + 1 + 4 // outgoing_cltv
1798
- + 1 + 1 + 8 ; // short_channel_id
1799
-
1800
- let num_reserved_bytes = match & route_params. payment_params . payee {
1801
- Payee :: Blinded { route_hints, .. } => {
1802
- let ( blinded_payinfo, largest_path) = route_hints
1803
- . iter ( )
1804
- . max_by ( |( _, path_a) , ( _, path_b) |
1805
- path_a. serialized_length ( ) . cmp ( & path_b. serialized_length ( ) ) )
1806
- . ok_or ( ( ) ) ?;
1807
-
1808
- largest_path. blinded_hops
1809
- . iter ( )
1810
- . rev ( )
1811
- . skip ( 1 )
1812
- . map ( |bh| msgs:: OutboundOnionPayload :: BlindedForward {
1813
- encrypted_tlvs : & bh. encrypted_payload ,
1814
- // For simplicity, always set the intro_node_blinding_point in the
1815
- // final payload.
1816
- intro_node_blinding_point : None ,
1817
- } )
1818
- . chain ( core:: iter:: once ( msgs:: OutboundOnionPayload :: BlindedReceive {
1819
- sender_intended_htlc_amt_msat : route_params. final_value_msat ,
1820
- total_msat : route_params. final_value_msat ,
1821
- cltv_expiry_height :
1822
- best_block_height. saturating_add ( blinded_payinfo. cltv_expiry_delta as u32 ) ,
1823
- encrypted_tlvs : largest_path. blinded_hops
1824
- . last ( )
1825
- . map ( |bh| & bh. encrypted_payload )
1826
- . unwrap_or ( & Vec :: new ( ) ) ,
1827
- intro_node_blinding_point : Some ( largest_path. blinding_point ) ,
1828
- keysend_preimage,
1829
- custom_tlvs : & recipient_onion. custom_tlvs ,
1830
- } ) )
1831
- . map ( |payload| payload. serialized_length ( ) . saturating_add ( PAYLOAD_HMAC_LEN ) )
1832
- . fold ( 0 , |acc : usize , payload_len| acc. saturating_add ( payload_len) )
1833
- } ,
1834
- Payee :: Clear { final_cltv_expiry_delta, .. } => {
1835
- msgs:: OutboundOnionPayload :: Receive {
1836
- payment_data : recipient_onion. payment_secret . map ( |payment_secret| {
1837
- msgs:: FinalOnionHopData { payment_secret, total_msat : route_params. final_value_msat }
1838
- } ) ,
1839
- payment_metadata : recipient_onion. payment_metadata . as_ref ( ) ,
1840
- keysend_preimage,
1841
- custom_tlvs : & recipient_onion. custom_tlvs ,
1842
- sender_intended_htlc_amt_msat : route_params. final_value_msat ,
1843
- cltv_expiry_height : best_block_height. saturating_add ( * final_cltv_expiry_delta) ,
1844
- }
1845
- . serialized_length ( )
1846
- . saturating_add ( PAYLOAD_HMAC_LEN )
1847
- }
1848
- } ;
1849
- let max_intermediate_unblinded_hops = 1300usize . checked_sub ( num_reserved_bytes)
1850
- . map ( |p| p / UNBLINDED_INTERMED_PAYLOAD_LEN )
1851
- . and_then ( |l| u8:: try_from ( l) . ok ( ) )
1852
- . ok_or ( ( ) ) ?;
1853
-
1854
- route_params. payment_params . max_intermediate_hops = core:: cmp:: min ( max_intermediate_unblinded_hops, MAX_PATH_LENGTH_ESTIMATE ) ;
1855
- Ok ( ( ) )
1856
- }
1857
-
1858
1790
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
1859
1791
/// payment probe.
1860
1792
pub ( super ) fn payment_is_probe ( payment_hash : & PaymentHash , payment_id : & PaymentId ,
0 commit comments