Add ListPayments / ListInvoices RPC#2150
Conversation
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
ListPayments / ListInvoices RPC
Summary of ChangesHello, 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 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
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.
Reference the new asset-aware ListInvoices and ListPayments RPCs in the 0.8.0 release notes under RPC Additions.
4fc7304 to
f7dcffd
Compare
| }, | ||
| ) | ||
| require.NoError(t.t, err) | ||
| require.GreaterOrEqual(t.t, len(bobInvoices.Invoices), 1) |
There was a problem hiding this comment.
Why not asset the length of the Invoices array is 2?
There was a problem hiding this comment.
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.
f7dcffd to
9b61cb6
Compare
|
@GeorgeTsagk, remember to re-request review from reviewers when ready |
Description
Adds asset-aware
ListInvoicesandListPaymentsRPCs 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 fulllnrpc.Invoice/lnrpc.Paymentalongside a repeatedAssetAmountsummary (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