Skip to content

Commit 0d9ea10

Browse files
docs: update payments.md with deposit addresses, claim deposits, withdraw-sats
1 parent 5018829 commit 0d9ea10

1 file changed

Lines changed: 35 additions & 13 deletions

File tree

docs/payments.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ jss start --pay --pay-cost 10 --pay-address your-address --pay-token PODS --pay-
7373
| Method | Path | Description |
7474
|--------|------|-------------|
7575
| GET | `/pay/.info` | Public: cost, token info, chains, pool |
76-
| GET | `/pay/.balance` | Check your balance (NIP-98 auth) |
77-
| POST | `/pay/.deposit` | Deposit sats via TXO URI or MRC20 state proof |
76+
| GET | `/pay/.address` | Public: pod's taproot deposit address (optional `?user=did:nostr:...` for per-user address) |
77+
| GET | `/pay/.balance` | Check your balance (NIP-98 auth) — also auto-detects new deposits |
78+
| POST | `/pay/.deposit` | Deposit sats via TXO URI, claim `{txid, vout, chain}`, or MRC20 state proof |
79+
| POST | `/pay/.withdraw-sats` | Withdraw sats as a TXO voucher URI |
7880
| POST | `/pay/.buy` | Buy tokens with sat balance (requires `--pay-token`) |
7981
| POST | `/pay/.withdraw` | Withdraw balance as portable tokens (requires `--pay-token`) |
8082
| GET | `/pay/.offers` | List open sell orders (secondary market) |
@@ -86,41 +88,61 @@ jss start --pay --pay-cost 10 --pay-address your-address --pay-token PODS --pay-
8688

8789
### How It Works
8890

89-
1. Authenticate with NIP-98 (Nostr HTTP Auth)
90-
2. Check balance at `/pay/.balance`
91-
3. Deposit sats by POSTing a TXO URI to `/pay/.deposit`
91+
1. Get your deposit address: `GET /pay/.address?user=did:nostr:YOUR_PUBKEY`
92+
2. Send sats to that address from any Bitcoin wallet
93+
3. Check balance at `/pay/.balance` — deposits are auto-detected
9294
4. Access paid resources — each request deducts the configured cost
93-
5. Optionally buy tokens (`/pay/.buy`) or withdraw as portable tokens (`/pay/.withdraw`)
94-
6. Balance tracked in a [Web Ledger](https://webledgers.org/) at `/.well-known/webledgers/webledgers.json`
95+
5. Withdraw sats as a portable voucher: `POST /pay/.withdraw-sats`
96+
6. Optionally buy tokens (`/pay/.buy`) or withdraw as portable tokens (`/pay/.withdraw`)
97+
7. Balance tracked in a [Web Ledger](https://webledgers.org/) at `/.well-known/webledgers/webledgers.json`
98+
99+
Each user gets a unique taproot deposit address derived from the pod's master key + their identity. The pod auto-detects deposits by scanning the mempool API when you check your balance.
95100

96101
### Example
97102

98103
```bash
99-
# Check balance
104+
# Get your deposit address
105+
curl http://localhost:4443/pay/.address?chain=tbtc4&user=did:nostr:YOUR_PUBKEY
106+
# → {"address": "tb1p...", "chain": "tbtc4", "pubkey": "02..."}
107+
108+
# Send sats to that address, then check balance (auto-detects deposits)
100109
curl -H "Authorization: Nostr <base64-event>" http://localhost:4443/pay/.balance
101110

102-
# Deposit (post a confirmed transaction output)
111+
# Or deposit manually with a TXO voucher URI
103112
curl -X POST -H "Authorization: Nostr <base64-event>" \
104113
http://localhost:4443/pay/.deposit \
105-
-d "txid:vout"
114+
-d "txo:tbtc4:txid:vout?amount=X&key=Y"
115+
116+
# Or claim a deposit to the pod's address
117+
curl -X POST -H "Authorization: Nostr <base64-event>" \
118+
-H "Content-Type: application/json" \
119+
http://localhost:4443/pay/.deposit \
120+
-d '{"txid": "abc...", "vout": 0, "chain": "tbtc4"}'
106121

107122
# Access paid resource
108123
curl -H "Authorization: Nostr <base64-event>" http://localhost:4443/pay/my-resource
109124

125+
# Withdraw sats as a portable TXO voucher
126+
curl -X POST -H "Authorization: Nostr <base64-event>" \
127+
-H "Content-Type: application/json" \
128+
http://localhost:4443/pay/.withdraw-sats \
129+
-d '{"amount": 10000, "chain": "tbtc4"}'
130+
# → {"voucher": "txo:tbtc4:txid:0?amount=10000&key=...", ...}
131+
110132
# Buy tokens with sat balance
111133
curl -X POST -H "Authorization: Nostr <base64-event>" \
112134
-H "Content-Type: application/json" \
113135
http://localhost:4443/pay/.buy \
114-
-d '{"amount": 100}'
136+
-d '{"amount": 100, "currency": "tbtc4"}'
115137

116138
# Withdraw entire balance as portable tokens
117139
curl -X POST -H "Authorization: Nostr <base64-event>" \
118140
-H "Content-Type: application/json" \
119141
http://localhost:4443/pay/.withdraw \
120-
-d '{"all": true}'
142+
-d '{"all": true, "currency": "tbtc4"}'
121143
```
122144

123-
Deposit verification uses the mempool API (default: testnet4). The `X-Balance` and `X-Cost` headers are returned on successful paid requests. Buy and withdraw return portable MRC20 proofs with Bitcoin anchor data for independent verification.
145+
Three deposit methods: (1) send to your per-user address and check balance (auto-detected), (2) TXO voucher URI with private key, (3) claim a txid after sending to the pod's address. The `X-Balance`, `X-Cost`, and `X-Pay-Currency` headers are returned on successful paid requests. Buy and withdraw return portable MRC20 proofs with Bitcoin anchor data for independent verification.
124146

125147
### Secondary Market
126148

0 commit comments

Comments
 (0)