Skip to content

Commit

Permalink
some CRs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
algoidan committed Sep 1, 2021
1 parent 7d8ceef commit 356a4e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 3 additions & 6 deletions daemon/kmd/wallet/driver/ledger_hid.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (
"encoding/binary"
"fmt"
"os"
"runtime"

"github.com/karalabe/hid"
)

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 @@ -87,10 +87,7 @@ func (l *LedgerUSB) WritePackets(msg []byte) error {
// 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 runtime.GOOS == "windows" && cc > 0 {
cc = cc - 1
}
if cc != len(packet) {
if cc < len(packet) {
return fmt.Errorf("WritePackets: short write: %d != %d", cc, len(packet))
}

Expand Down Expand Up @@ -214,7 +211,7 @@ func LedgerEnumerate() ([]hid.DeviceInfo, error) {
// 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 != 0xffa0 && info.Interface != 0 {
if info.UsagePage != ledgerUsagePage && info.Interface != 0 {
continue
}
infos = append(infos, info)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ 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=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
Expand Down

0 comments on commit 356a4e2

Please sign in to comment.