fix: avoid imported wallet account deletion while converting it to keycard account (#2827)

- imported wallet accounts via seed phrase or private key are not deleted anymore
when migrating any of those key pairs to a keycard
This commit is contained in:
saledjenic 2022-08-31 18:11:42 +02:00 committed by GitHub
parent 6376ad6e2d
commit 2e51450393
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 12 deletions

View file

@ -699,6 +699,9 @@ func TestConvertAccount(t *testing.T) {
err = backend.ensureAppDBOpened(keycardAccount, keycardPassword)
require.NoError(t, err)
b := NewGethStatusBackend()
require.NoError(t, b.OpenAccounts())
}
func copyFile(srcFolder string, dstFolder string, fileName string, t *testing.T) {

View file

@ -576,23 +576,18 @@ func (b *GethStatusBackend) ConvertToKeycardAccount(keyStoreDir string, account
return err
}
err = accountDB.DeleteSeedAndKeyAccounts()
if err != nil {
return err
}
dbPath := filepath.Join(b.rootDataDir, fmt.Sprintf("%s.db", account.KeyUID))
err = appdatabase.ChangeDatabasePassword(dbPath, password, newPassword)
if err != nil {
return err
}
err = b.closeAppDB()
if err != nil {
return err
}
return os.RemoveAll(keyStoreDir)
err = os.RemoveAll(keyStoreDir)
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 {