Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e39ccaa

Browse files
committedMar 13, 2025·
f: Improve docs, and keep downgrade support
1 parent b31a6c9 commit e39ccaa

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed
 

‎lightning/src/events/mod.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -774,15 +774,11 @@ pub enum Event {
774774
/// Information for claiming this received payment, based on whether the purpose of the
775775
/// payment is to pay an invoice or to send a spontaneous payment.
776776
purpose: PaymentPurpose,
777-
/// The `channel_id`(s) indicating over which channel(s) we received the payment.
778-
/// - In a non-MPP scenario, this will contain a single `channel_id` where the payment was received.
779-
/// - In an MPP scenario, this will contain multiple `channel_id`s corresponding to the channels over
780-
/// which the payment parts were received.
777+
/// The `channel_id`(s) over which the payment was received.
778+
/// This will be an empty vector for events created/serialised using LDK version 0.0.112 and prior.
781779
via_channel_ids: Vec<ChannelId>,
782-
/// The `user_channel_id`(s) indicating over which channel(s) we received the payment.
783-
/// - In a non-MPP scenario, this will contain a single `user_channel_id`.
784-
/// - In an MPP scenario, this will contain multiple `user_channel_id`s corresponding to the channels
785-
/// over which the payment parts were received.
780+
/// The `user_channel_id`(s) corresponding to the channels over which the payment was received.
781+
/// This will be an empty vector for HTLC events created/serialised using LDK version 0.0.112 and prior.
786782
via_user_channel_ids: Vec<u128>,
787783
/// The block height at which this payment will be failed back and will no longer be
788784
/// eligible for claiming.
@@ -1546,15 +1542,16 @@ impl Writeable for Event {
15461542
}
15471543
let skimmed_fee_opt = if counterparty_skimmed_fee_msat == 0 { None }
15481544
else { Some(counterparty_skimmed_fee_msat) };
1545+
1546+
let via_channel_id_legacy = via_channel_ids.last().cloned();
1547+
let via_user_channel_id_legacy = via_user_channel_ids.last().cloned();
15491548
write_tlv_fields!(writer, {
15501549
(0, payment_hash, required),
15511550
(1, receiver_node_id, option),
15521551
(2, payment_secret, option),
1553-
// legacy field
1554-
// (3, via_channel_id, option),
1552+
(3, via_channel_id_legacy, option),
15551553
(4, amount_msat, required),
1556-
// legacy field
1557-
// (5, via_user_channel_id, option),
1554+
(5, via_user_channel_id_legacy, option),
15581555
// Type 6 was `user_payment_id` on 0.0.103 and earlier
15591556
(7, claim_deadline, option),
15601557
(8, payment_preimage, option),
@@ -1859,9 +1856,9 @@ impl MaybeReadable for Event {
18591856
let mut counterparty_skimmed_fee_msat_opt = None;
18601857
let mut receiver_node_id = None;
18611858
let mut _user_payment_id = None::<u64>; // Used in 0.0.103 and earlier, no longer written in 0.0.116+.
1862-
let mut via_channel_id = None;
1859+
let mut via_channel_id_legacy = None;
18631860
let mut claim_deadline = None;
1864-
let mut via_user_channel_id = None;
1861+
let mut via_user_channel_id_legacy = None;
18651862
let mut onion_fields = None;
18661863
let mut payment_context = None;
18671864
let mut payment_id = None;
@@ -1871,9 +1868,9 @@ impl MaybeReadable for Event {
18711868
(0, payment_hash, required),
18721869
(1, receiver_node_id, option),
18731870
(2, payment_secret, option),
1874-
(3, via_channel_id, option),
1871+
(3, via_channel_id_legacy, option),
18751872
(4, amount_msat, required),
1876-
(5, via_user_channel_id, option),
1873+
(5, via_user_channel_id_legacy, option),
18771874
(6, _user_payment_id, option),
18781875
(7, claim_deadline, option),
18791876
(8, payment_preimage, option),
@@ -1892,11 +1889,11 @@ impl MaybeReadable for Event {
18921889
};
18931890

18941891
let via_channel_ids = via_channel_ids_opt
1895-
.or_else(|| via_channel_id.map(|id| vec![id]))
1892+
.or_else(|| via_channel_id_legacy.map(|id| vec![id]))
18961893
.unwrap_or_default();
18971894

18981895
let via_user_channel_ids = via_user_channel_ids_opt
1899-
.or_else(|| via_user_channel_id.map(|id| vec![id]))
1896+
.or_else(|| via_user_channel_id_legacy.map(|id| vec![id]))
19001897
.unwrap_or_default();
19011898

19021899
Ok(Some(Event::PaymentClaimable {

0 commit comments

Comments
 (0)
Please sign in to comment.