Repository navigation
Description
Motivation
A reverse swap can be claimed only once its lockup has its confirmations, and the wallet has to be running to claim it. coreyphillips/pubky-swap#117 added the provider side: when the lockup reaches depth, the provider wakes the owner's device once, through a wake grant the owner sent for that swap. The peer topic is swap.claimable (synonymdev/wake#1). The owner side is not in bitkit-core, so no swap this wallet starts can use it.
Current behavior (verified on master at cd8af15)
quote_edgeinsrc/modules/pubky_swaps/client.rssends everyQuoteRequestwithfeatures: vec![]. A provider accepts a capability only for a swap quoted withclaimable-hint-v1, so none of this wallet's swaps qualify.- Nothing sends
SwapMessage::SwapWakeCapability. The pinned swap-common (f45e204) already includes pubky-swap#117: the message,WakeCapability,CLAIMABLE_HINT_FEATURE,SWAP_WAKE_FEATUREandSWAP_WAKE_TOPIC. pubky_swaps_commit_routereturns afterSwapAccept, which is when the capability has to be sent. Its result does not say whether the provider advertisesswap-wake-v1.- The wake module can already create and revoke the grant (
wake_create_grant,wake_revoke_grant).
Requested change
- List
claimable-hint-v1in a reverseQuoteRequest.featureswhen the provider's offer advertises it. Leave the request unchanged for providers that do not. - Tell the app, in the commit result or the swap record, whether the provider advertises
swap-wake-v1, so it creates a grant only when the provider can use it. - Add a call that sends
SwapWakeCapabilityfor one of the wallet's open reverse swaps, afterSwapAccept:{ v: 1, gateway, topics: ["swap.claimable"], token, expires_at }, with the token and expiry from the app's grant. The provider answers with the swap's snapshot. It refuses a second, different capability for the same swap and accepts an identical resend. - Keep the token out of the swap record, logs and errors, including the error for a provider's
Reject. The provider keeps it in memory only.
The grant stays in the app: it calls wake_create_grant for its pk: identity and swap.claimable, with an expiry that covers the claim window, and revokes the grant when the swap ends. Grants are capped at 30 created per hour per device and 200 live per identity. A claimable flag from the provider is a hint only. pubky_swaps_advance still checks the lockup on the wallet's own chain view before it claims.
Out of scope
- Handling the wake and resuming the swap from the background. That is app work: feat: resume unfinished swaps until their claim confirms bitkit-android#1835 and feat: resume unfinished swaps until their claim confirms bitkit-ios#1262 for resuming, feat: adopt the wake gateway for background pushes bitkit-android#1804 and feat: adopt the wake gateway for background pushes bitkit-ios#1238 for wakes.
- The provider's gateway allowlist. It stays empty until the gateway has a production hostname (synonymdev/wake#2).
Acceptance criteria
- A reverse quote from a provider advertising
claimable-hint-v1lists it infeatures. A quote from any other provider is unchanged. - The app can tell from the commit whether the provider takes a wake capability.
- Sending a capability for an open swap returns the provider's snapshot. Sending a different one for the same swap returns an error.
- No error, log line or stored record contains the token.
- Unit tests cover the feature list and the capability message.
Activity