wallet: set WIF and public key on account decrypt

They are set during account creation and open+decrypt is
expected to put account in the same state.
This commit is contained in:
Evgenii Stratonikov 2020-02-20 13:06:10 +03:00
parent d837eb3761
commit ad6fa2aea9

View file

@ -122,9 +122,16 @@ func (a *Account) Decrypt(passphrase string) error {
return errors.New("no encrypted wif in the account") return errors.New("no encrypted wif in the account")
} }
a.privateKey, err = keys.NEP2Decrypt(a.EncryptedWIF, passphrase) a.privateKey, err = keys.NEP2Decrypt(a.EncryptedWIF, passphrase)
if err != nil {
return err return err
} }
a.publicKey = a.privateKey.PublicKey().Bytes()
a.wif = a.privateKey.WIF()
return nil
}
// Encrypt encrypts the wallet's PrivateKey with the given passphrase // Encrypt encrypts the wallet's PrivateKey with the given passphrase
// under the NEP-2 standard. // under the NEP-2 standard.
func (a *Account) Encrypt(passphrase string) error { func (a *Account) Encrypt(passphrase string) error {