fix: deleting derived from address keystore file applied to all keypairs being migrated instead to a profile keypair only
This commit is contained in:
parent
96532f97c4
commit
c8ef2c1a7f
|
@ -647,11 +647,6 @@ func (b *GethStatusBackend) ConvertToKeycardAccount(account multiaccounts.Accoun
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
masterAddress, err := accountDB.GetMasterAddress()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
dappsAddress, err := accountDB.GetDappsAddress()
|
dappsAddress, err := accountDB.GetDappsAddress()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -678,8 +673,6 @@ func (b *GethStatusBackend) ConvertToKeycardAccount(account multiaccounts.Accoun
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to delete all accounts for the keypair which is being migrated
|
// We need to delete all accounts for the keypair which is being migrated
|
||||||
// no need to check for the error below cause if this action fails from
|
|
||||||
// whichever reason the account is still successfully migrated
|
|
||||||
for _, acc := range knownAccounts {
|
for _, acc := range knownAccounts {
|
||||||
if account.KeyUID == acc.KeyUID {
|
if account.KeyUID == acc.KeyUID {
|
||||||
err = b.tryToDeleteAccount(acc.Address, password, newPassword)
|
err = b.tryToDeleteAccount(acc.Address, password, newPassword)
|
||||||
|
@ -689,11 +682,6 @@ func (b *GethStatusBackend) ConvertToKeycardAccount(account multiaccounts.Accoun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = b.tryToDeleteAccount(masterAddress, password, newPassword)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = b.tryToDeleteAccount(dappsAddress, password, newPassword)
|
err = b.tryToDeleteAccount(dappsAddress, password, newPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -243,6 +243,19 @@ func (api *API) VerifyPassword(password string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) AddMigratedKeyPairOrAddAccountsIfKeyPairIsAdded(ctx context.Context, kcUID string, kpName string, keyUID string, accountAddresses []string, password string) error {
|
func (api *API) AddMigratedKeyPairOrAddAccountsIfKeyPairIsAdded(ctx context.Context, kcUID string, kpName string, keyUID string, accountAddresses []string, password string) error {
|
||||||
|
if len(accountAddresses) == 0 {
|
||||||
|
return errors.New("cannot migrate a keypair without any address")
|
||||||
|
}
|
||||||
|
|
||||||
|
acc, err := api.db.GetAccountByAddress(types.Address(common.HexToAddress(accountAddresses[0])))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(acc.DerivedFrom) == 0 {
|
||||||
|
return errors.New("an account being migrated doesn't contain `derived_from` field set")
|
||||||
|
}
|
||||||
|
|
||||||
kp := keypairs.KeyPair{
|
kp := keypairs.KeyPair{
|
||||||
KeycardUID: kcUID,
|
KeycardUID: kcUID,
|
||||||
KeycardName: kpName,
|
KeycardName: kpName,
|
||||||
|
@ -267,7 +280,13 @@ func (api *API) AddMigratedKeyPairOrAddAccountsIfKeyPairIsAdded(ctx context.Cont
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = api.manager.DeleteAccount(types.Address(common.HexToAddress(acc.DerivedFrom)), password)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue