diff options
author | Wei-Ning Huang <w@cobinhood.com> | 2018-10-11 15:01:10 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:49 +0800 |
commit | d7127cb517f29e727a48a588484834d7f242aadb (patch) | |
tree | e8737bce55f56d49245dba5a2a717ff2454b3bf6 /core/gen_genesis_account.go | |
parent | ccaefd2fa1b7a28ff2310f2ee339a460563a4ff0 (diff) | |
download | dexon-d7127cb517f29e727a48a588484834d7f242aadb.tar dexon-d7127cb517f29e727a48a588484834d7f242aadb.tar.gz dexon-d7127cb517f29e727a48a588484834d7f242aadb.tar.bz2 dexon-d7127cb517f29e727a48a588484834d7f242aadb.tar.lz dexon-d7127cb517f29e727a48a588484834d7f242aadb.tar.xz dexon-d7127cb517f29e727a48a588484834d7f242aadb.tar.zst dexon-d7127cb517f29e727a48a588484834d7f242aadb.zip |
core: add stake and public key to genesis account info
Diffstat (limited to 'core/gen_genesis_account.go')
-rw-r--r-- | core/gen_genesis_account.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/gen_genesis_account.go b/core/gen_genesis_account.go index 45a03c329..1a5653e4b 100644 --- a/core/gen_genesis_account.go +++ b/core/gen_genesis_account.go @@ -14,12 +14,15 @@ import ( var _ = (*genesisAccountMarshaling)(nil) +// MarshalJSON marshals as JSON. func (g GenesisAccount) MarshalJSON() ([]byte, error) { type GenesisAccount struct { Code hexutil.Bytes `json:"code,omitempty"` Storage map[storageJSON]storageJSON `json:"storage,omitempty"` Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"` Nonce math.HexOrDecimal64 `json:"nonce,omitempty"` + Staked *math.HexOrDecimal256 `json:"staked"` + PublicKey hexutil.Bytes `json:"publicKey"` PrivateKey hexutil.Bytes `json:"secretKey,omitempty"` } var enc GenesisAccount @@ -32,16 +35,21 @@ func (g GenesisAccount) MarshalJSON() ([]byte, error) { } enc.Balance = (*math.HexOrDecimal256)(g.Balance) enc.Nonce = math.HexOrDecimal64(g.Nonce) + enc.Staked = (*math.HexOrDecimal256)(g.Staked) + enc.PublicKey = g.PublicKey enc.PrivateKey = g.PrivateKey return json.Marshal(&enc) } +// UnmarshalJSON unmarshals from JSON. func (g *GenesisAccount) UnmarshalJSON(input []byte) error { type GenesisAccount struct { Code *hexutil.Bytes `json:"code,omitempty"` Storage map[storageJSON]storageJSON `json:"storage,omitempty"` Balance *math.HexOrDecimal256 `json:"balance" gencodec:"required"` Nonce *math.HexOrDecimal64 `json:"nonce,omitempty"` + Staked *math.HexOrDecimal256 `json:"staked"` + PublicKey *hexutil.Bytes `json:"publicKey"` PrivateKey *hexutil.Bytes `json:"secretKey,omitempty"` } var dec GenesisAccount @@ -64,6 +72,12 @@ func (g *GenesisAccount) UnmarshalJSON(input []byte) error { if dec.Nonce != nil { g.Nonce = uint64(*dec.Nonce) } + if dec.Staked != nil { + g.Staked = (*big.Int)(dec.Staked) + } + if dec.PublicKey != nil { + g.PublicKey = *dec.PublicKey + } if dec.PrivateKey != nil { g.PrivateKey = *dec.PrivateKey } |