diff options
| author | Your Name <you@example.com> | 2026-05-23 22:09:57 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-23 22:09:57 +0530 |
| commit | bf8e095b94fe500a9c35d7f2f616eb85569dbe5e (patch) | |
| tree | c6bb9a2b11d20aff855cc324f1c3d60751629d1f | |
| parent | aec549f83d5084aa9fd16c00e1c09e06ac7471d4 (diff) | |
Phase 10a v1.2.0: MIT license, metadata update, full API docs
- Bump idf_component.yml to v1.2.0 with MIT license, targets, tags
- Add LICENSE (MIT) for IDF Component Registry compatibility
- Update CHANGELOG.md with v1.2.0 entries (portal, stratum_client, mint_health, client)
- Update README.md with all 13 modules documented, API reference table
- Add REMAINING_PLAN.md with full execution plan and checklist
- 25 unit tests pass, ESP-IDF build passes
| -rw-r--r-- | REMAINING_PLAN.md | 97 | ||||
| -rw-r--r-- | components/tollgate_core/CHANGELOG.md | 10 | ||||
| -rw-r--r-- | components/tollgate_core/LICENSE | 21 | ||||
| -rw-r--r-- | components/tollgate_core/README.md | 74 | ||||
| -rw-r--r-- | components/tollgate_core/idf_component.yml | 18 |
5 files changed, 207 insertions, 13 deletions
diff --git a/REMAINING_PLAN.md b/REMAINING_PLAN.md new file mode 100644 index 0000000..74ae353 --- /dev/null +++ b/REMAINING_PLAN.md | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | # TollGate Core — Remaining Execution Plan | ||
| 2 | |||
| 3 | **Branch:** `feature/tollgate-core-v2` | ||
| 4 | **Created:** 2026-05-23 | ||
| 5 | **Goal:** Complete all remaining extraction, integration, CI/CD, and publishing steps. | ||
| 6 | |||
| 7 | --- | ||
| 8 | |||
| 9 | ## Checklist | ||
| 10 | |||
| 11 | ### Phase A: Version bump + metadata | ||
| 12 | - [ ] A1. Bump `idf_component.yml` to v1.2.0, add MIT license, targets, tags | ||
| 13 | - [ ] A2. Create `LICENSE` file (MIT) in `components/tollgate_core/` | ||
| 14 | - [ ] A3. Update `CHANGELOG.md` with v1.2.0 entries | ||
| 15 | - [ ] A4. Update `README.md` to document all 13 modules | ||
| 16 | - [ ] A5. Run `make test-unit` + `idf.py build` | ||
| 17 | - [ ] A6. Commit + push | ||
| 18 | |||
| 19 | ### Phase B: Re-sync component to NerdQAxePlus | ||
| 20 | - [ ] B1. Copy 4 new source pairs + updated files to NerdQAxePlus | ||
| 21 | - [ ] B2. Verify `TOLLGATE=1 BOARD=NERDQAXEPLUS idf.py build` | ||
| 22 | - [ ] B3. Commit + push to NerdQAxePlus develop | ||
| 23 | |||
| 24 | ### Phase C: Full wallet integration on NerdQAxePlus (Phase 9c) | ||
| 25 | - [ ] C1. Copy `nucula_lib/` component and `nucula_src/` submodule to NerdQAxePlus | ||
| 26 | - [ ] C2. Update NerdQAxePlus top-level CMakeLists to REQUIRES `nucula_lib` | ||
| 27 | - [ ] C3. Replace `spend_proofs` stub with `nucula_wallet_receive()` | ||
| 28 | - [ ] C4. Add `nucula_wallet_init(mint_url)` to `tollgate_nerdqaxe_init()` | ||
| 29 | - [ ] C5. Wire `get_hashrate` to actual ASIC stats | ||
| 30 | - [ ] C6. Wire `on_share_accepted` to real share tracking | ||
| 31 | - [ ] C7. Verify build | ||
| 32 | - [ ] C8. Commit + push | ||
| 33 | |||
| 34 | ### Phase D: NerdQAxePlus UI integration (Phase 9d) | ||
| 35 | - [ ] D1. Add POST `/api/tollgate/pay` endpoint accepting Cashu tokens | ||
| 36 | - [ ] D2. Add minimal captive portal HTML page | ||
| 37 | - [ ] D3. Add GET `/api/tollgate/wallet` and POST `/api/tollgate/wallet/send` endpoints | ||
| 38 | - [ ] D4. Update portal screen: wallet balance, session count, payment QR | ||
| 39 | - [ ] D5. Add session status to mining screen | ||
| 40 | - [ ] D6. Verify build, flash, test payment flow | ||
| 41 | - [ ] D7. Commit + push | ||
| 42 | |||
| 43 | ### Phase E: Ansible CI/CD workflow (Phase 10b) | ||
| 44 | - [ ] E1. Create ansible role `ci_runner` with tasks for Docker + ESP-IDF | ||
| 45 | - [ ] E2. Create Python nostr relay listener script | ||
| 46 | - [ ] E3. Create systemd service unit for listener | ||
| 47 | - [ ] E4. Create ansible playbook `20-ci-runner.yml` | ||
| 48 | - [ ] E5. Create ansible playbook for localhost hardware runner | ||
| 49 | - [ ] E6. Test ansible deployment | ||
| 50 | |||
| 51 | ### Phase F: Publish to IDF Component Registry (Phase 10c) | ||
| 52 | - [ ] F1. Create `docs/PUBLISHING.md` with step-by-step upload instructions | ||
| 53 | - [ ] F2. Run `compote registry login` (manual — requires browser OAuth) | ||
| 54 | - [ ] F3. Run `compote component upload --dry-run` to validate | ||
| 55 | - [ ] F4. Run `compote component upload` to publish v1.2.0 | ||
| 56 | - [ ] F5. Verify with clean test project | ||
| 57 | - [ ] F6. Commit + push updated metadata | ||
| 58 | |||
| 59 | ### Phase G: Hardware smoke test | ||
| 60 | - [ ] G1. Flash Board A with updated firmware | ||
| 61 | - [ ] G2. Run `TOLLGATE_IP=10.185.47.1 BOARD=a make test-smoke` | ||
| 62 | - [ ] G3. Commit any fixes | ||
| 63 | |||
| 64 | --- | ||
| 65 | |||
| 66 | ## Execution Order | ||
| 67 | |||
| 68 | ``` | ||
| 69 | A → G → B → C → D → E → F | ||
| 70 | ``` | ||
| 71 | |||
| 72 | Phase A is quick metadata updates. G verifies on hardware. B syncs to NerdQAxePlus. | ||
| 73 | C adds the wallet. D adds the UI. E sets up CI/CD. F publishes. | ||
| 74 | |||
| 75 | --- | ||
| 76 | |||
| 77 | ## Architecture Notes | ||
| 78 | |||
| 79 | ### CI/CD Design | ||
| 80 | - **Runner:** Docker container using `espressif/idf:latest` image | ||
| 81 | - **Trigger:** Python WebSocket client subscribed to `wss://ngit.orangesync.tech` | ||
| 82 | for NIP-34 git state events (kind 30617) | ||
| 83 | - **Pipeline:** clone from GRASP → `idf.py build` → `make test-unit` → report | ||
| 84 | - **Hardware tests:** Run on localhost (dev machine) where boards are connected | ||
| 85 | - **Reporting:** Build status posted as nostr badge event (kind 1985) | ||
| 86 | |||
| 87 | ### Wallet Integration Design | ||
| 88 | - `nucula_lib` provides C API: `nucula_wallet_init()`, `nucula_wallet_receive()`, `nucula_wallet_send()`, `nucula_wallet_balance()` | ||
| 89 | - `spend_proofs` callback in `tollgate_platform_t` maps directly to `nucula_wallet_receive()` | ||
| 90 | - Wallet proofs persisted to NVS automatically by nucula | ||
| 91 | - `libsecp256k1` already compiled in NerdQAxePlus build with Schnorr + Extrakeys modules | ||
| 92 | |||
| 93 | ### Component Registry | ||
| 94 | - License: MIT (required for upload) | ||
| 95 | - Namespace: GitHub username (auto-created on first login) | ||
| 96 | - Version immutability: once uploaded, cannot overwrite — must bump version | ||
| 97 | - `compote` CLI installed at `~/.local/bin/compote` (v3.0.2) | ||
diff --git a/components/tollgate_core/CHANGELOG.md b/components/tollgate_core/CHANGELOG.md index b6d664f..946c600 100644 --- a/components/tollgate_core/CHANGELOG.md +++ b/components/tollgate_core/CHANGELOG.md | |||
| @@ -1,5 +1,15 @@ | |||
| 1 | # Changelog | 1 | # Changelog |
| 2 | 2 | ||
| 3 | ## 1.2.0 (2026-05-23) | ||
| 4 | |||
| 5 | - Added `tollgate_core_portal` — HTML template rendering, usage calculation, captive URI detection | ||
| 6 | - Added `tollgate_core_stratum_client` — Stratum V1 JSON protocol parsing, message building (subscribe, authorize, submit, mining.notify, mining.set_difficulty) | ||
| 7 | - Added `tollgate_core_mint_health` — mint health state tracking with recovery threshold (3 consecutive successes), reachable/unreachable transitions | ||
| 8 | - Added `tollgate_core_client` — upstream TollGate discovery JSON parsing (kind 10021), session response parsing (kind 1022), usage string parsing, renewal threshold check, price-per-minute calculation | ||
| 9 | - Added MIT license for IDF Component Registry compatibility | ||
| 10 | - 13 compiled source files, 14 headers, full platform abstraction via `tollgate_platform_t` | ||
| 11 | - 25 host unit tests covering all modules | ||
| 12 | |||
| 3 | ## 1.1.0 (2026-05-23) | 13 | ## 1.1.0 (2026-05-23) |
| 4 | 14 | ||
| 5 | - Added `tollgate_core_beacon` — WiFi vendor IE construction (hash_mint, hash_npub, build_ie) | 15 | - Added `tollgate_core_beacon` — WiFi vendor IE construction (hash_mint, hash_npub, build_ie) |
diff --git a/components/tollgate_core/LICENSE b/components/tollgate_core/LICENSE new file mode 100644 index 0000000..fc72599 --- /dev/null +++ b/components/tollgate_core/LICENSE | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | MIT License | ||
| 2 | |||
| 3 | Copyright (c) 2024-2026 orangesync.tech | ||
| 4 | |||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 6 | of this software and associated documentation files (the "Software"), to deal | ||
| 7 | in the Software without restriction, including without limitation the rights | ||
| 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 9 | copies of the Software, and to permit persons to whom the Software is | ||
| 10 | furnished to do so, subject to the following conditions: | ||
| 11 | |||
| 12 | The above copyright notice and this permission notice shall be included in all | ||
| 13 | copies or substantial portions of the Software. | ||
| 14 | |||
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 21 | SOFTWARE. | ||
diff --git a/components/tollgate_core/README.md b/components/tollgate_core/README.md index d83d634..57bab4d 100644 --- a/components/tollgate_core/README.md +++ b/components/tollgate_core/README.md | |||
| @@ -4,14 +4,27 @@ ESP-IDF component providing paid WiFi hotspot logic with Cashu e-cash payments. | |||
| 4 | 4 | ||
| 5 | ## Features | 5 | ## Features |
| 6 | 6 | ||
| 7 | - **Session management** — time-based and bytes-based sessions with auto-expiry | 7 | ### Session & Payment |
| 8 | - **Cashu token processing** — decode Cashu e-cash tokens, calculate allotments, multi-mint support | 8 | - **Session management** (`tollgate_core_session`) — time-based and bytes-based sessions with auto-expiry, extension, and revocation |
| 9 | - **Per-client firewall** — whitelist-based NAT filtering with sandbox mode | 9 | - **Cashu token processing** (`tollgate_core_cashu`) — decode Cashu e-cash tokens, calculate allotments, multi-mint support, proof state checking |
| 10 | - **DNS server** — per-client DNS hijack/forward with DoT rejection | 10 | - **Per-client firewall** (`tollgate_core_firewall`) — whitelist-based NAT filtering with sandbox mode for unauthenticated clients |
| 11 | - **Mining payment** — Stratum share tracking, hashprice calculation, difficulty conversion | 11 | |
| 12 | - **Stratum proxy** — transparent TCP proxy for mining traffic with job management | 12 | ### Network |
| 13 | - **Beacon price** — WiFi vendor IE construction for price/mint/geohash advertising | 13 | - **DNS server** (`tollgate_core_dns`) — per-client DNS hijack/forward with DoT rejection |
| 14 | - **Market scanner** — discover and compare nearby TollGate prices | 14 | - **Stratum proxy** (`tollgate_core_stratum_proxy`) — transparent TCP proxy for mining traffic with job management |
| 15 | |||
| 16 | ### Mining | ||
| 17 | - **Mining payment** (`tollgate_core_mining`) — Stratum share tracking, hashprice calculation, difficulty conversion, share-to-allotment mapping | ||
| 18 | - **Stratum client** (`tollgate_core_stratum_client`) — Stratum V1 JSON protocol parsing (mining.notify, mining.set_difficulty), message construction (subscribe, authorize, submit) | ||
| 19 | |||
| 20 | ### Discovery & Market | ||
| 21 | - **Beacon price** (`tollgate_core_beacon`) — WiFi vendor IE construction for price/mint/geohash advertising | ||
| 22 | - **Market scanner** (`tollgate_core_market`) — discover and compare nearby TollGate prices via vendor IEs | ||
| 23 | - **Mint health** (`tollgate_core_mint_health`) — mint health state tracking with recovery threshold, reachable/unreachable transitions | ||
| 24 | |||
| 25 | ### Portal & Client | ||
| 26 | - **Portal rendering** (`tollgate_core_portal`) — HTML template rendering with multi-key substitution, usage calculation, captive URI detection | ||
| 27 | - **TollGate client** (`tollgate_core_client`) — upstream TollGate discovery JSON parsing, session/usage response parsing, renewal threshold logic, price comparison | ||
| 15 | 28 | ||
| 16 | ## Integration | 29 | ## Integration |
| 17 | 30 | ||
| @@ -26,7 +39,15 @@ static tollgate_platform_t platform = { | |||
| 26 | .get_mint_url = my_get_mint_url, | 39 | .get_mint_url = my_get_mint_url, |
| 27 | .get_metric = my_get_metric, | 40 | .get_metric = my_get_metric, |
| 28 | .get_time_ms = my_get_time_ms, | 41 | .get_time_ms = my_get_time_ms, |
| 29 | // ... other callbacks | 42 | .spend_proofs = my_spend_proofs, |
| 43 | .get_stratum_url = my_get_stratum_url, | ||
| 44 | .get_stratum_port = my_get_stratum_port, | ||
| 45 | .get_stratum_user = my_get_stratum_user, | ||
| 46 | .get_stratum_pass = my_get_stratum_pass, | ||
| 47 | .get_mining_port = my_get_mining_port, | ||
| 48 | .get_hashprice_sats_per_ghs_day = my_get_hashprice, | ||
| 49 | .on_share_accepted = my_on_share_accepted, | ||
| 50 | .get_hashrate = my_get_hashrate, | ||
| 30 | }; | 51 | }; |
| 31 | ``` | 52 | ``` |
| 32 | 53 | ||
| @@ -54,9 +75,40 @@ tollgate_core_process_payment(client_ip, cashu_token_string); | |||
| 54 | 75 | ||
| 55 | Call `tollgate_core_tick()` periodically (e.g., every second) to expire sessions. | 76 | Call `tollgate_core_tick()` periodically (e.g., every second) to expire sessions. |
| 56 | 77 | ||
| 78 | ### 5. Use sub-modules directly | ||
| 79 | |||
| 80 | ```c | ||
| 81 | #include "tollgate_core_portal.h" | ||
| 82 | char *html = tollgate_core_portal_render(template, subs, nsubs); | ||
| 83 | |||
| 84 | #include "tollgate_core_stratum_client.h" | ||
| 85 | tollgate_core_stratum_build_subscribe(buf, size, req_id); | ||
| 86 | |||
| 87 | #include "tollgate_core_mint_health.h" | ||
| 88 | tollgate_core_mint_health_update(&state, idx, probe_ok, status, err, time); | ||
| 89 | |||
| 90 | #include "tollgate_core_client.h" | ||
| 91 | bool renew = tollgate_core_client_should_renew(remaining, allotment, threshold); | ||
| 92 | ``` | ||
| 93 | |||
| 57 | ## API Reference | 94 | ## API Reference |
| 58 | 95 | ||
| 59 | See `include/tollgate_core.h` for the public API and `include/tollgate_platform.h` for platform callbacks. | 96 | | Header | Description | |
| 97 | |--------|-------------| | ||
| 98 | | `tollgate_core.h` | Main API: init, process_payment, tick, status queries | | ||
| 99 | | `tollgate_platform.h` | Platform callback struct definition | | ||
| 100 | | `tollgate_core_session.h` | Session create/find/extend/revoke | | ||
| 101 | | `tollgate_core_cashu.h` | Token decode, checkstate, allotment | | ||
| 102 | | `tollgate_core_firewall.h` | Client grant/revoke, sandbox ports | | ||
| 103 | | `tollgate_core_dns.h` | DNS start/stop | | ||
| 104 | | `tollgate_core_mining.h` | Share tracking, hashprice, difficulty | | ||
| 105 | | `tollgate_core_stratum_proxy.h` | Proxy init/stop, job management | | ||
| 106 | | `tollgate_core_beacon.h` | IE construction, mint/npub hashing | | ||
| 107 | | `tollgate_core_market.h` | Market table, price comparison | | ||
| 108 | | `tollgate_core_portal.h` | Template rendering, usage calc, captive URIs | | ||
| 109 | | `tollgate_core_stratum_client.h` | Stratum V1 protocol parsing | | ||
| 110 | | `tollgate_core_mint_health.h` | Mint health state tracking | | ||
| 111 | | `tollgate_core_client.h` | Discovery/session parsing, renewal logic | | ||
| 60 | 112 | ||
| 61 | ## Dependencies | 113 | ## Dependencies |
| 62 | 114 | ||
| @@ -68,4 +120,4 @@ See `include/tollgate_core.h` for the public API and `include/tollgate_platform. | |||
| 68 | 120 | ||
| 69 | ## License | 121 | ## License |
| 70 | 122 | ||
| 71 | Proprietary — see repository for details. | 123 | MIT — see [LICENSE](LICENSE). |
diff --git a/components/tollgate_core/idf_component.yml b/components/tollgate_core/idf_component.yml index cdf2ee3..05337d3 100644 --- a/components/tollgate_core/idf_component.yml +++ b/components/tollgate_core/idf_component.yml | |||
| @@ -1,11 +1,25 @@ | |||
| 1 | version: "1.1.0" | 1 | version: "1.2.0" |
| 2 | description: | | 2 | description: | |
| 3 | TollGate core component for paid WiFi hotspots with Cashu e-cash payments. | 3 | TollGate core component for paid WiFi hotspots with Cashu e-cash payments. |
| 4 | Provides session management, per-client DNS/firewall, Cashu token processing, | 4 | Provides session management, per-client DNS/firewall, Cashu token processing, |
| 5 | mining payment tracking, beacon price advertising, and market scanning. | 5 | mining payment tracking, beacon price advertising, market scanning, |
| 6 | portal template rendering, Stratum protocol parsing, mint health tracking, | ||
| 7 | and upstream TollGate client logic. | ||
| 6 | Platform-agnostic via tollgate_platform_t callbacks for easy integration | 8 | Platform-agnostic via tollgate_platform_t callbacks for easy integration |
| 7 | with any ESP32 firmware (TollGate, NerdQAxePlus, BitAxe, etc.). | 9 | with any ESP32 firmware (TollGate, NerdQAxePlus, BitAxe, etc.). |
| 8 | url: https://git.orangesync.tech/npub12m5exm2uk3xa674cc5r0hlyvccs5xxn7qv83ezuteefv5972nquq4j4szl/esp32-tollgate | 10 | url: https://git.orangesync.tech/npub12m5exm2uk3xa674cc5r0hlyvccs5xxn7qv83ezuteefv5972nquq4j4szl/esp32-tollgate |
| 11 | license: "MIT" | ||
| 12 | targets: | ||
| 13 | - esp32s3 | ||
| 14 | tags: | ||
| 15 | - wifi | ||
| 16 | - hotspot | ||
| 17 | - cashu | ||
| 18 | - payment | ||
| 19 | - mining | ||
| 20 | - captive-portal | ||
| 21 | - stratum | ||
| 22 | - nostr | ||
| 9 | dependencies: | 23 | dependencies: |
| 10 | idf: | 24 | idf: |
| 11 | version: ">=5.3.0" | 25 | version: ">=5.3.0" |