-
Notifications
You must be signed in to change notification settings - Fork 400
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
[RFC] Implement a way to do BOLT 12 Proof of Payment #3593
[RFC] Implement a way to do BOLT 12 Proof of Payment #3593
Conversation
c7e9e61
to
cc714ae
Compare
a5c211c
to
9cdbb44
Compare
9cdbb44
to
8f5dc5e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3593 +/- ##
==========================================
+ Coverage 89.25% 89.30% +0.05%
==========================================
Files 155 156 +1
Lines 119708 121825 +2117
Branches 119708 121825 +2117
==========================================
+ Hits 106845 108796 +1951
- Misses 10250 10388 +138
- Partials 2613 2641 +28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Thank you for picking this up! Sorry about the delay in review, not sure why this slipped through the cracks.
7da68f6
to
0e7b503
Compare
Thanks for the review @TheBlueMatt, I applied the suggestion in the review. In the meanwhile, I rebased on top of |
0e7b503
to
a4897fb
Compare
a4897fb
to
2c65d6a
Compare
9b72246
to
2c65d6a
Compare
Ok @TheBlueMatt this PR is really funny to work! I worked to clean up the PR a bit and divide the code to support both Bolt12 and static invoices. However, I am currently working on supporting the async payment functionality. As far as I understand, the code involving async payments is a bit tricky to support for the following reasons (code available 85c3f73). The async workflow is initialized with The only way I have to access the static invoice when passing it down inside
I would prefer the 3rd point, but this requires a follow-up PR to rework a little bit how the async payment is handled and I do not know if there is any plan for that,t or there is other code that will be depending on this architecture in the pipeline. Probably @valentinewallace will be interested in this conversation |
Generally we just copy and paste the impl with different cfg flags and go back and clean it up after we drop the cfg. I'll let @valentinewallace comment on the rest. |
Hey sorry I missed this tag. In #3618 right now we actually un-cfg-gate |
Yes, but in this case, we need to duplicate all the |
734c955
to
525c01e
Compare
d69787b
to
3929d07
Compare
Ok at my desk trying to finish this PR ASAP. I had to rebase the PR to fix the conflicts to be able to run the CI! now waiting for the latter to see if I am forgetting something else to fix. Thanks for your time in review this PR @valentinewallace Probably the only thing left to fix Is the lining with the new change at the docs https://github.com/lightningdevkit/rust-lightning/actions/runs/14196272391/job/39772046844?pr=3593 |
7450529
to
9ed2e06
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.
I think you can go ahead and squash and we can probably do final passes?
We need to include static invoices in the public API as part of the onion messages we're adding for static invoice server support. Utilities to create these static invoices and other parts of the async receive API will remain cfg-gated for now. Generally, we can't totally avoid exposing half baked async receive support in the public API because OnionMessenger is parameterized by an async payments message handler, which can't be cfg-gated easily. Signed-off-by: Vincenzo Palazzo <[email protected]>
9ed2e06
to
22f8c50
Compare
Ok should be ready for another round of review! However, I am not sure why the linter is failing now, looks like unrelated to this PR? |
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 one nit
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 Matt's last comment
2abe14a
to
44bb850
Compare
@@ -1200,7 +1200,7 @@ macro_rules! impl_writeable_tlv_based_enum { | |||
$($tuple_variant_id => { | |||
let length: $crate::util::ser::BigSize = $crate::util::ser::Readable::read(reader)?; | |||
let mut s = $crate::util::ser::FixedLengthReader::new(reader, length.0); | |||
let res = $crate::util::ser::Readable::read(&mut s)?; | |||
let res = $crate::util::ser::LengthReadable::read_from_fixed_length_buffer(&mut s)?; |
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.
It actually still says that this is a temporary workaround, but not blocking
When introducing the LengthLimitedRead trait in [1], for some serialization macros we need this change to avoid that we have the following compilation error error[E0277]: the trait bound `Bolt12Invoice: Readable` is not satisfied --> lightning/src/util/ser_macros.rs:1243:35 | 1243 | Ok($st::$tuple_variant_name($crate::util::ser::Readable::read(reader)?)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Readable` is not implemented for `Bolt12Invoice` | ::: lightning/src/events/mod.rs:2463:1 | 2463 | / impl_writeable_tlv_based_enum_legacy!(PaidInvoice, 2464 | | ; 2465 | | (0, Bolt12Invoice), 2466 | | (2, StaticInvoice) 2467 | | ); | |_- in this macro invocation | = help: the following other types implement trait `Readable`: () (A, B) (A, B, C) (A, B, C, D) (A, B, C, D, E) (A, B, C, D, E, F) (A, B, C, D, E, F, G) AnnouncementSigsState and 200 others = note: this error originates in the macro `impl_writeable_tlv_based_enum_legacy` (in Nightly builds, run with -Z macro-backtrace for more info) This changes are needed since [1] is landed on mainline. [1] lightningdevkit#3640 Co-Developed-by: @valentinewallace Suggested-by: @valentinewallace Signed-off-by: Vincenzo Palazzo <[email protected]>
This commit make two things possible: 1. make persistent BOLT12 invoice through PendingOutboundPayment This commit prepares the code to pass down the BOLT12 invoice inside the `PaymentSent` event. To achieve this, the `bolt12` field has been added to the `PendingOutboundPayment::Retryable` enum, allowing it to be attached to the `PaymentSent` event when the payment is completed. 2. To enable proof of payment, we need to share the bolt12 invoice with the library user. This is already possible if we `manually_handle_bolt12_invoices`, but this approach requires a significant amount of work from the user. This commit adds the bolt12 invoice to the PaymentSend event when the payment is completed. This allows the user to always have the option to perform proof of payment. We also Inject the static invoice inside the PendingOutboundPayment::StaticInvoiceReceived to allow to use the static invoice inside the PendingOutboundPayment::PaymentReceived. Link: lightningdevkit#3344 Signed-off-by: Vincenzo Palazzo <[email protected]>
44bb850
to
57772d3
Compare
Sorry I forgot to read also the upper part of the commit body, luckily |
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.
One issue, but I'm gonna go ahead and land this as fixing the issue can be separate.
@@ -2374,6 +2388,7 @@ impl OutboundPayments { | |||
payment_metadata: None, // only used for retries, and we'll never retry on startup | |||
keysend_preimage: None, // only used for retries, and we'll never retry on startup | |||
invoice_request: None, // only used for retries, and we'll never retry on startup | |||
bolt12_invoice: None, // only used for retries, and we'll never retry on startup! |
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.
Oof. Sorry I missed this until now. This is not, in fact, "only used for retries", we use it on claims only, in fact. If a user is relying on the event field for PoP, what this can mean is that we can initiate a send, restart with a stale ChannelManager
, notice the payment is pending, then when it claims fail to provide the invoice (only the preimage) to the payer.
In practice, to fix this, we'll need to include the PaidBolt12Invoice
in the HTLCSource::OutboundRoute
, I believe.
This is already possible if we
manually_handle_bolt12_invoices
, butthis approach requires a significant amount of work from the user.
This commit adds the bolt12 invoice to the PaymentSend event when
the payment is completed. This always gives the user the option to
provide proof of payment.
I am opening this up for an initial review, but I need to look inside the
DNSSECProof
to add this proof, butprobably be also a follow-up PR
Opening in draft for now to make the CI happyFixes: #3344