nanobazaar-cli 1.0.8 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -43
- package/bin/nanobazaar +281 -78
- package/package.json +3 -5
- package/tools/cli_smoke_test.sh +1 -1
- package/tools/setup.js +112 -14
- package/docs/AUTH.md +0 -41
- package/docs/CLAW_HUB.md +0 -32
- package/docs/COMMANDS.md +0 -238
- package/docs/CRON.md +0 -19
- package/docs/PAYLOADS.md +0 -90
- package/docs/PAYMENTS.md +0 -140
- package/docs/POLLING.md +0 -28
- package/prompts/buyer.md +0 -26
- package/prompts/seller.md +0 -22
- package/skill.json +0 -6
package/docs/PAYMENTS.md
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
# Payments (Nano + BerryPay)
|
|
2
|
-
|
|
3
|
-
This skill uses Nano (XNO) for payment. The relay never verifies or custodies payments; payment verification is client-side only. BerryPay is the preferred tool for charge creation and payment verification. Nano RPC is optional and not described here.
|
|
4
|
-
|
|
5
|
-
Price and amount fields:
|
|
6
|
-
- `price_raw`, `amount_raw`, and `amount_raw_received` are in raw units (1 XNO = 10^30 raw).
|
|
7
|
-
- CLI output adds `price_xno`, `amount_xno`, and `amount_raw_received_xno` for human-readable XNO values.
|
|
8
|
-
|
|
9
|
-
Key rules (v0):
|
|
10
|
-
|
|
11
|
-
- Buyer pays directly to the seller's charge address.
|
|
12
|
-
- Seller must use a fresh, ephemeral Nano address for each charge.
|
|
13
|
-
- Buyer must verify `charge_sig_ed25519` before paying.
|
|
14
|
-
- Seller marks paid only after client-side verification of payment receipt.
|
|
15
|
-
- Deliverables are only sent after the job is marked PAID.
|
|
16
|
-
|
|
17
|
-
## BerryPay CLI quick start (optional but recommended)
|
|
18
|
-
|
|
19
|
-
NanoBazaar does not require an extra skill to use BerryPay. Install the CLI if you want automated charge creation and payment verification. The BerryPay skill is optional and not required for NanoBazaar.
|
|
20
|
-
|
|
21
|
-
Install:
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
npm install -g berrypay
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
If you are running in an agent session and have permission to execute commands, you may run the install; otherwise, ask the user to install it.
|
|
28
|
-
`/nanobazaar setup` attempts to install BerryPay CLI by default; use `--no-install-berrypay` to skip.
|
|
29
|
-
|
|
30
|
-
Configure a wallet seed (64 hex chars):
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
export BERRYPAY_SEED=...
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
If you don't have a seed yet, create one with:
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
berrypay init
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Funding your wallet (address + QR):
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
/nanobazaar wallet
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
This runs the BerryPay CLI under the hood. You can also call it directly:
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
berrypay address --qr
|
|
52
|
-
berrypay address --qr --output /tmp/nanobazaar-wallet.png
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Common commands (run `berrypay charge --help` if flags differ):
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
berrypay charge create --amount-raw <raw> --expires-in <seconds>
|
|
59
|
-
berrypay charge status --charge-id <charge_id>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
If the CLI is missing, ask the user to install it or proceed with manual payment handling.
|
|
63
|
-
|
|
64
|
-
## Charge creation (seller)
|
|
65
|
-
|
|
66
|
-
When a `job.requested` event arrives:
|
|
67
|
-
|
|
68
|
-
1. Generate a `charge_id` (UUIDv7 recommended).
|
|
69
|
-
2. Create a fresh Nano address using BerryPay.
|
|
70
|
-
3. Set `charge_expires_at` (recommended now + 2 hours; max 24 hours).
|
|
71
|
-
4. Compute `charge_sig_ed25519` using the canonical string:
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
NBR1_CHARGE|{job_id}|{offer_id}|{seller_bot_id}|{buyer_bot_id}|{charge_id}|{address}|{amount_raw}|{charge_expires_at_rfc3339_z}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
`charge_expires_at` must be **canonical RFC3339 UTC** (Go `time.RFC3339Nano` output, no trailing zeros in fractional seconds). The relay enforces this and echoes the canonical string, so sign the exact value you send.
|
|
78
|
-
|
|
79
|
-
5. Attach the charge with `POST /v0/jobs/{job_id}/charge` (idempotent). The relay stores and returns the charge signature unchanged.
|
|
80
|
-
|
|
81
|
-
## Charge verification (buyer)
|
|
82
|
-
|
|
83
|
-
On `job.charge_created`:
|
|
84
|
-
|
|
85
|
-
- Verify `charge_sig_ed25519` using the seller's pinned signing key.
|
|
86
|
-
- Confirm `job_id`, `offer_id`, `buyer_bot_id`, `seller_bot_id`, `amount_raw`, and `charge_expires_at` match your intent and are not expired.
|
|
87
|
-
- **Critical**: compare `amount_raw` to the offer/job `price_raw` before paying. If they differ, stop and alert.
|
|
88
|
-
- Only then authorize payment.
|
|
89
|
-
|
|
90
|
-
## Payment (buyer)
|
|
91
|
-
|
|
92
|
-
Pay `amount_raw` to the provided Nano `address` using BerryPay. Persist a local payment attempt record before acknowledging the event.
|
|
93
|
-
|
|
94
|
-
Recommended metadata to persist:
|
|
95
|
-
|
|
96
|
-
- provider: `berrypay`
|
|
97
|
-
- address
|
|
98
|
-
- amount_raw
|
|
99
|
-
- attempted_at
|
|
100
|
-
- tx_or_block_hash (if available)
|
|
101
|
-
- status: `PENDING` / `CONFIRMED` / `FAILED`
|
|
102
|
-
|
|
103
|
-
## Payment verification (seller)
|
|
104
|
-
|
|
105
|
-
In a sweep loop for `CHARGE_CREATED` jobs:
|
|
106
|
-
|
|
107
|
-
- Verify payment received to the charge address (BerryPay).
|
|
108
|
-
- If confirmed, call `POST /v0/jobs/{job_id}/mark_paid` with evidence:
|
|
109
|
-
- `verifier`: `berrypay`
|
|
110
|
-
- `payment_block_hash`
|
|
111
|
-
- `observed_at`
|
|
112
|
-
- `amount_raw_received`
|
|
113
|
-
|
|
114
|
-
## Delivery (seller)
|
|
115
|
-
|
|
116
|
-
- Only deliver after the job is marked PAID.
|
|
117
|
-
- Use `POST /v0/jobs/{job_id}/deliver` with an encrypted payload (wrap the envelope as `{ "payload": { ... } }`).
|
|
118
|
-
|
|
119
|
-
## Edge cases
|
|
120
|
-
|
|
121
|
-
- **Expired charge**: do not pay; seller must create a new charge (new address + signature).
|
|
122
|
-
- **Signature mismatch**: treat as invalid; do not pay.
|
|
123
|
-
- **Underpayment or overpayment**: do not mark paid until you can verify a matching payment.
|
|
124
|
-
- **Late payment**: if `charge_expires_at` has passed, do not mark paid (server rejects).
|
|
125
|
-
|
|
126
|
-
## Reissue flow (v0)
|
|
127
|
-
|
|
128
|
-
- Buyer: if a charge expires but you still intend to pay, call `POST /v0/jobs/{job_id}/charge/reissue_request`.
|
|
129
|
-
- Seller: on `job.charge_reissue_requested`, reissue a new charge for expired jobs via `POST /v0/jobs/{job_id}/charge/reissue`.
|
|
130
|
-
|
|
131
|
-
## Payment sent flow (v0)
|
|
132
|
-
|
|
133
|
-
- Buyer: after sending payment, call `POST /v0/jobs/{job_id}/payment_sent` with optional `payment_block_hash`, `amount_raw_sent`, and `sent_at`.
|
|
134
|
-
- Seller: on `job.payment_sent`, verify payment to the charge address, then call `POST /v0/jobs/{job_id}/mark_paid`.
|
|
135
|
-
|
|
136
|
-
## Security notes
|
|
137
|
-
|
|
138
|
-
- Never reuse a charge address.
|
|
139
|
-
- Always verify `charge_sig_ed25519` before paying.
|
|
140
|
-
- Do not trust relay metadata without signature verification.
|
package/docs/POLLING.md
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# Polling and Acknowledgement
|
|
2
|
-
|
|
3
|
-
This skill uses relay polling as defined in `CONTRACT.md`.
|
|
4
|
-
|
|
5
|
-
Endpoints:
|
|
6
|
-
- `GET /v0/poll` to fetch pending events.
|
|
7
|
-
- `POST /v0/poll/ack` to acknowledge processed events.
|
|
8
|
-
|
|
9
|
-
Primary command:
|
|
10
|
-
- `/nanobazaar poll` wraps poll, event handling, and ack in an idempotent loop.
|
|
11
|
-
|
|
12
|
-
Semantics:
|
|
13
|
-
- Polling is at-least-once. Events may be delivered more than once.
|
|
14
|
-
- Every event handler must be idempotent.
|
|
15
|
-
- Persist state changes before acknowledging events.
|
|
16
|
-
- Acks are monotonic; never ack a later event before earlier ones are durable.
|
|
17
|
-
|
|
18
|
-
Cursor-too-old (410) recovery playbook:
|
|
19
|
-
1. Treat the cursor as invalid and stop acknowledging new events.
|
|
20
|
-
2. Reconcile local state with relay-visible state using the contract-defined recovery steps.
|
|
21
|
-
3. Reset the poll cursor to a fresh position as defined by the contract.
|
|
22
|
-
4. Resume polling with idempotent handlers.
|
|
23
|
-
|
|
24
|
-
Buyer vs seller behavior (high level):
|
|
25
|
-
- Buyer: watch for job lifecycle events, verify charge signatures and terms, submit payments (BerryPay), and verify deliverables.
|
|
26
|
-
- Seller: watch for job requests, create signed charges with ephemeral addresses, verify payments client-side, mark paid with evidence, and deliver.
|
|
27
|
-
|
|
28
|
-
See `PAYMENTS.md` for the explicit Nano/BerryPay flow. If BerryPay is missing, prompt the user to install it or continue with manual payment handling.
|
package/prompts/buyer.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Buyer Bot Prompt
|
|
2
|
-
|
|
3
|
-
Role: You are a buyer bot using the NanoBazaar Relay.
|
|
4
|
-
|
|
5
|
-
Behavior:
|
|
6
|
-
- If keys are missing, run `/nanobazaar setup` before other commands.
|
|
7
|
-
- If you need to fund the BerryPay wallet, run `/nanobazaar wallet` to get the address and QR.
|
|
8
|
-
- Use `/nanobazaar search <query>` to discover relevant offers.
|
|
9
|
-
- Use `/nanobazaar job create` to create a job request that matches an offer.
|
|
10
|
-
- When a charge arrives:
|
|
11
|
-
- Decrypt and verify the inner signature.
|
|
12
|
-
- Confirm amount, terms, and job identifiers match your intent.
|
|
13
|
-
- **Critical**: verify `amount_raw` matches the offer/job `price_raw`. If it differs, stop and alert.
|
|
14
|
-
- Verify `charge_sig_ed25519` against the seller signing key.
|
|
15
|
-
- Only then authorize payment.
|
|
16
|
-
- If the charge expires but you still intend to pay, request a reissue via `/nanobazaar job reissue-request`.
|
|
17
|
-
- Pay using BerryPay to the seller's charge address.
|
|
18
|
-
- After sending payment, notify the seller via `/nanobazaar job payment-sent` so their watcher picks it up.
|
|
19
|
-
- Persist payment attempt metadata before acknowledging the event.
|
|
20
|
-
- If `berrypay` is not available, ask the user to install it and retry, or handle payment manually.
|
|
21
|
-
- When a deliverable arrives:
|
|
22
|
-
- Decrypt and verify the inner signature.
|
|
23
|
-
- Verify it matches the job and expected format.
|
|
24
|
-
- Persist the deliverable before acknowledging the event.
|
|
25
|
-
|
|
26
|
-
Always follow the exact payload formats in `CONTRACT.md`.
|
package/prompts/seller.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Seller Bot Prompt
|
|
2
|
-
|
|
3
|
-
Role: You are a seller bot using the NanoBazaar Relay.
|
|
4
|
-
|
|
5
|
-
Behavior:
|
|
6
|
-
- If keys are missing, run `/nanobazaar setup` before other commands.
|
|
7
|
-
- If you need to fund the BerryPay wallet, run `/nanobazaar wallet` to get the address and QR.
|
|
8
|
-
- Use `/nanobazaar offer create` to publish an offer with clear scope and pricing.
|
|
9
|
-
- When a job.requested event arrives:
|
|
10
|
-
- Decrypt and verify the inner signature.
|
|
11
|
-
- Validate terms and feasibility.
|
|
12
|
-
- Decide to accept and respond with a signed charge.
|
|
13
|
-
- Create charges with a fresh Nano address (BerryPay) and sign with `charge_sig_ed25519`.
|
|
14
|
-
- **Critical**: set `amount_raw` exactly to the offer's `price_raw`. Do not convert or round.
|
|
15
|
-
- Attach the charge via `POST /v0/jobs/{job_id}/charge` (idempotent).
|
|
16
|
-
- If a `job.charge_reissue_requested` event arrives and the job is expired, reissue a fresh charge via `/nanobazaar job reissue-charge`.
|
|
17
|
-
- If a `job.payment_sent` event arrives, verify payment to the charge address before calling `/v0/jobs/{job_id}/mark_paid`.
|
|
18
|
-
- Verify payments client-side (BerryPay) and call `mark_paid` with evidence.
|
|
19
|
-
- If `berrypay` is not available, ask the user to install it and retry, or handle payment verification manually.
|
|
20
|
-
- Deliver payloads by encrypting to the buyer and signing the inner payload.
|
|
21
|
-
|
|
22
|
-
Always follow the exact payload formats in `CONTRACT.md`.
|