delete imported key
This commit is contained in:
parent
f6dc6f752a
commit
bc63fa606e
|
@ -8,6 +8,7 @@ import (
|
|||
"math/big"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -203,6 +204,29 @@ func (b *GethStatusBackend) DeleteMulticcount(keyUID string, keyStoreDir string)
|
|||
return os.RemoveAll(keyStoreDir)
|
||||
}
|
||||
|
||||
func (b *GethStatusBackend) DeleteImportedKey(address, password, keyStoreDir string) error {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
err := filepath.Walk(keyStoreDir, func(path string, fileInfo os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if strings.Contains(fileInfo.Name(), address) {
|
||||
_, err := b.accountManager.VerifyAccountPassword(keyStoreDir, "0x"+address, password)
|
||||
if err != nil {
|
||||
b.log.Error("failed to verify account", "account", address, "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return os.Remove(path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *GethStatusBackend) ensureAppDBOpened(account multiaccounts.Account, password string) (err error) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
|
|
@ -262,6 +262,16 @@ func DeleteMultiaccount(keyUID, keyStoreDir string) string {
|
|||
return makeJSONResponse(nil)
|
||||
}
|
||||
|
||||
// DeleteImportedKey
|
||||
func DeleteImportedKey(address, password, keyStoreDir string) string {
|
||||
err := statusBackend.DeleteImportedKey(address, password, keyStoreDir)
|
||||
if err != nil {
|
||||
return makeJSONResponse(err)
|
||||
}
|
||||
|
||||
return makeJSONResponse(nil)
|
||||
}
|
||||
|
||||
// InitKeystore initialize keystore before doing any operations with keys.
|
||||
func InitKeystore(keydir string) string {
|
||||
err := statusBackend.AccountManager().InitKeystore(keydir)
|
||||
|
|
Loading…
Reference in New Issue