From cad0d7f00dce4f5fff4baae03b9328259176c284 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 1 Sep 2022 21:03:37 +0300 Subject: [PATCH] wallet: add some warnings to Decrypt and PrivateKey docs --- pkg/wallet/account.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/wallet/account.go b/pkg/wallet/account.go index 2f5cb59f6..e1a7c30e3 100644 --- a/pkg/wallet/account.go +++ b/pkg/wallet/account.go @@ -150,7 +150,9 @@ func (a *Account) GetVerificationScript() []byte { } // Decrypt decrypts the EncryptedWIF with the given passphrase returning error -// if anything goes wrong. +// if anything goes wrong. After the decryption Account can be used to sign +// things unless it's locked. Don't decrypt the key unless you want to sign +// something and don't forget to call Close after use for maximum safety. func (a *Account) Decrypt(passphrase string, scrypt keys.ScryptParams) error { var err error @@ -176,7 +178,11 @@ func (a *Account) Encrypt(passphrase string, scrypt keys.ScryptParams) error { return nil } -// PrivateKey returns private key corresponding to the account. +// PrivateKey returns private key corresponding to the account if it's unlocked. +// Please be very careful when using it, do not copy its contents and do not +// keep a pointer to it unless you absolutely need to. Most of the time you can +// use other methods (PublicKey, ScriptHash, SignHashable) depending on your +// needs and it'll be safer this way. func (a *Account) PrivateKey() *keys.PrivateKey { return a.privateKey }