Skip to content

Commit 931df07

Browse files
authored
Merge pull request #1021 from tnull/2026-08-expose-htlc-locator-amounts
Expose per-HTLC forwarded amounts
2 parents e7f9283 + df8ab91 commit 931df07

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/event.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ use crate::{
6868
pub struct HTLCLocator {
6969
/// The channel that the HTLC was sent or received on.
7070
pub channel_id: ChannelId,
71+
/// The amount, in milli-satoshis, of the HTLC that was sent or received, if known.
72+
///
73+
/// This will be `None` for events serialized by LDK Node v0.7.0 and prior.
74+
pub amount_msat: Option<u64>,
7175
/// The `user_channel_id` for the channel.
7276
///
7377
/// Will only be `None` for events serialized with LDK Node v0.3.0 or prior, or if the
@@ -84,12 +88,14 @@ impl_writeable_tlv_based!(HTLCLocator, {
8488
(1, channel_id, required),
8589
(3, user_channel_id, option),
8690
(5, node_id, option),
91+
(7, amount_msat, option),
8792
});
8893

8994
impl From<LdkHtlcLocator> for HTLCLocator {
9095
fn from(value: LdkHtlcLocator) -> Self {
9196
HTLCLocator {
9297
channel_id: value.channel_id,
98+
amount_msat: value.amount_msat,
9399
user_channel_id: value.user_channel_id.map(|u| UserChannelId(u)),
94100
node_id: value.node_id,
95101
}
@@ -355,11 +361,13 @@ impl_writeable_tlv_based_enum!(Event,
355361
(14, outbound_amount_forwarded_msat, (default_value, 0)),
356362
(15, prev_htlcs, (default_value_vec, vec![HTLCLocator {
357363
channel_id: legacy_prev_channel_id.ok_or(lightning::ln::msgs::DecodeError::InvalidValue)?,
364+
amount_msat: None,
358365
user_channel_id: legacy_prev_user_channel_id.map(UserChannelId),
359366
node_id: legacy_prev_node_id,
360367
}])),
361368
(17, next_htlcs, (default_value_vec, vec![HTLCLocator {
362369
channel_id: legacy_next_channel_id.ok_or(lightning::ln::msgs::DecodeError::InvalidValue)?,
370+
amount_msat: None,
363371
user_channel_id: legacy_next_user_channel_id.map(UserChannelId),
364372
node_id: legacy_next_node_id,
365373
}])),
@@ -2214,11 +2222,13 @@ mod tests {
22142222
let logger = Arc::new(TestLogger::new());
22152223
let prev_htlcs = vec![HTLCLocator {
22162224
channel_id: ChannelId([1; 32]),
2225+
amount_msat: None,
22172226
user_channel_id: None,
22182227
node_id: None,
22192228
}];
22202229
let next_htlcs = vec![HTLCLocator {
22212230
channel_id: ChannelId([2; 32]),
2231+
amount_msat: None,
22222232
user_channel_id: None,
22232233
node_id: None,
22242234
}];

0 commit comments

Comments
 (0)