{"id":43893165,"url":"https://github.com/skycoin/hardware-wallet-go","last_synced_at":"2026-02-06T17:11:06.854Z","repository":{"id":33504902,"uuid":"209256492","full_name":"skycoin/hardware-wallet-go","owner":"skycoin","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-12T17:56:24.000Z","size":6706,"stargazers_count":5,"open_issues_count":14,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-12-14T08:37:25.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skycoin.png","metadata":{"files":{"readme":"README-USB-FIX.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-09-18T08:22:24.000Z","updated_at":"2025-12-12T17:56:28.000Z","dependencies_parsed_at":"2022-08-07T22:00:24.534Z","dependency_job_id":null,"html_url":"https://github.com/skycoin/hardware-wallet-go","commit_stats":null,"previous_names":["skycoinproject/hardware-wallet-go"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/skycoin/hardware-wallet-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skycoin%2Fhardware-wallet-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skycoin%2Fhardware-wallet-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skycoin%2Fhardware-wallet-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skycoin%2Fhardware-wallet-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skycoin","download_url":"https://codeload.github.com/skycoin/hardware-wallet-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skycoin%2Fhardware-wallet-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29169389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T16:33:35.550Z","status":"ssl_error","status_checked_at":"2026-02-06T16:33:30.716Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-06T17:11:05.931Z","updated_at":"2026-02-06T17:11:06.850Z","avatar_url":"https://github.com/skycoin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# USB Permissions Fix for Skycoin Hardware Wallet\n\n## Summary\n\nThis branch fixes the \"libusb: bad access [code -3]\" error when accessing the Skycoin hardware wallet without sudo.\n\n## Fixes Applied\n\n### 1. Filtered Device Enumeration\n**Problem:** Code tried to open ALL USB devices, triggering permission errors on inaccessible devices  \n**Solution:** `Get_Device_List_Filtered()` only opens devices matching VID/PID 313a:0001\n\n###2. VID/PID Matching\n**Problem:** `matchVidPid()` only checked for Trezor2 devices (VID 0x1209), rejecting Skycoin wallets (VID 0x313a)  \n**Solution:** Accept both Trezor and Skycoin devices in all modes\n\n### 3. Config Descriptor Parsing\n**Problem:** Treated gousb's `map[int]ConfigDesc` as array, causing index out of bounds  \n**Solution:** Properly lookup by config number (1) not array index (0)\n\n### 4. Endpoint Iteration\n**Problem:** Treated `map[EndpointAddress]EndpointDesc` as slice  \n**Solution:** Iterate over map keys correctly\n\n## Usage\n\n### Quick Test (Temporary)\n\n1. **Unbind the HID driver:**\n   ```bash\n   # Find interface (usually 1-1.5:1.0 or similar)\n   ls -la /sys/bus/usb/devices/*/driver 2\u003e/dev/null | grep usbhid | grep 313a\n   \n   # Unbind (replace 1-1.5:1.0 with your interface)\n   echo \"1-1.5:1.0\" | sudo tee /sys/bus/usb/drivers/usbhid/unbind\n   ```\n\n2. **Test the wallet:**\n   ```bash\n   ./hw cli features  # Should work without sudo!\n   ```\n\n### Permanent Solution (udev Rule)\n\nCreate `/etc/udev/rules.d/51-skywallet.rules`:\n\n```udev\n# Skycoin Hardware Wallet\nACTION==\"add|bind\", SUBSYSTEM==\"usb\", ENV{DEVTYPE}==\"usb_interface\", \\\n  ATTRS{idVendor}==\"313a\", ATTRS{idProduct}==\"0001\", ATTR{bInterfaceClass}==\"03\", \\\n  RUN+=\"/bin/sh -c 'echo $kernel \u003e /sys/bus/usb/drivers/usbhid/unbind 2\u003e/dev/null || true'\"\n\nSUBSYSTEM==\"usb\", ATTRS{idVendor}==\"313a\", ATTRS{idProduct}==\"0001\", MODE=\"0666\"\n```\n\nThen reload:\n```bash\nsudo udevadm control --reload-rules \u0026\u0026 sudo udevadm trigger\n```\n\nReplug the device - it should work immediately!\n\n## Technical Details\n\n**Why unbind is required:**\n- Skywallet interface uses HID class (bInterfaceClass=03)\n- Linux automatically binds `usbhid` driver to HID devices\n- Only one driver can claim an interface at a time\n- Kernel driver detachment requires CAP_SYS_ADMIN (even with correct file permissions)\n- udev can unbind on device insertion without requiring application privileges\n\n**Alternatives considered:**\n- `SetAutoDetach(true)` - requires CAP_SYS_ADMIN ✗\n- Manual `detachKernelDriver()` - requires CAP_SYS_ADMIN ✗  \n- `setcap cap_sys_admin+ep` on binary - security risk ✗\n- udev unbind rule - works perfectly ✓\n\n## Files Changed\n\n- `src/usb/lowlevel/libusb/libusb.go` - Core USB wrapper fixes\n- `src/skywallet/usb/libusb.go` - Device enumeration and matching\n- `TESTING.md` - Detailed testing instructions\n- `README-USB-FIX.md` - This file\n\n## Next Steps\n\n1. Test with unbind script: `./unbind-skywallet.sh` (in skycoin repo)\n2. Verify works: `./hw cli features`\n3. If successful, create PR to merge to develop\n4. Update skycoin vendor after merge\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskycoin%2Fhardware-wallet-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskycoin%2Fhardware-wallet-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskycoin%2Fhardware-wallet-go/lists"}