Skip to content

Commit 030cd2d

Browse files
authored
cmd/utils: use IsHexAddress method (#32997)
Using the `IsHexAddress` method will result in no gaps in the verification logic, making it simpler.
1 parent 2bb3d9a commit 030cd2d

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"
@@ -1341,15 +1340,10 @@ func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) {
13411340
return
13421341
}
13431342
addr := ctx.String(MinerPendingFeeRecipientFlag.Name)
1344-
if strings.HasPrefix(addr, "0x") || strings.HasPrefix(addr, "0X") {
1345-
addr = addr[2:]
1346-
}
1347-
b, err := hex.DecodeString(addr)
1348-
if err != nil || len(b) != common.AddressLength {
1343+
if !common.IsHexAddress(addr) {
13491344
Fatalf("-%s: invalid pending block producer address %q", MinerPendingFeeRecipientFlag.Name, addr)
1350-
return
13511345
}
1352-
cfg.Miner.PendingFeeRecipient = common.BytesToAddress(b)
1346+
cfg.Miner.PendingFeeRecipient = common.HexToAddress(addr)
13531347
}
13541348

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

0 commit comments

Comments
 (0)