From 3cf41c92b5553799083a048269d28a308939b972 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Mon, 18 Mar 2019 15:47:48 -0700 Subject: [PATCH] waddrmgr: use methods that do not hold the manager's lock --- waddrmgr/manager.go | 8 ++++++++ waddrmgr/scoped_manager.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/waddrmgr/manager.go b/waddrmgr/manager.go index 2035a89..85d034d 100644 --- a/waddrmgr/manager.go +++ b/waddrmgr/manager.go @@ -337,6 +337,14 @@ func (m *Manager) WatchOnly() bool { m.mtx.RLock() defer m.mtx.RUnlock() + return m.watchOnly() +} + +// watchOnly returns true if the root manager is in watch only mode, and false +// otherwise. +// +// NOTE: This method requires the Manager's lock to be held. +func (m *Manager) watchOnly() bool { return m.watchingOnly } diff --git a/waddrmgr/scoped_manager.go b/waddrmgr/scoped_manager.go index 0f6ee3a..b9acda3 100644 --- a/waddrmgr/scoped_manager.go +++ b/waddrmgr/scoped_manager.go @@ -842,7 +842,7 @@ func (s *ScopedKeyManager) nextAddresses(ns walletdb.ReadWriteBucket, // Add the new managed address to the list of addresses // that need their private keys derived when the // address manager is next unlocked. - if s.rootManager.IsLocked() && !s.rootManager.WatchOnly() { + if s.rootManager.isLocked() && !s.rootManager.watchOnly() { s.deriveOnUnlock = append(s.deriveOnUnlock, info) } }