Skip to content

offers: add used_count to listoffers#9162

Closed
alexgrad42 wants to merge 1 commit into
ElementsProject:masterfrom
alexgrad42:feature/add_offer_used_count
Closed

offers: add used_count to listoffers#9162
alexgrad42 wants to merge 1 commit into
ElementsProject:masterfrom
alexgrad42:feature/add_offer_used_count

Conversation

@alexgrad42

Copy link
Copy Markdown

This adds a new 'used_count' field to the 'listoffers' RPC command output to see the exact number of times a BOLT12 offer has been paid by counting associated settled invoices.

Changelog-Added: add a new 'used_count' field to the 'listoffers' RPC command

Closes #9146

@alexgrad42 alexgrad42 requested a review from cdecker as a code owner May 21, 2026 19:33
@alexgrad42 alexgrad42 force-pushed the feature/add_offer_used_count branch 2 times, most recently from e3719b3 to 5370032 Compare May 21, 2026 20:50

@nGoline nGoline left a comment

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.

Great addition. This fills a real gap and the implementation is straightforward, the core idea is solid and it's close to being mergeable.
A few things to fix before we can land this.

Comment thread lightningd/offer.c Outdated
Comment thread wallet/wallet.h
Comment thread wallet/wallet.c Outdated
Comment thread lightningd/offer.c Outdated
Comment thread .msggen.json Outdated
Comment thread doc/schemas/listoffers.json
Comment thread wallet/wallet.c Outdated
Comment thread wallet/wallet.c Outdated
Comment thread lightningd/offer.c Outdated
Comment thread tests/test_pay.py Outdated
@nGoline

nGoline commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Please rebase onto master instead of merging it in. Merging master into your feature branch creates a noisy history and makes the diff harder to follow. A clean rebase keeps the commits linear and makes it easier to bisect if something goes wrong later

@nGoline

nGoline commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Please rebase onto master instead of merging it in. Merging master into your feature branch creates a noisy history and makes the diff harder to follow. A clean rebase keeps the commits linear and makes it easier to bisect if something goes wrong later

Also, when addressing the review feedback, please use fixup! commits (or git commit --fixup=<sha>) rather than separate "fix" commits. Having a commit like "fix indentation" or "address review comments" in the final history makes it harder to bisect.

@alexgrad42 alexgrad42 force-pushed the feature/add_offer_used_count branch 2 times, most recently from 919c837 to 5e2e08f Compare May 27, 2026 18:03
@alexgrad42

Copy link
Copy Markdown
Author

I managed to squash the commits right before realizing that you prefer separate fixups, sorry about that! I will definitely use git commit --fixup next time.

@alexgrad42 alexgrad42 force-pushed the feature/add_offer_used_count branch 3 times, most recently from 95f7ebf to 11a754f Compare May 27, 2026 18:43
@alexgrad42 alexgrad42 requested a review from nGoline May 27, 2026 18:45
@alexgrad42 alexgrad42 force-pushed the feature/add_offer_used_count branch from 11a754f to 3daafa8 Compare May 27, 2026 19:52
This adds a new 'used_count' field to the 'listoffers' RPC command
output to see the exact number of times a BOLT12 offer has been paid
by counting associated settled invoices.

Changelog-Added: add a new 'used_count' field to the 'listoffers' RPC command

Closes ElementsProject#9146
@alexgrad42 alexgrad42 force-pushed the feature/add_offer_used_count branch from 3daafa8 to 7712956 Compare May 27, 2026 20:37
@nGoline

nGoline commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

I was talking to @rustyrussell last week and he mentioned the sql plugin. It was specifically designed to avoid baking ad-hoc aggregations into individual RPCs.

Following the philosophy of keeping individual RPCs lean, I strongly believe the sql plugin already covers this use case without adding a field to listoffers that has to be maintained, schema'd, and kept in sync across gRPC, msggen, etc.

Thank you for the time you've put into this @alexgrad42. I'll add instructions on how to achieve the proposed functionality on the original issue (#9146)

@nGoline nGoline closed this Jun 10, 2026
@nGoline nGoline removed request for cdecker and nGoline June 10, 2026 13:21
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.

BOLT12: getting how many times an offer was used

2 participants