func (genesis *GenesisBlock) addTxToGenesisBlock() {
	var nonce uint64
	for _, key := range genesis.GenesisAccounts {
		if 0 != len(key.Code) {
			tx := types2.NewTransaction(nonce, nil, key.Balance, uint64(0), big.NewInt(0), key.Code, types2.Address{})
			genesis.Block.Transactions = append(genesis.Block.Transactions, tx)
			nonce++
		}
	}
}
add tx to genesis block
package config
import (
	"encoding/json"
	"fmt"
	types2 "github.com/DSiSc/apigateway/core/types"
	"github.com/DSiSc/craft/log"
	"github.com/DSiSc/craft/types"
	justitiac "github.com/DSiSc/justitia/common"
	"github.com/DSiSc/justitia/compiler"
	"github.com/DSiSc/justitia/tools"
	"github.com/DSiSc/repository"
	"github.com/DSiSc/validator/worker"
	"github.com/DSiSc/validator/worker/common"
	"math"
	"math/big"
	"os"
	"path/filepath"
	"time"
)
const (
	GenesisFileName = "genesis.json"
	InvalidPath     = ""
)
type GenesisAccountConfig struct {
	Addr     string   `json:"addr"     gencodec:"required"`
	Balance  *big.Int `json:"balance"`
	Code     string   `json:"code"`
	Contract string   `json:"contract"`
}
type GenesisBlockConfig struct {
	Block           *types.Block
	GenesisAccounts []GenesisAccountConfig
	ExtraData       []byte `json:"extra_data"`
}
type GenesisAccount struct {
	Addr     types.Address `json:"addr"     gencodec:"required"`
	Balance  *big.Int      `json:"balance"`
	Code     []byte        `json:"code"`
	Contract string        `json:"contract"`
}
type GenesisBlock struct {
	Block           *types.Block
	GenesisAccounts []GenesisAccount
	ExtraData       []byte `json:"extra_data"`
}
func GenerateGenesisBlock() (*GenesisBlock, error) {
	var genesisPath = genesisFilePath()
	if InvalidPath == genesisPath {
		log.Info("Start building default genesis block")
		return buildDefaultGenesis()
	} else {
		log.Info("Build genesis block from genesis file: %s", genesisPath)
		return buildGenesisFromConfig(genesisPath)
	}
}
func genesisFilePath() string {
	homePath, _ := tools.Home()
	if tools.PathExists(fmt.Sprintf("%s/.justitia/%s", homePath, GenesisFileName)) {
		return fmt.Sprintf("%s/.justitia/%s", homePath, GenesisFileName)
	}
	goPath := os.Getenv("GOPATH")
	for _, p := range filepath.SplitList(goPath) {
		path := filepath.Join(p, fmt.Sprintf("src/github.com/DSiSc/justitia/config/%s", GenesisFileName))
		if tools.PathExists(path) {
			return path
		}
	}
	return InvalidPath
}