Skip to content

Commit ef28e9f

Browse files
committed
Include RecipientOnionFields in PaymentClaimed
RecipientOnionFields are included in Event::PaymentClaimable, so naturally they should be included in Event::PaymentClaimed, too.
1 parent f447416 commit ef28e9f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lightning/src/events/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,11 @@ pub enum Event {
653653
/// The sender-intended sum total of all the MPP parts. This will be `None` for events
654654
/// serialized prior to LDK version 0.0.117.
655655
sender_intended_total_msat: Option<u64>,
656+
/// The fields in the onion which were received with each HTLC. Only fields which were
657+
/// identical in each HTLC involved in the payment will be included here.
658+
///
659+
/// Payments received on LDK versions prior to 0.0.124 will have this field unset.
660+
onion_fields: Option<RecipientOnionFields>,
656661
},
657662
/// Indicates that a peer connection with a node is needed in order to send an [`OnionMessage`].
658663
///
@@ -1348,7 +1353,7 @@ impl Writeable for Event {
13481353
// We never write the OpenChannelRequest events as, upon disconnection, peers
13491354
// drop any channels which have not yet exchanged funding_signed.
13501355
},
1351-
&Event::PaymentClaimed { ref payment_hash, ref amount_msat, ref purpose, ref receiver_node_id, ref htlcs, ref sender_intended_total_msat } => {
1356+
&Event::PaymentClaimed { ref payment_hash, ref amount_msat, ref purpose, ref receiver_node_id, ref htlcs, ref sender_intended_total_msat, ref onion_fields } => {
13521357
19u8.write(writer)?;
13531358
write_tlv_fields!(writer, {
13541359
(0, payment_hash, required),
@@ -1357,6 +1362,7 @@ impl Writeable for Event {
13571362
(4, amount_msat, required),
13581363
(5, *htlcs, optional_vec),
13591364
(7, sender_intended_total_msat, option),
1365+
(9, onion_fields, option),
13601366
});
13611367
},
13621368
&Event::ProbeSuccessful { ref payment_id, ref payment_hash, ref path } => {
@@ -1719,13 +1725,15 @@ impl MaybeReadable for Event {
17191725
let mut receiver_node_id = None;
17201726
let mut htlcs: Option<Vec<ClaimedHTLC>> = Some(vec![]);
17211727
let mut sender_intended_total_msat: Option<u64> = None;
1728+
let mut onion_fields = None;
17221729
read_tlv_fields!(reader, {
17231730
(0, payment_hash, required),
17241731
(1, receiver_node_id, option),
17251732
(2, purpose, upgradable_required),
17261733
(4, amount_msat, required),
17271734
(5, htlcs, optional_vec),
17281735
(7, sender_intended_total_msat, option),
1736+
(9, onion_fields, option),
17291737
});
17301738
Ok(Some(Event::PaymentClaimed {
17311739
receiver_node_id,
@@ -1734,6 +1742,7 @@ impl MaybeReadable for Event {
17341742
amount_msat,
17351743
htlcs: htlcs.unwrap_or(vec![]),
17361744
sender_intended_total_msat,
1745+
onion_fields,
17371746
}))
17381747
};
17391748
f()

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6753,7 +6753,7 @@ where
67536753
receiver_node_id,
67546754
htlcs,
67556755
sender_intended_value: sender_intended_total_msat,
6756-
onion_fields: _,
6756+
onion_fields,
67576757
}) = payment {
67586758
self.pending_events.lock().unwrap().push_back((events::Event::PaymentClaimed {
67596759
payment_hash,
@@ -6762,6 +6762,7 @@ where
67626762
receiver_node_id: Some(receiver_node_id),
67636763
htlcs,
67646764
sender_intended_total_msat,
6765+
onion_fields,
67656766
}, None));
67666767
}
67676768
},
@@ -12272,6 +12273,7 @@ where
1227212273
amount_msat: claimable_amt_msat,
1227312274
htlcs: payment.htlcs.iter().map(events::ClaimedHTLC::from).collect(),
1227412275
sender_intended_total_msat: payment.htlcs.first().map(|htlc| htlc.total_msat),
12276+
onion_fields: payment.onion_fields,
1227512277
}, None));
1227612278
}
1227712279
}

0 commit comments

Comments
 (0)