@@ -301,7 +301,11 @@ func accountUpdate(ctx *cli.Context) error {
301301 utils .Fatalf ("No accounts specified to update" )
302302 }
303303 stack , _ := makeConfigNode (ctx )
304- ks := stack .AccountManager ().Backends (keystore .KeyStoreType )[0 ].(* keystore.KeyStore )
304+ backends := stack .AccountManager ().Backends (keystore .KeyStoreType )
305+ if len (backends ) == 0 {
306+ utils .Fatalf ("Keystore is not available" )
307+ }
308+ ks := backends [0 ].(* keystore.KeyStore )
305309
306310 for _ , addr := range ctx .Args ().Slice () {
307311 account , oldPassword := unlockAccount (ks , addr , 0 , nil )
@@ -326,7 +330,11 @@ func importWallet(ctx *cli.Context) error {
326330 stack , _ := makeConfigNode (ctx )
327331 passphrase := utils .GetPassPhraseWithList ("" , false , 0 , utils .MakePasswordList (ctx ))
328332
329- ks := stack .AccountManager ().Backends (keystore .KeyStoreType )[0 ].(* keystore.KeyStore )
333+ backends := stack .AccountManager ().Backends (keystore .KeyStoreType )
334+ if len (backends ) == 0 {
335+ utils .Fatalf ("Keystore is not available" )
336+ }
337+ ks := backends [0 ].(* keystore.KeyStore )
330338 acct , err := ks .ImportPreSaleKey (keyJSON , passphrase )
331339 if err != nil {
332340 utils .Fatalf ("%v" , err )
@@ -347,7 +355,11 @@ func accountImport(ctx *cli.Context) error {
347355 stack , _ := makeConfigNode (ctx )
348356 passphrase := utils .GetPassPhraseWithList ("Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 , utils .MakePasswordList (ctx ))
349357
350- ks := stack .AccountManager ().Backends (keystore .KeyStoreType )[0 ].(* keystore.KeyStore )
358+ backends := stack .AccountManager ().Backends (keystore .KeyStoreType )
359+ if len (backends ) == 0 {
360+ utils .Fatalf ("Keystore is not available" )
361+ }
362+ ks := backends [0 ].(* keystore.KeyStore )
351363 acct , err := ks .ImportECDSA (key , passphrase )
352364 if err != nil {
353365 utils .Fatalf ("Could not create the account: %v" , err )
0 commit comments