Skip to content

Breez SDK Spark migration#585

Merged
Nodirbek75 merged 46 commits intomainfrom
feat/spark-migration
Mar 18, 2026
Merged

Breez SDK Spark migration#585
Nodirbek75 merged 46 commits intomainfrom
feat/spark-migration

Conversation

@Nodirbek75
Copy link
Copy Markdown
Contributor

@Nodirbek75 Nodirbek75 commented Mar 14, 2026

Migrate from Breez Liquid SDK to Breez Spark SDK

This PR replaces the Breez Liquid SDK with the Breez Spark SDK across the entire app, and implements an automatic fund migration flow for existing users.

Changes

Spark SDK Integration

  • Implemented Spark SDK wrapper (spark.ts) with all payment methods: Lightning, on-chain, LNURL pay/withdraw, Spark addresses
  • Migrated send flow, receive flow, conversion flow, and redeem flow to use Spark SDK
  • Replaced refund flow with unclaimed deposit claim/refund flow (Spark architecture)
  • Updated transaction history to use UnifiedTransaction type combining Spark and USD transactions
  • Implemented Spark-specific transaction detail screen
  • Added Spark SDK log buffer with periodic disk flush and CSV export in settings

Liquid-to-Spark Balance Migration

  • Auto-migrates funds on app startup if sparkMigrationCompleted is not set
  • Auto-migrates on wallet import (resets flag, triggers on next BreezProvider mount)
  • Fee discovery via probe invoice at half balance, then drain at balance - fee * 1.5
  • Fee reimbursement via LNURL-withdraw (MIGRATION_FEE_LNURL_W env var)
  • Non-dismissable modal with loading state, error display, and CSV export button
  • Retry on failure (flag stays false), fee reimbursement failure doesn't block success
  • Handles "Already initialized" native SDK state from prior crash
  • Migration documentation in spark-migration.md with cleanup checklist

Test Plan

  • Fresh install — App starts, Spark SDK initializes, no migration triggered
  • Existing user with Liquid balance — Migration modal appears, funds transfer to Spark, balance updates
  • Existing user with zero Liquid balance — Migration completes silently, no modal shown
  • Existing user with balance below minimum — Migration skipped, appropriate message shown
  • Migration failure — Modal shows error, sparkMigrationCompleted stays false, retries on next launch
  • Fee reimbursement failure — Migration still marked successful, error message shown
  • Export Liquid transactions — CSV share sheet opens with correct transaction data
  • Wallet import — After import, migration flag resets and migration runs for the new wallet
  • Send Lightning payment — Fee estimation and payment succeed via Spark
  • Send on-chain payment — Fee tiers (fast/medium/slow) work, payment succeeds
  • Receive Lightning — Invoice generated, payment received, balance updates
  • Receive on-chain — Address generated, deposit detected, claim flow works
  • LNURL pay — Pay to Lightning address works
  • LNURL withdraw / Redeem — Withdraw and redeem flows work
  • Conversion flow — BTC to USD swap works with correct fee display
  • Unclaimed deposits — List, claim, and refund flows work
  • Transaction history — BTC and USD transactions display correctly with details
  • Spark log export — Settings > Export Logs shares the CSV file
  • App crash during migration — On relaunch, handles "Already initialized" and retries

…wallet is selectedsince spark supports no amount invoice
…ndPayment provides fee for 3 categories (fast, medium, slow) and add a logic to check if amount+fee is greater than balance
…gMax since spark doesn't provide drain wallet
…fund list logics and implement fetch unclaimed deposits logic
…details of breezspark and updated transaction-detail-screen that shows only usd transaction details now
Copy link
Copy Markdown
Contributor

@islandbitcoin islandbitcoin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@Nodirbek75 Nodirbek75 merged commit 6128e2b into main Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants