wallet.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. // Copyright 2017 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. // Package usbwallet implements support for USB hardware wallets.
  17. package usbwallet
  18. import (
  19. "context"
  20. "fmt"
  21. "io"
  22. "math/big"
  23. "sync"
  24. "time"
  25. "github.com/ethereum/go-ethereum"
  26. "github.com/ethereum/go-ethereum/accounts"
  27. "github.com/ethereum/go-ethereum/common"
  28. "github.com/ethereum/go-ethereum/core/types"
  29. "github.com/ethereum/go-ethereum/crypto"
  30. "github.com/ethereum/go-ethereum/log"
  31. "github.com/karalabe/usb"
  32. )
  33. // Maximum time between wallet health checks to detect USB unplugs.
  34. const heartbeatCycle = time.Second
  35. // Minimum time to wait between self derivation attempts, even it the user is
  36. // requesting accounts like crazy.
  37. const selfDeriveThrottling = time.Second
  38. // driver defines the vendor specific functionality hardware wallets instances
  39. // must implement to allow using them with the wallet lifecycle management.
  40. type driver interface {
  41. // Status returns a textual status to aid the user in the current state of the
  42. // wallet. It also returns an error indicating any failure the wallet might have
  43. // encountered.
  44. Status() (string, error)
  45. // Open initializes access to a wallet instance. The passphrase parameter may
  46. // or may not be used by the implementation of a particular wallet instance.
  47. Open(device io.ReadWriter, passphrase string) error
  48. // Close releases any resources held by an open wallet instance.
  49. Close() error
  50. // Heartbeat performs a sanity check against the hardware wallet to see if it
  51. // is still online and healthy.
  52. Heartbeat() error
  53. // Derive sends a derivation request to the USB device and returns the Ethereum
  54. // address located on that path.
  55. Derive(path accounts.DerivationPath) (common.Address, error)
  56. // SignTx sends the transaction to the USB device and waits for the user to confirm
  57. // or deny the transaction.
  58. SignTx(path accounts.DerivationPath, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error)
  59. }
  60. // wallet represents the common functionality shared by all USB hardware
  61. // wallets to prevent reimplementing the same complex maintenance mechanisms
  62. // for different vendors.
  63. type wallet struct {
  64. hub *Hub // USB hub scanning
  65. driver driver // Hardware implementation of the low level device operations
  66. url *accounts.URL // Textual URL uniquely identifying this wallet
  67. info usb.DeviceInfo // Known USB device infos about the wallet
  68. device usb.Device // USB device advertising itself as a hardware wallet
  69. accounts []accounts.Account // List of derive accounts pinned on the hardware wallet
  70. paths map[common.Address]accounts.DerivationPath // Known derivation paths for signing operations
  71. deriveNextPaths []accounts.DerivationPath // Next derivation paths for account auto-discovery (multiple bases supported)
  72. deriveNextAddrs []common.Address // Next derived account addresses for auto-discovery (multiple bases supported)
  73. deriveChain ethereum.ChainStateReader // Blockchain state reader to discover used account with
  74. deriveReq chan chan struct{} // Channel to request a self-derivation on
  75. deriveQuit chan chan error // Channel to terminate the self-deriver with
  76. healthQuit chan chan error
  77. // Locking a hardware wallet is a bit special. Since hardware devices are lower
  78. // performing, any communication with them might take a non negligible amount of
  79. // time. Worse still, waiting for user confirmation can take arbitrarily long,
  80. // but exclusive communication must be upheld during. Locking the entire wallet
  81. // in the mean time however would stall any parts of the system that don't want
  82. // to communicate, just read some state (e.g. list the accounts).
  83. //
  84. // As such, a hardware wallet needs two locks to function correctly. A state
  85. // lock can be used to protect the wallet's software-side internal state, which
  86. // must not be held exclusively during hardware communication. A communication
  87. // lock can be used to achieve exclusive access to the device itself, this one
  88. // however should allow "skipping" waiting for operations that might want to
  89. // use the device, but can live without too (e.g. account self-derivation).
  90. //
  91. // Since we have two locks, it's important to know how to properly use them:
  92. // - Communication requires the `device` to not change, so obtaining the
  93. // commsLock should be done after having a stateLock.
  94. // - Communication must not disable read access to the wallet state, so it
  95. // must only ever hold a *read* lock to stateLock.
  96. commsLock chan struct{} // Mutex (buf=1) for the USB comms without keeping the state locked
  97. stateLock sync.RWMutex // Protects read and write access to the wallet struct fields
  98. log log.Logger // Contextual logger to tag the base with its id
  99. }
  100. // URL implements accounts.Wallet, returning the URL of the USB hardware device.
  101. func (w *wallet) URL() accounts.URL {
  102. return *w.url // Immutable, no need for a lock
  103. }
  104. // Status implements accounts.Wallet, returning a custom status message from the
  105. // underlying vendor-specific hardware wallet implementation.
  106. func (w *wallet) Status() (string, error) {
  107. w.stateLock.RLock() // No device communication, state lock is enough
  108. defer w.stateLock.RUnlock()
  109. status, failure := w.driver.Status()
  110. if w.device == nil {
  111. return "Closed", failure
  112. }
  113. return status, failure
  114. }
  115. // Open implements accounts.Wallet, attempting to open a USB connection to the
  116. // hardware wallet.
  117. func (w *wallet) Open(passphrase string) error {
  118. w.stateLock.Lock() // State lock is enough since there's no connection yet at this point
  119. defer w.stateLock.Unlock()
  120. // If the device was already opened once, refuse to try again
  121. if w.paths != nil {
  122. return accounts.ErrWalletAlreadyOpen
  123. }
  124. // Make sure the actual device connection is done only once
  125. if w.device == nil {
  126. device, err := w.info.Open()
  127. if err != nil {
  128. return err
  129. }
  130. w.device = device
  131. w.commsLock = make(chan struct{}, 1)
  132. w.commsLock <- struct{}{} // Enable lock
  133. }
  134. // Delegate device initialization to the underlying driver
  135. if err := w.driver.Open(w.device, passphrase); err != nil {
  136. return err
  137. }
  138. // Connection successful, start life-cycle management
  139. w.paths = make(map[common.Address]accounts.DerivationPath)
  140. w.deriveReq = make(chan chan struct{})
  141. w.deriveQuit = make(chan chan error)
  142. w.healthQuit = make(chan chan error)
  143. go w.heartbeat()
  144. go w.selfDerive()
  145. // Notify anyone listening for wallet events that a new device is accessible
  146. go w.hub.updateFeed.Send(accounts.WalletEvent{Wallet: w, Kind: accounts.WalletOpened})
  147. return nil
  148. }
  149. // heartbeat is a health check loop for the USB wallets to periodically verify
  150. // whether they are still present or if they malfunctioned.
  151. func (w *wallet) heartbeat() {
  152. w.log.Debug("USB wallet health-check started")
  153. defer w.log.Debug("USB wallet health-check stopped")
  154. // Execute heartbeat checks until termination or error
  155. var (
  156. errc chan error
  157. err error
  158. )
  159. for errc == nil && err == nil {
  160. // Wait until termination is requested or the heartbeat cycle arrives
  161. select {
  162. case errc = <-w.healthQuit:
  163. // Termination requested
  164. continue
  165. case <-time.After(heartbeatCycle):
  166. // Heartbeat time
  167. }
  168. // Execute a tiny data exchange to see responsiveness
  169. w.stateLock.RLock()
  170. if w.device == nil {
  171. // Terminated while waiting for the lock
  172. w.stateLock.RUnlock()
  173. continue
  174. }
  175. <-w.commsLock // Don't lock state while resolving version
  176. err = w.driver.Heartbeat()
  177. w.commsLock <- struct{}{}
  178. w.stateLock.RUnlock()
  179. if err != nil {
  180. w.stateLock.Lock() // Lock state to tear the wallet down
  181. w.close()
  182. w.stateLock.Unlock()
  183. }
  184. // Ignore non hardware related errors
  185. err = nil
  186. }
  187. // In case of error, wait for termination
  188. if err != nil {
  189. w.log.Debug("USB wallet health-check failed", "err", err)
  190. errc = <-w.healthQuit
  191. }
  192. errc <- err
  193. }
  194. // Close implements accounts.Wallet, closing the USB connection to the device.
  195. func (w *wallet) Close() error {
  196. // Ensure the wallet was opened
  197. w.stateLock.RLock()
  198. hQuit, dQuit := w.healthQuit, w.deriveQuit
  199. w.stateLock.RUnlock()
  200. // Terminate the health checks
  201. var herr error
  202. if hQuit != nil {
  203. errc := make(chan error)
  204. hQuit <- errc
  205. herr = <-errc // Save for later, we *must* close the USB
  206. }
  207. // Terminate the self-derivations
  208. var derr error
  209. if dQuit != nil {
  210. errc := make(chan error)
  211. dQuit <- errc
  212. derr = <-errc // Save for later, we *must* close the USB
  213. }
  214. // Terminate the device connection
  215. w.stateLock.Lock()
  216. defer w.stateLock.Unlock()
  217. w.healthQuit = nil
  218. w.deriveQuit = nil
  219. w.deriveReq = nil
  220. if err := w.close(); err != nil {
  221. return err
  222. }
  223. if herr != nil {
  224. return herr
  225. }
  226. return derr
  227. }
  228. // close is the internal wallet closer that terminates the USB connection and
  229. // resets all the fields to their defaults.
  230. //
  231. // Note, close assumes the state lock is held!
  232. func (w *wallet) close() error {
  233. // Allow duplicate closes, especially for health-check failures
  234. if w.device == nil {
  235. return nil
  236. }
  237. // Close the device, clear everything, then return
  238. w.device.Close()
  239. w.device = nil
  240. w.accounts, w.paths = nil, nil
  241. return w.driver.Close()
  242. }
  243. // Accounts implements accounts.Wallet, returning the list of accounts pinned to
  244. // the USB hardware wallet. If self-derivation was enabled, the account list is
  245. // periodically expanded based on current chain state.
  246. func (w *wallet) Accounts() []accounts.Account {
  247. // Attempt self-derivation if it's running
  248. reqc := make(chan struct{}, 1)
  249. select {
  250. case w.deriveReq <- reqc:
  251. // Self-derivation request accepted, wait for it
  252. <-reqc
  253. default:
  254. // Self-derivation offline, throttled or busy, skip
  255. }
  256. // Return whatever account list we ended up with
  257. w.stateLock.RLock()
  258. defer w.stateLock.RUnlock()
  259. cpy := make([]accounts.Account, len(w.accounts))
  260. copy(cpy, w.accounts)
  261. return cpy
  262. }
  263. // selfDerive is an account derivation loop that upon request attempts to find
  264. // new non-zero accounts.
  265. func (w *wallet) selfDerive() {
  266. w.log.Debug("USB wallet self-derivation started")
  267. defer w.log.Debug("USB wallet self-derivation stopped")
  268. // Execute self-derivations until termination or error
  269. var (
  270. reqc chan struct{}
  271. errc chan error
  272. err error
  273. )
  274. for errc == nil && err == nil {
  275. // Wait until either derivation or termination is requested
  276. select {
  277. case errc = <-w.deriveQuit:
  278. // Termination requested
  279. continue
  280. case reqc = <-w.deriveReq:
  281. // Account discovery requested
  282. }
  283. // Derivation needs a chain and device access, skip if either unavailable
  284. w.stateLock.RLock()
  285. if w.device == nil || w.deriveChain == nil {
  286. w.stateLock.RUnlock()
  287. reqc <- struct{}{}
  288. continue
  289. }
  290. select {
  291. case <-w.commsLock:
  292. default:
  293. w.stateLock.RUnlock()
  294. reqc <- struct{}{}
  295. continue
  296. }
  297. // Device lock obtained, derive the next batch of accounts
  298. var (
  299. accs []accounts.Account
  300. paths []accounts.DerivationPath
  301. nextPaths = append([]accounts.DerivationPath{}, w.deriveNextPaths...)
  302. nextAddrs = append([]common.Address{}, w.deriveNextAddrs...)
  303. context = context.Background()
  304. )
  305. for i := 0; i < len(nextAddrs); i++ {
  306. for empty := false; !empty; {
  307. // Retrieve the next derived Ethereum account
  308. if nextAddrs[i] == (common.Address{}) {
  309. if nextAddrs[i], err = w.driver.Derive(nextPaths[i]); err != nil {
  310. w.log.Warn("USB wallet account derivation failed", "err", err)
  311. break
  312. }
  313. }
  314. // Check the account's status against the current chain state
  315. var (
  316. balance *big.Int
  317. nonce uint64
  318. )
  319. balance, err = w.deriveChain.BalanceAt(context, nextAddrs[i], nil)
  320. if err != nil {
  321. w.log.Warn("USB wallet balance retrieval failed", "err", err)
  322. break
  323. }
  324. nonce, err = w.deriveChain.NonceAt(context, nextAddrs[i], nil)
  325. if err != nil {
  326. w.log.Warn("USB wallet nonce retrieval failed", "err", err)
  327. break
  328. }
  329. // We've just self-derived a new account, start tracking it locally
  330. // unless the account was empty.
  331. path := make(accounts.DerivationPath, len(nextPaths[i]))
  332. copy(path[:], nextPaths[i][:])
  333. if balance.Sign() == 0 && nonce == 0 {
  334. empty = true
  335. // If it indeed was empty, make a log output for it anyway. In the case
  336. // of legacy-ledger, the first account on the legacy-path will
  337. // be shown to the user, even if we don't actively track it
  338. if i < len(nextAddrs)-1 {
  339. w.log.Info("Skipping trakcking first account on legacy path, use personal.deriveAccount(<url>,<path>, false) to track",
  340. "path", path, "address", nextAddrs[i])
  341. break
  342. }
  343. }
  344. paths = append(paths, path)
  345. account := accounts.Account{
  346. Address: nextAddrs[i],
  347. URL: accounts.URL{Scheme: w.url.Scheme, Path: fmt.Sprintf("%s/%s", w.url.Path, path)},
  348. }
  349. accs = append(accs, account)
  350. // Display a log message to the user for new (or previously empty accounts)
  351. if _, known := w.paths[nextAddrs[i]]; !known || (!empty && nextAddrs[i] == w.deriveNextAddrs[i]) {
  352. w.log.Info("USB wallet discovered new account", "address", nextAddrs[i], "path", path, "balance", balance, "nonce", nonce)
  353. }
  354. // Fetch the next potential account
  355. if !empty {
  356. nextAddrs[i] = common.Address{}
  357. nextPaths[i][len(nextPaths[i])-1]++
  358. }
  359. }
  360. }
  361. // Self derivation complete, release device lock
  362. w.commsLock <- struct{}{}
  363. w.stateLock.RUnlock()
  364. // Insert any accounts successfully derived
  365. w.stateLock.Lock()
  366. for i := 0; i < len(accs); i++ {
  367. if _, ok := w.paths[accs[i].Address]; !ok {
  368. w.accounts = append(w.accounts, accs[i])
  369. w.paths[accs[i].Address] = paths[i]
  370. }
  371. }
  372. // Shift the self-derivation forward
  373. // TODO(karalabe): don't overwrite changes from wallet.SelfDerive
  374. w.deriveNextAddrs = nextAddrs
  375. w.deriveNextPaths = nextPaths
  376. w.stateLock.Unlock()
  377. // Notify the user of termination and loop after a bit of time (to avoid trashing)
  378. reqc <- struct{}{}
  379. if err == nil {
  380. select {
  381. case errc = <-w.deriveQuit:
  382. // Termination requested, abort
  383. case <-time.After(selfDeriveThrottling):
  384. // Waited enough, willing to self-derive again
  385. }
  386. }
  387. }
  388. // In case of error, wait for termination
  389. if err != nil {
  390. w.log.Debug("USB wallet self-derivation failed", "err", err)
  391. errc = <-w.deriveQuit
  392. }
  393. errc <- err
  394. }
  395. // Contains implements accounts.Wallet, returning whether a particular account is
  396. // or is not pinned into this wallet instance. Although we could attempt to resolve
  397. // unpinned accounts, that would be an non-negligible hardware operation.
  398. func (w *wallet) Contains(account accounts.Account) bool {
  399. w.stateLock.RLock()
  400. defer w.stateLock.RUnlock()
  401. _, exists := w.paths[account.Address]
  402. return exists
  403. }
  404. // Derive implements accounts.Wallet, deriving a new account at the specific
  405. // derivation path. If pin is set to true, the account will be added to the list
  406. // of tracked accounts.
  407. func (w *wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Account, error) {
  408. // Try to derive the actual account and update its URL if successful
  409. w.stateLock.RLock() // Avoid device disappearing during derivation
  410. if w.device == nil {
  411. w.stateLock.RUnlock()
  412. return accounts.Account{}, accounts.ErrWalletClosed
  413. }
  414. <-w.commsLock // Avoid concurrent hardware access
  415. address, err := w.driver.Derive(path)
  416. w.commsLock <- struct{}{}
  417. w.stateLock.RUnlock()
  418. // If an error occurred or no pinning was requested, return
  419. if err != nil {
  420. return accounts.Account{}, err
  421. }
  422. account := accounts.Account{
  423. Address: address,
  424. URL: accounts.URL{Scheme: w.url.Scheme, Path: fmt.Sprintf("%s/%s", w.url.Path, path)},
  425. }
  426. if !pin {
  427. return account, nil
  428. }
  429. // Pinning needs to modify the state
  430. w.stateLock.Lock()
  431. defer w.stateLock.Unlock()
  432. if _, ok := w.paths[address]; !ok {
  433. w.accounts = append(w.accounts, account)
  434. w.paths[address] = make(accounts.DerivationPath, len(path))
  435. copy(w.paths[address], path)
  436. }
  437. return account, nil
  438. }
  439. // SelfDerive sets a base account derivation path from which the wallet attempts
  440. // to discover non zero accounts and automatically add them to list of tracked
  441. // accounts.
  442. //
  443. // Note, self derivation will increment the last component of the specified path
  444. // opposed to decending into a child path to allow discovering accounts starting
  445. // from non zero components.
  446. //
  447. // Some hardware wallets switched derivation paths through their evolution, so
  448. // this method supports providing multiple bases to discover old user accounts
  449. // too. Only the last base will be used to derive the next empty account.
  450. //
  451. // You can disable automatic account discovery by calling SelfDerive with a nil
  452. // chain state reader.
  453. func (w *wallet) SelfDerive(bases []accounts.DerivationPath, chain ethereum.ChainStateReader) {
  454. w.stateLock.Lock()
  455. defer w.stateLock.Unlock()
  456. w.deriveNextPaths = make([]accounts.DerivationPath, len(bases))
  457. for i, base := range bases {
  458. w.deriveNextPaths[i] = make(accounts.DerivationPath, len(base))
  459. copy(w.deriveNextPaths[i][:], base[:])
  460. }
  461. w.deriveNextAddrs = make([]common.Address, len(bases))
  462. w.deriveChain = chain
  463. }
  464. // signHash implements accounts.Wallet, however signing arbitrary data is not
  465. // supported for hardware wallets, so this method will always return an error.
  466. func (w *wallet) signHash(account accounts.Account, hash []byte) ([]byte, error) {
  467. return nil, accounts.ErrNotSupported
  468. }
  469. // SignData signs keccak256(data). The mimetype parameter describes the type of data being signed
  470. func (w *wallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error) {
  471. return w.signHash(account, crypto.Keccak256(data))
  472. }
  473. // SignDataWithPassphrase implements accounts.Wallet, attempting to sign the given
  474. // data with the given account using passphrase as extra authentication.
  475. // Since USB wallets don't rely on passphrases, these are silently ignored.
  476. func (w *wallet) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error) {
  477. return w.SignData(account, mimeType, data)
  478. }
  479. func (w *wallet) SignText(account accounts.Account, text []byte) ([]byte, error) {
  480. return w.signHash(account, accounts.TextHash(text))
  481. }
  482. // SignTx implements accounts.Wallet. It sends the transaction over to the Ledger
  483. // wallet to request a confirmation from the user. It returns either the signed
  484. // transaction or a failure if the user denied the transaction.
  485. //
  486. // Note, if the version of the Ethereum application running on the Ledger wallet is
  487. // too old to sign EIP-155 transactions, but such is requested nonetheless, an error
  488. // will be returned opposed to silently signing in Homestead mode.
  489. func (w *wallet) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
  490. w.stateLock.RLock() // Comms have own mutex, this is for the state fields
  491. defer w.stateLock.RUnlock()
  492. // If the wallet is closed, abort
  493. if w.device == nil {
  494. return nil, accounts.ErrWalletClosed
  495. }
  496. // Make sure the requested account is contained within
  497. path, ok := w.paths[account.Address]
  498. if !ok {
  499. return nil, accounts.ErrUnknownAccount
  500. }
  501. // All infos gathered and metadata checks out, request signing
  502. <-w.commsLock
  503. defer func() { w.commsLock <- struct{}{} }()
  504. // Ensure the device isn't screwed with while user confirmation is pending
  505. // TODO(karalabe): remove if hotplug lands on Windows
  506. w.hub.commsLock.Lock()
  507. w.hub.commsPend++
  508. w.hub.commsLock.Unlock()
  509. defer func() {
  510. w.hub.commsLock.Lock()
  511. w.hub.commsPend--
  512. w.hub.commsLock.Unlock()
  513. }()
  514. // Sign the transaction and verify the sender to avoid hardware fault surprises
  515. sender, signed, err := w.driver.SignTx(path, tx, chainID)
  516. if err != nil {
  517. return nil, err
  518. }
  519. if sender != account.Address {
  520. return nil, fmt.Errorf("signer mismatch: expected %s, got %s", account.Address.Hex(), sender.Hex())
  521. }
  522. return signed, nil
  523. }
  524. // SignHashWithPassphrase implements accounts.Wallet, however signing arbitrary
  525. // data is not supported for Ledger wallets, so this method will always return
  526. // an error.
  527. func (w *wallet) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
  528. return w.SignText(account, accounts.TextHash(text))
  529. }
  530. // SignTxWithPassphrase implements accounts.Wallet, attempting to sign the given
  531. // transaction with the given account using passphrase as extra authentication.
  532. // Since USB wallets don't rely on passphrases, these are silently ignored.
  533. func (w *wallet) SignTxWithPassphrase(account accounts.Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
  534. return w.SignTx(account, tx, chainID)
  535. }