aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/usbwallet/ledger_wallet.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-03-28 14:16:23 +0800
committerGitHub <noreply@github.com>2017-03-28 14:16:23 +0800
commit225c28716fd353604f73b7cfdab7674b354faab8 (patch)
tree6a2e266c2fbd476ca6b1c451ab129e26141d1a6f /accounts/usbwallet/ledger_wallet.go
parent7419d0c38291236ecc4e54b1a905d5cbcbe065a4 (diff)
parent8ff7e55ab547e6c915a74971126f64b7582f2b77 (diff)
downloadgo-tangerine-225c28716fd353604f73b7cfdab7674b354faab8.tar
go-tangerine-225c28716fd353604f73b7cfdab7674b354faab8.tar.gz
go-tangerine-225c28716fd353604f73b7cfdab7674b354faab8.tar.bz2
go-tangerine-225c28716fd353604f73b7cfdab7674b354faab8.tar.lz
go-tangerine-225c28716fd353604f73b7cfdab7674b354faab8.tar.xz
go-tangerine-225c28716fd353604f73b7cfdab7674b354faab8.tar.zst
go-tangerine-225c28716fd353604f73b7cfdab7674b354faab8.zip
Merge pull request #3801 from karalabe/ledger-linux-confirm
accounts/usbwallet: fix Ledger hidapi/libusb protocol violation
Diffstat (limited to 'accounts/usbwallet/ledger_wallet.go')
-rw-r--r--accounts/usbwallet/ledger_wallet.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/accounts/usbwallet/ledger_wallet.go b/accounts/usbwallet/ledger_wallet.go
index 698e85f48..f1beebb2c 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,17 @@ 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.Lock()
+ w.hub.commsPend++
+ w.hub.commsLock.Unlock()
+
+ defer func() {
+ w.hub.commsLock.Lock()
+ w.hub.commsPend--
+ w.hub.commsLock.Unlock()
+ }()
return w.ledgerSign(path, account.Address, tx, chainID)
}