diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index d5414b771..949e1a9e1 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1612,18 +1612,28 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { } // Create new developer account or reuse existing one var ( - developer accounts.Account - err error + developer accounts.Account + passphrase string + err error ) - if accs := ks.Accounts(); len(accs) > 0 { + if list := MakePasswordList(ctx); len(list) > 0 { + // Just take the first value. Although the function returns a possible multiple values and + // some usages iterate through them as attempts, that doesn't make sense in this setting, + // when we're definitely concerned with only one account. + passphrase = list[0] + } + // setEtherbase has been called above, configuring the miner address from command line flags. + if cfg.Miner.Etherbase != (common.Address{}) { + developer = accounts.Account{Address: cfg.Miner.Etherbase} + } else if accs := ks.Accounts(); len(accs) > 0 { developer = ks.Accounts()[0] } else { - developer, err = ks.NewAccount("") + developer, err = ks.NewAccount(passphrase) if err != nil { Fatalf("Failed to create developer account: %v", err) } } - if err := ks.Unlock(developer, ""); err != nil { + if err := ks.Unlock(developer, passphrase); err != nil { Fatalf("Failed to unlock developer account: %v", err) } log.Info("Using developer account", "address", developer.Address)