Skip to content

Commit d24bef8

Browse files
committed
Include Counterparty Node IDs in PaymentForwarded
This commit adds counterparty node IDs to `PaymentForwarded` to address the potential ambiguity of using `ChannelIds` alone, especially in cases like v1 0conf opens where `ChannelIds` may not be unique. Including the counterparty node IDs provides better clarity and makes the information more useful.
1 parent abf72a5 commit d24bef8

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

lightning/src/events/mod.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,15 @@ pub enum Event {
11841184
/// caveat described for the `total_fee_earned_msat` field. Moreover it will be `None` for
11851185
/// events generated or serialized by versions prior to 0.0.122.
11861186
next_user_channel_id: Option<u128>,
1187+
/// The node id of the previous node.
1188+
///
1189+
/// This is only `None` for events generated or serialized by versions prior to 0.1
1190+
prev_node_id: Option<PublicKey>,
1191+
/// The node id of the next node.
1192+
///
1193+
/// This is only `None` for events generated or serialized by versions prior to 0.1
1194+
next_node_id: Option<PublicKey>,
1195+
11871196
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
11881197
///
11891198
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
@@ -1601,8 +1610,8 @@ impl Writeable for Event {
16011610
}
16021611
&Event::PaymentForwarded {
16031612
prev_channel_id, next_channel_id, prev_user_channel_id, next_user_channel_id,
1604-
total_fee_earned_msat, skimmed_fee_msat, claim_from_onchain_tx,
1605-
outbound_amount_forwarded_msat,
1613+
prev_node_id, next_node_id, total_fee_earned_msat, skimmed_fee_msat,
1614+
claim_from_onchain_tx, outbound_amount_forwarded_msat,
16061615
} => {
16071616
7u8.write(writer)?;
16081617
write_tlv_fields!(writer, {
@@ -1614,6 +1623,8 @@ impl Writeable for Event {
16141623
(7, skimmed_fee_msat, option),
16151624
(9, prev_user_channel_id, option),
16161625
(11, next_user_channel_id, option),
1626+
(13, prev_node_id, option),
1627+
(15, next_node_id, option),
16171628
});
16181629
},
16191630
&Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason,
@@ -1981,6 +1992,8 @@ impl MaybeReadable for Event {
19811992
let mut next_channel_id = None;
19821993
let mut prev_user_channel_id = None;
19831994
let mut next_user_channel_id = None;
1995+
let mut prev_node_id = None;
1996+
let mut next_node_id = None;
19841997
let mut total_fee_earned_msat = None;
19851998
let mut skimmed_fee_msat = None;
19861999
let mut claim_from_onchain_tx = false;
@@ -1994,11 +2007,14 @@ impl MaybeReadable for Event {
19942007
(7, skimmed_fee_msat, option),
19952008
(9, prev_user_channel_id, option),
19962009
(11, next_user_channel_id, option),
2010+
(13, prev_node_id, option),
2011+
(15, next_node_id, option),
19972012
});
19982013
Ok(Some(Event::PaymentForwarded {
19992014
prev_channel_id, next_channel_id, prev_user_channel_id,
2000-
next_user_channel_id, total_fee_earned_msat, skimmed_fee_msat,
2001-
claim_from_onchain_tx, outbound_amount_forwarded_msat,
2015+
next_user_channel_id, prev_node_id, next_node_id,
2016+
total_fee_earned_msat, skimmed_fee_msat, claim_from_onchain_tx,
2017+
outbound_amount_forwarded_msat,
20022018
}))
20032019
};
20042020
f()

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7309,6 +7309,7 @@ where
73097309
HTLCSource::PreviousHopData(hop_data) => {
73107310
let prev_channel_id = hop_data.channel_id;
73117311
let prev_user_channel_id = hop_data.user_channel_id;
7312+
let prev_node_id = hop_data.counterparty_node_id;
73127313
let completed_blocker = RAAMonitorUpdateBlockingAction::from_prev_hop_data(&hop_data);
73137314
self.claim_funds_from_hop(hop_data, payment_preimage, None,
73147315
|htlc_claim_value_msat, definitely_duplicate| {
@@ -7358,6 +7359,8 @@ where
73587359
next_channel_id: Some(next_channel_id),
73597360
prev_user_channel_id,
73607361
next_user_channel_id,
7362+
prev_node_id,
7363+
next_node_id: next_channel_counterparty_node_id,
73617364
total_fee_earned_msat,
73627365
skimmed_fee_msat,
73637366
claim_from_onchain_tx: from_onchain,

0 commit comments

Comments
 (0)