@@ -1102,6 +1102,12 @@ pub enum Event {
1102
1102
///
1103
1103
/// May contain a closed channel if the HTLC sent along the path was fulfilled on chain.
1104
1104
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 > ,
1105
1111
} ,
1106
1112
/// Indicates an outbound HTLC we sent failed, likely due to an intermediary node being unable to
1107
1113
/// handle the HTLC.
@@ -1153,7 +1159,11 @@ pub enum Event {
1153
1159
error_code : Option < u16 > ,
1154
1160
#[ cfg( any( test, feature = "_test_utils" ) ) ]
1155
1161
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.
1157
1167
hold_times : Vec < u32 > ,
1158
1168
} ,
1159
1169
/// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination.
@@ -1792,16 +1802,13 @@ impl Writeable for Event {
1792
1802
ref error_code,
1793
1803
#[ cfg( any( test, feature = "_test_utils") ) ]
1794
1804
ref error_data,
1795
- #[ cfg( any( test, feature = "_test_utils") ) ]
1796
1805
ref hold_times,
1797
1806
} => {
1798
1807
3u8 . write ( writer) ?;
1799
1808
#[ cfg( any( test, feature = "_test_utils" ) ) ]
1800
1809
error_code. write ( writer) ?;
1801
1810
#[ cfg( any( test, feature = "_test_utils" ) ) ]
1802
1811
error_data. write ( writer) ?;
1803
- #[ cfg( any( test, feature = "_test_utils" ) ) ]
1804
- hold_times. write ( writer) ?;
1805
1812
write_tlv_fields ! ( writer, {
1806
1813
( 0 , payment_hash, required) ,
1807
1814
( 1 , None :: <NetworkUpdate >, option) , // network_update in LDK versions prior to 0.0.114
@@ -1813,6 +1820,7 @@ impl Writeable for Event {
1813
1820
( 9 , None :: <RouteParameters >, option) , // retry in LDK versions prior to 0.0.115
1814
1821
( 11 , payment_id, option) ,
1815
1822
( 13 , failure, required) ,
1823
+ ( 15 , * hold_times, optional_vec) ,
1816
1824
} ) ;
1817
1825
} ,
1818
1826
& Event :: PendingHTLCsForwardable { time_forwardable : _ } => {
@@ -1910,10 +1918,16 @@ impl Writeable for Event {
1910
1918
( 4 , funding_info, required) ,
1911
1919
} )
1912
1920
} ,
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
+ } => {
1914
1927
13u8 . write ( writer) ?;
1915
1928
write_tlv_fields ! ( writer, {
1916
1929
( 0 , payment_id, required) ,
1930
+ ( 1 , * hold_times, optional_vec) ,
1917
1931
( 2 , payment_hash, option) ,
1918
1932
( 4 , path. hops, required_vec) ,
1919
1933
( 6 , path. blinded_tail, option) ,
@@ -2232,8 +2246,6 @@ impl MaybeReadable for Event {
2232
2246
let error_code = Readable :: read ( reader) ?;
2233
2247
#[ cfg( any( test, feature = "_test_utils" ) ) ]
2234
2248
let error_data = Readable :: read ( reader) ?;
2235
- #[ cfg( any( test, feature = "_test_utils" ) ) ]
2236
- let hold_times = Readable :: read ( reader) ?;
2237
2249
let mut payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
2238
2250
let mut payment_failed_permanently = false ;
2239
2251
let mut network_update = None ;
@@ -2242,6 +2254,7 @@ impl MaybeReadable for Event {
2242
2254
let mut short_channel_id = None ;
2243
2255
let mut payment_id = None ;
2244
2256
let mut failure_opt = None ;
2257
+ let mut hold_times = None ;
2245
2258
read_tlv_fields ! ( reader, {
2246
2259
( 0 , payment_hash, required) ,
2247
2260
( 1 , network_update, upgradable_option) ,
@@ -2253,7 +2266,9 @@ impl MaybeReadable for Event {
2253
2266
( 7 , short_channel_id, option) ,
2254
2267
( 11 , payment_id, option) ,
2255
2268
( 13 , failure_opt, upgradable_option) ,
2269
+ ( 15 , hold_times, optional_vec) ,
2256
2270
} ) ;
2271
+ let hold_times = hold_times. unwrap_or ( Vec :: new ( ) ) ;
2257
2272
let failure =
2258
2273
failure_opt. unwrap_or_else ( || PathFailure :: OnPath { network_update } ) ;
2259
2274
Ok ( Some ( Event :: PaymentPathFailed {
@@ -2267,7 +2282,6 @@ impl MaybeReadable for Event {
2267
2282
error_code,
2268
2283
#[ cfg( any( test, feature = "_test_utils" ) ) ]
2269
2284
error_data,
2270
- #[ cfg( any( test, feature = "_test_utils" ) ) ]
2271
2285
hold_times,
2272
2286
} ) )
2273
2287
} ;
@@ -2413,14 +2427,19 @@ impl MaybeReadable for Event {
2413
2427
let mut f = || {
2414
2428
_init_and_read_len_prefixed_tlv_fields ! ( reader, {
2415
2429
( 0 , payment_id, required) ,
2430
+ ( 1 , hold_times, optional_vec) ,
2416
2431
( 2 , payment_hash, option) ,
2417
2432
( 4 , path, required_vec) ,
2418
2433
( 6 , blinded_tail, option) ,
2419
2434
} ) ;
2435
+
2436
+ let hold_times = hold_times. unwrap_or ( Vec :: new ( ) ) ;
2437
+
2420
2438
Ok ( Some ( Event :: PaymentPathSuccessful {
2421
2439
payment_id : payment_id. 0 . unwrap ( ) ,
2422
2440
payment_hash,
2423
2441
path : Path { hops : path, blinded_tail } ,
2442
+ hold_times,
2424
2443
} ) )
2425
2444
} ;
2426
2445
f ( )
0 commit comments