Skip to content

feat: let reverse swaps wake the wallet when they can be claimed - #223

Open
coreyphillips wants to merge 2 commits into
masterfrom
feat/swap-wake-capability
Open

coreyphillips wants to merge 2 commits into
masterfrom
feat/swap-wake-capability

Conversation

@coreyphillips

Copy link
Copy Markdown
Collaborator

Closes #200

  • A reverse quote lists claimable-hint-v1 when the provider's offer does.
  • PubkySwapRoutePayment.provider_takes_wake is true when the offer also lists swap-wake-v1. The swap record keeps it.
  • New pubky_swaps_send_wake_capability sends the app's swap.claimable grant as a SwapWakeCapability and returns the snapshot's claimable hint. It refuses a swap whose provider takes no wake, since an older provider never answers.
  • The token is checked as the provider checks it, never stored or logged, and scrubbed from every error, including a provider's Reject.

No swap-common bump: the pinned paykit-cap RFQ carries features, and current providers still answer that wire and take a plain SwapWakeCapability.

Tests: cargo test --lib pubky_swaps passes, with new tests for the feature list, the capability message and token redaction. Not run: the live regtest swap, which needs a provider with a gateway allowlist.

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No findings. Asks reverse quotes for claimable-hint-v1, records whether the provider takes a wake, and adds pubky_swaps_send_wake_capability to hand over a swap.claimable grant with the token kept out of records and errors. Reviewed f791c03, full tier, static: talos-pr-run could not confirm the author's permission on this repo and failed closed, so nothing was built or run here.

What I checked, and 6 candidates I ruled out

Read in full: the diff in client.rs, errors.rs, store.rs, types.rs, lib.rs, mod.rs; transport.rs for logging and error paths
Contract checked against the pinned pubky-swap rev f45e204: swap-provider/src/wake.rs (check, hold), accept_wake_capability and offer features in swap-provider/src/lib.rs, cap_adapter.rs (claimable hint read from the RFQ), swap-common/src/paykit_cap.rs (RFQ copies request.features)
CI: green so far (paykit-route, wake, manifests, recovery fixture); iOS/Android bindgen and usdt still pending

Ruled out

  • Hint never reaches the provider: paykit_cap builds the RFQ with features: request.features.clone(), and cap_adapter.rs sets claimable_hint from those, so the signed path carries it without a swap-common bump, as the body says.
  • Client and provider token checks drift: wake_capability mirrors Wake::check exactly (wkg_ prefix, WAKE_TOKEN_MAX_LEN, [A-Za-z0-9_-], expires_at > now); gateway allowlist and topic stay provider-side, and their refusals are token-free.
  • Wake sent to a provider that cannot parse it: takes_wake needs both swap-wake-v1 and claimable-hint-v1, matching the provider, which advertises wake only alongside the hint and refuses a swap quoted without it.
  • Token leaks through an error or log: WakeCapability's Debug redacts the token, the non-snapshot arm avoids unexpected(...), transport.rs logs nothing per message, and redact covers every PubkySwapError variant including Refused.code.
  • Old records fail to load: takes_wake is #[serde(default)], and a_record_saved_before_wakes_takes_none covers it; restored swaps get false, which the README states.
  • Race where the swap turns claimable while the grant is held: the provider re-reads the record after hold and returns the snapshot, so the returned claimable covers it; the doc comment tells the app to advance on true.

Merge confidence: 4/5, not built here, no CI job runs modules::pubky_swaps so the new tests ran only on the author's machine, and the live regtest wake is untested.

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.

feat: let reverse swaps wake the wallet when they can be claimed

2 participants