waddrmgr: return err when priv key is requested for watch-only addr

This commit is contained in:
Wilmer Paulino 2021-02-22 16:16:41 -08:00
parent 0b5eca1835
commit 283f914b95
No known key found for this signature in database
GPG key ID: 6DF57B9F9514972F

View file

@ -151,6 +151,12 @@ func (a *managedAddress) unlock(key EncryptorDecryptor) ([]byte, error) {
a.privKeyMutex.Lock()
defer a.privKeyMutex.Unlock()
// If the address belongs to a watch-only account, the encrypted private
// key won't be present, so we'll return an error.
if len(a.privKeyEncrypted) == 0 {
return nil, managerError(ErrWatchingOnly, errWatchingOnly, nil)
}
if len(a.privKeyCT) == 0 {
privKey, err := key.Decrypt(a.privKeyEncrypted)
if err != nil {