@@ -1272,6 +1272,39 @@ pub struct ChannelCounterparty {
1272
1272
pub outbound_htlc_maximum_msat : Option < u64 > ,
1273
1273
}
1274
1274
1275
+ /// An enum gathering stats on pending HTLCs, either inbound or outbound side.
1276
+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
1277
+ pub struct HTLCStats {
1278
+ /// The number of pending HTLCs.
1279
+ pub pending_htlcs : u32 ,
1280
+ /// The total value of pending HTLCs.
1281
+ pub pending_htlcs_value_msat : u64 ,
1282
+ /// The total dust exposure for the counterparty.
1283
+ pub on_counterparty_tx_dust_exposure_msat : u64 ,
1284
+ /// The total dust exposure for the local node.
1285
+ pub on_holder_tx_dust_exposure_msat : u64 ,
1286
+ /// The total value of pending, outgoing HTLCs being held.
1287
+ ///
1288
+ /// These HTLCs are being held temporarily after sending commitment_signed to discern them
1289
+ /// from HTLCs implicitly included in the counterparty's revoke_and_ack.
1290
+ pub holding_cell_msat : u64 ,
1291
+ /// The number of pending, outgoing HTLCs being added that are being held,
1292
+ /// dust HTLCS not included.
1293
+ ///
1294
+ /// These HTLCs are being held temporarily after sending commitment_signed to discern them
1295
+ /// from HTLCs implicitly included in the counterparty's revoke_and_ack.
1296
+ pub on_holder_tx_holding_cell_htlcs_count : u32 ,
1297
+ }
1298
+
1299
+ impl_writeable_tlv_based ! ( HTLCStats , {
1300
+ ( 0 , pending_htlcs, required) ,
1301
+ ( 2 , pending_htlcs_value_msat, required) ,
1302
+ ( 4 , on_counterparty_tx_dust_exposure_msat, required) ,
1303
+ ( 6 , on_holder_tx_dust_exposure_msat, required) ,
1304
+ ( 8 , holding_cell_msat, required) ,
1305
+ ( 10 , on_holder_tx_holding_cell_htlcs_count, required) ,
1306
+ } ) ;
1307
+
1275
1308
/// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`]
1276
1309
#[ derive( Clone , Debug , PartialEq ) ]
1277
1310
pub struct ChannelDetails {
@@ -1443,6 +1476,14 @@ pub struct ChannelDetails {
1443
1476
///
1444
1477
/// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1445
1478
pub config : Option < ChannelConfig > ,
1479
+ /// Statistics on pending incoming HTLCs.
1480
+ ///
1481
+ /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.116.
1482
+ pub incoming_htlc_stats : Option < HTLCStats > ,
1483
+ /// Statistics on pending outgoing HTLCs.
1484
+ ///
1485
+ /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.116.
1486
+ pub outgoing_htlc_stats : Option < HTLCStats > ,
1446
1487
}
1447
1488
1448
1489
impl ChannelDetails {
@@ -1514,6 +1555,8 @@ impl ChannelDetails {
1514
1555
inbound_htlc_minimum_msat : Some ( channel. get_holder_htlc_minimum_msat ( ) ) ,
1515
1556
inbound_htlc_maximum_msat : channel. get_holder_htlc_maximum_msat ( ) ,
1516
1557
config : Some ( channel. config ( ) ) ,
1558
+ incoming_htlc_stats : Some ( channel. get_inbound_pending_htlc_stats ( None ) ) ,
1559
+ outgoing_htlc_stats : Some ( channel. get_outbound_pending_htlc_stats ( None ) ) ,
1517
1560
}
1518
1561
}
1519
1562
}
@@ -7156,6 +7199,8 @@ impl Writeable for ChannelDetails {
7156
7199
( 35 , self . inbound_htlc_maximum_msat, option) ,
7157
7200
( 37 , user_channel_id_high_opt, option) ,
7158
7201
( 39 , self . feerate_sat_per_1000_weight, option) ,
7202
+ ( 41 , self . incoming_htlc_stats, option) ,
7203
+ ( 43 , self . outgoing_htlc_stats, option) ,
7159
7204
} ) ;
7160
7205
Ok ( ( ) )
7161
7206
}
@@ -7193,6 +7238,8 @@ impl Readable for ChannelDetails {
7193
7238
( 35 , inbound_htlc_maximum_msat, option) ,
7194
7239
( 37 , user_channel_id_high_opt, option) ,
7195
7240
( 39 , feerate_sat_per_1000_weight, option) ,
7241
+ ( 40 , incoming_htlc_stats, option) ,
7242
+ ( 41 , outgoing_htlc_stats, option) ,
7196
7243
} ) ;
7197
7244
7198
7245
// `user_channel_id` used to be a single u64 value. In order to remain backwards compatible with
@@ -7228,6 +7275,8 @@ impl Readable for ChannelDetails {
7228
7275
inbound_htlc_minimum_msat,
7229
7276
inbound_htlc_maximum_msat,
7230
7277
feerate_sat_per_1000_weight,
7278
+ incoming_htlc_stats,
7279
+ outgoing_htlc_stats,
7231
7280
} )
7232
7281
}
7233
7282
}
0 commit comments