Deviant BCH wallet — CashTokens + covenants (Katalogos v1 · chipnet)
My Transactions was localStorage-only, so a swap made on mobile never appeared on desktop with the same WIF. Fixed by scanning the chain on wallet attach (and at boot resume): blockchain.address.get_history → per-tx verbose fetches → classify → merge into TX_LOG_KEY with txid-dedupe. Architecture note (user asked): no dedicated database / indexer needed. The chain IS the database. Fulcrum's address history + verbose-tx RPCs give us every historical swap in a bounded number of calls (bounded here by HYDRATE_MAX_TXS = 100 most-recent per address). Adding a server-side indexer would violate the lean-endpoint stance (wiki/infra/lean-utxo-endpoint.md), introduce a custody-adjacent surface, and buy ~100 ms of speed for something we do once per session. If a wallet ever accumulates thousands of swaps we can paginate get_history and cache verbose fetches per txid, but that's a knob-turn not a re-architecture. Wiring: - hydrateTxLogFromChain(signer) fires 300 ms after onSignerChanged (attach / switch / disconnect+reattach) and 500 ms after bootLocalSigner picks up a resumed wallet. Idempotent — hydrateInFlight guard + txid dedupe means duplicate calls are no-ops. - Parallel worker pool (HYDRATE_CONCURRENCY = 4) so a 100-tx address hydrates in ~2-3 s on chipnet. Classification (v1, claims-only): - Match the user's PKH against each verbose output's scriptPubKey to find outputs going TO the user. - If an output carries token_data.category matching a KNOWN_MBAS entry → it's a CLAIM: pick the largest FT delta as the primary swap, derive BCH gross from units × rate, log with fromSym=BCH, toSym=<ticker>, chain block time as ts. - REDEEM detection deferred — burn-in-place txs don't touch the covenant address; distinguishing "I redeemed" from "I received a BCH payment" without input-scan is fuzzy. v2 task queued. Storage: hydrateInsert() writes directly to TX_LOG_KEY with the chain block time (not Date.now()) so the log stays ordered by real chain time, then re-sorts newest-first and repaints odTxLog. Verified with wallet D on chipnet: 17 claim entries hydrated across ASM / SHR745 / ASM2 tickers, first row is a 2026-09-21 claim of 550 ASM for 0.00055 BCH (txid 79084691e78e…). Panel repaints on completion. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .claude | ||
| brand | ||
| contracts | ||
| design | ||
| docs | ||
| KnowledgeBase | ||
| Parameters | ||
| public | ||
| scripts | ||
| services | ||
| shells | ||
| site/deviant | ||
| snapshots | ||
| spike | ||
| src | ||
| telegram-orderbook | ||
| test | ||
| wiki | ||
| .calibration-sweep.json | ||
| .catalytic-sweep.json | ||
| .env.example | ||
| .gitignore | ||
| .kac-extract.txt | ||
| .sim-athenae.json | ||
| adaptive-data.json | ||
| bch-history.json | ||
| bch-market.json | ||
| BCH_Token_Economy_Concept_Paper.md | ||
| bch_wallet_architecture.svg | ||
| CLAUDE.md | ||
| deviant_technical_spec_v2.7.md | ||
| package-lock.json | ||
| package.json | ||
| project-context.md | ||
| README.md | ||
| tsconfig.json | ||
| usdm-historical.json | ||
Deviant
BCH two-tier token economy platform. Pre-implementation. See BCH_Token_Economy_Concept_Paper.md for the full design.
Status
Bootstrap snapshot — protocol swap mechanism is the validation target.
Project map
| Path | Purpose |
|---|---|
BCH_Token_Economy_Concept_Paper.md |
Architecture spec, all [PROPOSED] claims |
CLAUDE.md |
Working agreement for Claude sessions |
src/ |
TypeScript wallet + token logic |
contracts/ |
CashScript source for Architecture A contracts |
test/ |
Unit tests (regtest) + integration plan (chipnet, mainnet) |
scripts/ |
Code-scan, snapshot, compile helpers |
wiki/ |
Living docs: architecture, decisions, testing strategy, code map |
snapshots/ |
Numbered progress snapshots |
Quickstart
npm install
npm run compile:contracts # produces artifacts from contracts/*.cash
npm run test:regtest # runs regtest suite
npm run scan # regenerates wiki/code-map.md
npm run snapshot # appends a new snapshot
Build priorities (active)
- Protocol swap mechanism — most novel claim, needs validation first.
- CashScript enforcement on mainnet — not just theoretical verification.
- tokenId correlation across A/B tiers — edge cases expected.
See wiki/testing-strategy.md for the staged regtest → chipnet → mainnet plan.