Skip to content

feat: wake the wallet to claim swaps - #1387

Draft
coreyphillips wants to merge 1 commit into
feat/resume-unfinished-swapsfrom
feat/swap-claim-wakes
Draft

coreyphillips wants to merge 1 commit into
feat/resume-unfinished-swapsfrom
feat/swap-claim-wakes

Conversation

@coreyphillips

@coreyphillips coreyphillips commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1238

Twin: synonymdev/bitkit-android#1991
Dependency: synonymdev/bitkit-core#223

Stacked on #1386; I'll retarget to master once it merges. Pins bitkit-core 0.8.0-swaps.12, a prerelease of rc15 plus synonymdev/bitkit-core#223, until a release includes it.

Description

  • After a commit whose provider takes wakes, the app creates a 2-day swap.claimable grant for its registered pk: identity, else ln:, and bitkit-core hands it to the provider. Only a registered install with notifications on gets one. Only the grant id is kept, never the token.
  • The grant is revoked when the swap ends, when the provider refuses it, and when the swap is already claimable, which is then advanced at once.
  • A swap.claimable wake advances every open swap for up to 18 s and is acknowledged handled once a claim goes out or no swap is left open, else failed. The swaps then keep advancing in the background. The notification extension does not handle it.

Out of Scope

Design

N/A: no UI changes.

Preview

N/A

QA Notes

Setup

As #1386, plus a registered install (Dev Settings, Wake shows the device) on a gateway the provider allowlists (--wake-gateway), and notifications on.

Journeys

N/A: not drivable; see Manual Tests.

Manual Tests

  • 1. Pay the contact through a swap, send Bitkit to the background before the lockup confirms, mine the confirmations: the wake claims the swap, and wake status shows it acked handled.
  • 2. After the claim confirms, the gateway lists the swap's grant as revoked.
  • 3. regression: with notifications off, a swap creates no grant and still claims on the next launch.

Automated Checks

  • new PubkySwapsWakeGrantsTests.swift: grant gating, the pk: then ln: recipient, the token and expiry the provider receives, and revoking on refusal, on an already claimable swap, on a swap that ended meanwhile, on finish and on wipe.
  • updated PubkySwapsTrackerTests.swift: a finished swap revokes its grant; the claimable wake's outcomes. WakeReceiverTests.swift: the app registry handles swap.claimable.

Evidence

  • 799bd8e, iPhone 17 simulator, bitkit-core 0.8.0-swaps.12: SwiftFormat lint passes; the CI test selection passes (4,182 unit tests).

Gaps

  • Manual tests not run: no provider with a gateway allowlist is running yet.
  • A background wake on a locked device is untested; if the mnemonic cannot be read then, the wake is acknowledged failed and the swap claims on the next launch.

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