Skip to content

Add flag-based input to wallet and sign commands - #112

Draft
figitaki wants to merge 5 commits into
carey/private-key-commandsfrom
carey/wallet-sign-flags
Draft

figitaki wants to merge 5 commits into
carey/private-key-commandsfrom
carey/wallet-sign-flags

Conversation

@figitaki

@figitaki figitaki commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #111 (carey/private-key-commands). Retarget to main once #111 merges.

What

Adds flag-based input beside the raw-JSON path for wallet create, wallet account create, sign payload, and sign transaction. Flags and --input-json/--input-file are mutually exclusive, enforced by clap (exit 2). Output, error codes, and pending handling are unchanged.

  • wallet create --name [--account ADDRESS_FORMAT[:PATH]]... [--mnemonic-length]. Like Go, no accounts are created by default. Accounts without a path get the next conventional path not already used by an explicit path or an earlier account. Repeated explicit paths are rejected.
  • wallet account create --wallet-id --address-format [--curve] [--path-format] [--path]. The curve is inferred as in Go. Without --path, the next unused conventional path for that address format is predicted from get_wallet_accounts (all pages, decoded loosely so address formats newer than the client don't break it). Documented in docs/resources.md.
  • sign payload --sign-with (--payload | --payload-file) --encoding --hash-function
  • sign transaction --sign-with (--unsigned-transaction | --unsigned-transaction-file) --type

Enum flags use the shared kebab-case parser (src/enum_args.rs, moved out of #111's private-key code and generalized to address format, curve, path format, payload encoding, hash function, and transaction type). Values are listed in --help, Unspecified is excluded, and API names like ADDRESS_FORMAT_ETHEREUM are rejected.

Why

Go CLI parity (wallets create, wallets accounts create, raw sign, ethereum transaction).

Encoding, hash function, and transaction type stay required with flags. The "explicit algorithm inputs" requirement comes from the original port's docs, so I did not add Go's UTF-8/sha256 defaults. A silent hash default changes which digest gets signed. Say if you want defaults.

Testing

cargo +nightly-2026-09-01 fmt --check, cargo clippy --all-targets --locked -- -D warnings, cargo doc, and cargo test pass. tests/wallet_sign_flags.rs (wiremock) checks exact intent bodies, mixed explicit/predicted paths, path prediction with pagination and an unknown address format, curve inference, mutual exclusion, kebab-only values, and usage errors. Live e2e tests (wallets, gpg) were updated but not run here. operations::tests::mutation_timeout_is_unknown_and_does_not_leak_body is flaky under parallel load, including on main.

@tkhq-valet-dev
tkhq-valet-dev Bot force-pushed the carey/wallet-sign-flags branch from 954e999 to 3f6fc20 Compare November 5, 2026 19:51
@tkhq-valet-dev
tkhq-valet-dev Bot force-pushed the carey/wallet-sign-flags branch from 3f6fc20 to 0fc319a Compare November 5, 2026 20:04
@figitaki
figitaki changed the base branch from main to carey/private-key-commands November 5, 2026 20:04
@figitaki
figitaki added this pull request to stack #113 November 5, 2026 21:00
figitaki and others added 4 commits November 5, 2026 13:03
Parse --account into a curve plus either an explicit path or a
conventional format, so wallet create rejects formats it cannot infer
during parsing. wallet account create now requires --curve and --path
through clap when the address format has no inferred value, so these
exit with usage_error.

CreateNextAccount keeps only the conventional format; the address
format comes from it. Account prediction stops with an error when the
API returns the same full page again. --payload-file drops one trailing
newline, so echo and editor-saved files sign the text shown.

Share the file-or-stdin read with JSON parameter input. Replace the
wiremock flag suite with unit tests for local parsing and three mock
tests for pages the live API cannot produce. The e2e suite now signs a
transaction from flags.

Co-authored-by: Turnkey <noreply@turnkey.com>
Drop comments that restate code, merge the StandardFormat impl blocks,
tie the account list page size to the prediction page size, and use
0x… placeholders in the signing docs.

Co-authored-by: Turnkey <noreply@turnkey.com>
@figitaki
figitaki force-pushed the carey/wallet-sign-flags branch from 0fc319a to 092765e Compare November 5, 2026 21:08
Path prediction posted to get_wallet_accounts, which the API answers
with 404. The SDK client and the gpg mock tests use list_wallet_accounts.

Co-authored-by: Turnkey <noreply@turnkey.com>
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.

1 participant