Commit 3314b39
fix(daemon): #22 v3 — codex P2s on rebased PR — validate + normalize --parent
Two new P2s from codex review of the rebased PR #22:
**P2 — Unknown `--parent` wallets accepted without backend validation**
The v1 `looks_like_raw_wallet` fast path returned `0x` + 40-hex input as a
literal wallet with no existence check. Any syntactically valid address,
even one that doesn't correspond to any account, was accepted — the
daemon then opened a pair request with a `parent_wallet` that no session
could ever match, so the flow hung until timeout instead of failing
immediately. Route raw wallets through `/identity/resolve` with
`identity_type="wallet"`; the backend's post-PR-#21 wallet arm validates
existence via the `accounts` table and 404s unknown values.
**P2 — Mixed-case `--parent` wallets fail approval**
EIP-55 checksummed addresses travel verbatim through the old fast path,
but the mock backend stores wallets in lowercase. `parent_wallet`
equality check at approval time compared the mixed-case input to the
stored lowercase value, so valid checksummed addresses timed out.
Normalize raw wallets to lowercase (`to_ascii_lowercase`) before
sending to `/identity/resolve`; the backend's response comes back in
canonical lowercase, so the stored `parent_wallet` matches what
subsequent approve calls compare against.
The old `looks_like_raw_wallet` helper is kept — it now just selects
between `identity_type="wallet"` (with lowercase normalization) and
`identity_type="alias"` (verbatim). Aliases with reserved characters
still percent-encode via reqwest's `.query()` builder.
Test: cargo test -p agentkeys-daemon --test pair_tests -- --test-threads=1
pair_tests: 15 passed.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent ffdc908 commit 3314b39
1 file changed
Lines changed: 27 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | | - | |
248 | | - | |
249 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
250 | 259 | | |
251 | 260 | | |
252 | 261 | | |
| |||
255 | 264 | | |
256 | 265 | | |
257 | 266 | | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
263 | 274 | | |
264 | | - | |
265 | 275 | | |
266 | 276 | | |
267 | 277 | | |
268 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
269 | 282 | | |
270 | 283 | | |
271 | | - | |
| 284 | + | |
272 | 285 | | |
273 | 286 | | |
274 | | - | |
| 287 | + | |
275 | 288 | | |
276 | 289 | | |
277 | 290 | | |
278 | 291 | | |
279 | 292 | | |
280 | 293 | | |
281 | | - | |
| 294 | + | |
282 | 295 | | |
283 | 296 | | |
284 | | - | |
| 297 | + | |
285 | 298 | | |
286 | 299 | | |
287 | 300 | | |
| |||
0 commit comments