Skip to content

lnwallet+rpc: add label filter to GetTransactions#10806

Open
saraogiraj94 wants to merge 1 commit into
lightningnetwork:masterfrom
saraogiraj94:label-filter-get-transactions
Open

lnwallet+rpc: add label filter to GetTransactions#10806
saraogiraj94 wants to merge 1 commit into
lightningnetwork:masterfrom
saraogiraj94:label-filter-get-transactions

Conversation

@saraogiraj94
Copy link
Copy Markdown

@saraogiraj94 saraogiraj94 commented May 15, 2026

Closes #10785

Summary

  • Adds an optional label field (proto field 6) to GetTransactionsRequest so callers can filter chain transactions by their label
  • WalletController.ListTransactionDetails gains a labelFilter string parameter; when non-empty, only transactions whose Label field exactly matches are returned
  • lncli listchaintxns gains a --label flag

Testing

  • All existing mocks and integration-test call sites updated to pass the new parameter
  • New integration test testListTransactionDetailsLabelFilter covers: exact match by label A, exact match by label B, no filter returns all, unknown label returns empty

Release Notes

Updates docs/release-notes/release-notes-0.22.0.md under RPC Additions and lncli Additions.

🤖 Generated with Claude Code

@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 label-based filtering for chain transactions across the RPC, CLI, and internal wallet interfaces. By allowing users to filter transactions by a specific label, it improves the discoverability and management of wallet activity. The changes include updates to the gRPC definition, internal wallet controller logic, and command-line interface, accompanied by comprehensive integration tests to ensure correctness.

Highlights

  • RPC API Update: Added an optional label field to GetTransactionsRequest to allow filtering chain transactions by label.
  • Wallet Controller Enhancement: Updated WalletController.ListTransactionDetails to accept a labelFilter parameter for precise transaction retrieval.
  • CLI Tooling: Introduced a new --label flag to the listchaintxns command in lncli.
  • Testing: Implemented a new integration test testListTransactionDetailsLabelFilter to verify exact label matching and empty result scenarios.
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.

saraogiraj94 added a commit to saraogiraj94/lnd that referenced this pull request May 15, 2026
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 an optional "label" filter to the GetTransactions RPC and the listchaintxns CLI command, allowing users to filter transactions by their exact label. The changes span the API definitions, the wallet controller interface, and the btcwallet implementation, supported by new integration tests. Review feedback highlighted a placeholder PR number in the release notes that needs updating and noted significant formatting regressions in the generated gRPC code, suggesting the file be regenerated using the standard project toolchain to reduce diff noise.

Comment thread docs/release-notes/release-notes-0.22.0.md
Comment thread lnrpc/lightning_grpc.pb.go
@github-actions github-actions Bot added the severity-critical Requires expert review - security/consensus critical label May 15, 2026
@github-actions
Copy link
Copy Markdown

PR Severity: CRITICAL - lnwallet and rpcserver.go changes require expert review. <!-- pr-severity-bot -->

@github-actions
Copy link
Copy Markdown

PR Severity: CRITICAL

Automated classification | 9 files | 210 lines changed (excluding auto-generated and test files)

Critical (5 files):

  • lnwallet/btcwallet/btcwallet.go - Wallet operations (lnwallet/*)
  • lnwallet/interface.go - Core wallet interface (lnwallet/*)
  • lnwallet/mock.go - Wallet mock (lnwallet/*)
  • lnwallet/test/test_interface.go - Wallet test interface (lnwallet/*)
  • rpcserver.go - Core server coordination

High (2 files):

  • lnrpc/lightning.proto - RPC/API definitions (lnrpc/*)
  • lnrpc/lightning.swagger.json - RPC/API definitions (lnrpc/*)

Medium (1 file): cmd/commands/commands.go
Low (1 file): docs/release-notes/release-notes-0.22.0.md
Excluded (auto-gen/test): lnrpc/lightning.pb.go, lnrpc/lightning_grpc.pb.go, lntest/mock/walletcontroller.go

Analysis: This PR modifies lnwallet/* and rpcserver.go, both CRITICAL. The wallet interface change (lnwallet/interface.go) affects channel funding, signing, and commitment transactions. The lnrpc proto addition adds new RPC surface. No severity bump: 9 files (threshold 20) and 210 lines (threshold 500).

To override: add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

Adds an optional `label` string field to `GetTransactionsRequest` (proto
field 6) so callers can filter chain transactions by label.

- `WalletController.ListTransactionDetails` gains a `labelFilter string`
  parameter; when non-empty, only transactions whose `Label` field exactly
  matches are returned (client-side filter after the full fetch).
- `rpcserver.GetTransactions` threads `req.Label` through to the wallet call.
- `lncli listchaintxns` gains a `--label` flag.
- All mocks and the integration-test harness are updated to pass the new
  parameter.
- New integration test `testListTransactionDetailsLabelFilter` covers: exact
  match by label, no-filter returns all, and unknown label returns empty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@murraystewart96
Copy link
Copy Markdown

Looks good. Nice use of the in place filter!


// If a label filter is specified, only include transactions whose label
// matches exactly.
if labelFilter != "" {
Copy link
Copy Markdown

@TechLateef TechLateef May 25, 2026

Choose a reason for hiding this comment

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

This look solid!

However, there might be a little bug here with how pagination interacts with this filter. Since the code above this block populates txDetails from the database using the raw maxTransactions limit, the result set is already truncated before it hits this loop.

If a node has thousands of transactions, but the client queries with a default maxTransactions window (like 20 or 50) along with a specific label, the filter will only check that initial batch. If the matching transaction sits further down in the history, it'll be missed entirely. The label filter likely needs to be applied to the raw results before the pagination slices and offsets are handled.

require.NoError(t, err)
require.Len(t, txDetails, 0)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The test cases cover the exact matching nicely.

One minor thing: all the test queries here pass 0 for maxTransactions, which fetches the whole history at once and disables pagination boundaries. Because of that, it doesn't catch the edge case where a client passes both a label filter and a tight max_transactions limit at the same time.

It would be great to add one more test assertion in here that uses a small maxTransactions limit to verify that pagination doesn't accidentally chop off matching records from the results.

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

Labels

severity-critical Requires expert review - security/consensus critical

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature]: Add label filter to GetTransactions RPC

3 participants