@@ -83,6 +83,38 @@ type ImportAccountsConfig struct {
83
83
// values necessary to run the function.
84
84
func ImportAccountsCli (cliCtx * cli.Context ) error {
85
85
w , err := wallet .OpenWalletOrElseCli (cliCtx , func (cliCtx * cli.Context ) (* wallet.Wallet , error ) {
86
+ walletDir , err := prompt .InputDirectory (cliCtx , prompt .WalletDirPromptText , flags .WalletDirFlag )
87
+ if err != nil {
88
+ return nil , err
89
+ }
90
+ exists , err := wallet .Exists (walletDir )
91
+ if err != nil {
92
+ return nil , errors .Wrap (err , wallet .CheckExistsErrMsg )
93
+ }
94
+ if exists {
95
+ isValid , err := wallet .IsValid (walletDir )
96
+ if err != nil {
97
+ return nil , errors .Wrap (err , wallet .CheckValidityErrMsg )
98
+ }
99
+ if ! isValid {
100
+ return nil , errors .New (wallet .InvalidWalletErrMsg )
101
+ }
102
+ walletPassword , err := wallet .InputPassword (
103
+ cliCtx ,
104
+ flags .WalletPasswordFileFlag ,
105
+ wallet .PasswordPromptText ,
106
+ false , /* Do not confirm password */
107
+ wallet .ValidateExistingPass ,
108
+ )
109
+ if err != nil {
110
+ return nil , err
111
+ }
112
+ return wallet .OpenWallet (cliCtx .Context , & wallet.Config {
113
+ WalletDir : walletDir ,
114
+ WalletPassword : walletPassword ,
115
+ })
116
+ }
117
+
86
118
cfg , err := extractWalletCreationConfigFromCli (cliCtx , keymanager .Imported )
87
119
if err != nil {
88
120
return nil , err
0 commit comments