Skip to content

Commit 7c735d9

Browse files
committed
Add a counterparty_node_id to ClaimedHTLC in claimed events
When we claim a payment, `Event::PaymentClaimed` contains a list of the HTLCs we claimed from as `ClaimedHTLC` objects. While they include a `channel_id` the pyment came to us over, in theory `channel_id`s aren't guaranteed to be unique (though in practice they are in all opened channels aside from 0conf ones with a malicious counterparty). Further, our APIs often require passing both the `counterparty_node_id` and the `channel_id` to do things to chanels. Thus, here we add the missing `counterparty_node-id` to `ClaimedHTLC`.
1 parent f624047 commit 7c735d9

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lightning/src/events/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ impl_writeable_tlv_based_enum_legacy!(PaymentPurpose,
233233
/// Information about an HTLC that is part of a payment that can be claimed.
234234
#[derive(Clone, Debug, PartialEq, Eq)]
235235
pub struct ClaimedHTLC {
236+
/// The counterparty of the channel.
237+
///
238+
/// This value will always be `None` for objects serialized with LDK versions prior to 0.2 and
239+
/// `Some` otherwise.
240+
pub counterparty_node_id: Option<PublicKey>,
236241
/// The `channel_id` of the channel over which the HTLC was received.
237242
pub channel_id: ChannelId,
238243
/// The `user_channel_id` of the channel over which the HTLC was received. This is the value
@@ -263,6 +268,7 @@ impl_writeable_tlv_based!(ClaimedHTLC, {
263268
(0, channel_id, required),
264269
(1, counterparty_skimmed_fee_msat, (default_value, 0u64)),
265270
(2, user_channel_id, required),
271+
(3, counterparty_node_id, option),
266272
(4, cltv_expiry, required),
267273
(6, value_msat, required),
268274
});

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ struct ClaimableHTLC {
512512
impl From<&ClaimableHTLC> for events::ClaimedHTLC {
513513
fn from(val: &ClaimableHTLC) -> Self {
514514
events::ClaimedHTLC {
515+
counterparty_node_id: val.prev_hop.counterparty_node_id,
515516
channel_id: val.prev_hop.channel_id,
516517
user_channel_id: val.prev_hop.user_channel_id.unwrap_or(0),
517518
cltv_expiry: val.cltv_expiry,

0 commit comments

Comments
 (0)