upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/CHECKLIST.md
diff options
context:
space:
mode:
Diffstat (limited to 'CHECKLIST.md')
-rw-r--r--CHECKLIST.md148
1 files changed, 145 insertions, 3 deletions
diff --git a/CHECKLIST.md b/CHECKLIST.md
index 9842390..dd21b0c 100644
--- a/CHECKLIST.md
+++ b/CHECKLIST.md
@@ -189,9 +189,151 @@
189- [ ] Update `package.json` npm scripts for new paths 189- [ ] Update `package.json` npm scripts for new paths
190- [ ] All `make test-*` targets work 190- [ ] All `make test-*` targets work
191 191
192## Phase 4: ESP32-to-OpenWRT TollGate Interop — NOT STARTED 192## Phase 4: ESP32 TollGate Client Detection + Auto-Payment — IN PROGRESS
193- [ ] ESP32 pays OpenWRT TollGate using Cashu tokens 193
194- [ ] Interoperability testing with existing OpenWRT TollGate on enx00e04c683d2d 194### tollgate_client.c/h (New)
195- [ ] Create `tollgate_client.h` — types: `tollgate_discovery_t`, `tollgate_client_state_t` enum (IDLE/DETECTING/NEEDS_PAY/PAYING/PAID/RENEWING)
196- [ ] Create `tollgate_client.c` — detection, payment, monitoring, state machine
197- [ ] `tollgate_client_detect(gw_ip)` — HTTP GET `http://{gw}:2121/`, parse kind=10021, extract price tags
198- [ ] `tollgate_client_pay(gw_ip, amount_sats)` — `nucula_wallet_send()` → POST to upstream → parse kind=1022/21023
199- [ ] `tollgate_client_on_sta_connected()` — extract gw from DHCP, detect, pay (blocking)
200- [ ] `tollgate_client_tick()` — GET `/usage`, renew at 20% remaining
201- [ ] `tollgate_client_on_sta_disconnected()` — reset state
202- [ ] `tollgate_client_get_usage(gw_ip)` — GET `/usage` → parse remaining/total
203
204### Config Changes
205- [ ] Add to `config.h`: `client_enabled`, `client_steps_to_buy`, `client_renewal_threshold_pct`, `client_retry_interval_ms`
206- [ ] Parse new fields in `config.c`
207
208### Integration (tollgate_main.c)
209- [ ] Make wallet init synchronous (call `nucula_wallet_init()` directly, not as task)
210- [ ] Add `tollgate_client_on_sta_connected()` in `ip_event_handler` (blocking, before `start_services()`)
211- [ ] Add `tollgate_client_on_sta_disconnected()` in `wifi_event_handler`
212- [ ] Add `tollgate_client_tick()` in main loop
213- [ ] Update `main/CMakeLists.txt` — add `tollgate_client.c`
214
215### Unit Tests
216- [ ] `tests/unit/test_tollgate_client.c` — discovery parsing, price extraction, state machine, renewal threshold
217- [ ] All unit tests passing
218
219### Integration Tests
220- [ ] ESP32→OpenWRT auto-payment (Scenario 4)
221- [ ] ESP32→ESP32 auto-payment (Scenario 5, needs Board B)
222
223### Test Cases 39-43
224- [ ] Test 39: Client detection (kind=10021 parse)
225- [ ] Test 40: Client payment flow (mock HTTP)
226- [ ] Test 41: Session renewal (20% threshold)
227- [ ] Test 42: ESP32→OpenWRT auto-pay
228- [ ] Test 43: ESP32→ESP32 auto-pay
229
230## Phase 5: Lightning Auto-Payout — NOT STARTED
231
232### lnurl_pay.c/h (New)
233- [ ] Create `lnurl_pay.h` — `lnurl_get_invoice(lightning_address, amount_sats, bolt11_out, out_size)`
234- [ ] Create `lnurl_pay.c` — GET `.well-known/lnurlp/{user}` → parse callback → GET callback with amount → extract BOLT11
235
236### lightning_payout.c/h (New)
237- [ ] Create `lightning_payout.h` — `payout_recipient_t`, config, init/tick API
238- [ ] Create `lightning_payout.c` — periodic balance check, threshold, multi-recipient split, melt with retry
239
240### nucula Bridge Extension
241- [ ] Add `nucula_wallet_melt(bolt11, max_fee_sats)` to `nucula_wallet.h/cpp`
242- [ ] Wraps `Wallet::request_melt_quote()` + `Wallet::melt_tokens()` (NUT-05)
243
244### Config Changes
245- [ ] Add payout config to `config.h`: `payout_enabled`, `min_payout_amount`, `min_balance`, `fee_tolerance_pct`, `check_interval_s`, `recipients[]`
246- [ ] Parse payout config in `config.c`
247
248### Integration (tollgate_main.c)
249- [ ] Add periodic payout timer (60s interval)
250- [ ] Update `main/CMakeLists.txt`
251
252### Unit Tests
253- [ ] `tests/unit/test_lnurl_pay.c` — LNURL-pay URL construction, response parsing
254- [ ] `tests/unit/test_lightning_payout.c` — threshold check, multi-recipient split, fee tolerance
255
256### Test Cases 44-48
257- [ ] Test 44: LNURL-pay flow
258- [ ] Test 45: Payout threshold
259- [ ] Test 46: Multi-recipient split
260- [ ] Test 47: Melt with fee tolerance
261- [ ] Test 48: Full payout cycle
262
263## Phase 6: Bytes-Based Billing — NOT STARTED
264
265### lwIP NAPT Stats Component (New)
266- [ ] Create `components/lwip_napt_stats/` — patched `ip4_napt.c` with byte counters
267- [ ] Add `uint64_t bytes_up/bytes_down` to `struct ip_napt_entry`
268- [ ] Increment in `ip_napt_forward()` and `ip_napt_recv()`
269- [ ] Add public API: `ip_napt_get_client_bytes(client_ip, &up, &down)`
270- [ ] Create component CMakeLists.txt
271
272### Session Changes
273- [ ] Add `allotment_bytes`, `bytes_consumed` to `session_t`
274- [ ] Dual-metric `session_is_expired()` dispatches on metric type
275- [ ] `session_add_bytes(client_ip, byte_count)` called from firewall counting
276
277### Config Changes
278- [ ] Add `metric` field ("milliseconds" or "bytes") to `config.h`
279- [ ] Add `step_size_bytes` to `config.h`
280- [ ] Parse in `config.c`
281
282### TollGate API Changes
283- [ ] Discovery endpoint advertises correct metric
284- [ ] `/usage` returns byte-based or time-based values
285- [ ] Allotment calculation dispatches on metric
286
287### Firewall Changes
288- [ ] `firewall_count_traffic()` — queries NAPT byte counters per active client
289- [ ] Called from `session_tick()` or main loop
290
291### Cashu Changes
292- [ ] Unify `cashu_calculate_allotment()` for both metrics
293
294### Unit Tests
295- [ ] `tests/unit/test_bytes_metric.c` — byte allotment calc, dual-metric session expiry
296
297### Test Cases 49-52
298- [ ] Test 49: Byte allotment calc
299- [ ] Test 50: Byte session expiry
300- [ ] Test 51: NAPT byte counting
301- [ ] Test 52: Bytes metric end-to-end
302
303## Phase 7: ContextVM Server (MCP over Nostr) — NOT STARTED
304
305### NIP-44 Encryption (New)
306- [ ] Create `nip44.h` — encrypt/decrypt API
307- [ ] Create `nip44.c` — XChaCha20-Poly1305 + secp256k1 ECDH + conversation key derivation
308
309### MCP Handler (New)
310- [ ] Create `mcp_handler.h` — tool registration, JSON-RPC parse/dispatch
311- [ ] Create `mcp_handler.c` — register tools, handle requests, build responses
312
313### CVM Server (New)
314- [ ] Create `cvm_server.h` — init/start/stop API
315- [ ] Create `cvm_server.c` — WebSocket listener, DM subscription, NIP-44 decrypt, MCP dispatch
316
317### MCP Tool Registration
318- [ ] `get_config`, `set_config`, `get_balance`, `get_sessions`, `get_usage`
319- [ ] `set_payout`, `set_metric`, `set_price`, `wallet_send`, `wallet_melt`
320
321### Auth
322- [ ] Only accept commands from owner npub
323
324### Integration (tollgate_main.c)
325- [ ] Start CVM server alongside wifistr
326- [ ] Update `main/CMakeLists.txt`
327
328### Unit Tests
329- [ ] `tests/unit/test_nip44.c` — encrypt/decrypt roundtrip
330- [ ] `tests/unit/test_mcp_handler.c` — JSON-RPC parse, tool dispatch
331
332### Test Cases 53-56
333- [ ] Test 53: NIP-44 encrypt/decrypt
334- [ ] Test 54: MCP JSON-RPC parse
335- [ ] Test 55: Config change via DM
336- [ ] Test 56: Balance query via CVM
195 337
196## Reminders 338## Reminders
197- Do NOT ask for instructions — proceed independently, skip blocked items, work on unblocked ones 339- Do NOT ask for instructions — proceed independently, skip blocked items, work on unblocked ones