Skip to content

Commit 60540f7

Browse files
committed
Rename Event::PaymentClaimable::inbound_channel_ids to via_...
In c62aa23 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`.
1 parent 29a6383 commit 60540f7

6 files changed

+34
-34
lines changed

lightning/src/events/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ pub enum Event {
808808
/// The `(channel_id, user_channel_id)` pairs over which the payment was received.
809809
///
810810
/// This will be an incomplete vector for MPP payment events created/serialized using LDK version 0.1.0 and prior.
811-
inbound_channel_ids: Vec<(ChannelId, Option<u128>)>,
811+
via_channel_ids: Vec<(ChannelId, Option<u128>)>,
812812
/// The block height at which this payment will be failed back and will no longer be
813813
/// eligible for claiming.
814814
///
@@ -1553,7 +1553,7 @@ impl Writeable for Event {
15531553
// drop any channels which have not yet exchanged funding_signed.
15541554
},
15551555
&Event::PaymentClaimable { ref payment_hash, ref amount_msat, counterparty_skimmed_fee_msat,
1556-
ref purpose, ref receiver_node_id, ref inbound_channel_ids,
1556+
ref purpose, ref receiver_node_id, ref via_channel_ids,
15571557
ref claim_deadline, ref onion_fields, ref payment_id,
15581558
} => {
15591559
1u8.write(writer)?;
@@ -1588,15 +1588,15 @@ impl Writeable for Event {
15881588
let skimmed_fee_opt = if counterparty_skimmed_fee_msat == 0 { None }
15891589
else { Some(counterparty_skimmed_fee_msat) };
15901590

1591-
let (via_channel_id_legacy, via_user_channel_id_legacy) = match inbound_channel_ids.last() {
1591+
let (via_channel_id_legacy, via_user_channel_id_legacy) = match via_channel_ids.last() {
15921592
Some((chan_id, user_chan_id)) => (Some(*chan_id), *user_chan_id),
15931593
None => (None, None),
15941594
};
15951595
write_tlv_fields!(writer, {
15961596
(0, payment_hash, required),
15971597
(1, receiver_node_id, option),
15981598
(2, payment_secret, option),
1599-
// Marked as legacy in version 0.2.0; superseded by `inbound_channel_ids`, which
1599+
// Marked as legacy in version 0.2.0; superseded by `via_channel_ids`, which
16001600
// includes all channel IDs used in the payment instead of only the last one.
16011601
(3, via_channel_id_legacy, option),
16021602
(4, amount_msat, required),
@@ -1610,7 +1610,7 @@ impl Writeable for Event {
16101610
(10, skimmed_fee_opt, option),
16111611
(11, payment_context, option),
16121612
(13, payment_id, option),
1613-
(15, *inbound_channel_ids, optional_vec),
1613+
(15, *via_channel_ids, optional_vec),
16141614
});
16151615
},
16161616
&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 {
19141914
let mut onion_fields = None;
19151915
let mut payment_context = None;
19161916
let mut payment_id = None;
1917-
let mut inbound_channel_ids_opt = None;
1917+
let mut via_channel_ids_opt = None;
19181918
read_tlv_fields!(reader, {
19191919
(0, payment_hash, required),
19201920
(1, receiver_node_id, option),
@@ -1929,7 +1929,7 @@ impl MaybeReadable for Event {
19291929
(10, counterparty_skimmed_fee_msat_opt, option),
19301930
(11, payment_context, option),
19311931
(13, payment_id, option),
1932-
(15, inbound_channel_ids_opt, optional_vec),
1932+
(15, via_channel_ids_opt, optional_vec),
19331933
});
19341934
let purpose = match payment_secret {
19351935
Some(secret) => PaymentPurpose::from_parts(payment_preimage, secret, payment_context)
@@ -1938,7 +1938,7 @@ impl MaybeReadable for Event {
19381938
None => return Err(msgs::DecodeError::InvalidValue),
19391939
};
19401940

1941-
let inbound_channel_ids = inbound_channel_ids_opt
1941+
let via_channel_ids = via_channel_ids_opt
19421942
.or_else(|| via_channel_id_legacy.map(|chan_id| vec![(chan_id, via_user_channel_id_legacy)]))
19431943
.unwrap_or_default();
19441944

@@ -1948,7 +1948,7 @@ impl MaybeReadable for Event {
19481948
amount_msat,
19491949
counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat_opt.unwrap_or(0),
19501950
purpose,
1951-
inbound_channel_ids,
1951+
via_channel_ids,
19521952
claim_deadline,
19531953
onion_fields,
19541954
payment_id,

lightning/src/ln/blinded_payment_tests.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,18 @@ fn mpp_to_one_hop_blinded_path() {
251251
Some(payment_secret), ev.clone(), true, None);
252252

253253
match event.unwrap() {
254-
Event::PaymentClaimable { mut inbound_channel_ids, .. } => {
255-
let mut expected_inbound_channel_ids = nodes[3].node.list_channels()
254+
Event::PaymentClaimable { mut via_channel_ids, .. } => {
255+
let mut expected_via_channel_ids = nodes[3].node.list_channels()
256256
.iter()
257257
.map(|d| (d.channel_id, Some(d.user_channel_id)))
258258
.collect::<Vec<(_, _)>>();
259259

260260
// `list_channels` returns channels in arbitrary order, so we sort both vectors
261261
// to ensure the comparison is order-agnostic.
262-
inbound_channel_ids.sort();
263-
expected_inbound_channel_ids.sort();
262+
via_channel_ids.sort();
263+
expected_via_channel_ids.sort();
264264

265-
assert_eq!(inbound_channel_ids, expected_inbound_channel_ids);
265+
assert_eq!(via_channel_ids, expected_via_channel_ids);
266266
}
267267
_ => panic!("Unexpected event"),
268268
}

lightning/src/ln/chanmon_update_fail_tests.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
167167
let events_3 = nodes[1].node.get_and_clear_pending_events();
168168
assert_eq!(events_3.len(), 1);
169169
match events_3[0] {
170-
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => {
170+
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => {
171171
assert_eq!(payment_hash_1, *payment_hash);
172172
assert_eq!(amount_msat, 1_000_000);
173173
assert_eq!(receiver_node_id.unwrap(), nodes[1].node.get_our_node_id());
174-
assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(user_channel_id))]);
174+
assert_eq!(*via_channel_ids, vec![(channel_id, Some(user_channel_id))]);
175175
match &purpose {
176176
PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => {
177177
assert!(payment_preimage.is_none());
@@ -550,11 +550,11 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
550550
let events_5 = nodes[1].node.get_and_clear_pending_events();
551551
assert_eq!(events_5.len(), 1);
552552
match events_5[0] {
553-
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => {
553+
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => {
554554
assert_eq!(payment_hash_2, *payment_hash);
555555
assert_eq!(amount_msat, 1_000_000);
556556
assert_eq!(receiver_node_id.unwrap(), nodes[1].node.get_our_node_id());
557-
assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(user_channel_id))]);
557+
assert_eq!(*via_channel_ids, vec![(channel_id, Some(user_channel_id))]);
558558
match &purpose {
559559
PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => {
560560
assert!(payment_preimage.is_none());
@@ -669,11 +669,11 @@ fn test_monitor_update_fail_cs() {
669669
let events = nodes[1].node.get_and_clear_pending_events();
670670
assert_eq!(events.len(), 1);
671671
match events[0] {
672-
Event::PaymentClaimable { payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => {
672+
Event::PaymentClaimable { payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => {
673673
assert_eq!(payment_hash, our_payment_hash);
674674
assert_eq!(amount_msat, 1_000_000);
675675
assert_eq!(receiver_node_id.unwrap(), nodes[1].node.get_our_node_id());
676-
assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(user_channel_id))]);
676+
assert_eq!(*via_channel_ids, vec![(channel_id, Some(user_channel_id))]);
677677
match &purpose {
678678
PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => {
679679
assert!(payment_preimage.is_none());
@@ -1682,11 +1682,11 @@ fn test_monitor_update_fail_claim() {
16821682
let events = nodes[0].node.get_and_clear_pending_events();
16831683
assert_eq!(events.len(), 2);
16841684
match events[0] {
1685-
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => {
1685+
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => {
16861686
assert_eq!(payment_hash_2, *payment_hash);
16871687
assert_eq!(1_000_000, amount_msat);
16881688
assert_eq!(receiver_node_id.unwrap(), nodes[0].node.get_our_node_id());
1689-
assert_eq!(*inbound_channel_ids.last().unwrap(), (channel_id, Some(42)));
1689+
assert_eq!(*via_channel_ids.last().unwrap(), (channel_id, Some(42)));
16901690
match &purpose {
16911691
PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => {
16921692
assert!(payment_preimage.is_none());
@@ -1698,11 +1698,11 @@ fn test_monitor_update_fail_claim() {
16981698
_ => panic!("Unexpected event"),
16991699
}
17001700
match events[1] {
1701-
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => {
1701+
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => {
17021702
assert_eq!(payment_hash_3, *payment_hash);
17031703
assert_eq!(1_000_000, amount_msat);
17041704
assert_eq!(receiver_node_id.unwrap(), nodes[0].node.get_our_node_id());
1705-
assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(42))]);
1705+
assert_eq!(*via_channel_ids, vec![(channel_id, Some(42))]);
17061706
match &purpose {
17071707
PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => {
17081708
assert!(payment_preimage.is_none());

lightning/src/ln/channelmanager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ impl ClaimablePayment {
934934
/// Returns the inbound `(channel_id, user_channel_id)` pairs for all HTLCs associated with the payment.
935935
///
936936
/// Note: The `user_channel_id` will be `None` for HTLCs created using LDK version 0.0.117 or prior.
937-
fn inbound_channel_ids(&self) -> Vec<(ChannelId, Option<u128>)> {
937+
fn via_channel_ids(&self) -> Vec<(ChannelId, Option<u128>)> {
938938
self.htlcs.iter().map(|htlc| {
939939
(htlc.prev_hop.channel_id, htlc.prev_hop.user_channel_id)
940940
}).collect()
@@ -6362,7 +6362,7 @@ where
63626362
purpose: $purpose,
63636363
amount_msat,
63646364
counterparty_skimmed_fee_msat,
6365-
inbound_channel_ids: claimable_payment.inbound_channel_ids(),
6365+
via_channel_ids: claimable_payment.via_channel_ids(),
63666366
claim_deadline: Some(earliest_expiry - HTLC_FAIL_BACK_BUFFER),
63676367
onion_fields: claimable_payment.onion_fields.clone(),
63686368
payment_id: Some(payment_id),

lightning/src/ln/functional_test_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2770,7 +2770,7 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
27702770
assert_eq!(events_2.len(), 1);
27712771
match &events_2[0] {
27722772
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat,
2773-
receiver_node_id, ref inbound_channel_ids,
2773+
receiver_node_id, ref via_channel_ids,
27742774
claim_deadline, onion_fields, ..
27752775
} => {
27762776
assert_eq!(our_payment_hash, *payment_hash);
@@ -2805,7 +2805,7 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
28052805
}
28062806
assert_eq!(*amount_msat, recv_value);
28072807
let channels = node.node.list_channels();
2808-
for (chan_id, user_chan_id) in inbound_channel_ids {
2808+
for (chan_id, user_chan_id) in via_channel_ids {
28092809
let chan = channels.iter().find(|details| &details.channel_id == chan_id).unwrap();
28102810
assert_eq!(*user_chan_id, Some(chan.user_channel_id));
28112811
}

lightning/src/ln/functional_tests.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2127,11 +2127,11 @@ pub fn test_channel_reserve_holding_cell_htlcs() {
21272127
let events = nodes[2].node.get_and_clear_pending_events();
21282128
assert_eq!(events.len(), 2);
21292129
match events[0] {
2130-
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => {
2130+
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => {
21312131
assert_eq!(our_payment_hash_21, *payment_hash);
21322132
assert_eq!(recv_value_21, amount_msat);
21332133
assert_eq!(nodes[2].node.get_our_node_id(), receiver_node_id.unwrap());
2134-
assert_eq!(*inbound_channel_ids, vec![(chan_2.2, Some(chan_2_user_id))]);
2134+
assert_eq!(*via_channel_ids, vec![(chan_2.2, Some(chan_2_user_id))]);
21352135
match &purpose {
21362136
PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => {
21372137
assert!(payment_preimage.is_none());
@@ -2143,11 +2143,11 @@ pub fn test_channel_reserve_holding_cell_htlcs() {
21432143
_ => panic!("Unexpected event"),
21442144
}
21452145
match events[1] {
2146-
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => {
2146+
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => {
21472147
assert_eq!(our_payment_hash_22, *payment_hash);
21482148
assert_eq!(recv_value_22, amount_msat);
21492149
assert_eq!(nodes[2].node.get_our_node_id(), receiver_node_id.unwrap());
2150-
assert_eq!(*inbound_channel_ids, vec![(chan_2.2, Some(chan_2_user_id))]);
2150+
assert_eq!(*via_channel_ids, vec![(chan_2.2, Some(chan_2_user_id))]);
21512151
match &purpose {
21522152
PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => {
21532153
assert!(payment_preimage.is_none());
@@ -4374,11 +4374,11 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken
43744374
let events_2 = nodes[1].node.get_and_clear_pending_events();
43754375
assert_eq!(events_2.len(), 1);
43764376
match events_2[0] {
4377-
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref inbound_channel_ids, .. } => {
4377+
Event::PaymentClaimable { ref payment_hash, ref purpose, amount_msat, receiver_node_id, ref via_channel_ids, .. } => {
43784378
assert_eq!(payment_hash_1, *payment_hash);
43794379
assert_eq!(amount_msat, 1_000_000);
43804380
assert_eq!(receiver_node_id.unwrap(), nodes[1].node.get_our_node_id());
4381-
assert_eq!(*inbound_channel_ids, vec![(channel_id, Some(user_channel_id))]);
4381+
assert_eq!(*via_channel_ids, vec![(channel_id, Some(user_channel_id))]);
43824382
match &purpose {
43834383
PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => {
43844384
assert!(payment_preimage.is_none());

0 commit comments

Comments
 (0)