CLI 参考 - Alpha Book
跳转至

CLI 参考

OneCipher 提供 AI 代理友好的 CLI(密钥类命令支持 --json / --stdin)。

顶层命令

Text Only
onecipher [--daemon] <COMMAND>

Commands:
  wallet       钱包管理(create/import/export/delete/rename/list/info/change-password)
  sign         签名消息 / 交易(message/tx/send-tx/auth)
  verify       验证签名
  send         ERC-20 代币转账(构建 + 签名 + 广播)
  vanity       暴力生成虚荣地址
  mnemonic     助记词生成与派生
  policy       策略管理(create/list/show/delete)
  key          Agent API 密钥(create/list/revoke)
  session-key  会话密钥(经 Network-Agent)
  intent       意图生命周期(submit/simulate/execute)
  audit        审计日志(list/secrets 安全审计)
  vault        保险库解锁
  backup       .ocbk 加密备份(export/import)
  sbom         CycloneDX SBOM(verify/generate)
  wc           WalletConnect v2(pair/connect/sessions/disconnect/relay/probe/dapp-send)
  webui        本地 Web UI(open/approval/auth)
  service      systemd 用户服务(install/uninstall/status)
  status       Key-Agent / Network-Agent 状态
  config       配置查看与设置
  secret       通用密钥 CRUD(list/get/add/update/delete/rename/edit/copy/move)
  password     密码管理(add/get/generate)
  totp         TOTP/HOTP 管理(add/generate/uris/hotp)
  age          age 加密身份与接收者(init/recipient/identity-show/reencrypt)
  agent-secret Agent 模式密钥读取(API token 权限约束)
  env          以环境变量注入方式运行命令
  grep/find    解密内容搜索 / 名称模糊搜索
  fsck         密钥库完整性检查与修复
  history      密钥版本历史(git feature)
  migrate      旧版 keystore 迁移到 age 保险库
  tui          交互式终端界面
  git          保险库 git 同步(init/pull/push/log/status,git feature)
  doctor       系统健康诊断
  completion   Shell 补全脚本
  wallet-rpc   回环 JSON-RPC 2.0 WalletSigner 服务(LedgerFlow 集成)
  update/uninstall 更新与卸载

wallet

Bash
# 创建钱包(一次派生全部链地址)
onecipher wallet create --name my-wallet [--words 12|15|18|21|24] [--show-mnemonic]

# 导入助记词 / 私钥(从 ONECIPHER_MNEMONIC / ONECIPHER_PRIVATE_KEY 或 stdin 读取)
echo "<phrase>" | onecipher wallet import --name imported --mnemonic
ONECIPHER_PRIVATE_KEY="0x..." onecipher wallet import --name from-evm --private-key
ONECIPHER_PRIVATE_KEY="..." onecipher wallet import --name from-sol --private-key --chain solana

# 导出密钥材料或公钥
onecipher wallet export --wallet my-wallet
onecipher wallet export --wallet my-wallet --public-key --chain ethereum [--compressed]

# 列出 / 详情 / 重命名 / 删除 / 改密码
onecipher wallet list
onecipher wallet info
onecipher wallet rename --wallet old --new-name new
onecipher wallet delete --wallet old --confirm
onecipher wallet change-password --wallet my-wallet \
  [--passphrase "$OLD" --new-passphrase "$NEW"]

sign / verify / send

Bash
# 消息签名(EIP-191 / 链特定;--encoding utf8|hex)
onecipher sign message --chain <chain> --wallet <name> --message <text> [--json]

# EIP-712 类型化数据(提供 --typed-data 时无需 --message)
onecipher sign message --chain <chain> --wallet <name> --typed-data '<json>'

# 交易签名(--via local|wc 选择本地或 WalletConnect 后端)
onecipher sign tx --chain <chain> --wallet <name> --tx <0x-hex> [--via wc]

# 签名并广播
onecipher sign send-tx --chain <chain> --wallet <name> --tx <0x-hex> [--rpc-url <url>]

# EIP-7702 授权签名
onecipher sign auth --chain <chain> --wallet <name> --address <delegate> --nonce <n>

# 验证签名(message / typed-data / typed-data-file / hash 输入互斥)
onecipher verify --address <addr> --message "hello" --signature 0x...

# ERC-20 转账(金额为基础单位整数)
onecipher send --chain base --to 0xRecipient --token 0xUSDC \
  --amount 1000000 --wallet <name> --rpc-url <url>

链的写法统一支持三种:名称(ethereum/base/solana…)、CAIP-2 ID (eip155:8453)、裸 EVM chain ID(8453)。

统一保险库(secret / password / totp)

Bash
# 通用密钥 CRUD(类型:password/note/totp/mnemonic/private-key)
echo '{"secret":"..."}' | onecipher secret add api-keys/openai --type password --stdin --meta url=...
onecipher secret list [--type note] [--json]
onecipher secret get notes/recovery [--field secret] [--qr] [--copy] [--timeout 45]
onecipher secret edit notes/recovery [--editor vim]
onecipher secret rename/copy/move/delete ...

# 密码快捷命令(生成器:cryptic | memorable | xkcd)
onecipher password add github/personal --url https://github.com --username alice [--generate --length 32]
onecipher password get github/personal [--copy]
onecipher password generate --generator xkcd --xkcd-words 5 [--qr]

# TOTP / HOTP
onecipher totp add discord --otpauth "otpauth://..."
onecipher totp generate discord [--qr]
onecipher totp uris discord
onecipher totp hotp legacy --counter 42 --increment

# age 身份与多设备
onecipher age init
onecipher age identity-show
onecipher age recipient add/list/remove age1...
onecipher age reencrypt

# 搜索 / 注入 / 体检
onecipher grep "pattern" [--regex] [--json]
onecipher find openai [--type password]
onecipher env --name api-keys/openai [--keep-case] [--exec] -- ./deploy.sh
onecipher agent-secret get/list/totp ...    # API token 模式(读权限约束)
onecipher fsck [--fix] [--decrypt]

policy / key(Agent 访问控制)

Bash
# 从 JSON 文件注册策略(声明式规则 AND 组合,默认拒绝)
onecipher policy create --file base-policy.json
onecipher policy list | show --id base-only | delete --id base-only --confirm

# 创建 API 密钥(ows_key_ 前缀,只显示一次),可挂多个钱包与策略
onecipher key create --name claude-agent --wallet my-wallet \
  --policy base-only --expires-at 2026-12-31T23:59:59Z
onecipher key list
onecipher key revoke --id <key-id> --confirm

声明式规则只有三种:allowed_chains、expires_at、 allowed_typed_data_contracts。复杂逻辑用 executable 自定义程序 (stdin 收 PolicyContext JSON,stdout 回 {"allow":true|false}, 5 秒超时,失败即拒绝)。

WalletConnect / Web UI / 守护进程

Bash
onecipher wc pair [--ttl 3600]
onecipher wc connect "wc:<topic>@2?..."
onecipher wc sessions
onecipher wc disconnect <topic>
onecipher wc relay wss://relay.walletconnect.com --project-id <id>
onecipher wc probe [--url ...]           # 中继连通性诊断
onecipher wc dapp-send <topic> personal_sign '{"data":"0xdead"}'

onecipher webui open                     # 浏览器打开本地 Web UI
onecipher webui approval list/show/approve/reject ...
onecipher webui auth status/bootstrap/lock

onecipher service install|uninstall|status   # systemd 用户服务
onecipher status                             # Key-Agent / Network-Agent 状态

备份 / 迁移 / 维护

Bash
onecipher backup export --out backup.ocbk    # XChaCha20 加密备份容器
onecipher backup import --in backup.ocbk
onecipher migrate [--dry-run] [--rollback]   # 旧 keystore → age 保险库
onecipher audit list --since 24h [--agent id] [--status DENIED]
onecipher audit secrets [--max-age 365] [--skip-hibp]
onecipher doctor [--verbose]
onecipher completion zsh > ~/.zfunc/_onecipher
onecipher tui                                # ratatui 交互式界面
onecipher git init/pull/push/log/status      # 加密保险库 git 同步(git feature)

LedgerFlow 集成(wallet-rpc)

Bash
# 回环 JSON-RPC 2.0 服务:ledgerflow_sign / ledgerflow_keys / ledgerflow_sign_payment
OC_WALLET_RPC_LISTEN=127.0.0.1:18080 onecipher --daemon
# 或独立运行:
onecipher wallet-rpc serve [--listen 127.0.0.1:18080] [--wallet default] [--index 0]

每个签名请求必须携带新鲜的 Passkey 授权载荷;服务默认关闭、仅监听回环地址。

参见