From 60540f70c5dc8bb4db9691178d2de703f0c42a47 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 2 May 2025 14:31:19 +0000 Subject: [PATCH] Rename `Event::PaymentClaimable::inbound_channel_ids` to `via_...` In c62aa23b7919d62f49bceb7ce1f87967fc5de077 we merged `via_channel_id` and `via_user_channel_id` and added support for MPP to the fields, but created a new `inbound_channel_ids` field to replace them. The existing fields were labeled `via_` to differentiate between inbound channels (i.e. channels which were to us) and channels over which we received the payment. Here we restore the original naming by renaming the new `inbound_channel_ids` field to `via_channel_ids`. --- lightning/src/events/mod.rs | 18 ++++++++--------- lightning/src/ln/blinded_payment_tests.rs | 10 +++++----- lightning/src/ln/chanmon_update_fail_tests.rs | 20 +++++++++---------- lightning/src/ln/channelmanager.rs | 4 ++-- lightning/src/ln/functional_test_utils.rs | 4 ++-- lightning/src/ln/functional_tests.rs | 12 +++++------ 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs index 3d8391d8971..00c49ec4ff1 100644 --- a/lightning/src/events/mod.rs +++ b/lightning/src/events/mod.rs @@ -808,7 +808,7 @@ pub enum Event { /// The `(channel_id, user_channel_id)` pairs over which the payment was received. /// /// This will be an incomplete vector for MPP payment events created/serialized using LDK version 0.1.0 and prior. - inbound_channel_ids: Vec<(ChannelId, Option)>, + via_channel_ids: Vec<(ChannelId, Option)>, /// The block height at which this payment will be failed back and will no longer be /// eligible for claiming. /// @@ -1553,7 +1553,7 @@ impl Writeable for Event { // drop any channels which have not yet exchanged funding_signed. }, &Event::PaymentClaimable { ref payment_hash, ref amount_msat, counterparty_skimmed_fee_msat, - ref purpose, ref receiver_node_id, ref inbound_channel_ids, + ref purpose, ref receiver_node_id, ref via_channel_ids, ref claim_deadline, ref onion_fields, ref payment_id, } => { 1u8.write(writer)?; @@ -1588,7 +1588,7 @@ impl Writeable for Event { let skimmed_fee_opt = if counterparty_skimmed_fee_msat == 0 { None } else { Some(counterparty_skimmed_fee_msat) }; - let (via_channel_id_legacy, via_user_channel_id_legacy) = match inbound_channel_ids.last() { + let (via_channel_id_legacy, via_user_channel_id_legacy) = match via_channel_ids.last() { Some((chan_id, user_chan_id)) => (Some(*chan_id), *user_chan_id), None => (None, None), }; @@ -1596,7 +1596,7 @@ impl Writeable for Event { (0, payment_hash, required), (1, receiver_node_id, option), (2, payment_secret, option), - // Marked as legacy in version 0.2.0; superseded by `inbound_channel_ids`, which + // Marked as legacy in version 0.2.0; superseded by `via_channel_ids`, which // includes all channel IDs used in the payment instead of only the last one. (3, via_channel_id_legacy, option), (4, amount_msat, required), @@ -1610,7 +1610,7 @@ impl Writeable for Event { (10, skimmed_fee_opt, option), (11, payment_context, option), (13, payment_id, option), - (15, *inbound_channel_ids, optional_vec), + (15, *via_channel_ids, optional_vec), }); }, &Event::PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref amount_msat, ref fee_paid_msat, ref bolt12_invoice } => { @@ -1914,7 +1914,7 @@ impl MaybeReadable for Event { let mut onion_fields = None; let mut payment_context = None; let mut payment_id = None; - let mut inbound_channel_ids_opt = None; + let mut via_channel_ids_opt = None; read_tlv_fields!(reader, { (0, payment_hash, required), (1, receiver_node_id, option), @@ -1929,7 +1929,7 @@ impl MaybeReadable for Event { (10, counterparty_skimmed_fee_msat_opt, option), (11, payment_context, option), (13, payment_id, option), - (15, inbound_channel_ids_opt, optional_vec), + (15, via_channel_ids_opt, optional_vec), }); let purpose = match payment_secret { Some(secret) => PaymentPurpose::from_parts(payment_preimage, secret, payment_context) @@ -1938,7 +1938,7 @@ impl MaybeReadable for Event { None => return Err(msgs::DecodeError::InvalidValue), }; - let inbound_channel_ids = inbound_channel_ids_opt + let via_channel_ids = via_channel_ids_opt .or_else(|| via_channel_id_legacy.map(|chan_id| vec![(chan_id, via_user_channel_id_legacy)])) .unwrap_or_default(); @@ -1948,7 +1948,7 @@ impl MaybeReadable for Event { amount_msat, counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat_opt.unwrap_or(0), purpose, - inbound_channel_ids, + via_channel_ids, claim_deadline, onion_fields, payment_id, diff --git a/lightning/src/ln/blinded_payment_tests.rs b/lightning/src/ln/blinded_payment_tests.rs index 9092efa09b4..18a1089d647 100644 --- a/lightning/src/ln/blinded_payment_tests.rs +++ b/lightning/src/ln/blinded_payment_tests.rs @@ -251,18 +251,18 @@ fn mpp_to_one_hop_blinded_path() { Some(payment_secret), ev.clone(), true, None); match event.unwrap() { - Event::PaymentClaimable { mut inbound_channel_ids, .. } => { - let mut expected_inbound_channel_ids = nodes[3].node.list_channels() + Event::PaymentClaimable { mut via_channel_ids, .. } => { + let mut expected_via_channel_ids = nodes[3].node.list_channels() .iter() .map(|d| (d.channel_id, Some(d.user_channel_id))) .collect::>(); // `list_channels` returns channels in arbitrary order, so we sort both vectors // to ensure the comparison is order-agnostic. - inbound_channel_ids.sort(); - expected_inbound_channel_ids.sort(); + via_channel_ids.sort(); + expected_via_channel_ids.sort(); - assert_eq!(inbound_channel_ids, expected_inbound_channel_ids); + assert_eq!(via_channel_ids, expected_via_channel_ids); } _ => panic!("Unexpected event"), } diff --git a/lightning/src/ln/chanmon_update_fail_tests.rs b/lightning/src/ln/chanmon_update_fail_tests.rs index b64e40e1605..ba5952dee89 100644 --- a/lightning/src/ln/chanmon_update_fail_tests.rs +++ b/lightning/src/ln/chanmon_update_fail_tests.rs @@ -167,11 +167,11 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) { let events_3 = nodes[1].node.get_and_clear_pending_events(); assert_eq!(events_3.len(), 1); match events_3[0] { - Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => { + Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => { assert_eq!(payment_hash_1, *payment_hash); assert_eq!(amount_msat, 1_000_000); assert_eq!(receiver_node_id.unwrap(), nodes[1].node.get_our_node_id()); - assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(user_channel_id))]); + assert_eq!(*via_channel_ids, vec![(channel_id, Some(user_channel_id))]); match &purpose { PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -550,11 +550,11 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) { let events_5 = nodes[1].node.get_and_clear_pending_events(); assert_eq!(events_5.len(), 1); match events_5[0] { - Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => { + Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => { assert_eq!(payment_hash_2, *payment_hash); assert_eq!(amount_msat, 1_000_000); assert_eq!(receiver_node_id.unwrap(), nodes[1].node.get_our_node_id()); - assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(user_channel_id))]); + assert_eq!(*via_channel_ids, vec![(channel_id, Some(user_channel_id))]); match &purpose { PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -669,11 +669,11 @@ fn test_monitor_update_fail_cs() { let events = nodes[1].node.get_and_clear_pending_events(); assert_eq!(events.len(), 1); match events[0] { - Event::PaymentClaimable { payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => { + Event::PaymentClaimable { payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => { assert_eq!(payment_hash, our_payment_hash); assert_eq!(amount_msat, 1_000_000); assert_eq!(receiver_node_id.unwrap(), nodes[1].node.get_our_node_id()); - assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(user_channel_id))]); + assert_eq!(*via_channel_ids, vec![(channel_id, Some(user_channel_id))]); match &purpose { PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -1682,11 +1682,11 @@ fn test_monitor_update_fail_claim() { let events = nodes[0].node.get_and_clear_pending_events(); assert_eq!(events.len(), 2); match events[0] { - Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => { + Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => { assert_eq!(payment_hash_2, *payment_hash); assert_eq!(1_000_000, amount_msat); assert_eq!(receiver_node_id.unwrap(), nodes[0].node.get_our_node_id()); - assert_eq!(*inbound_channel_ids.last().unwrap(), (channel_id, Some(42))); + assert_eq!(*via_channel_ids.last().unwrap(), (channel_id, Some(42))); match &purpose { PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -1698,11 +1698,11 @@ fn test_monitor_update_fail_claim() { _ => panic!("Unexpected event"), } match events[1] { - Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => { + Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => { assert_eq!(payment_hash_3, *payment_hash); assert_eq!(1_000_000, amount_msat); assert_eq!(receiver_node_id.unwrap(), nodes[0].node.get_our_node_id()); - assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(42))]); + assert_eq!(*via_channel_ids, vec![(channel_id, Some(42))]); match &purpose { PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index ed77c834d1c..336cf2be493 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -934,7 +934,7 @@ impl ClaimablePayment { /// Returns the inbound `(channel_id, user_channel_id)` pairs for all HTLCs associated with the payment. /// /// Note: The `user_channel_id` will be `None` for HTLCs created using LDK version 0.0.117 or prior. - fn inbound_channel_ids(&self) -> Vec<(ChannelId, Option)> { + fn via_channel_ids(&self) -> Vec<(ChannelId, Option)> { self.htlcs.iter().map(|htlc| { (htlc.prev_hop.channel_id, htlc.prev_hop.user_channel_id) }).collect() @@ -6362,7 +6362,7 @@ where purpose: $purpose, amount_msat, counterparty_skimmed_fee_msat, - inbound_channel_ids: claimable_payment.inbound_channel_ids(), + via_channel_ids: claimable_payment.via_channel_ids(), claim_deadline: Some(earliest_expiry - HTLC_FAIL_BACK_BUFFER), onion_fields: claimable_payment.onion_fields.clone(), payment_id: Some(payment_id), diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 73af3a83729..c00e5a5bf6f 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -2770,7 +2770,7 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option assert_eq!(events_2.len(), 1); match &events_2[0] { Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, - receiver_node_id, ref inbound_channel_ids, + receiver_node_id, ref via_channel_ids, claim_deadline, onion_fields, .. } => { assert_eq!(our_payment_hash, *payment_hash); @@ -2805,7 +2805,7 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option } assert_eq!(*amount_msat, recv_value); let channels = node.node.list_channels(); - for (chan_id, user_chan_id) in inbound_channel_ids { + for (chan_id, user_chan_id) in via_channel_ids { let chan = channels.iter().find(|details| &details.channel_id == chan_id).unwrap(); assert_eq!(*user_chan_id, Some(chan.user_channel_id)); } diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 3fdd579535b..2f8a9b53a5d 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -2127,11 +2127,11 @@ pub fn test_channel_reserve_holding_cell_htlcs() { let events = nodes[2].node.get_and_clear_pending_events(); assert_eq!(events.len(), 2); match events[0] { - Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => { + Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => { assert_eq!(our_payment_hash_21, *payment_hash); assert_eq!(recv_value_21, amount_msat); assert_eq!(nodes[2].node.get_our_node_id(), receiver_node_id.unwrap()); - assert_eq!(*inbound_channel_ids, vec![(chan_2.2, Some(chan_2_user_id))]); + assert_eq!(*via_channel_ids, vec![(chan_2.2, Some(chan_2_user_id))]); match &purpose { PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -2143,11 +2143,11 @@ pub fn test_channel_reserve_holding_cell_htlcs() { _ => panic!("Unexpected event"), } match events[1] { - Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => { + Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => { assert_eq!(our_payment_hash_22, *payment_hash); assert_eq!(recv_value_22, amount_msat); assert_eq!(nodes[2].node.get_our_node_id(), receiver_node_id.unwrap()); - assert_eq!(*inbound_channel_ids, vec![(chan_2.2, Some(chan_2_user_id))]); + assert_eq!(*via_channel_ids, vec![(chan_2.2, Some(chan_2_user_id))]); match &purpose { PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none()); @@ -4374,11 +4374,11 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken let events_2 = nodes[1].node.get_and_clear_pending_events(); assert_eq!(events_2.len(), 1); match events_2[0] { - Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => { + Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => { assert_eq!(payment_hash_1, *payment_hash); assert_eq!(amount_msat, 1_000_000); assert_eq!(receiver_node_id.unwrap(), nodes[1].node.get_our_node_id()); - assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(user_channel_id))]); + assert_eq!(*via_channel_ids, vec![(channel_id, Some(user_channel_id))]); match &purpose { PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { assert!(payment_preimage.is_none());