accounts/usbwallet: fix Ledger hidapi/libusb protocol violation

This commit is contained in:
Péter Szilágyi
2017-03-20 13:35:56 +02:00
parent 11e7a712f4
commit 26da6daaa9
2 changed files with 36 additions and 13 deletions

View File

@ -83,6 +83,7 @@ var errInvalidVersionReply = errors.New("invalid version reply")
// ledgerWallet represents a live USB Ledger hardware wallet.
type ledgerWallet struct {
hub *LedgerHub // USB hub the device originates from (TODO(karalabe): remove if hotplug lands on Windows)
url *accounts.URL // Textual URL uniquely identifying this wallet
info hid.DeviceInfo // Known USB device infos about the wallet
@ -576,6 +577,11 @@ func (w *ledgerWallet) SignTx(account accounts.Account, tx *types.Transaction, c
<-w.commsLock
defer func() { w.commsLock <- struct{}{} }()
// Ensure the device isn't screwed with while user confirmation is pending
// TODO(karalabe): remove if hotplug lands on Windows
w.hub.commsLock.RLock()
defer w.hub.commsLock.RUnlock()
return w.ledgerSign(path, account.Address, tx, chainID)
}