@paychainly/cli 1.1.3 → 1.1.4

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.
Files changed (2) hide show
  1. package/README.md +76 -23
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @paychainly/cli
2
2
 
3
- > Relay live Paychainly webhooks to your local server during development — no public URL needed.
3
+ > Relay live Paychainly webhooks to your local server during development — no public URL, no tunneling tool needed.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@paychainly/cli)](https://www.npmjs.com/package/@paychainly/cli)
6
6
  [![license](https://img.shields.io/npm/l/@paychainly/cli)](LICENSE)
@@ -21,7 +21,7 @@ npm install -g @paychainly/cli
21
21
  paychainly listen --api-key pk_live_... --forward-to http://localhost:3000/webhook
22
22
  ```
23
23
 
24
- Webhooks fired on [api.paychainly.com](https://api.paychainly.com) are forwarded in real time to your local server.
24
+ Webhooks fired on [api.paychainly.com](https://api.paychainly.com) are forwarded in real time to your local server. **You do not need a webhook URL configured in your Paychainly account** — the CLI relay works independently.
25
25
 
26
26
  ---
27
27
 
@@ -47,7 +47,7 @@ paychainly listen [options]
47
47
  **Examples**
48
48
 
49
49
  ```bash
50
- # Basic
50
+ # Basic — forward to port 3000
51
51
  paychainly listen --api-key pk_live_... --port 3000
52
52
 
53
53
  # Show full payload for every event
@@ -62,6 +62,8 @@ paychainly listen --api-key pk_live_... \
62
62
  paychainly listen --api-key pk_live_... --secret whsec_...
63
63
  ```
64
64
 
65
+ Press `Ctrl+C` to stop. A per-event-type summary is printed on exit.
66
+
65
67
  ---
66
68
 
67
69
  ### `status` — check API key & connectivity
@@ -70,7 +72,7 @@ paychainly listen --api-key pk_live_... --secret whsec_...
70
72
  paychainly status --api-key pk_live_...
71
73
  ```
72
74
 
73
- Connects to the server, validates the key, and prints the user ID and account mode. Useful for confirming your key is correct before starting a session.
75
+ Connects to the server, validates the key, and prints your account email and mode. Exit code `0` = valid, `1` = invalid/unreachable.
74
76
 
75
77
  ---
76
78
 
@@ -104,26 +106,88 @@ paychainly replay --log events.jsonl \
104
106
 
105
107
  ---
106
108
 
109
+ ## How Relay Forwarding Works
110
+
111
+ The CLI connects to `api.paychainly.com` over a persistent WebSocket. When any payment event fires, the server checks whether your CLI is connected and routes accordingly. **You do not need a webhook URL saved in your account for the CLI to receive events.**
112
+
113
+ | # | Scenario | Webhook in account? | CLI connected? | What happens |
114
+ |---|---|---|---|---|
115
+ | 1 | **CLI only** | None | ✅ Yes | Event delivered to CLI → forwarded to `--forward-to` |
116
+ | 2 | **`localhost` webhook + CLI** | Yes — `localhost` URL | ✅ Yes | Routed through CLI relay only — **no double-send** |
117
+ | 3 | **Public webhook + CLI** | Yes — `https://...` URL | ✅ Yes | Public URL is called via HTTP **and** CLI relay also receives the event |
118
+ | 4 | **Public webhook, no CLI** | Yes — `https://...` URL | ❌ No | Public URL called only, works as normal |
119
+ | 5 | **Nothing configured** | None | ❌ No | Event fires on-chain but nothing receives it — connect the CLI or add a webhook |
120
+
121
+ ### Key rules
122
+
123
+ - **No webhook required** — connect the CLI and events arrive immediately, zero dashboard config needed.
124
+ - **No double-send for `localhost` webhooks** — if your saved webhook URL is a `localhost` address, the server routes it through the CLI relay and does not make a separate HTTP call.
125
+ - **Public webhook + CLI = both receive** — your production endpoint gets the HTTP POST and the CLI relay also gets a copy so you can inspect it locally.
126
+ - **`--forward-to` is the delivery target** — for relay-only deliveries (scenarios 1 & 3), the server sends an empty target URL and the CLI falls back to your `--forward-to` value.
127
+
128
+ ### Covered events
129
+
130
+ All server-side events are relayed:
131
+
132
+ | Event | Trigger |
133
+ |---|---|
134
+ | `deposit_detected` | USDT transfer confirmed at a deposit address |
135
+ | `sweep_started` | Fund sweep initiated |
136
+ | `sweep_completed` | Funds swept to master wallet |
137
+ | `sweep_failed` | Sweep failed after max retries |
138
+ | `sweep_skipped` | Sweep skipped (e.g. dust amount) |
139
+ | `address_created` | New deposit address generated |
140
+ | `withdrawal_pending` | Withdrawal queued |
141
+ | `withdrawal_processing` | Withdrawal submitted on-chain |
142
+ | `withdrawal_completed` | Withdrawal confirmed |
143
+ | `withdrawal_failed` | Withdrawal failed |
144
+ | `manual_drain_pending` | Manual drain queued |
145
+ | `manual_drain_completed` | Manual drain confirmed |
146
+ | `manual_drain_failed` | Manual drain failed |
147
+
148
+ ---
149
+
107
150
  ## Typical Developer Workflow
108
151
 
109
152
  ```bash
110
- # 1. Start listening and capture events to a file
111
- paychainly listen --api-key pk_live_... --log events.jsonl --verbose
153
+ # 1. Start your local webhook handler
154
+ node server.js
112
155
 
113
- # 2. Trigger a test payment on your dashboard
114
- # 3. Inspect your webhook handler logs
156
+ # 2. In a second terminal start the CLI relay and capture events
157
+ paychainly listen \
158
+ --api-key pk_live_... \
159
+ --log events.jsonl \
160
+ --verbose
161
+
162
+ # 3. Trigger a test payment from the Paychainly dashboard
163
+ # → event appears in the terminal, forwarded to your handler
164
+
165
+ # 4. Fix a bug in your handler, restart it
115
166
 
116
- # 4. Fix a bug in your handler, restart your server
167
+ # 5. Replay the exact same events no new payment needed
168
+ paychainly replay \
169
+ --log events.jsonl \
170
+ --filter deposit_detected
171
+ ```
172
+
173
+ ### Sandbox testing (no real funds)
117
174
 
118
- # 5. Replay the captured events — no real payment needed
119
- paychainly replay --log events.jsonl --filter deposit_detected
175
+ ```bash
176
+ # Use a pk_test_... key — free, no real USDT
177
+ paychainly listen --api-key pk_test_...
178
+
179
+ # Credit test USDT to a sandbox deposit address
180
+ curl -X POST https://api.paychainly.com/api/sandbox/credit \
181
+ -H "X-Api-Key: pk_test_..." \
182
+ -H "Content-Type: application/json" \
183
+ -d '{"address":"0xYOUR_DEPOSIT_ADDRESS","amount":"50"}'
120
184
  ```
121
185
 
122
186
  ---
123
187
 
124
188
  ## Environment Variables
125
189
 
126
- You can set these instead of passing flags every time:
190
+ Set these to avoid passing flags every session:
127
191
 
128
192
  ```bash
129
193
  export PAYCHAINLY_API_KEY=pk_live_...
@@ -133,17 +197,6 @@ export PAYCHAINLY_WEBHOOK_SECRET=whsec_... # optional
133
197
 
134
198
  ---
135
199
 
136
- ## Webhook Events
137
-
138
- | Event | Description |
139
- |---|---|
140
- | `deposit_detected` | A USDT transfer to a monitored deposit address was confirmed |
141
- | `sweep_completed` | Funds swept from deposit address to master wallet |
142
- | `address_expired` | A deposit address session expired without a payment |
143
- | `withdrawal_completed` | A user-initiated withdrawal was processed |
144
-
145
- ---
146
-
147
200
  ## License
148
201
 
149
202
  MIT © [Paychainly](https://paychainly.com)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paychainly/cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Paychainly CLI — relay webhooks to your localhost during development",
5
5
  "keywords": [
6
6
  "paychainly",