aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/usbwallet/ledger_wallet.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-03-20 19:35:56 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-03-23 22:51:04 +0800
commit26da6daaa96a6d45187e5a2ff519676e9e772cb2 (patch)
treefe6ae815a4ccd83a7ae24a03e8ab34f7a4f67304 /accounts/usbwallet/ledger_wallet.go
parent11e7a712f469fb24ddb88ecebcefab6ed8880eb8 (diff)
downloaddexon-26da6daaa96a6d45187e5a2ff519676e9e772cb2.tar.gz
dexon-26da6daaa96a6d45187e5a2ff519676e9e772cb2.tar.zst
dexon-26da6daaa96a6d45187e5a2ff519676e9e772cb2.zip
accounts/usbwallet: fix Ledger hidapi/libusb protocol violation
Diffstat (limited to 'accounts/usbwallet/ledger_wallet.go')
-rw-r--r--accounts/usbwallet/ledger_wallet.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/accounts/usbwallet/ledger_wallet.go b/accounts/usbwallet/ledger_wallet.go
index 698e85f48..97434ed3b 100644
--- a/accounts/usbwallet/ledger_wallet.go
+++ b/accounts/usbwallet/ledger_wallet.go
@@ -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)
}