-
Notifications
You must be signed in to change notification settings - Fork 373
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
Provide the HTLCs that settled a payment. #2478
Conversation
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #2478 +/- ##
==========================================
- Coverage 90.40% 90.39% -0.02%
==========================================
Files 106 106
Lines 56268 56320 +52
Branches 56268 56320 +52
==========================================
+ Hits 50868 50908 +40
- Misses 5400 5412 +12
☔ View full report in Codecov by Sentry. |
@valentinewallace @wpaulino thank you for the reviews! I went ahead and promoted |
This is probably due to #2319. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after squash
This is due to #2062, see PR description for the reasoning behind this value. We probably want to add some more documentation to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blocking feedback!
For test coverage, could we add this diff to functional_test_utils
:
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index 39396685f..438dc2f90 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -2253,12 +2253,16 @@ pub fn do_claim_payment_along_route_with_extra_penultimate_hop_fees<'a, 'b, 'c>(
let claim_event = expected_paths[0].last().unwrap().node.get_and_clear_pending_events();
assert_eq!(claim_event.len(), 1);
- match claim_event[0] {
- Event::PaymentClaimed { purpose: PaymentPurpose::SpontaneousPayment(preimage), .. }|
- Event::PaymentClaimed { purpose: PaymentPurpose::InvoicePayment { payment_preimage: Some(preimage), ..}, .. } =>
- assert_eq!(preimage, our_payment_preimage),
- Event::PaymentClaimed { purpose: PaymentPurpose::InvoicePayment { .. }, payment_hash, .. } =>
- assert_eq!(&payment_hash.0, &Sha256::hash(&our_payment_preimage.0)[..]),
+ match &claim_event[0] {
+ Event::PaymentClaimed { purpose: PaymentPurpose::SpontaneousPayment(preimage), htlcs, .. } |
+ Event::PaymentClaimed { purpose: PaymentPurpose::InvoicePayment { payment_preimage: Some(preimage), ..}, htlcs, .. } => {
+ assert_eq!(htlcs.len(), expected_paths.len());
+ assert_eq!(preimage, &our_payment_preimage);
+ },
+ Event::PaymentClaimed { purpose: PaymentPurpose::InvoicePayment { .. }, payment_hash, htlcs, .. } => {
+ assert_eq!(htlcs.len(), expected_paths.len());
+ assert_eq!(&payment_hash.0, &Sha256::hash(&our_payment_preimage.0)[..]);
+ },
_ => panic!(),
}
And also modify an existing (or new) test call to expect_payment_claimed!
to check each ClaimedHTLC
field explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash the fixup commit - in general we shouldn't land PRs that have commits in them that fix bugs in the previous commits in the same PR. When you do so, please also line-break the first commit in the PR at 70 chars.
9dd402c
to
89808b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically LGTM, two minor comments and one nit.
This LGTM, feel free to squash the fixup commit, I think. |
Creates a new `events::ClaimedHTLC` struct that contains the relevant information about a claimed HTLC; e.g., the channel it arrived on, its ID, the amount of the HTLC, the overall amount of the payment, etc. Adds appropriate serialization support. Adds a `Vec<events::ClaimedHTLC>` to the `ClaimingPayment` structure. Populates this when creating the struct by converting the `payment.htlcs` (which are `ClaimingHTLC` structs) into `event::ClaimedHTLC` structs. This is a straightforward transformation. Adds a `Vec<events::ClaimedHTLC>` to the `events::Event::PaymentClaimed` enum. This is populated directly from the `ClaimingPayment`'s `htlcs` vec. Fixes lightningdevkit#2477.
} | ||
impl_writeable_tlv_based!(ClaimedHTLC, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: separate with newline, but so nitty feel free to ignore.
@@ -5129,9 +5152,20 @@ where | |||
match action { | |||
MonitorUpdateCompletionAction::PaymentClaimed { payment_hash } => { | |||
let payment = self.claimable_payments.lock().unwrap().pending_claiming_payments.remove(&payment_hash); | |||
if let Some(ClaimingPayment { amount_msat, payment_purpose: purpose, receiver_node_id }) = payment { | |||
if let Some(ClaimingPayment { | |||
amount_msat, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At
least
personally,
I
find
the
rustfmt
comically-vertical
flows
to
be
kinda
hard
to
read
:)
Creates a new
events::ClaimedHTLC
struct that contains the relevant information about a claimed HTLC; e.g., the channel it arrived on, its ID, the amount of the HTLC, the overall amount of the payment, etc. Adds appropriate serialization support.Adds a
Vec<events::ClaimedHTLC>
to theClaimingPayment
structure. Populates this when creating the struct by converting thepayment.htlcs
(which areClaimingHTLC
structs) intoevent::ClaimedHTLC
structs. This is a straightforward transformation.Adds a
Vec<events::ClaimedHTLC>
to theevents::Event::PaymentClaimed
enum. This is populated directly from theClaimingPayment
'shtlcs
vec.Fixes #2477.