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.
This commit is contained in:
parent
cb3343ae15
commit
6d7b545acb
2 changed files with 10 additions and 10 deletions
|
@ -508,7 +508,7 @@ type scriptAddress struct {
|
||||||
account uint32
|
account uint32
|
||||||
address *btcutil.AddressScriptHash
|
address *btcutil.AddressScriptHash
|
||||||
scriptEncrypted []byte
|
scriptEncrypted []byte
|
||||||
scriptCT []byte
|
scriptClearText []byte
|
||||||
scriptMutex sync.Mutex
|
scriptMutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ func (a *scriptAddress) unlock(key EncryptorDecryptor) ([]byte, error) {
|
||||||
a.scriptMutex.Lock()
|
a.scriptMutex.Lock()
|
||||||
defer a.scriptMutex.Unlock()
|
defer a.scriptMutex.Unlock()
|
||||||
|
|
||||||
if len(a.scriptCT) == 0 {
|
if len(a.scriptClearText) == 0 {
|
||||||
script, err := key.Decrypt(a.scriptEncrypted)
|
script, err := key.Decrypt(a.scriptEncrypted)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
str := fmt.Sprintf("failed to decrypt script for %s",
|
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)
|
return nil, managerError(ErrCrypto, str, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.scriptCT = script
|
a.scriptClearText = script
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptCopy := make([]byte, len(a.scriptCT))
|
scriptCopy := make([]byte, len(a.scriptClearText))
|
||||||
copy(scriptCopy, a.scriptCT)
|
copy(scriptCopy, a.scriptClearText)
|
||||||
return scriptCopy, nil
|
return scriptCopy, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// lock zeroes the associated clear text private key.
|
// lock zeroes the associated clear text script.
|
||||||
func (a *scriptAddress) lock() {
|
func (a *scriptAddress) lock() {
|
||||||
// Zero and nil the clear text script associated with this address.
|
// Zero and nil the clear text script associated with this address.
|
||||||
a.scriptMutex.Lock()
|
a.scriptMutex.Lock()
|
||||||
zero.Bytes(a.scriptCT)
|
zero.Bytes(a.scriptClearText)
|
||||||
a.scriptCT = nil
|
a.scriptClearText = nil
|
||||||
a.scriptMutex.Unlock()
|
a.scriptMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2114,8 +2114,8 @@ func (s *ScopedKeyManager) ImportScript(ns walletdb.ReadWriteBucket,
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !s.rootManager.WatchOnly() {
|
if !s.rootManager.WatchOnly() {
|
||||||
scriptAddr.scriptCT = make([]byte, len(script))
|
scriptAddr.scriptClearText = make([]byte, len(script))
|
||||||
copy(scriptAddr.scriptCT, script)
|
copy(scriptAddr.scriptClearText, script)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new managed address to the cache of recent addresses and
|
// Add the new managed address to the cache of recent addresses and
|
||||||
|
|
Loading…
Reference in a new issue