Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion daemon/kmd/wallet/driver/ledger_hid.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
)

const ledgerVendorID = 0x2c97
const ledgerUsagePage = 0xffa0

// LedgerUSB is a wrapper around a Ledger USB HID device, used to implement
// the protocol used for sending messages to the application running on the
Expand Down Expand Up @@ -82,7 +83,11 @@ func (l *LedgerUSB) WritePackets(msg []byte) error {
if err != nil {
return err
}
if cc != len(packet) {
// on Windows:
// The usb library adds one extra byte to the input passed to the USB device
// so the written bytes are larger than what we've send
// https://github.com/karalabe/hid/blob/9c14560f9ee858c43f40b5cd01392b167aacf4e8/hid_enabled.go#L167
if cc < len(packet) {
return fmt.Errorf("WritePackets: short write: %d != %d", cc, len(packet))
}

Expand Down Expand Up @@ -202,7 +207,13 @@ func LedgerEnumerate() ([]hid.DeviceInfo, error) {
}

var infos []hid.DeviceInfo
// The enumeration process is based on:
// https://github.com/LedgerHQ/blue-loader-python/blob/master/ledgerblue/comm.py#L212
// we search for the Ledger Vendor id and igonre devices that don't have specific usagepage or interface
for _, info := range hid.Enumerate(ledgerVendorID, 0) {
if info.UsagePage != ledgerUsagePage && info.Interface != 0 {
continue
}
infos = append(infos, info)
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/gorilla/websocket v1.4.2 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmoiron/sqlx v1.2.0
github.com/karalabe/hid v0.0.0-20181128192157-d815e0c1a2e2
github.com/karalabe/hid v1.0.0
github.com/labstack/echo/v4 v4.1.17
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-sqlite3 v1.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/karalabe/hid v0.0.0-20181128192157-d815e0c1a2e2 h1:BkkpZxPVs3gIf+3Tejt8lWzuo2P29N1ChGUMEpuSJ8U=
github.com/karalabe/hid v0.0.0-20181128192157-d815e0c1a2e2/go.mod h1:YvbcH+3Wo6XPs9nkgTY3u19KXLauXW+J5nB7hEHuX0A=
github.com/karalabe/hid v1.0.0 h1:+/CIMNXhSU/zIJgnIvBD2nKHxS/bnRHhhs9xBryLpPo=
github.com/karalabe/hid v1.0.0/go.mod h1:Vr51f8rUOLYrfrWDFlV12GGQgM5AT8sVh+2fY4MPeu8=
Comment thread
id-ms marked this conversation as resolved.
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down