Skip to content

Track inbound payments by PaymentId#948

Draft
tnull wants to merge 3 commits into
lightningdevkit:mainfrom
tnull:2026-06-payment-id-prefactors
Draft

Track inbound payments by PaymentId#948
tnull wants to merge 3 commits into
lightningdevkit:mainfrom
tnull:2026-06-payment-id-prefactors

Conversation

@tnull

@tnull tnull commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Closes #298.

This finally switches our inbound payments over to be fully tracked by payment id, and decouples payment IDs from payment hashes.

The switch to tracking payments by ID happened with LDK Node v0.3.0,
which is >1.5 years old by now. We can be pretty certain that nobody is
upgrading from an older version to the upcoming v0.8.

Here we hence make the `payment_id` fields in `Event` required which is
a nice API simplification that will also be utilized in the next commit.

Co-Authored-By: HAL 9000
@ldk-reviews-bot

ldk-reviews-bot commented Jun 24, 2026

Copy link
Copy Markdown

👋 Hi! This PR is now in draft status.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@tnull tnull force-pushed the 2026-06-payment-id-prefactors branch from 51dba72 to ff3345d Compare June 24, 2026 15:21
tnull added 2 commits June 24, 2026 17:21
Create inbound BOLT11 records from claimable and claimed events.

Stop pre-creating those records when invoices are generated.

Generate outbound BOLT11 IDs from KeysManager entropy.

Do not derive them from the payment hash.

Duplicate invoice detection is restored in the next commit.

Co-Authored-By: HAL 9000
Manual BOLT11 invoices need a pending entry before HTLC arrival.
That lets duplicate registrations be rejected while keeping randomized
payment IDs.

Store the pending entries with their invoice expiry and resolve BOLT11
claimable events by scanning those entries.

Co-Authored-By: HAL 9000
@tnull tnull marked this pull request as draft June 24, 2026 15:22
@tnull tnull force-pushed the 2026-06-payment-id-prefactors branch from ff3345d to 544e100 Compare June 24, 2026 15:23
Comment thread src/payment/bolt11.rs

let payment_hash = invoice.payment_hash();
let payment_id = PaymentId(invoice.payment_hash().0);
if let Some(payment) = self.payment_store.get(&payment_id) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Dropped this for now, bit on the fence on whether it's worth maintaining a secondary index for this is worth it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

(Although will probably be necessary for the next commit, too)

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.

Track inbound payments by also unique payment IDs

2 participants