wallet: don't permanently store wif in the Account

It's useless and it's just another copy of the key. If really needed, it can
be derived from the key.
This commit is contained in:
Roman Khimov 2022-09-01 15:27:38 +03:00
parent 20224cb39c
commit 0090577446
3 changed files with 1 additions and 9 deletions

View file

@ -24,9 +24,6 @@ type Account struct {
// NEO public key.
publicKey []byte
// Account import file.
wif string
// NEO public address.
Address string `json:"address"`
@ -164,7 +161,6 @@ func (a *Account) Decrypt(passphrase string, scrypt keys.ScryptParams) error {
}
a.publicKey = a.privateKey.PublicKey().Bytes()
a.wif = a.privateKey.WIF()
return nil
}
@ -239,13 +235,11 @@ func (a *Account) ConvertMultisig(m int, pubs []*keys.PublicKey) error {
func NewAccountFromPrivateKey(p *keys.PrivateKey) *Account {
pubKey := p.PublicKey()
pubAddr := p.Address()
wif := p.WIF()
a := &Account{
publicKey: pubKey.Bytes(),
privateKey: p,
Address: pubAddr,
wif: wif,
Contract: &Contract{
Script: pubKey.GetVerificationScript(),
Parameters: getContractParams(1),

View file

@ -215,7 +215,7 @@ func convertPubs(t *testing.T, hexKeys []string) []*keys.PublicKey {
func compareFields(t *testing.T, tk keytestcases.Ktype, acc *Account) {
want, have := tk.Address, acc.Address
require.Equalf(t, want, have, "expected address %s got %s", want, have)
want, have = tk.Wif, acc.wif
want, have = tk.Wif, acc.privateKey.WIF()
require.Equalf(t, want, have, "expected wif %s got %s", want, have)
want, have = tk.PublicKey, hex.EncodeToString(acc.publicKey)
require.Equalf(t, want, have, "expected pub key %s got %s", want, have)

View file

@ -49,7 +49,6 @@ func TestAddAccount(t *testing.T) {
wallet.AddAccount(&Account{
privateKey: nil,
publicKey: nil,
wif: "",
Address: "real",
EncryptedWIF: "",
Label: "",
@ -79,7 +78,6 @@ func TestSave(t *testing.T) {
wallet.AddAccount(&Account{
privateKey: nil,
publicKey: nil,
wif: "",
Address: "",
EncryptedWIF: "",
Label: "",