Skip to content

feat(trader): add sphere trader withdraw subcommand#12

Open
vrogojin wants to merge 2 commits intomainfrom
feat/trader-withdraw-cli
Open

feat(trader): add sphere trader withdraw subcommand#12
vrogojin wants to merge 2 commits intomainfrom
feat/trader-withdraw-cli

Conversation

@vrogojin
Copy link
Copy Markdown
Contributor

@vrogojin vrogojin commented May 9, 2026

Summary

Registers the sphere trader withdraw subcommand, which sends a WITHDRAW_TOKEN ACP command via the existing transport layer. The subcommand was missing from src/trader/trader-commands.ts despite already being invoked by the trader-service e2e helpers — this PR closes that gap. Inputs (--asset, --amount, --to-address) are validated up-front before the ACP command is dispatched.

Test plan

npm run build
node bin/sphere.mjs trader withdraw --help

The help output should show the new subcommand with its three required flags. For an end-to-end check, run the trader-service hma-trade-settlement.e2e-live.test.ts live test — it shells out to sphere trader withdraw to drive the withdraw step.

Vladimir Rogojin and others added 2 commits May 8, 2026 14:37
Mirrors the pattern in trader-service, escrow-service, agentic-hosting,
and js-faucet. When set to a comma-separated list of WebSocket URLs,
overrides the network preset's relay list. Used by the trader-service
local-infra e2e harness so 'sphere wallet init', 'sphere host spawn',
'sphere trader create-intent', etc., target the same Docker-hosted
relay as the spawned tenants.

Falls back to SPHERE_NOSTR_RELAYS if UNICITY_NOSTR_RELAYS is unset.
Empty/unset → use network default (no behavioral change).

Patches both initSphere() in src/host/sphere-init.ts (the new
'sphere host …' / 'sphere trader …' inits) AND the legacy-cli's
getSphere() in src/legacy/legacy-cli.ts (the 'sphere wallet init'
path).
Wires the missing controller-side CLI for the trader's WITHDRAW_TOKEN
ACP command. Validates --asset / --amount / --to-address up-front (so
malformed inputs fail with clear messages before reaching the trader's
own validation gate), then sends the WITHDRAW_TOKEN command via the
existing transport.

The trader image already implements WITHDRAW_TOKEN end-to-end (split
selected token + send + history record + balance update), and the
HMA-trade-settlement e2e helper has been calling
`sphere trader withdraw` for a while — but the subcommand was never
registered, so every test run failed at the withdraw step with
"unknown command 'withdraw'".

Verified: HMA-trade-settlement.e2e-live Pair-2 reaches deal COMPLETED,
runs withdraw, prints transfer_id, and the post-withdraw balance
delta matches the withdrawn amount. Pair-1 failed only on a transient
testnet Market API 502 (external infra), not on the withdraw path.
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