From 6d7b545acba74b083edf40616e16e8d975b65e31 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 2 Dec 2021 15:10:21 +0100 Subject: [PATCH] waddrmgr: rename ambiguous scriptCT to scriptClearText Since CT can mean both Cipher Text as well as Clear Text, the variable name scriptCT lead to confusion about its meaning. We rename it to make it more clear how it's used. --- waddrmgr/address.go | 16 ++++++++-------- waddrmgr/scoped_manager.go | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/waddrmgr/address.go b/waddrmgr/address.go index 45df8e0..a162308 100644 --- a/waddrmgr/address.go +++ b/waddrmgr/address.go @@ -508,7 +508,7 @@ type scriptAddress struct { account uint32 address *btcutil.AddressScriptHash scriptEncrypted []byte - scriptCT []byte + scriptClearText []byte scriptMutex sync.Mutex } @@ -524,7 +524,7 @@ func (a *scriptAddress) unlock(key EncryptorDecryptor) ([]byte, error) { a.scriptMutex.Lock() defer a.scriptMutex.Unlock() - if len(a.scriptCT) == 0 { + if len(a.scriptClearText) == 0 { script, err := key.Decrypt(a.scriptEncrypted) if err != nil { str := fmt.Sprintf("failed to decrypt script for %s", @@ -532,20 +532,20 @@ func (a *scriptAddress) unlock(key EncryptorDecryptor) ([]byte, error) { return nil, managerError(ErrCrypto, str, err) } - a.scriptCT = script + a.scriptClearText = script } - scriptCopy := make([]byte, len(a.scriptCT)) - copy(scriptCopy, a.scriptCT) + scriptCopy := make([]byte, len(a.scriptClearText)) + copy(scriptCopy, a.scriptClearText) return scriptCopy, nil } -// lock zeroes the associated clear text private key. +// lock zeroes the associated clear text script. func (a *scriptAddress) lock() { // Zero and nil the clear text script associated with this address. a.scriptMutex.Lock() - zero.Bytes(a.scriptCT) - a.scriptCT = nil + zero.Bytes(a.scriptClearText) + a.scriptClearText = nil a.scriptMutex.Unlock() } diff --git a/waddrmgr/scoped_manager.go b/waddrmgr/scoped_manager.go index db188d9..897b4de 100644 --- a/waddrmgr/scoped_manager.go +++ b/waddrmgr/scoped_manager.go @@ -2114,8 +2114,8 @@ func (s *ScopedKeyManager) ImportScript(ns walletdb.ReadWriteBucket, return nil, err } if !s.rootManager.WatchOnly() { - scriptAddr.scriptCT = make([]byte, len(script)) - copy(scriptAddr.scriptCT, script) + scriptAddr.scriptClearText = make([]byte, len(script)) + copy(scriptAddr.scriptClearText, script) } // Add the new managed address to the cache of recent addresses and