Skip to content

WIP: Add BOLT12 payer proof support#845

Draft
vincenzopalazzo wants to merge 6 commits intolightningdevkit:mainfrom
vincenzopalazzo:macros/bolt12-pop
Draft

WIP: Add BOLT12 payer proof support#845
vincenzopalazzo wants to merge 6 commits intolightningdevkit:mainfrom
vincenzopalazzo:macros/bolt12-pop

Conversation

@vincenzopalazzo
Copy link
Copy Markdown
Contributor

@vincenzopalazzo vincenzopalazzo commented Mar 25, 2026

Summary

  • integrate the payer proof rust-lightning branch and patch transitive rust-lightning crates onto the same forked revision
  • persist BOLT12 invoice payer-proof context from InvoiceReceived and expose Bolt12Payment::create_payer_proof with selective disclosure options
  • add UniFFI-facing payer proof support and wire new payer proof errors through the public API

Verification

  • cargo fmt --all
  • cargo check --lib
  • cargo check --lib --features uniffi
  • cargo test --lib
  • cargo test --lib --features uniffi

Disclosure

  • This PR was prepared with Codex AI assistance.

Please note that this PR is just a test to see if we are adding all the necessary API to the main PR lightningdevkit/rust-lightning#4297

@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Mar 25, 2026

👋 Thanks for assigning @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@vincenzopalazzo vincenzopalazzo marked this pull request as draft March 25, 2026 17:13
@vincenzopalazzo vincenzopalazzo changed the title Add BOLT12 payer proof support WIP: Add BOLT12 payer proof support Mar 25, 2026
@vincenzopalazzo vincenzopalazzo force-pushed the macros/bolt12-pop branch 2 times, most recently from 18e0c72 to 312b662 Compare March 26, 2026 15:42
@tnull tnull self-requested a review March 26, 2026 17:28
@vincenzopalazzo vincenzopalazzo force-pushed the macros/bolt12-pop branch 4 times, most recently from 781d3ee to 0aaab83 Compare March 26, 2026 18:46
@ldk-reviews-bot
Copy link
Copy Markdown

🔔 1st Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link
Copy Markdown

🔔 2nd Reminder

Hey @tnull! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

vincenzopalazzo and others added 5 commits April 2, 2026 14:15
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add payer-proof creation for outbound BOLT12 payments, persist the invoice context needed to build the proof, and expose the new types through the public and UniFFI surfaces.

AI-assisted-by: Codex
Update rust-lightning dependency to include commits from PRs #4210
(BLIP-42 contact secrets) and #4297 (payment_nonce in PaymentSent).

The payment_nonce in PaymentSent allows capturing the nonce needed for
payer proof construction directly from the payment success event,
eliminating the need to set manually_handle_bolt12_invoices and
intercept InvoiceReceived.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use cfg-gated match to extract Bolt12Invoice correctly per build mode:
  non-uniffi uses PaidBolt12Invoice::Bolt12Invoice variant,
  uniffi uses PaidBolt12Invoice::Bolt12 variant and unwraps Arc + inner
- Apply cargo fmt to fix formatting diffs
- Remove redundant .clone() in PayerProofContext construction

Co-Authored-By: Claude <noreply@anthropic.com>
- Bump rust-lightning rev from f5c24c6 to c836395
- PaidBolt12Invoice changed from enum (lightning::events) to struct
  (lightning::offers::payer_proof)
- New Bolt12InvoiceType enum replaces old PaidBolt12Invoice variants
- OptionalOfferPaymentParams lost contact_secrets/payer_offer fields
- PayerProofContextStore is now in-memory only since PaidBolt12Invoice
  cannot be serialized or reconstructed externally (new/nonce/invoice_type
  are all pub(crate) in LDK)
- Removed payment_nonce field from Event::PaymentSuccessful
- Removed read_payer_proof_contexts and related persistence constants
- cfg-gated Bolt12InvoiceType vs FFI PaidBolt12Invoice for uniffi compat

Co-authored-by: AI Assistant <ai@lightningdevkit.org>
(3, quantity, option),
(4, secret, option),
(6, offer_id, required),
(8, bolt12_invoice, option),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned elsewhere, we probably don't want to do this, at least not before we can use #811

scorer: Arc<Mutex<Scorer>>,
peer_store: Arc<PeerStore<Arc<Logger>>>,
payment_store: Arc<PaymentStore>,
payer_proof_context_store: Arc<PayerProofContextStore>,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'd rather not add yet another store just for this. Can we store this in the payment metadata store post #811?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes OFC, I wanted to have a runnable version in a fork, but currently I am interesting in you giving some feedback on the payer proof API, if you think are good enough!

Thanks after ldk 0.3 I can wait for #811 and vibe code another integration :)

The previous CI run had a flaky failure in test async_payment on
ubuntu-latest/1.85.0 due to a BrokenPipe in block header subscription
(tests/common/mod.rs:541), which is a race condition in the test
infrastructure unrelated to our changes.

The semver-checks failure is expected: it compares the published crate
against our PR which patches LDK to a different fork revision, causing
type mismatches in NetworkGraph/OnionMessenger. This will resolve once
the upstream rust-lightning PR #4297 merges.

Generated with AI assistance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants