Skip to content

feat: add boltz savings swap#632

Draft
coreyphillips wants to merge 2 commits into
masterfrom
feat/savings-swap
Draft

feat: add boltz savings swap#632
coreyphillips wants to merge 2 commits into
masterfrom
feat/savings-swap

Conversation

@coreyphillips

@coreyphillips coreyphillips commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This PR adds a swap-based path for transferring spending balance to savings, so Lightning funds can move on-chain through a Boltz reverse swap instead of only by closing a channel. It ports the equivalent Android feature (synonymdev/bitkit-android#1081) to iOS.

Description

  • Adds a Boltz reverse swap flow to the transfer-to-savings journey. The confirm screen now shows a live quote (amount to savings, network fee, service fee, and the amount you will receive) and lets the user proceed with a swap or fall back to closing the channel.
  • Guards against amounts that are too low to swap, holding back a small reserve for Lightning routing fees and surfacing a clear message when the amount cannot be transferred.
  • Waits for the on-chain claim during the progress step and resumes any pending swaps when the wallet starts, refreshing balances automatically once a swap lands on-chain. The updates stream stops with the node and restarts on the next wallet start.
  • Adds a Swaps section under Dev Settings to list swaps and claim a reverse swap, backed by a new service that wraps the Boltz module. The manual claim button only shows while the swap is actually claimable (lockup on-chain and no claim broadcast yet).
  • Adds a reusable continuous amount slider component used by the swap amount controls.
  • Bumps bitkit-core to 0.5.1, which introduces the Boltz module this flow depends on. The bump is purely additive over 0.4.1 (verified against the published Swift bindings).

Linked Issues/Tasks

Android counterpart: synonymdev/bitkit-android#1081

QA Notes

Manual Tests

  • 1. With a spending balance, Transfer to Savings → Savings Confirm: quote shows amount to savings, network fee, service fee, and you'll receive.
  • 2. Savings Confirm → drag the amount slider: quote recomputes for the new amount.
  • 3. Savings Confirm with a balance below the swap minimum: amount-too-low message shows and swipe does nothing.
  • 4a. Savings Confirm → swipe to confirm → Savings Progress: completes after the on-chain claim.
    • 4b. After claim: savings balance reflects the swapped funds without a manual sync.
  • 5. regression: Savings Confirm → Close channel instead: falls back to the channel-close path.
  • 6. regression: Start the app with a pending swap: swap resumes and balance updates once it lands on-chain.
  • 7a. Dev Settings → Swaps → tap a swap → Swap Details: Claim now shows only for an unclaimed reverse swap with its lockup in mempool or confirmed.
    • 7b. Swap Details of a created, expired, refunded, or claimed swap: no Claim button.

Automated Checks

  • Unit tests added: savings swap quote fee breakdown and claimable status gating in SavingsSwapTests.swift.
  • Ran locally against bitkit-core 0.5.1: simulator Debug build and translation validation pass.

@coreyphillips coreyphillips self-assigned this Jul 16, 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

Development

Successfully merging this pull request may close these issues.

1 participant