Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/account/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ func ImportKeyStore(keyPath, name, passphrase string) (string, error) {
if hasAddress {
return "", fmt.Errorf("address %s already exists in keystore", key.Address.String())
}
// create home dir if it doesn't exist
store.InitConfigDir()
uDir, _ := homedir.Dir()
newPath := filepath.Join(uDir, common.DefaultConfigDirName, common.DefaultConfigAccountAliasesDirName, name, filepath.Base(keyPath))
err = writeToFile(newPath, string(keyJSON))
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/pkg/errors"
)

func init() {
func InitConfigDir() {
uDir, _ := homedir.Dir()
tronCTLDir := path.Join(uDir, c.DefaultConfigDirName, c.DefaultConfigAccountAliasesDirName)
if _, err := os.Stat(tronCTLDir); os.IsNotExist(err) {
Expand Down