From 2b86cb20bf6ad7e976118a490968c31aad5f0e97 Mon Sep 17 00:00:00 2001 From: Ray Green Date: Sun, 1 Aug 2021 09:51:43 +0800 Subject: [PATCH] Merge PR: add uuid in case of duplicate file names (#928) * add uuid in case of duplicate file names * add uuid in case of duplicate file names --- app/rpc/namespaces/personal/api.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/rpc/namespaces/personal/api.go b/app/rpc/namespaces/personal/api.go index e9f36ee844..56bc19f86a 100644 --- a/app/rpc/namespaces/personal/api.go +++ b/app/rpc/namespaces/personal/api.go @@ -7,6 +7,7 @@ import ( "os" "time" + "github.com/google/uuid" "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/crypto/keys" @@ -71,7 +72,7 @@ func (api *PrivateAccountAPI) ImportRawKey(privkey, password string) (common.Add return common.BytesToAddress(info.GetAddress().Bytes()), nil } } - privKeyName := fmt.Sprintf("personal_%d", len(list)) + privKeyName := fmt.Sprintf("personal_%s", uuid.New()) armor := mintkey.EncryptArmorPrivKey(privKey, password, ethsecp256k1.KeyType) if err := api.ethAPI.ClientCtx().Keybase.ImportPrivKey(privKeyName, armor, password); err != nil { @@ -132,7 +133,7 @@ func (api *PrivateAccountAPI) LockAccount(address common.Address) bool { func (api *PrivateAccountAPI) NewAccount(password string) (common.Address, error) { api.logger.Debug("personal_newAccount") - name := "key_" + time.Now().UTC().Format(time.RFC3339) + name := "key_" + time.Now().UTC().Format(time.RFC3339) + uuid.New().String() info, _, err := api.ethAPI.ClientCtx().Keybase.CreateMnemonic(name, keys.English, password, hd.EthSecp256k1, "") if err != nil { return common.Address{}, err