Multi-standard token support (STAS, DSTAS, BSV-21) + Back-to-Genesis provenance verification - #61
Merged
Conversation
…o-Genesis Adds native wallet support for three token standards on top of the BRC-100 wallet — receive, on-chain transfer (full + partial), peer-to-peer settlement over MessageBox, WhatsOnChain discovery, and Back-to-Genesis provenance verification. Single squashed commit against upstream base 49b4b63; standard onboarding (the branch's one-click prototype was reverted, net-zero here). Engines & registry - src/lib/services/stas, tokens/dstas, tokens/bsv21 — per-standard build/sign/ broadcast + parsers (classic-STAS, DSTAS via the vendored dxs SDK, BSV-21 ord inscription). TokenProtocolRegistry + *ProtocolAdapter give the legacy address-send path one polymorphic seam. Discovery — WhatsOnChain, single source - woc/WocTokenIndexerClient serves all three standards (no Bitails/relay/1Sat fallbacks, no feature flag). Scan loops skip already-held outpoints before any per-candidate getRawTx. Peer settlement (MessageBox) - tokens/peer/* — PeerTokenClient (imported from @bsv/message-box-client) + per-standard TokenSettlementAdapters with BRC-29 owner derivation. Back-to-Genesis — counterfeit detection - BackToGenesisClient (tri-state, fail-safe verify/trace), TokenVerificationService (session cache + worst-verdict badge), verifyOnReceive (verify at registration), persisted in token_verifications (migration 0004). Token identity keys on the resolved genesis outpoint — for classic STAS the tokenId is only the issuer PKH, so genesis is the sole spoof-proof identity. Proven against a broadcast counterfeit (same tokenId+amount as a real token, no ancestor → not-authentic). Persistence, wiring, UI - electron/stas-queries + stas-migrations (satellite tables + verifications); fee model raised to 250 sat/kb (was on the miner floor). WalletService wires the bundle; onWalletReady exposes the HTTP token routes. Assets page (grouped holdings, partial send, verification badges), Transfers/PeerTokens. Tests: test/stas + test/tokens (derivation, discovery, migration incl. 0004, registration, inscription, dstas-transfer, woc-indexer, back-to-genesis, token-verification, verify-on-receive). Renderer + Electron builds pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K5d73SoN1pkMac9CbmtX5g
sirdeggen
force-pushed
the
token-integration
branch
from
July 16, 2026 07:34
c4d0815 to
6ae8fe2
Compare
The Transfers menu item added by the token-integration merge referenced menu_transfers via t(), but the key didn't exist in translations.ts for any language, failing the translation-coverage test.
better-sqlite3@12.x and @electron/rebuild@4.x already require Node >=20/22; the 18.x job only appeared to pass because push.yaml's cache key hashes only package.json, so PRs that don't touch it get a stale cache hit and skip npm install (and its postinstall rebuild) entirely. This PR's dependency changes miss that cache and hit the real, already pre-existing incompatibility.
sirdeggen
approved these changes
Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds native wallet support for three token standards — classic STAS, DSTAS, and BSV-21 — on top of the BRC-100 wallet: receive, on-chain transfer (full and partial), peer-to-peer settlement over MessageBox, WhatsOnChain discovery, and Back-to-Genesis provenance verification (counterfeit detection).
The branch is a single squashed commit for review. It is based on
49b4b63and is currently behindmaster; a rebase is needed before merge (see Reviewer notes below). GitHub shows the merge-base diff, so Files changed is the token work only.What it adds
Token engines & registry
src/lib/services/stas,tokens/dstas,tokens/bsv21(classic-STAS viastas-js, DSTAS via a vendored SDK, BSV-21 ord inscription).TokenProtocolRegistry+*ProtocolAdaptergive the address-send path one polymorphic seam.Discovery — WhatsOnChain, single source
woc/WocTokenIndexerClientserves all three standards (STAS by base58, DSTAS by owner hash160, BSV-21 by base58). No third-party fallbacks or feature flags.Peer settlement (MessageBox)
tokens/peer/*—PeerTokenClient(imported from the published@bsv/message-box-client) plus per-standardTokenSettlementAdapters with BRC-29 owner derivation.Back-to-Genesis — counterfeit detection
BackToGenesisClient(tri-state verify/trace, fail-safe),TokenVerificationService(cache + worst-verdict card badge),verifyOnReceive(verify at registration), persisted intoken_verifications(migration0004).tokenIdis only the issuer PKH, shared by every token that issuer minted, so genesis is the sole spoof-proof identity. Verified against a real broadcast counterfeit that clones a genuine token's tokenId + amount but has no ancestor →not-authentic.Persistence, wiring, UI
electron/stas-queries+stas-migrations(satellite tables + verifications); fee model set to 250 sat/kb (headroom above the miner floor so token packages don't stall). Assets page (grouped holdings, partial send with instant change, verification badges), Transfers/PeerTokens, Baskets browser.The one architectural note: two independent send paths
They do not share send code and must not be conflated:
*TransferService→ broadcastPeerTokenClient→*TokenSettlementAdapter→ broadcast + MessageBox pushBoth ultimately call the same per-standard on-chain engines.
Testing
npm run test:tokensandnpm run test:stas— 58 token + 15 STAS tests, plus a migration-0004roundtrip (npm run test:stas:db, which rebuilds the native module for Electron).Reviewer notes
49b4b63;masteris ~40 commits ahead with overlap in core files (WalletContext,WalletService,onWalletReady,electron/storage.ts,Menu.tsx,package.json). Happy to rebase once the approach is approved.:3321) are Origin-gated./stas/transferalso shows a permission modal;/dstas/transferand/bsv-21/transferare Origin-only (parity with/peerToken/send, to avoid the 30s bridge-timeout racing a human click). All HTTP token spends currently run under one fixed originator, so per-app spending-authorization would require threading the caller's origin — flagging for a design decision.🤖 Generated with Claude Code
https://claude.ai/code/session_01K5d73SoN1pkMac9CbmtX5g