Skip to content

Commit 4c268e6

Browse files
authored
cmd/utils: implement configurable developer (--dev) account options (#21301)
* geth,utils: implement configurable developer account options Prior to this change --dev (developer) mode generated one account with an empty password, irrespective of existing --password and --miner.etherbase options. This change makes --dev mode compatible with these existing flags. --dev mode may now be used in conjunction with --password and --miner.etherbase flags to configure the developer faucet using an existing keystore or in creating a new account. Signed-off-by: meows <[email protected]> * main: remove key/pass flags from usage developer section These flags are included already in other sections, and it is not desired to duplicate them. They were originally included in this section along with added support for these flags in the developer mode. Signed-off-by: meows <[email protected]>
1 parent 0b53e48 commit 4c268e6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

cmd/utils/flags.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,18 +1612,28 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
16121612
}
16131613
// Create new developer account or reuse existing one
16141614
var (
1615-
developer accounts.Account
1616-
err error
1615+
developer accounts.Account
1616+
passphrase string
1617+
err error
16171618
)
1618-
if accs := ks.Accounts(); len(accs) > 0 {
1619+
if list := MakePasswordList(ctx); len(list) > 0 {
1620+
// Just take the first value. Although the function returns a possible multiple values and
1621+
// some usages iterate through them as attempts, that doesn't make sense in this setting,
1622+
// when we're definitely concerned with only one account.
1623+
passphrase = list[0]
1624+
}
1625+
// setEtherbase has been called above, configuring the miner address from command line flags.
1626+
if cfg.Miner.Etherbase != (common.Address{}) {
1627+
developer = accounts.Account{Address: cfg.Miner.Etherbase}
1628+
} else if accs := ks.Accounts(); len(accs) > 0 {
16191629
developer = ks.Accounts()[0]
16201630
} else {
1621-
developer, err = ks.NewAccount("")
1631+
developer, err = ks.NewAccount(passphrase)
16221632
if err != nil {
16231633
Fatalf("Failed to create developer account: %v", err)
16241634
}
16251635
}
1626-
if err := ks.Unlock(developer, ""); err != nil {
1636+
if err := ks.Unlock(developer, passphrase); err != nil {
16271637
Fatalf("Failed to unlock developer account: %v", err)
16281638
}
16291639
log.Info("Using developer account", "address", developer.Address)

0 commit comments

Comments
 (0)