mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 00:39:26 +00:00
cmd/utils: use IsHexAddress method (#32997)
Using the `IsHexAddress` method will result in no gaps in the verification logic, making it simpler.
This commit is contained in:
parent
2bb3d9a330
commit
030cd2d155
1 changed files with 2 additions and 8 deletions
|
|
@ -20,7 +20,6 @@ package utils
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -1341,15 +1340,10 @@ func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
addr := ctx.String(MinerPendingFeeRecipientFlag.Name)
|
addr := ctx.String(MinerPendingFeeRecipientFlag.Name)
|
||||||
if strings.HasPrefix(addr, "0x") || strings.HasPrefix(addr, "0X") {
|
if !common.IsHexAddress(addr) {
|
||||||
addr = addr[2:]
|
|
||||||
}
|
|
||||||
b, err := hex.DecodeString(addr)
|
|
||||||
if err != nil || len(b) != common.AddressLength {
|
|
||||||
Fatalf("-%s: invalid pending block producer address %q", MinerPendingFeeRecipientFlag.Name, 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) {
|
func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue