Skip to content

Commit

Permalink
accounts: properly close managed wallets when closing manager (ethere…
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Jan 22, 2025
1 parent b450763 commit 3f2835e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions accounts/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func NewManager(config *Config, backends ...Backend) *Manager {

// Close terminates the account manager's internal notification processes.
func (am *Manager) Close() error {
for _, w := range am.wallets {
w.Close()
}
errc := make(chan error)
am.quit <- errc
return <-errc
Expand Down
4 changes: 4 additions & 0 deletions accounts/usbwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,10 @@ func (w *wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Accoun
w.stateLock.Lock()
defer w.stateLock.Unlock()

if w.device == nil {
return accounts.Account{}, accounts.ErrWalletClosed
}

if _, ok := w.paths[address]; !ok {
w.accounts = append(w.accounts, account)
w.paths[address] = make(accounts.DerivationPath, len(path))
Expand Down

0 comments on commit 3f2835e

Please sign in to comment.