From 3f421aca54bb5216e0f949966481fa4516c52273 Mon Sep 17 00:00:00 2001 From: Ha ĐANG Date: Fri, 4 Jan 2019 14:48:15 +0700 Subject: cmd/puppeth: fix panic error when export aleth genesis wo/ precompile-addresses (#18344) * cmd/puppeth: fix panic error when export aleth genesis wo/ precompile-addresses * cmd/puppeth: don't need to handle duplicate set --- cmd/puppeth/genesis.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/puppeth/genesis.go b/cmd/puppeth/genesis.go index 1025dfe82..c95c81a6d 100644 --- a/cmd/puppeth/genesis.go +++ b/cmd/puppeth/genesis.go @@ -174,7 +174,11 @@ func (spec *alethGenesisSpec) setPrecompile(address byte, data *alethGenesisSpec if spec.Accounts == nil { spec.Accounts = make(map[common.UnprefixedAddress]*alethGenesisSpecAccount) } - spec.Accounts[common.UnprefixedAddress(common.BytesToAddress([]byte{address}))].Precompiled = data + addr := common.UnprefixedAddress(common.BytesToAddress([]byte{address})) + if _, exist := spec.Accounts[addr]; !exist { + spec.Accounts[addr] = &alethGenesisSpecAccount{} + } + spec.Accounts[addr].Precompiled = data } func (spec *alethGenesisSpec) setAccount(address common.Address, account core.GenesisAccount) { -- cgit