Skip to content

Conversation

edouardparisvibes
Copy link

Summary

  • Handle multiple fallback URLs when primary PIN server fails
  • Add proper Accept header to PIN server requests
  • Provide detailed error messages for debugging handshake issues

Problem

The current Jade PIN server implementation only tries the first URL from the server list and doesn't include the required Accept header. This causes handshake failures when the primary server is unavailable.

Solution

This PR makes the Rust implementation match the Python jadepy library behavior more closely by:

  1. URL Fallback: Try all provided PIN server URLs in sequence instead of just the first one
  2. HTTP Headers: Include the Accept header as specified in the request parameters
  3. Error Handling: Provide detailed error messages that include which URL failed and why

Changes Made

  • Modified src/jade/pinserver.rs to iterate through all URLs instead of using only the first
  • Added Accept header to HTTP requests using req.accept parameter
  • Enhanced error messages to show specific URL and failure reason
  • Maintains backward compatibility while improving reliability

Test plan

  • Code compiles successfully with cargo check
  • Test with actual Jade device to verify handshake works
  • Test fallback behavior when primary PIN server is unavailable

This should resolve handshake issues by providing the same reliability as the Python jadepy library implementation.

🤖 Generated with Claude Code

@edouardparisvibes edouardparisvibes force-pushed the fix/jade-pinserver-handshake branch from 6677f49 to 1dbb764 Compare August 29, 2025 14:50
- Use first non-onion URL instead of trying all URLs as fallbacks
- Remove Accept header (Python doesn't set it)
- Use accept parameter only to determine JSON vs form encoding
- Send JSON when accept is "json" or "application/json"
- Send form data otherwise, matching Python requests.post(url, data)
- Add support for GET method (though only POST is used in practice)

This matches the Python jadepy _http_request() function behavior exactly
and should resolve handshake compatibility issues.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@edouardparisvibes edouardparisvibes force-pushed the fix/jade-pinserver-handshake branch from 1dbb764 to 9032df6 Compare August 29, 2025 15:30
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.

2 participants