fix(keycard): convert to keycard action removes keystore and doesn't change the pass properly fixed
This commit is contained in:
parent
5668bbaa8e
commit
d89c0c8d9e
|
@ -690,12 +690,13 @@ func TestConvertAccount(t *testing.T) {
|
||||||
KeycardPairing: "pairing",
|
KeycardPairing: "pairing",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, keyStoreErrBefore := os.Stat(keyStoreDir)
|
||||||
|
|
||||||
err = backend.ConvertToKeycardAccount(keyStoreDir, keycardAccount, keycardSettings, password, keycardPassword)
|
err = backend.ConvertToKeycardAccount(keyStoreDir, keycardAccount, keycardSettings, password, keycardPassword)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = os.Stat(keyStoreDir)
|
_, keyStoreErrAfter := os.Stat(keyStoreDir)
|
||||||
require.Error(t, err)
|
require.True(t, keyStoreErrBefore == keyStoreErrAfter)
|
||||||
require.True(t, os.IsNotExist(err))
|
|
||||||
|
|
||||||
err = backend.ensureAppDBOpened(keycardAccount, keycardPassword)
|
err = backend.ensureAppDBOpened(keycardAccount, keycardPassword)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -529,17 +529,22 @@ func (b *GethStatusBackend) ImportUnencryptedDatabase(acc multiaccounts.Account,
|
||||||
func (b *GethStatusBackend) ChangeDatabasePassword(keyUID string, password string, newPassword string) error {
|
func (b *GethStatusBackend) ChangeDatabasePassword(keyUID string, password string, newPassword string) error {
|
||||||
dbPath := filepath.Join(b.rootDataDir, fmt.Sprintf("%s.db", keyUID))
|
dbPath := filepath.Join(b.rootDataDir, fmt.Sprintf("%s.db", keyUID))
|
||||||
config := b.StatusNode().Config()
|
config := b.StatusNode().Config()
|
||||||
keyDir := config.KeyStoreDir
|
|
||||||
|
|
||||||
err := b.accountManager.ReEncryptKeyStoreDir(keyDir, password, newPassword)
|
if config != nil {
|
||||||
if err != nil {
|
keyDir := config.KeyStoreDir
|
||||||
return fmt.Errorf("ReEncryptKeyStoreDir error: %v", err)
|
err := b.accountManager.ReEncryptKeyStoreDir(keyDir, password, newPassword)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("ReEncryptKeyStoreDir error: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = appdatabase.ChangeDatabasePassword(dbPath, password, newPassword)
|
err := appdatabase.ChangeDatabasePassword(dbPath, password, newPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// couldn't change db password so undo keystore changes to mainitain consistency
|
if config != nil {
|
||||||
_ = b.accountManager.ReEncryptKeyStoreDir(keyDir, newPassword, password)
|
keyDir := config.KeyStoreDir
|
||||||
|
// couldn't change db password so undo keystore changes to mainitain consistency
|
||||||
|
_ = b.accountManager.ReEncryptKeyStoreDir(keyDir, newPassword, password)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -585,13 +590,7 @@ func (b *GethStatusBackend) ConvertToKeycardAccount(keyStoreDir string, account
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.RemoveAll(keyStoreDir)
|
return b.ChangeDatabasePassword(account.KeyUID, password, newPassword)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
dbPath := filepath.Join(b.rootDataDir, fmt.Sprintf("%s.db", account.KeyUID))
|
|
||||||
return appdatabase.ChangeDatabasePassword(dbPath, password, newPassword)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *GethStatusBackend) VerifyDatabasePassword(keyUID string, password string) error {
|
func (b *GethStatusBackend) VerifyDatabasePassword(keyUID string, password string) error {
|
||||||
|
|
Loading…
Reference in New Issue