From b745047fe463c560a31900f7b1705d4542db9bfb Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Fri, 24 May 2024 15:34:07 -0500 Subject: [PATCH] Include RecipientOnionFields in PaymentClaimed RecipientOnionFields are included in Event::PaymentClaimable, so naturally they should be included in Event::PaymentClaimed, too. --- lightning/src/events/mod.rs | 11 ++++++++++- lightning/src/ln/channelmanager.rs | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs index a4bf1501b..0350f816a 100644 --- a/lightning/src/events/mod.rs +++ b/lightning/src/events/mod.rs @@ -653,6 +653,11 @@ pub enum Event { /// The sender-intended sum total of all the MPP parts. This will be `None` for events /// serialized prior to LDK version 0.0.117. sender_intended_total_msat: Option, + /// The fields in the onion which were received with each HTLC. Only fields which were + /// identical in each HTLC involved in the payment will be included here. + /// + /// Payments received on LDK versions prior to 0.0.124 will have this field unset. + onion_fields: Option, }, /// Indicates that a peer connection with a node is needed in order to send an [`OnionMessage`]. /// @@ -1348,7 +1353,7 @@ impl Writeable for Event { // We never write the OpenChannelRequest events as, upon disconnection, peers // drop any channels which have not yet exchanged funding_signed. }, - &Event::PaymentClaimed { ref payment_hash, ref amount_msat, ref purpose, ref receiver_node_id, ref htlcs, ref sender_intended_total_msat } => { + &Event::PaymentClaimed { ref payment_hash, ref amount_msat, ref purpose, ref receiver_node_id, ref htlcs, ref sender_intended_total_msat, ref onion_fields } => { 19u8.write(writer)?; write_tlv_fields!(writer, { (0, payment_hash, required), @@ -1357,6 +1362,7 @@ impl Writeable for Event { (4, amount_msat, required), (5, *htlcs, optional_vec), (7, sender_intended_total_msat, option), + (9, onion_fields, option), }); }, &Event::ProbeSuccessful { ref payment_id, ref payment_hash, ref path } => { @@ -1719,6 +1725,7 @@ impl MaybeReadable for Event { let mut receiver_node_id = None; let mut htlcs: Option> = Some(vec![]); let mut sender_intended_total_msat: Option = None; + let mut onion_fields = None; read_tlv_fields!(reader, { (0, payment_hash, required), (1, receiver_node_id, option), @@ -1726,6 +1733,7 @@ impl MaybeReadable for Event { (4, amount_msat, required), (5, htlcs, optional_vec), (7, sender_intended_total_msat, option), + (9, onion_fields, option), }); Ok(Some(Event::PaymentClaimed { receiver_node_id, @@ -1734,6 +1742,7 @@ impl MaybeReadable for Event { amount_msat, htlcs: htlcs.unwrap_or(vec![]), sender_intended_total_msat, + onion_fields, })) }; f() diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 624de614d..1d5191b80 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -6753,7 +6753,7 @@ where receiver_node_id, htlcs, sender_intended_value: sender_intended_total_msat, - onion_fields: _, + onion_fields, }) = payment { self.pending_events.lock().unwrap().push_back((events::Event::PaymentClaimed { payment_hash, @@ -6762,6 +6762,7 @@ where receiver_node_id: Some(receiver_node_id), htlcs, sender_intended_total_msat, + onion_fields, }, None)); } }, @@ -12272,6 +12273,7 @@ where amount_msat: claimable_amt_msat, htlcs: payment.htlcs.iter().map(events::ClaimedHTLC::from).collect(), sender_intended_total_msat: payment.htlcs.first().map(|htlc| htlc.total_msat), + onion_fields: payment.onion_fields, }, None)); } } -- 2.39.5