Skip to content

litcli: drop unused flags from addinvoice command#1335

Open
0xfandom wants to merge 2 commits into
lightninglabs:masterfrom
0xfandom:fix/1121-addinvoice-flags
Open

litcli: drop unused flags from addinvoice command#1335
0xfandom wants to merge 2 commits into
lightninglabs:masterfrom
0xfandom:fix/1121-addinvoice-flags

Conversation

@0xfandom

Copy link
Copy Markdown
Contributor

Change Description

Fixes #1121.

litcli ln addinvoice builds its flag set by appending the asset-specific flags onto lncli's full addinvoice flag list. As a result, litcli ln addinvoice -h advertises a number of flags that the command's action never reads and that don't apply to Taproot Asset invoices.

This filters out the flags that are demonstrably unused by the addInvoice action:

  • cltv_expiry_delta
  • blind, min_real_blinded_hops, num_blinded_hops, max_blinded_paths, blinded_path_omit_node, blinded_path_incoming_channel_list

These are never referenced when building the AddInvoiceRequest, so removing them from the command only changes the help output, not behaviour. A test asserts the command keeps every flag the action consumes (including the asset flags) and drops the unsupported ones.

Note: --private, --amp and --fallback_addr are left in place for now since the action does pass them through to the RPC. If the Taproot Assets invoice path doesn't honour them either, they can be removed in a follow-up — happy to do that here too if preferred.

Steps to Test

make build
./litcli-debug ln addinvoice -h

The blinded-path options and --cltv_expiry_delta should no longer be listed. Or run the unit test:

go test -tags="autopilotrpc signrpc walletrpc chainrpc invoicesrpc watchtowerrpc neutrinorpc monitoring peersrpc kvdb_postgres kvdb_etcd kvdb_sqlite" ./cmd/litcli/ -run TestAddInvoiceCommandFlags -v

Pull Request Checklist

  • Test coverage added.
  • Commits are signed (DCO).

@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 cleans up the command-line interface for 'litcli ln addinvoice' by filtering out flags that are inherited from 'lncli' but are not supported by the Taproot Assets invoice implementation. By removing these irrelevant options, the command's help documentation is more accurate and less confusing for users, while ensuring that all functional flags remain available.

Highlights

  • Flag Cleanup: Removed unused flags from the 'litcli ln addinvoice' command that were inherited from 'lncli' but not applicable to Taproot Asset invoices.
  • Improved User Experience: The 'addinvoice -h' help output is now cleaner and more accurate, as it no longer advertises flags that have no effect on asset invoices.
  • Regression Testing: Added a new unit test to ensure that required flags are preserved while unsupported flags are correctly filtered out.
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.

0xfandom added a commit to 0xfandom/lightning-terminal that referenced this pull request Jun 24, 2026
Signed-off-by: 0xfandom <kashyapshivank01@gmail.com>

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

Copy link
Copy Markdown

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 a mechanism to filter out unsupported inherited flags (such as cltv_expiry_delta and blinded path options) from the addinvoice command in litcli, as they do not apply to Taproot Asset invoices. It also adds a corresponding unit test to verify that the correct flags are retained and unsupported ones are removed. The review feedback highlights a potential issue where flag.GetName() can return comma-separated aliases (e.g., 'blind, b'), which would bypass the filtering logic and cause test inaccuracies. It is recommended to split and trim the flag names by commas in both the filtering function and the test setup to ensure robust matching.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread cmd/litcli/ln.go
Comment on lines +716 to +728
func withoutUnsupportedAddInvoiceFlags(flags []cli.Flag) []cli.Flag {
filtered := make([]cli.Flag, 0, len(flags))
for _, flag := range flags {
_, unsupported := addInvoiceUnsupportedFlags[flag.GetName()]
if unsupported {
continue
}

filtered = append(filtered, flag)
}

return filtered
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

In urfave/cli (v1), flag.GetName() returns the raw Name string, which can contain comma-separated aliases (e.g., "blind, b"). If any of the inherited flags are defined with aliases now or in the future, addInvoiceUnsupportedFlags[flag.GetName()] will fail to match, and the unsupported flag will not be filtered out.

To make this robust against aliases, we should split the flag name by "," and trim whitespace before checking against the unsupported map.

func withoutUnsupportedAddInvoiceFlags(flags []cli.Flag) []cli.Flag {
	filtered := make([]cli.Flag, 0, len(flags))
	for _, flag := range flags {
		var unsupported bool
		for _, part := range strings.Split(flag.GetName(), ",") {
			if _, ok := addInvoiceUnsupportedFlags[strings.TrimSpace(part)]; ok {
				unsupported = true
				break
			}
		}
		if unsupported {
			continue
		}

		filtered = append(filtered, flag)
	}

	return filtered
}

Comment thread cmd/litcli/ln_test.go
Comment on lines +16 to +19
flagNames := make(map[string]struct{})
for _, flag := range addInvoiceCommand.Flags {
flagNames[flag.GetName()] = struct{}{}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similar to the implementation in ln.go, flag.GetName() can return a string containing aliases (e.g., "blind, b"). If a flag has aliases, flagNames[flag.GetName()] will store the full string, and checking flagNames["blind"] will return false even though the flag is still present. This can lead to false positives in the test.

We should split and trim the flag names here as well to ensure all names and aliases are correctly populated in the map. Note that you will need to import "strings" in this test file.

Suggested change
flagNames := make(map[string]struct{})
for _, flag := range addInvoiceCommand.Flags {
flagNames[flag.GetName()] = struct{}{}
}
flagNames := make(map[string]struct{})
for _, flag := range addInvoiceCommand.Flags {
for _, part := range strings.Split(flag.GetName(), ",") {
flagNames[strings.TrimSpace(part)] = struct{}{}
}
}

@0xfandom
0xfandom force-pushed the fix/1121-addinvoice-flags branch from 9a71faf to 0e04cd5 Compare June 25, 2026 07:07
@0xfandom

Copy link
Copy Markdown
Contributor Author

Dropped the release-notes entry for now — it was conflicting with release-notes-0.17.0.md on the latest master and blocking the merge. That means the check release notes updated job will be red. Happy to re-add a one-line entry on top of current master (or you can add one on merge) — whichever is easier. The code change itself is unaffected.

0xfandom added a commit to 0xfandom/lightning-terminal that referenced this pull request Jun 25, 2026
Signed-off-by: 0xfandom <kashyapshivank01@gmail.com>
@0xfandom

Copy link
Copy Markdown
Contributor Author

Update: re-added the release note after all — placed it under "Technical and Architectural Updates", which merges cleanly against the current master, so the check release notes updated job is green again. No admin-merge needed on that account.

@lightninglabs-deploy

Copy link
Copy Markdown

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


### Technical and Architectural Updates

* [Hide unsupported flags from `litcli ln

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0xfandom added a commit to 0xfandom/lightning-terminal that referenced this pull request Jul 21, 2026
Signed-off-by: 0xfandom <kashyapshivank01@gmail.com>
@0xfandom
0xfandom force-pushed the fix/1121-addinvoice-flags branch from 1c92ee3 to 16d1284 Compare July 21, 2026 09:46
@0xfandom

Copy link
Copy Markdown
Contributor Author

Done — moved the entry to release-notes-0.17.1.md. Also rebased the branch onto the latest master while I was at it, so the release-notes check is green again.

@0xfandom

Copy link
Copy Markdown
Contributor Author

Heads-up: the bbolt integration test job failed on terminal_stateless_init_mode (itest/litd_stateless_init_test.go:29 — "An error is expected but got nil" on the macaroon-file assertion). That looks unrelated to this PR, which only removes unused flags from the litcli ln addinvoice flag list and adds a unit test — nothing that touches macaroon file creation at node startup. The same job passed on my other PR against the same master commit, and the log carries the malformed header: missing HTTP content-type line from #1122. Could you kick off a re-run when you get a chance? I do not have permission to re-run jobs here.

0xfandom added 2 commits July 22, 2026 19:01
The litcli `ln addinvoice` command inherits all of lncli's addinvoice
flags but its action only acts on a subset. The blinded-path flags and
cltv_expiry_delta are never read and don't apply to Taproot Asset
invoices, yet they still show up in `litcli ln addinvoice -h`, which is
confusing.

Filter those flags out so the help output only lists options that have an
effect, and add a test asserting the command keeps the flags it uses and
drops the unsupported ones.

Addresses lightninglabs#1121

Signed-off-by: 0xfandom <kashyapshivank01@gmail.com>
Signed-off-by: 0xfandom <kashyapshivank01@gmail.com>
@0xfandom
0xfandom force-pushed the fix/1121-addinvoice-flags branch from 16d1284 to 0f59612 Compare July 22, 2026 13:37
@0xfandom

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest master — #1322 landed a new entry in the same Bug Fixes section, which put this branch into a conflicted state. Both entries are kept now and the branch merges cleanly again.

The earlier bbolt itest failure should get a fresh run off the new head.

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.

[bug]: remove irrelevant options from litcli ln addinvoice

3 participants