Skip to content

Commit 4ffa454

Browse files
mask-pprjl493456442
authored andcommitted
cmd/utils: use IsHexAddress method (ethereum#32997)
Using the `IsHexAddress` method will result in no gaps in the verification logic, making it simpler.
1 parent c949700 commit 4ffa454

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

cmd/utils/flags.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package utils
2020
import (
2121
"context"
2222
"crypto/ecdsa"
23-
"encoding/hex"
2423
"encoding/json"
2524
"errors"
2625
"fmt"
@@ -1346,15 +1345,10 @@ func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) {
13461345
return
13471346
}
13481347
addr := ctx.String(MinerPendingFeeRecipientFlag.Name)
1349-
if strings.HasPrefix(addr, "0x") || strings.HasPrefix(addr, "0X") {
1350-
addr = addr[2:]
1351-
}
1352-
b, err := hex.DecodeString(addr)
1353-
if err != nil || len(b) != common.AddressLength {
1348+
if !common.IsHexAddress(addr) {
13541349
Fatalf("-%s: invalid pending block producer address %q", MinerPendingFeeRecipientFlag.Name, addr)
1355-
return
13561350
}
1357-
cfg.Miner.PendingFeeRecipient = common.BytesToAddress(b)
1351+
cfg.Miner.PendingFeeRecipient = common.HexToAddress(addr)
13581352
}
13591353

13601354
func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {

0 commit comments

Comments
 (0)