Skip to content

Commit d3452a2

Browse files
authored
accounts: properly close managed wallets when closing manager (#28710)
1 parent 7124057 commit d3452a2

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

accounts/manager.go

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ func NewManager(config *Config, backends ...Backend) *Manager {
9898

9999
// Close terminates the account manager's internal notification processes.
100100
func (am *Manager) Close() error {
101+
for _, w := range am.wallets {
102+
w.Close()
103+
}
101104
errc := make(chan error)
102105
am.quit <- errc
103106
return <-errc

accounts/usbwallet/wallet.go

+4
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,10 @@ func (w *wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Accoun
483483
w.stateLock.Lock()
484484
defer w.stateLock.Unlock()
485485

486+
if w.device == nil {
487+
return accounts.Account{}, accounts.ErrWalletClosed
488+
}
489+
486490
if _, ok := w.paths[address]; !ok {
487491
w.accounts = append(w.accounts, account)
488492
w.paths[address] = make(accounts.DerivationPath, len(path))

cmd/clef/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ func signer(c *cli.Context) error {
704704
log.Info("Starting signer", "chainid", chainId, "keystore", ksLoc,
705705
"light-kdf", lightKdf, "advanced", advanced)
706706
am := core.StartClefAccountManager(ksLoc, nousb, lightKdf, scpath)
707+
defer am.Close()
707708
apiImpl := core.NewSignerAPI(am, chainId, nousb, ui, db, advanced, pwStorage)
708709

709710
// Establish the bidirectional communication, by creating a new UI backend and registering

0 commit comments

Comments
 (0)