Add BOLT12 support to LSPS2 via custom Router implementation#4463
Add BOLT12 support to LSPS2 via custom Router implementation#4463tnull wants to merge 11 commits into
Router implementation#4463Conversation
|
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
2cb0546 to
25ab3bc
Compare
|
🔔 1st Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 2nd Reminder Hey @jkczyz! This PR has been waiting for your review. |
25ab3bc to
5786409
Compare
|
No issues found. I re-reviewed the full current state of the PR (head commit What I verified in the current diff:
Security: the decoded payment metadata is authored by the recipient and authenticated via the offer/reply-path context HMAC, so a payer cannot inject malicious LSP parameters. Safe. One low-confidence observation I deliberately did not file (consistent with my prior pass): No inline comments posted this pass. |
5786409 to
98a9e9d
Compare
8800d48 to
7ca886d
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4463 +/- ##
==========================================
+ Coverage 87.08% 87.13% +0.04%
==========================================
Files 161 162 +1
Lines 109255 109707 +452
Branches 109255 109707 +452
==========================================
+ Hits 95147 95589 +442
- Misses 11627 11632 +5
- Partials 2481 2486 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7ca886d to
2ff16d7
Compare
bcc4e10 to
5602e07
Compare
ea05389 to
3acf915
Compare
|
Added back a commit that derives |
|
Does this need updating with the changes from #4584? |
Yes, probably we should now wait for that to land first. |
e56ea06 to
26da1dd
Compare
|
Now updated to use the new payment-metadata-in-BOLT12-context flow. Also updated lightningdevkit/ldk-node#817 to use this. |
| /// | ||
| /// The metadata is persisted with the async receive offer cache so future static-invoice | ||
| /// refreshes for the same offer continue to include it. | ||
| pub fn refresh_async_receive_offers_with_payment_metadata( |
There was a problem hiding this comment.
Why do we need this? Doesn't our router inject the metadata for us?
There was a problem hiding this comment.
The MessageRouter in LDK Node will do that for regular offers, but that doesn't work for the async path:
For regular offers, ldk-node does this:
- Wraps MessageRouter.
- When create_offer_builder_using_router(...) builds blinded invoice-request paths, the wrapper sees MessageContext::Offers(InvoiceRequest { payment_metadata, .. }).
- It writes LSPS2 metadata there.
- Later, when an invoice request arrives, LDK turns that into PaymentContext::Bolt12Offer { payment_metadata }.
- Then LSPS2BOLT12Router can decode it while building the actual invoice payment paths.
For async static invoices, the order is different:
- The recipient proactively builds a StaticInvoice before any payer invoice request exists.
- The static invoice’s payment paths are built via Router::create_blinded_payment_paths.
- That call receives PaymentContext::AsyncBolt12Offer { payment_metadata }.
- The MessageRouter is not involved in that payment-path construction, so it has no place to inject the metadata.
There was a problem hiding this comment.
Right, then shouldn't we wrap the router rather than adding a new top level method here?
There was a problem hiding this comment.
Hmm, no? I think we're going in circles here - if we have the router inject, then it would need to be stateful, meaning LDK Node will need to persist the LSPS2 params, and we just went through quite a bit of effort to avoid that. Or maybe I'm missing something?
| self.check_refresh_async_receive_offer_cache(false).unwrap(); | ||
| } | ||
|
|
||
| /// Requests fresh async receive offer paths from the configured static invoice server, if any. |
There was a problem hiding this comment.
Hmm, I don't think this currently works? If we build a static invoice when we connect to peers while we're negotiating LSPS2 (ie we have no LSPS2 parameters configured yet) we'll upload the static invoice to our static invoice storage server and there will be a window during which we cannot receive because the static invoice that is stored is bogus. LSPS2BOLT12Router really needs to fail until we have configured parameters so that we won't upload a bogus static invoice.
The docs here really need to mention that this should never really be required unless using LSPS.
|
🔔 1st Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 2nd Reminder Hey @jkczyz! This PR has been waiting for your review. |
|
🔔 3rd Reminder Hey @jkczyz! This PR has been waiting for your review. |
Let BOLT12 blinded payment paths include LSPS2 parameters decoded from payment metadata, so JIT-channel paths work without router state for the intercepted SCID. Co-Authored-By: HAL 9000
Fail async static-invoice path creation when no LSPS2 metadata exists. This prevents automatic refreshes from uploading unusable invoices. Co-Authored-By: HAL 9000
Allow offer metadata maps to key entries directly by offer id without wrapping the identifier. Co-Authored-By: HAL 9000
Let async recipients refresh receive offers explicitly, wait for readiness, and preserve payment metadata across static-invoice refreshes. Co-Authored-By: HAL 9000
Return a completed future when an async receive offer is already ready. Drop redundant public wrappers now covered by lower-level APIs. Co-Authored-By: HAL 9000
Align LSPS2 CLTV deltas with the wire format and LDK routing types. Co-Authored-By: HAL 9000
Clarify how LSPS2 invoice parameters relate to BOLT11 route hints and BOLT12 blinded payment path creation. Co-Authored-By: HAL 9000
Let integration tests force specific blinded payment paths, so LSPS2 BOLT12 routing behavior can be exercised deterministically. Co-Authored-By: HAL 9000
Exercise decoder-provided LSPS2 parameters across custom-router, end-to-end, compact message path, and async-payment BOLT12 flows. Co-Authored-By: HAL 9000
Assert no static invoice is uploaded before LSPS2 metadata is ready. Keep LSPS2 integration tests compiling with current upstream types. Co-Authored-By: HAL 9000
Record the new LSPS2 BOLT12 routing support and its compatibility note for the next release notes. Co-Authored-By: HAL 9000
26da1dd to
abdecc2
Compare
|
🔔 4th Reminder Hey @TheBlueMatt @jkczyz! This PR has been waiting for your review. |
Closes #4272.
This is an alternative approach to #4394 which leverages a custom
Routerimplementation on the client side to inject the respective.LDK Node integration PR over at lightningdevkit/ldk-node#817