-
Notifications
You must be signed in to change notification settings - Fork 412
Expand PaymentClaimable
to include all inbound channel IDs for a payment
#3655
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -924,6 +924,15 @@ impl ClaimablePayment { | |
self.htlcs.iter().map(|htlc| (htlc.prev_hop.channel_id, htlc.prev_hop.htlc_id)) | ||
) | ||
} | ||
|
||
/// 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>)> { | ||
self.htlcs.iter().map(|htlc| { | ||
(htlc.prev_hop.channel_id, htlc.prev_hop.user_channel_id) | ||
}).collect() | ||
} | ||
} | ||
|
||
/// Represent the channel funding transaction type. | ||
|
@@ -6282,8 +6291,7 @@ where | |
purpose: $purpose, | ||
amount_msat, | ||
counterparty_skimmed_fee_msat, | ||
via_channel_id: Some(prev_channel_id), | ||
via_user_channel_id: Some(prev_user_channel_id), | ||
inbound_channel_ids: claimable_payment.inbound_channel_ids(), | ||
claim_deadline: Some(earliest_expiry - HTLC_FAIL_BACK_BUFFER), | ||
onion_fields: claimable_payment.onion_fields.clone(), | ||
payment_id: Some(payment_id), | ||
|
@@ -10917,7 +10925,18 @@ where | |
let events = core::cell::RefCell::new(Vec::new()); | ||
let event_handler = |event: events::Event| Ok(events.borrow_mut().push(event)); | ||
self.process_pending_events(&event_handler); | ||
events.into_inner() | ||
let collected_events = events.into_inner(); | ||
|
||
// To expand the coverage and make sure all events are properly serialised and deserialised, | ||
// we test all generated events round-trip: | ||
for event in &collected_events { | ||
let ser = event.encode(); | ||
if let Some(deser) = events::Event::read(&mut &ser[..]).expect("event should deserialize") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the None case ok to ignore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIU, yes. Some event enums are designed to map to a That said, I'd love to hear @valentinewallace's thoughts to confirm if I’m understanding this correctly! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, some events are never written so I believe @shaavan is correct here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So could also continue when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh right, sorry. It looks like for events where we don't write the actual event, we will still write the type for the event: https://github.com/lightningdevkit/rust-lightning/blob/main/lightning/src/events/mod.rs#L1809 so I don't think we can check if it's empty but we could check if only a u8 was written. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps a too much internal detail then. Can leave this as is as far as I am concerned. |
||
assert_eq!(&deser, event, "event should roundtrip correctly"); | ||
} | ||
} | ||
|
||
collected_events | ||
} | ||
|
||
#[cfg(feature = "_test_utils")] | ||
|
Uh oh!
There was an error while loading. Please reload this page.