Skip to content

feat(license-server): zidecar sync, env config, block-time expiry#3

Merged
hitchho merged 9 commits into
masterfrom
fix/license-server-use-zidecar
Apr 23, 2026
Merged

feat(license-server): zidecar sync, env config, block-time expiry#3
hitchho merged 9 commits into
masterfrom
fix/license-server-use-zidecar

Conversation

@Catopish

Copy link
Copy Markdown
Contributor

Summary

  • License-server sync via zidecar + FVK — dropped zebrad RPC path; now pulls compact blocks from zidecar and trial-decrypts Orchard actions with the license FVK.
  • .env + docs — all flags env-backed (ZCLI_SIGNING_KEY, LICENSE_FVK, ZIDECAR_URL, etc.). .env.example explains the signing-key ↔ ROTKO_ZCASH_VERIFIER and FVK ↔ ROTKO_LICENSE_ADDRESS relationships; .gitignore covers secrets + runtime state.
  • Block-time expiry anchor — new ZidecarClient::get_block_time helper + block_time on ReceivedMemo. Expiry anchors to on-chain block time, not `SystemTime::now()`. DB wipes + rescans no longer refresh the license clock.
  • Stacking renewals — each payment adds N days to `max(current_expires, block_time)` instead of re-anchoring a cumulative total, so renewing early no longer refunds elapsed time.

Test plan

  • `cp bin/license-server/.env.example .env`, fill in `ZCLI_SIGNING_KEY` + `LICENSE_FVK`, run `cargo run -p license-server` — picks up env, starts syncing from zidecar.
  • Send 0.001 ZEC to `ROTKO_LICENSE_ADDRESS` with a `zid` memo; verify credit line `license: +30 days` appears after the block confirms.
  • Wipe `license.db` + restart: rescan re-credits at same expiry (anchored to block time, not "today").
  • Send a second 0.001 ZEC while license is still valid: expiry extends by exactly 30 days from the prior expiry (not refunded to 60d from latest block).

🤖 Generated with Claude Code

Catopish and others added 4 commits April 16, 2026 17:37
- Add tower-http CORS (permissive) so browser extensions can fetch
- Use JS Number.MAX_SAFE_INTEGER (2^53-1) for friends permanent expiry
  instead of u64::MAX which loses precision in JSON.parse
- Fix route syntax: `:zid` for axum 0.6 compat
- Comment out missing workspace members (relay, poker)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous implementation called zebrad's z_listreceivedbyaddress,
which doesn't exist — that RPC is zcashd-only. Zebrad is consensus-only
with no wallet, so the scan silently returned nothing and licenses
were never issued for real payments.

Rewrite the payment scanner as a single-FVK watch-only wallet:
- Connect to zidecar (gRPC-Web, HTTP/2) instead of zebrad JSON-RPC
- Pull compact blocks, decrypt Orchard actions with the license FVK
- For matched notes, fetch the full tx via GetTransaction and extract
  the 512-byte memo via zync-core's extract_enc_ciphertext
- Memos starting with "zid" credit the corresponding pubkey
- Persist sync height in sled so restarts resume from last block

CLI changes:
- --zebrad-rpc removed (no longer needed)
- --fvk added (96-byte hex Orchard FullViewingKey, env LICENSE_FVK)
- --zidecar-url added (default http://127.0.0.1:50051)
- --sync-from added (initial sync start block for fresh DBs)

Housekeeping:
- Comment out bin/relay and bin/poker workspace members (not present)
- Remove dead `auth` module declaration from zync-core

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
all important flags now can be input from env (with sensible defaults)
.gitignore ignores .env / runtime state (license.db, friends.txt)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- block-time anchor: scanner now fetches the block timestamp via a new
ZidecarClient::get_block_time helper (reads TreeState.time) and
records it on each ReceivedMemo.
 - stacking renewals: each payment now adds its own days to the CURRENT
expiry (or block time if already expired).
 - one extra RPC call per credited memo (get_tree_state);

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hitchho added 5 commits April 22, 2026 03:47
Same CI fix as zcli — the local path dep breaks CI which only
checks out the zcli repo.
The [patch] at workspace root silently redirected the git osst dep
to a sibling zeratul checkout. Works locally, fails in CI which
only clones zcli. Leave the patch commented out with a note; devs
can uncomment for local zeratul work.
@hitchho hitchho merged commit 3830d5c into master Apr 23, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants