The inner loop in refreshWallets drops cached wallets that sort before
the next enumerated device or that have failed. When this drop-while
logic was refactored into an early break, the condition was negated but
the boolean operator was left as ||, so the negation is incomplete.
The drop condition is:
(URL.Cmp(url) < 0) || (failure != nil)
so the break (abort dropping) condition must be its De Morgan negation:
(URL.Cmp(url) >= 0) && (failure == nil)
With ||, the loop breaks as soon as the front wallet is operational,
even when it sorts before the current device. The stale wallet is not
dropped in place, and neither the "wrap new wallet" nor the "keep
matching wallet" branch matches, so the still-present device is silently
skipped for that refresh cycle (no WalletArrived) and is only re-added
on a later refresh.
Switch the operator to && so the break condition correctly mirrors the
intended drop semantics.
This PR reverts the last change to the freebsd build, and it fixes the
_direct_ FreeBSD build.
Here, we change the upstream of github.com/karalabe/hid to its new home,
github.com/ethereum/hid. The new dependency includes a dummy.go file
that makes `go mod vendor` work.
##### Origin of the problem
Enrique is maintaining the FreeBSD ports, and FreeBSD ports only support
vendored go modules. It turns out that `go mod vendor` will not include
C files if there is no `.go` file in the directory. Since the C files
were missing for `karalabe/hid`, the ports maintainer tried to use the
version of `hidapi` that is provided by the ports. To do so, he had to
modify the way things are included. This broke the _out of ports_
FreeBSD build.
The latest firmware for Ledger Nano S Plus now returns `0x5000` for it's
product ID, which doesn't match any of the product IDs enumerated in
`hub.go`.
This PR removes the assumption about the interfaces exposed, and simply
checks the upper byte for a match.
Also adds support for the `0x0007` / `0x7000` product ID (Ledger Flex).
* usbwallet support Ledger Nano S Plus
* accounts/usbwallet: add definitions + ref to ledger docs
Co-authored-by: Martin Holst Swende <martin@swende.se>