Skip to content

Commit

Permalink
Merge PR: add uuid in case of duplicate file names (#928)
Browse files Browse the repository at this point in the history
* add uuid in case of duplicate file names

* add uuid in case of duplicate file names
  • Loading branch information
Ray Green authored Aug 1, 2021
1 parent 740a645 commit 2b86cb2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/rpc/namespaces/personal/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"time"

"github.com/google/uuid"
"github.com/tendermint/tendermint/libs/log"

"github.com/cosmos/cosmos-sdk/crypto/keys"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2b86cb2

Please sign in to comment.