Skip to content

Lazy auto-generate + bind v3 payout wallet on first API call#10

Open
epanonymous wants to merge 5 commits into
mainfrom
feat/lazy-payout-autobind
Open

Lazy auto-generate + bind v3 payout wallet on first API call#10
epanonymous wants to merge 5 commits into
mainfrom
feat/lazy-payout-autobind

Conversation

@epanonymous

Copy link
Copy Markdown
Contributor

Summary

  • Moves payout wallet setup out of registration and into the first authenticated SDK API call.
  • Adds a lazy payout-wallet binder that checks existing binding, generates a local v3 ed25519 wallet when needed, stores the secret locally, and sends only the base58 pubkey to the API.
  • Serializes concurrent first calls in-process, treats server already_bound as success, and caches the bound state per API key.
  • Supports caller-supplied external/passkey wallets via payoutWallet.pubkey, payoutWallet.publicKey, or payout_pubkey, plus configurable payoutWalletStorePath and payoutWalletApiBase.

Supersedes #9

This supersedes PR #9's registration-time / opt-in payout wallet binding model. PR #9 should be closed in favor of this lazy, automatic first-call binding flow.

Shared Contract

  • GET /api/v1/agent/payout-wallet with agent-key auth returns { payout_pubkey: base58|null, bound_at: iso|null }.
  • POST /api/v1/agent/payout-wallet/bind with agent-key auth and body { payout_pubkey } returns { payout_pubkey, bound_at, already_bound }.
  • The SDK relies on the server's first-write-wins behavior for cross-process races.

Local Secret Storage

  • Generated secrets are stored locally at ~/.deva/payout-wallet.json by default; callers can override this with payoutWalletStorePath.
  • Store entries are keyed by an API-base/API-key fingerprint, not the raw API key; the parent directory is created with 0700 and the store file with 0600 where supported.
  • The secret key is never transmitted to the server. Bind requests send only { payout_pubkey }.

Verification

  • npm test (46 passing tests; HTTP calls mocked, no live API)
  • npm run build
  • CJS import smoke test for the lazy flow: cjs lazy payout smoke ok: status=1 bind=1 resources=2

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