Skip to content

Release v3.0.1: SQLite DB-first architecture, atomic reindex, balance & UTXO consistency#61

Closed
boldbitcoin wants to merge 49 commits intomainfrom
v3.0.1
Closed

Release v3.0.1: SQLite DB-first architecture, atomic reindex, balance & UTXO consistency#61
boldbitcoin wants to merge 49 commits intomainfrom
v3.0.1

Conversation

@boldbitcoin
Copy link
Contributor

Summary

  • SQLite as single source of truth — full migration from file-based LocalCache to WAL-mode SQLite via @op-engineering/op-sqlite; repository pattern (BalanceRepository, TransactionRepository, UtxoRepository, WalletRepository, …); background sync via SyncCoordinator + per-data-type syncers.
  • Atomic wallet reset + reindexrunRestoreIndexing now runs HD discovery → balance sync → transaction sync → UTXO sync → aggregate balance computation as a single pipeline; throws and shows a Toast error on failure so navigation is aborted and the wallet never lands in a partially-synced state.
  • Balance always visibleWalletHome reads the aggregate balance synchronously from SQLite on every mount (including lock/unlock) so the balance is painted in frame 1; no flash of 0 or '-'.
  • UTXO & transaction consistency — UTXO list always reads from DB after API writes; transaction list merges (not replaces) API results; block_time persisted in utxos table so Confirmed/Unconfirmed status matches the summary card.
  • Historical fiat prices — confirmed transactions use block-time historical rate; pending transactions use current live rate.
  • MempoolClient TTLs: balance/txs/UTXOs → 5 s; fee rates → 30 s.
  • Version bump: package.json 3.0.1, Android versionCode 51.

Test plan

  • Switch network (mainnet ↔ testnet) — modal stays open through all phases ("Syncing balances…", "Syncing transactions…", "Syncing UTXOs…"), WalletHome shows correct balance and transactions immediately after navigation with no extra refresh required.
  • Switch address type — same atomic flow, no instant-close, no 0 balance on arrival.
  • Clear Cache — same atomic flow, success Toast on completion.
  • Disconnect network, pull-to-refresh on WalletHome — transactions and balance remain visible from DB; no empty list.
  • Lock and unlock app — balance is shown immediately (from DB), then updates after background sync completes.
  • UTXO screen — list is consistent on every open and refresh; confirmed/unconfirmed status matches summary card totals.
  • Transaction fiat values — confirmed transactions show historical price; pending show current price; no "-" in list or details.
  • Import new wallet via ShowcaseScreen — previous wallet's data is fully cleared before import.
  • On any network error during reindex, a descriptive Toast is shown and the app stays on WalletSettings.

Made with Cursor

bbtc and others added 30 commits March 3, 2026 11:03
Both MpcSendBTCWithUTXOs and NostrMpcSendBTCWithUTXOs were calling
FetchUTXODetails (GET /tx/{txid}) twice per input inside the signing
loop. A single API failure mid-session aborted the entire MPC round.

Changes:
- UTXOWithPath and utxoWithPathJSON now carry a scriptpubkey field (hex)
- Both signing functions build prevOuts from inline scriptpubkey;
  FetchUTXODetails is called only as a fallback when scriptpubkey is empty
  (backward-compatible: old callers without scriptpubkey continue to work)
- WalletService.enrichUtxosWithScriptpubkey() fetches /tx/{txid} per
  unique txid in TypeScript before MPC starts, with per-tx caching to
  avoid duplicate fetches for multi-input transactions
- MobilesPairing and MobileNostrPairing call enrichUtxosWithScriptpubkey
  and include scriptpubkey in the JSON passed to the native bridge
- NostrMpcSendBTCWithUTXOs and MpcSendBTCWithUTXOs now return errors on
  invalid amountSatoshi/estimatedFee strings instead of silently using 0

Made-with: Cursor
… UTXO summary card

- Add MempoolClient: in-memory cache + in-flight dedup + per-endpoint TTL
  (30 s default, 5 min tx, 60 s fees/price) + universal 10 s timeout
- Switch getWalletBalanceAggregate to /api/address/:address (chain_stats +
  mempool_stats); ~50x smaller responses; expose pendingSats in WalletBalance
- WalletHome: shimmer replaces ActivityIndicator; displayFiat via useMemo
  (fixes 0 BTC / non-zero fiat mismatch); amber pending chip for unconfirmed sats
- UtxosScreen: static balance summary card (Total / Confirmed / Pending with
  UTXO counts) pinned above scrollable list
- Fix receive-flow address mismatch: getCurrentReceivePathInfo atomically
  returns {path, index, address}; eliminates QR flicker at index boundary
- TransactionList: migrate axios → mempoolClient; remove manual timeout race
- TransactionDetailsModal: tighten flow-item accent bar style
- Update CHANGELOG.md with all v3.0.0 additions

Made-with: Cursor
…ansport

- pump.go: fix TOCTOU race in processEvent — move the processed-map check
  to AFTER assembly under a single lock acquisition; parallel initial-query
  goroutines can no longer double-dispatch the TSS handler for single-chunk
  messages (root cause of the reported signing failure with multiple relays)
- pump.go: replace fixed 1s retryTicker with exponential backoff (0→500ms→1s)
  for subscription failures and channel-close reconnects; reduces blind-spot
  window for messages arriving during relay reconnection
- session.go: parallelize AwaitPeers initial relay query using sync.WaitGroup;
  a slow/offline relay no longer blocks the others from being scanned within
  the timeout budget (previously sequential)
- session.go: continue publishing ready/complete wraps to all peers even when
  one peer's publish fails; report first error only after all peers attempted
- session.go: replace fixed 1s retryTicker with exponential backoff for
  AwaitPeers subscription setup and channel-close resubscription; eliminates
  duplicated nested retry loop
- config.go: increase ConnectTimeout default from 20s to 45s to give more
  room for mobile networks during peer rendezvous

Made-with: Cursor
@boldbitcoin
Copy link
Contributor Author

Superseded by new PR merging v3.0.2 branch with additional features (atomic API queue, 429 retry, progress indicators, UX fixes).

@boldbitcoin boldbitcoin deleted the v3.0.1 branch March 14, 2026 07:57
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.

3 participants