swaps: authorize credit account requests - #1103
Conversation
de951f7 to
5c7994b
Compare
|
@claude please review this PR. Please focus on the protocol and client-side authorization boundary:
The downstream verifier persists nonces before handler execution, so please also flag any client behavior that could accidentally reuse a nonce or sign a different payload from the one transmitted. |
|
Claude finished @bhandras's task in 6m 43s —— View job Review: credit account request authorization (PR #1103)I traced the full client-side boundary: What holds up ✅
Findings1. 2. The signature always binds the daemon identity key, but the digest helper advertises a different per-request account key — an implicit, unchecked coupling. [ This works today only because every call site sets
3. (minor) Shallow struct copy of a proto message. [ Server-side dependency to confirmThe downstream verifier must replicate the digest construction exactly: full method string + Note: I could not run |
5c7994b to
ca66bcd
Compare
Bind account-scoped credit requests to the wallet identity key. Use a short-lived nonce and a deterministic request digest.
Expose the daemon identity signer without exporting key material. Reject stale or overly broad authorization envelopes before signing.
Attach a fresh account proof before every credit-sensitive request. Share the daemon signer across gRPC and REST swap transports.
ca66bcd to
3eed78b
Compare
|
@claude please re-review the current head ( The first review has been addressed as follows:
Please focus the second pass on whether the explicit account-key signer contract closes the concern without weakening receive authorization, and flag any remaining merge blockers. |
|
Claude finished @bhandras's task in 2m 24s —— View job Re-review: credit account request authorization (HEAD
|
What it does
Protocol
The signature commits to the exact RPC method, deterministic request bytes, account public key, expiry, and a 32-byte random nonce. The authorization field is excluded from its own request digest. Proofs expire after one minute by default and signers reject expiries beyond five minutes.
The signer receives the account key extracted from the same canonical payload it signs. The daemon refuses to sign unless that key matches its identity key, preventing a caller from asking one wallet to authorize another wallet's account.
Compatibility
Ordinary Ark-to-Lightning quote and create requests remain unsigned when no credit account is supplied. Lightning-to-Ark route requests are account-scoped because the route may inspect or reserve receive credit, so receive callers must use a connection configured with an identity signer. The exported constructors document this distinction.
Testing
go test ./swaprpc ./sdk/swaps ./sdk/ark ./wavedgo test -tags=swapruntime ./swapclientservermake fmt-changed-checkmake lint-changed-local workers=4make commitmsg-lint range=origin/main..HEADThe changed-file lint pass runs all 71 configured linters and reports zero issues.