@@ -188,34 +188,15 @@ nodes.
188188 }
189189)
190190
191- // makeAccountManager creates an account manager with backends
192- func makeAccountManager (ctx * cli.Context ) * accounts.Manager {
193- cfg := loadBaseConfig (ctx )
194- am := accounts .NewManager (& accounts.Config {InsecureUnlockAllowed : cfg .Node .InsecureUnlockAllowed })
195- keydir , isEphemeral , err := cfg .Node .GetKeyStoreDir ()
196- if err != nil {
197- utils .Fatalf ("Failed to get the keystore directory: %v" , err )
198- }
199- if isEphemeral {
200- utils .Fatalf ("Can't use ephemeral directory as keystore path" )
201- }
202-
203- if err := setAccountManagerBackends (& cfg .Node , am , keydir ); err != nil {
204- utils .Fatalf ("Failed to set account manager backends: %v" , err )
205- }
206- return am
207- }
208-
209191func accountList (ctx * cli.Context ) error {
210- am := makeAccountManager (ctx )
192+ stack , _ := makeConfigNode (ctx )
211193 var index int
212- for _ , wallet := range am .Wallets () {
194+ for _ , wallet := range stack . AccountManager () .Wallets () {
213195 for _ , account := range wallet .Accounts () {
214196 fmt .Printf ("Account #%d: {%x} %s\n " , index , account .Address , & account .URL )
215197 index ++
216198 }
217199 }
218-
219200 return nil
220201}
221202
@@ -277,13 +258,17 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr
277258
278259// accountCreate creates a new account into the keystore defined by the CLI flags.
279260func accountCreate (ctx * cli.Context ) error {
280- cfg := loadBaseConfig (ctx )
281- keydir , isEphemeral , err := cfg .Node .GetKeyStoreDir ()
282- if err != nil {
283- utils .Fatalf ("Failed to get the keystore directory: %v" , err )
261+ cfg := gethConfig {Node : defaultNodeConfig ()}
262+ // Load config file.
263+ if file := ctx .String (configFileFlag .Name ); file != "" {
264+ if err := loadConfig (file , & cfg ); err != nil {
265+ utils .Fatalf ("%v" , err )
266+ }
284267 }
285- if isEphemeral {
286- utils .Fatalf ("Can't use ephemeral directory as keystore path" )
268+ utils .SetNodeConfig (ctx , & cfg .Node )
269+ keydir , err := cfg .Node .KeyDirConfig ()
270+ if err != nil {
271+ utils .Fatalf ("Failed to read configuration: %v" , err )
287272 }
288273 scryptN := keystore .StandardScryptN
289274 scryptP := keystore .StandardScryptP
@@ -315,8 +300,8 @@ func accountUpdate(ctx *cli.Context) error {
315300 if ctx .Args ().Len () == 0 {
316301 utils .Fatalf ("No accounts specified to update" )
317302 }
318- am := makeAccountManager (ctx )
319- backends := am .Backends (keystore .KeyStoreType )
303+ stack , _ := makeConfigNode (ctx )
304+ backends := stack . AccountManager () .Backends (keystore .KeyStoreType )
320305 if len (backends ) == 0 {
321306 utils .Fatalf ("Keystore is not available" )
322307 }
@@ -342,14 +327,14 @@ func importWallet(ctx *cli.Context) error {
342327 utils .Fatalf ("Could not read wallet file: %v" , err )
343328 }
344329
345- am := makeAccountManager (ctx )
346- backends := am .Backends (keystore .KeyStoreType )
330+ stack , _ := makeConfigNode (ctx )
331+ passphrase := utils .GetPassPhraseWithList ("" , false , 0 , utils .MakePasswordList (ctx ))
332+
333+ backends := stack .AccountManager ().Backends (keystore .KeyStoreType )
347334 if len (backends ) == 0 {
348335 utils .Fatalf ("Keystore is not available" )
349336 }
350337 ks := backends [0 ].(* keystore.KeyStore )
351- passphrase := utils .GetPassPhraseWithList ("" , false , 0 , utils .MakePasswordList (ctx ))
352-
353338 acct , err := ks .ImportPreSaleKey (keyJSON , passphrase )
354339 if err != nil {
355340 utils .Fatalf ("%v" , err )
@@ -367,14 +352,14 @@ func accountImport(ctx *cli.Context) error {
367352 if err != nil {
368353 utils .Fatalf ("Failed to load the private key: %v" , err )
369354 }
370- am := makeAccountManager (ctx )
371- backends := am .Backends (keystore .KeyStoreType )
355+ stack , _ := makeConfigNode (ctx )
356+ 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 ))
357+
358+ backends := stack .AccountManager ().Backends (keystore .KeyStoreType )
372359 if len (backends ) == 0 {
373360 utils .Fatalf ("Keystore is not available" )
374361 }
375362 ks := backends [0 ].(* keystore.KeyStore )
376- 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 ))
377-
378363 acct , err := ks .ImportECDSA (key , passphrase )
379364 if err != nil {
380365 utils .Fatalf ("Could not create the account: %v" , err )
0 commit comments