Skip to content

Add ListPayments / ListInvoices RPC#2150

Open
GeorgeTsagk wants to merge 4 commits into
lightninglabs:mainfrom
GeorgeTsagk:listpayments-listinvoices
Open

Add ListPayments / ListInvoices RPC#2150
GeorgeTsagk wants to merge 4 commits into
lightninglabs:mainfrom
GeorgeTsagk:listpayments-listinvoices

Conversation

@GeorgeTsagk
Copy link
Copy Markdown
Member

Description

Adds asset-aware ListInvoices and ListPayments RPCs to the TaprootAssetChannels service. Each request embeds the corresponding lnrpc list request, callers pass the same arguments they'd pass to lnd and each response item embeds the full lnrpc.Invoice / lnrpc.Payment alongside a repeated AssetAmount summary (asset_id, amount, and the tweaked group_key available) decoded from the HTLCs' custom records.

Results are filtered to records that actually involve a Taproot Asset; pagination offsets are passed through unchanged from lnd. Decode failures error out the whole RPC rather than silently dropping records, so corrupted data surfaces loudly. Unit tests cover the aggregation, binary-vs-JSON route decoding, error propagation, and length-validated asset IDs; a new custom-channels itest exercises the full flow end-to-end against a grouped asset.

Closes #2142

Add two new RPCs on the TaprootAssetChannels service that mirror lnd's
lnrpc.ListInvoices and lnrpc.ListPayments. Each request embeds the
standard lnd list request so callers can pass the same arguments they
would pass to lnd. Each response item embeds the full lnd invoice or
payment plus a repeated AssetAmount summary, so callers don't need to
parse the custom channel data themselves to learn which assets and
how many units an invoice or payment moved.

This commit only changes the proto definition (and the regenerated
files); the handlers are added in a follow-up commit.

Refs: lightninglabs#2142
@GeorgeTsagk GeorgeTsagk requested a review from jtobin May 28, 2026 19:17
@GeorgeTsagk GeorgeTsagk self-assigned this May 28, 2026
@GeorgeTsagk GeorgeTsagk changed the title Listpayments listinvoices Add ListPayments / ListInvoices RPC May 28, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces asset-aware ListInvoices and ListPayments RPCs to the TaprootAssetChannels service. These methods enable users to retrieve invoices and payments that involve Taproot Assets, providing detailed asset amount information and group keys by decoding HTLC custom records. The changes include full RPC implementation, updated protobuf definitions, and extensive testing to ensure accurate data aggregation and robust error handling.

Highlights

  • New RPC Endpoints: Added asset-aware ListInvoices and ListPayments RPCs to the TaprootAssetChannels service.
  • Asset Filtering and Decoding: Implemented logic to filter records for Taproot Assets and decode asset amounts and group keys from HTLC custom records.
  • Testing: Added comprehensive unit tests for aggregation logic and a new integration test to verify end-to-end flow.
  • Infrastructure Updates: Updated RPC permissions, protobuf definitions, and generated gRPC/Swagger documentation.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ListInvoices and ListPayments wrapper RPCs to the TaprootAssetChannels service, allowing clients to retrieve asset-aware views of invoices and payments filtered to only those involving Taproot Assets. The implementation is supported by new unit and integration tests. While the additions are solid, several functions in rpcserver.go lack defensive nil checks on inputs and loop elements (such as invoice, payment, htlc, and JSON tranches), which could trigger nil pointer dereference panics. Additionally, the helper function newAssetGroupLookup should be updated with a documentation comment to comply with the repository style guide.

Comment thread rpcserver/rpcserver.go
Comment thread rpcserver/rpcserver.go Outdated
Comment thread rpcserver/rpcserver.go
Comment thread rpcserver/rpcserver.go Outdated
Comment thread rpcserver/rpcserver.go
Comment thread rpcserver/rpcserver.go
Comment thread rpcserver/rpcserver.go
Implement the two new TaprootAssetChannels RPCs added in the previous
commit. Both proxy to lnd via the raw client and filter the result down
to records that involve a Taproot Asset, returning the lnrpc invoice or
payment together with the aggregated per-asset amounts decoded from the
HTLCs' custom records.

A few subtleties worth calling out:

  * Invoice amounts are read from the raw wire CustomRecords map of each
    InvoiceHTLC, which lnd's aux data parser never rewrites.

  * Payment amounts are aggregated from each HTLC attempt's
    Route.CustomChannelData. Depending on whether lnd has an aux data
    parser configured when marshalling the route (true in integrated
    litd mode), this blob is either the raw TLV encoding of the HTLC's
    custom records or its JSON representation; both forms are handled.

  * Per-payment first-hop custom records mark a payment as an asset
    payment even when no attempt has succeeded (e.g. fully failed
    payments, or invoice payments where the per-shard amount is only
    available on the individual route).

  * Failed HTLC attempts are excluded from the summed amounts but still
    flag the payment as an asset payment.
GeorgeTsagk added a commit to GeorgeTsagk/taproot-assets that referenced this pull request May 28, 2026
Reference the new asset-aware ListInvoices and ListPayments RPCs in the
0.8.0 release notes under RPC Additions.
@GeorgeTsagk GeorgeTsagk force-pushed the listpayments-listinvoices branch from 4fc7304 to f7dcffd Compare May 28, 2026 19:56
},
)
require.NoError(t.t, err)
require.GreaterOrEqual(t.t, len(bobInvoices.Invoices), 1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not asset the length of the Invoices array is 2?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch — fixed. The test setup is deterministic (1 warm-up keysend + 1 explicit createAssetInvoice = exactly 2 invoices on Bob, same for Alice's payments), so I tightened both assertions to require.Len(..., 2). Pushed in the updated itest: commit.

Add a custom-channels integration test that opens an asset channel
between two nodes, pays an asset invoice end-to-end, and then exercises
the new ListInvoices and ListPayments RPCs to verify:

  * the asset invoice and asset payment show up with the correct asset
    ID and aggregated unit amount;
  * a plain BTC invoice on the same node is correctly filtered out;
  * pagination offsets returned by lnd are passed through unchanged.

Run with: make itest icase=list_invoices_and_payments
Reference the new asset-aware ListInvoices and ListPayments RPCs in the
0.8.0 release notes under RPC Additions.
@GeorgeTsagk GeorgeTsagk force-pushed the listpayments-listinvoices branch from f7dcffd to 9b61cb6 Compare May 29, 2026 12:27
@jtobin jtobin added this to the v0.9 milestone Jun 2, 2026
@lightninglabs-deploy
Copy link
Copy Markdown

@GeorgeTsagk, remember to re-request review from reviewers when ready

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

Labels

None yet

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

[feature]: Add RPCs for ListPayments and ListInvoices.

4 participants