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) err = backend.ensureAppDBOpened(keycardAccount, keycardPassword)
require.NoError(t, err) require.NoError(t, err)
b := NewGethStatusBackend()
require.NoError(t, b.OpenAccounts())
} }
func copyFile(srcFolder string, dstFolder string, fileName string, t *testing.T) { 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 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() err = b.closeAppDB()
if err != nil { if err != nil {
return err 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 { func (b *GethStatusBackend) VerifyDatabasePassword(keyUID string, password string) error {