Skip to content

fix(cli): name each candidate's environment when --env is not given - #77

Merged
thebrandonlucas merged 1 commit into
feat/cli-invoice-wallet-shortlistfrom
fix/cli-shortlist-env-flags
Oct 21, 2026
Merged

thebrandonlucas merged 1 commit into
feat/cli-invoice-wallet-shortlistfrom
fix/cli-shortlist-env-flags

Conversation

@thebrandonlucas

Copy link
Copy Markdown
Contributor

Stack

One stack, merged bottom up:

  1. feat(cli): name the wallets that could pay a BOLT11 invoice #73: wallets that could pay a BOLT11 invoice (base master)
  2. This PR: tee8z's review fixes for feat(cli): name the wallets that could pay a BOLT11 invoice #73 (base feat(cli): name the wallets that could pay a BOLT11 invoice #73)
  3. feat(cli): list wallets in every organization with --all-orgs #74: wallets list --all-orgs (base this branch)
  4. feat(cli): offer a pinned profile after login on a terminal #75: offer a pinned profile after login (base feat(cli): list wallets in every organization with --all-orgs #74)

Refs #34

Why a separate PR

These fixes answer tee8z's review of #73 (ed53d14). Amended into #73, they would take its diff to about 1,140 changed lines, over the repository's 1,000-line limit (AGENTS.md). So they are stacked directly on #73, and #73 is unchanged at ed53d14.

Changes

tee8z finding Fix
P2: without --env, the candidate flags omit the environment, so the pasted command fails with Exactly one --env is required When the scope selects no environment, each candidate adds its wallet's own environment_id as --env (api::scope_flags_in). A given --env is kept.
The USD candidate's quote command has the same gap: quotes live under /organizations/{org}/environments/{env}/quotes The quote command uses the same flags, so it gets the wallet's --env too.
A valid prefix with a malformed amount (lnbc1p1qqq) reads as "does not start with a BOLT11 prefix" The hint now says "is not a BOLT11 invoice the CLI can read: it must start with lnbc, lntb, lntbs, or lnbcrt, then an optional amount."
The no-candidate hint lists every excluded wallet The hint names at most five and counts the rest ("and N more, listed in --json as excluded"). --json still lists every wallet.

The insufficient_balance finding was already fixed in #73 at ed53d14.

Tests

  • An integration test, a_bolt11_send_without_an_environment_names_each_candidates_environment, runs a send with --org and no --env. It checks that the listing sends no environment_id, and that the candidate's flags are --wallet ID --org ORG --env ENV.
  • Unit tests:
    • With no --env, the candidate's flags and quote command name the wallet's environment.
    • A given --env is kept.
    • The hint is capped at five wallets: with more, it adds "and N more"; with exactly five, it does not.
    • scope_flags_in with and without a fallback environment.
  • The malformed-amount invoice gets the new hint in the integration test.

Checks

  • The verification gate passes in nix develop: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo machete --with-metadata, cargo test --locked and python3 scripts/check-coverage.py.
  • On this head: 126 unit and 106 integration tests.
  • On the stack tip (feat(cli): offer a pinned profile after login on a terminal #75): 131 unit and 120 integration tests.
  • CRAP on the stack tip: 0 of 607 measured functions are at or above 20. The highest is wait_for_payment at 19.60.
  • Size: 168 changed lines.

Without --env, the wallet shortlist for a BOLT11 send lists the whole
organization, but its pasted flags and quote command named no
environment, so the payment or quote failed with "Exactly one --env is
required". Each candidate now adds its wallet's own --env when the scope
selects none, and keeps a given --env.

An invoice with a BOLT11 prefix but an unreadable amount no longer
reads as missing the prefix, and the no-candidate hint names at most
five excluded wallets and counts the rest, which --json still lists.

Refs #34
@thebrandonlucas
thebrandonlucas merged commit 46d3f45 into master Oct 21, 2026
7 checks passed
@thebrandonlucas
thebrandonlucas deleted the fix/cli-shortlist-env-flags branch October 21, 2026 21:49
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.

2 participants