Skip to content

Commit

Permalink
cmd: dev mode with faucet hex key
Browse files Browse the repository at this point in the history
  • Loading branch information
4000D committed Aug 6, 2019
1 parent b68962d commit 7182d72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ var (
utils.NodeKeyHexFlag,
utils.DeveloperFlag,
utils.DeveloperPeriodFlag,
utils.DeveloperFaucetKeyHexFlag,
utils.TestnetFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
Expand Down
15 changes: 14 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ var (
Name: "dev.period",
Usage: "Block period to use in developer mode (0 = mine only if transaction pending)",
}
DeveloperFaucetKeyHexFlag = cli.StringFlag{
Name: "dev.faucetkey",
Usage: "Developer account key as hex",
}
IdentityFlag = cli.StringFlag{
Name: "identity",
Usage: "Custom node name",
Expand Down Expand Up @@ -1482,9 +1486,18 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Create new developer account or reuse existing one
var (
developer accounts.Account
key *ecdsa.PrivateKey
err error
)
if accs := ks.Accounts(); len(accs) > 0 {

if hex := ctx.GlobalString(DeveloperFaucetKeyHexFlag.Name); hex != "" {
if key, err = crypto.HexToECDSA(hex); err != nil {
Fatalf("Option %q: %v", DeveloperFaucetKeyHexFlag.Name, err)
}
if developer, err = ks.ImportECDSA(key, ""); err != nil {
Fatalf("Failed to create developer account: %v", err)
}
} else if accs := ks.Accounts(); len(accs) > 0 {
developer = ks.Accounts()[0]
} else {
developer, err = ks.NewAccount("")
Expand Down

0 comments on commit 7182d72

Please sign in to comment.