cmd/utils: use IsHexAddress method (#32997)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

Using the `IsHexAddress` method will result in no gaps in the
verification logic, making it simpler.
This commit is contained in:
maskpp 2025-10-23 17:56:47 +08:00 committed by GitHub
parent 2bb3d9a330
commit 030cd2d155
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,7 +20,6 @@ package utils
import (
"context"
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
@ -1341,15 +1340,10 @@ func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) {
return
}
addr := ctx.String(MinerPendingFeeRecipientFlag.Name)
if strings.HasPrefix(addr, "0x") || strings.HasPrefix(addr, "0X") {
addr = addr[2:]
}
b, err := hex.DecodeString(addr)
if err != nil || len(b) != common.AddressLength {
if !common.IsHexAddress(addr) {
Fatalf("-%s: invalid pending block producer address %q", MinerPendingFeeRecipientFlag.Name, addr)
return
}
cfg.Miner.PendingFeeRecipient = common.BytesToAddress(b)
cfg.Miner.PendingFeeRecipient = common.HexToAddress(addr)
}
func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {