diff options
Diffstat (limited to 'rpc/api/miner_args.go')
-rw-r--r-- | rpc/api/miner_args.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/rpc/api/miner_args.go b/rpc/api/miner_args.go index 7b0560c16..9da3b95ad 100644 --- a/rpc/api/miner_args.go +++ b/rpc/api/miner_args.go @@ -5,6 +5,7 @@ import ( "math/big" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rpc/shared" ) @@ -76,6 +77,31 @@ func (args *GasPriceArgs) UnmarshalJSON(b []byte) (err error) { return shared.NewInvalidTypeError("Price", "not a string") } +type SetEtherbaseArgs struct { + Etherbase common.Address +} + +func (args *SetEtherbaseArgs) UnmarshalJSON(b []byte) (err error) { + var obj []interface{} + if err := json.Unmarshal(b, &obj); err != nil { + return shared.NewDecodeParamError(err.Error()) + } + + if len(obj) < 1 { + return shared.NewInsufficientParamsError(len(obj), 1) + } + + if addr, ok := obj[0].(string); ok { + args.Etherbase = common.HexToAddress(addr) + if (args.Etherbase == common.Address{}) { + return shared.NewInvalidTypeError("Etherbase", "not a valid address") + } + return nil + } + + return shared.NewInvalidTypeError("Etherbase", "not a string") +} + type MakeDAGArgs struct { BlockNumber int64 } |