Skip to content

Rename Event::PaymentClaimable::inbound_channel_ids to via_... #3764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u128>)>,
via_channel_ids: Vec<(ChannelId, Option<u128>)>,
/// The block height at which this payment will be failed back and will no longer be
/// eligible for claiming.
///
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -1588,15 +1588,15 @@ 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),
};
write_tlv_fields!(writer, {
(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),
Expand All @@ -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 } => {
Expand Down Expand Up @@ -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),
Expand All @@ -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)
Expand All @@ -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();

Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions lightning/src/ln/blinded_payment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<(_, _)>>();

// `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"),
}
Expand Down
20 changes: 10 additions & 10 deletions lightning/src/ln/chanmon_update_fail_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u128>)> {
fn via_channel_ids(&self) -> Vec<(ChannelId, Option<u128>)> {
self.htlcs.iter().map(|htlc| {
(htlc.prev_hop.channel_id, htlc.prev_hop.user_channel_id)
}).collect()
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,7 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
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);
Expand Down Expand Up @@ -2805,7 +2805,7 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
}
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));
}
Expand Down
12 changes: 6 additions & 6 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
Loading