@@ -63,15 +63,15 @@ def generate(alias):
6363 "Add extra entropy for key generation..." ,
6464 hide_input = True ,
6565 )
66- a = EthAccount .create (extra_entropy )
66+ account = EthAccount .create (extra_entropy )
6767 passphrase = click .prompt (
6868 "Create Passphrase" ,
6969 hide_input = True ,
7070 confirmation_prompt = True ,
7171 )
72- path .write_text (json .dumps (EthAccount .encrypt (a .key , passphrase )))
72+ path .write_text (json .dumps (EthAccount .encrypt (account .key , passphrase )))
7373
74- notify ("SUCCESS" , f"A new account '{ a .address } ' has been added with the id '{ alias } '" )
74+ notify ("SUCCESS" , f"A new account '{ account .address } ' has been added with the id '{ alias } '" )
7575
7676
7777# Different name because `import` is a keyword
@@ -84,15 +84,19 @@ def _import(alias):
8484
8585 path = container .data_folder .joinpath (f"{ alias } .json" )
8686 key = click .prompt ("Enter Private Key" , hide_input = True )
87- a = EthAccount .from_key (to_bytes (hexstr = key ))
87+ try :
88+ account = EthAccount .from_key (to_bytes (hexstr = key ))
89+ except Exception as error :
90+ notify ("ERROR" , f"Key can't be imported { error } " )
91+ return
8892 passphrase = click .prompt (
8993 "Create Passphrase" ,
9094 hide_input = True ,
9195 confirmation_prompt = True ,
9296 )
93- path .write_text (json .dumps (EthAccount .encrypt (a .key , passphrase )))
97+ path .write_text (json .dumps (EthAccount .encrypt (account .key , passphrase )))
9498
95- notify ("SUCCESS" , f"A new account '{ a .address } ' has been added with the id '{ alias } '" )
99+ notify ("SUCCESS" , f"A new account '{ account .address } ' has been added with the id '{ alias } '" )
96100
97101
98102@cli .command (short_help = "Change the password of an existing account" )
0 commit comments