# Self-hosted merchant watcher kit

The privacy-maximal way to accept Ziggybank orders: **your keys never leave your
machine.** You run this watcher against your own zkmoney account; it detects
incoming payments locally and posts only the match (order words + amount + tx
hash) to the Ziggybank API, authenticated with your apiKey. The API scope-limits
those calls to YOUR orders.

Ziggybank continues to host orders, pay pages, and webhooks — you host detection.
If you want zero Ziggybank involvement at all, this script is also the reference
implementation: point it at your own order store instead of our API.

## Files
- `selfhost-watch.sh` — the watcher (bash + python3 + zkmoney CLI)

## Run
```sh
export ZKMONEY_PASSPHRASE='your account passphrase'
export ZIGGYBANK_API_KEY='<64-hex apiKey from /api/merchants>'
./selfhost-watch.sh
```

Optional: `API_BASE`, `ZKMONEY_HOME`, `POLL_SECONDS`, `SEEN_FILE`, `WATCH_LOG`.

Payments land in `selfhost-payments.jsonl` (JSON lines) and matches post to
`/api/internal/match-payment`. Orders flip to paid and your webhook fires
exactly as in the hosted model.

## Fully independent mode
Everything the matching needs is in the script: watch your account, extract the
3-word memo + amount, compare to your open orders (paid iff amount >= due).
Replace the `urllib.request` block with your own order store lookup and the
Ziggybank dependency disappears.
