asgayapedia

Android App: Implementation Architecture

📖 Unfamiliar terms? See the glossary for definitions.

Purpose: Index of Asgaya client implementation docs (Android-first, platform-agnostic architecture)

Status: Phase 0 in progress — Core covenant flow production-proven (all paths validated on Pi-chan July-Aug 2026; first inter-device claim August 10, 2026)


Overview

Asgaya implements peer-to-peer Bitcoin Cash remittances with no backend servers:

Core thesis: Remittances are the funnel to merchants. The covenant’s merchantCashout path enables cash pickup, making Asgaya a permissionless merchant acquisition system.

Key principle: Any competent developer (not blockchain expert) can build an Asgaya client from these docs.


Development Philosophy

Pragmatic approach (Jun-Aug 2026):

  1. Study existing apps first - Learn from working code, don’t reinvent
  2. Small incremental changes - Save strength for integration (reliability + UX)
  3. Choose our battles - Identify blockers → decide: redesign vs restart vs defer
  4. Incremental validation - Each milestone proves next step is possible

Note: This philosophy emerged from BizumParser work and WebView pivot. Future contributors (or AI in fresh context) benefit from understanding the pragmatic, incremental approach that got us to production.


Phase Model (Canonical)

Phase Definition Status
Phase 0 MVP in development (covenant flow working, integration ongoing) 🔴 In progress
Phase 0+ Features added during testing (cheap UX/reliability wins) 🔵 Opportunistic
Phase 1+ Post-MVP enhancements based on observed behavior 🟢 Future

Phase 0 MVP Definition: Full value proposition working end-to-end:


Current Implementation (Phase 0 — August 2026)

Production-proven components:

Component What It Does Status Doc
Multi-Wallet Sender/recipient/merchant wallet switching, Room persistence ✅ Working wallet.md
CovenantWebView Kotlin ↔ JS bridge, CashScript SDK integration, P2SH32 address generation ✅ Working (v0.2 hybrid: compute-only) webview-covenant-bridge.md
CovenantBuildService v0.2: Kotlin network ops (UTXO fetch + broadcast, native TCP) ✅ Working webview-covenant-bridge.md
ElectrumClient Balance queries, transaction broadcast, UTXO management ✅ Working connection-management-patterns.md
NotificationListener Telegram parameter parsing (testing tool + fallback; Nostr is Phase 0 target) ✅ Working notification-bot.md
Connection Management TCP cooldown (5s after balance query), WebSocket cleanup, manual updates ✅ Working (v0.2: WebSocket only for brief UTXO fetch) connection-management-patterns.md
SendViewModel v0.2: viewModelScope transaction state, pending_transactions DB, rebroadcast, background confirmation (RS083) ✅ Working state-management.md

Covenant v2.6: All 5 spending paths implemented (claim, merchantCashout, refund, abort, sellerRecoverBuffer); v2.5 validated on chipnet, abort on testnet3 (Aug 15)

v0.2 hybrid architecture (Aug 20-21): All 4 covenant operations (CREATE/REFUND/CLAIM/ABORT) now build in the WebView and broadcast from Kotlin. WebView is compute-only. Multi-device reliability restored (the WebSocket connection-accumulation bug is eliminated at the root).

Evidence: First inter-device claim August 10, 2026 (TXID: 193c3c9e5287e13cc56e1401aed55de34db9a375312e052807aea060e58e3d96)

See complete flow: claim-flow-end-to-end.md


Phase-Ranked Feature Map

Phase 0 (In Development)

Feature Status Notes
Multi-wallet management ✅ Done Room database, WalletManager, reactive UI
Covenant v2.6 (5 paths) ✅ Done All paths validated (v2.5 on chipnet, abort on testnet3)
WebView + CashScript SDK ✅ Done v0.2 hybrid: compute-only (build/sign), broadcast in Kotlin
ElectrumClient (balance/broadcast) ✅ Done TCP + WebSocket support
Telegram parameter parsing ✅ Done Testing tool + fallback (Nostr is target)
Connection management patterns ✅ Done TCP cooldown, cleanup, manual updates
Self-funded sender flow ✅ Done Also a real future use case (BCH stable, B2B, CEX savings)
v0.2 hybrid (build + Kotlin broadcast) ✅ Done CREATE/REFUND/CLAIM/ABORT all hybrid (Aug 20-21)
Nostr coordination (DM) 🔨 In progress Phase 0 target (automation needed for real covenants)
Bulletin board 🔨 Planned Merchant/seller discoverability (MVP needs it)
Merchant cash-out flow 🔨 Planned Covenant path tested; needs UI integration
First BCH seller (Suso) 🔨 Needed MVP validation requires real seller

Phase 0+ (During Testing — Opportunistic)

Feature Why 0+ Notes
Cash Accounts Cheap UX win Elena#142 instead of bchtest:qq...
Seed phrase backup Cheap UX win BIP39 HD wallets, 12-word recovery
Seller device health Already built! RS072/RS075 DeviceHealthMonitor.kt exists; needs integration + bulletin board ranking
Stability layer (H€/HAu) Retention incentive Launch-first per stability-layer.md; merchant hook
Kraken API Volume dependent Manual/mining covers Phase 0; automate when needed

Phase 1+ (Post-MVP)

Feature Why defer Notes
Offline-first Can wait Online-only acceptable for MVP
Own Nostr relay Operational burden Public relays sufficient; revisit if reliability issues
Cross-border expansion Progressive rollout Spain→Venezuela first, then PagoMóvil/M-Pesa
Multi-covenant batching Optimization Not needed at MVP scale

Component Documentation

Phase 0 (Implemented / In Progress)

  1. claim-flow-end-to-end.md
    Complete August 10 flow, architecture decisions, production evidence

  2. connection-management-patterns.md
    TCP cooldown, WebSocket cleanup, manual updates, seller resolution notifications (production-proven Aug 8-10)

  3. webview-covenant-bridge.md
    Kotlin ↔ JavaScript bridge, CashScript SDK bundling, Webpack config (4 claims + 3 refunds validated)

  4. asgaya-trinity.md
    Create → Send → Claim architecture, scope boundary (wallet not infrastructure)

  5. two-layer-architecture.md
    Covenant (permissionless) vs Client (opinionated) separation principle

  6. wallet.md 🔨
    Multi-wallet ✅, HD derivation (Phase 0+), Cash Account registration (Phase 0+)

  7. notification-bot.md 🔨
    Telegram parsing ✅, bank notification parsing (Phase 0+), market price subscription (Phase 0+)

  8. state-management.md 🔨
    Wallet storage ✅ (Room + WalletEntity), covenant tracking (Phase 0+), bulletin board cache (Phase 0+)

Phase 0+ / Phase 1+ (Future)

  1. bulletin-board.md — Electrum NFT queries, listing discovery, seller/merchant matching
  2. nostr.md — Relay management, NIP-44 encrypted DMs, payment coordination
  3. stability-layer.md — H€/HAu token detection, AnyHedge integration, merchant retention hook
  4. offline-first.md — Offline queue, cache strategies, sync patterns

Legend:


Key Implementation Challenges

Phase 0 challenges (learned during Aug 2026 work):

Phase 0+ challenges (deferred):

See component docs for detailed solutions.


External Dependencies

Phase 0 (in use):

Phase 0+ (planned):

See component docs for integration details.


Conceptual (read first):

Implementation (covenants):

Research:

Media (Phase 0+ content refresh needed):


Success Criteria

Phase 0 success (August 10, 2026): ✅ Achieved

Full MVP success (Phase 0 ongoing): 🔨 In Progress

Documentation success:


🏠 Home ↑ Implementation 📖 Glossary

This section: Android App
Related: Covenants | The Mechanism


Last updated: 2026-08-24 (v0.2 hybrid + covenant v2.6 path count)
Status: Phase 0 in progress (covenant flow proven, integration ongoing)
Evidence: First inter-device claim TXID 193c3c9e5287e13cc56e1401aed55de34db9a375312e052807aea060e58e3d96