upleb.uk

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

summaryrefslogtreecommitdiff
path: root/components/tollgate_core/README.md
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-23 22:09:57 +0530
committerYour Name <you@example.com>2026-05-23 22:09:57 +0530
commitbf8e095b94fe500a9c35d7f2f616eb85569dbe5e (patch)
treec6bb9a2b11d20aff855cc324f1c3d60751629d1f /components/tollgate_core/README.md
parentaec549f83d5084aa9fd16c00e1c09e06ac7471d4 (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
Diffstat (limited to 'components/tollgate_core/README.md')
-rw-r--r--components/tollgate_core/README.md74
1 files changed, 63 insertions, 11 deletions
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
55Call `tollgate_core_tick()` periodically (e.g., every second) to expire sessions. 76Call `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"
82char *html = tollgate_core_portal_render(template, subs, nsubs);
83
84#include "tollgate_core_stratum_client.h"
85tollgate_core_stratum_build_subscribe(buf, size, req_id);
86
87#include "tollgate_core_mint_health.h"
88tollgate_core_mint_health_update(&state, idx, probe_ok, status, err, time);
89
90#include "tollgate_core_client.h"
91bool renew = tollgate_core_client_should_renew(remaining, allotment, threshold);
92```
93
57## API Reference 94## API Reference
58 95
59See `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
71Proprietary — see repository for details. 123MIT — see [LICENSE](LICENSE).