@@ -1102,6 +1102,12 @@ pub enum Event {
11021102 ///
11031103 /// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
11041104 path : Path ,
1105+ /// The hold times as reported by each hop. The unit in which the hold times are expressed are 100's of
1106+ /// milliseconds. So a hop reporting 2 is a hold time that corresponds to roughly 200 milliseconds. As earlier
1107+ /// hops hold on to an HTLC for longer, the hold times in the list are expected to decrease. When our peer
1108+ /// didn't provide attribution data, the list is empty. The same applies to HTLCs that were resolved onchain.
1109+ /// Because of unavailability of hold times, the list may be shorter than the number of hops in the path.
1110+ hold_times : Vec < u32 > ,
11051111 } ,
11061112 /// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to
11071113 /// handle the HTLC.
@@ -1153,7 +1159,11 @@ pub enum Event {
11531159 error_code : Option < u16 > ,
11541160 #[ cfg( any( test, feature = "_test_utils" ) ) ]
11551161 error_data : Option < Vec < u8 > > ,
1156- #[ cfg( any( test, feature = "_test_utils" ) ) ]
1162+ /// The hold times as reported by each hop. The unit in which the hold times are expressed are 100's of
1163+ /// milliseconds. So a hop reporting 2 is a hold time that corresponds to roughly 200 milliseconds. As earlier
1164+ /// hops hold on to an HTLC for longer, the hold times in the list are expected to decrease. When our peer
1165+ /// didn't provide attribution data, the list is empty. The same applies to HTLCs that were resolved onchain.
1166+ /// Because of unavailability of hold times, the list may be shorter than the number of hops in the path.
11571167 hold_times : Vec < u32 > ,
11581168 } ,
11591169 /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.
@@ -1792,16 +1802,13 @@ impl Writeable for Event {
17921802 ref error_code,
17931803 #[ cfg( any( test, feature = "_test_utils") ) ]
17941804 ref error_data,
1795- #[ cfg( any( test, feature = "_test_utils") ) ]
17961805 ref hold_times,
17971806 } => {
17981807 3u8 . write ( writer) ?;
17991808 #[ cfg( any( test, feature = "_test_utils" ) ) ]
18001809 error_code. write ( writer) ?;
18011810 #[ cfg( any( test, feature = "_test_utils" ) ) ]
18021811 error_data. write ( writer) ?;
1803- #[ cfg( any( test, feature = "_test_utils" ) ) ]
1804- hold_times. write ( writer) ?;
18051812 write_tlv_fields ! ( writer, {
18061813 ( 0 , payment_hash, required) ,
18071814 ( 1 , None :: <NetworkUpdate >, option) , // network_update in LDK versions prior to 0.0.114
@@ -1813,6 +1820,7 @@ impl Writeable for Event {
18131820 ( 9 , None :: <RouteParameters >, option) , // retry in LDK versions prior to 0.0.115
18141821 ( 11 , payment_id, option) ,
18151822 ( 13 , failure, required) ,
1823+ ( 15 , * hold_times, optional_vec) ,
18161824 } ) ;
18171825 } ,
18181826 & Event :: PendingHTLCsForwardable { time_forwardable : _ } => {
@@ -1910,10 +1918,16 @@ impl Writeable for Event {
19101918 ( 4 , funding_info, required) ,
19111919 } )
19121920 } ,
1913- & Event :: PaymentPathSuccessful { ref payment_id, ref payment_hash, ref path } => {
1921+ & Event :: PaymentPathSuccessful {
1922+ ref payment_id,
1923+ ref payment_hash,
1924+ ref path,
1925+ ref hold_times,
1926+ } => {
19141927 13u8 . write ( writer) ?;
19151928 write_tlv_fields ! ( writer, {
19161929 ( 0 , payment_id, required) ,
1930+ ( 1 , * hold_times, optional_vec) ,
19171931 ( 2 , payment_hash, option) ,
19181932 ( 4 , path. hops, required_vec) ,
19191933 ( 6 , path. blinded_tail, option) ,
@@ -2232,8 +2246,6 @@ impl MaybeReadable for Event {
22322246 let error_code = Readable :: read ( reader) ?;
22332247 #[ cfg( any( test, feature = "_test_utils" ) ) ]
22342248 let error_data = Readable :: read ( reader) ?;
2235- #[ cfg( any( test, feature = "_test_utils" ) ) ]
2236- let hold_times = Readable :: read ( reader) ?;
22372249 let mut payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
22382250 let mut payment_failed_permanently = false ;
22392251 let mut network_update = None ;
@@ -2242,6 +2254,7 @@ impl MaybeReadable for Event {
22422254 let mut short_channel_id = None ;
22432255 let mut payment_id = None ;
22442256 let mut failure_opt = None ;
2257+ let mut hold_times = None ;
22452258 read_tlv_fields ! ( reader, {
22462259 ( 0 , payment_hash, required) ,
22472260 ( 1 , network_update, upgradable_option) ,
@@ -2253,7 +2266,9 @@ impl MaybeReadable for Event {
22532266 ( 7 , short_channel_id, option) ,
22542267 ( 11 , payment_id, option) ,
22552268 ( 13 , failure_opt, upgradable_option) ,
2269+ ( 15 , hold_times, optional_vec) ,
22562270 } ) ;
2271+ let hold_times = hold_times. unwrap_or ( Vec :: new ( ) ) ;
22572272 let failure =
22582273 failure_opt. unwrap_or_else ( || PathFailure :: OnPath { network_update } ) ;
22592274 Ok ( Some ( Event :: PaymentPathFailed {
@@ -2267,7 +2282,6 @@ impl MaybeReadable for Event {
22672282 error_code,
22682283 #[ cfg( any( test, feature = "_test_utils" ) ) ]
22692284 error_data,
2270- #[ cfg( any( test, feature = "_test_utils" ) ) ]
22712285 hold_times,
22722286 } ) )
22732287 } ;
@@ -2413,14 +2427,19 @@ impl MaybeReadable for Event {
24132427 let mut f = || {
24142428 _init_and_read_len_prefixed_tlv_fields ! ( reader, {
24152429 ( 0 , payment_id, required) ,
2430+ ( 1 , hold_times, optional_vec) ,
24162431 ( 2 , payment_hash, option) ,
24172432 ( 4 , path, required_vec) ,
24182433 ( 6 , blinded_tail, option) ,
24192434 } ) ;
2435+
2436+ let hold_times = hold_times. unwrap_or ( Vec :: new ( ) ) ;
2437+
24202438 Ok ( Some ( Event :: PaymentPathSuccessful {
24212439 payment_id : payment_id. 0 . unwrap ( ) ,
24222440 payment_hash,
24232441 path : Path { hops : path, blinded_tail } ,
2442+ hold_times,
24242443 } ) )
24252444 } ;
24262445 f ( )
0 commit comments