6 log "github.com/sirupsen/logrus"
8 "github.com/bytom/consensus"
9 "github.com/bytom/protocol/bc"
10 "github.com/bytom/protocol/bc/types"
13 func genesisTx() *types.Tx {
14 contract, err := hex.DecodeString("00148c9d063ff74ee6d9ffa88d83aeb038068366c4c4")
16 log.Panicf("fail on decode genesis tx output control program")
19 txData := types.TxData{
21 Inputs: []*types.TxInput{
22 types.NewCoinbaseInput([]byte("Information is power. -- Jan/11/2013. Computing is power. -- Apr/24/2018.")),
24 Outputs: []*types.TxOutput{
25 types.NewTxOutput(*consensus.BTMAssetID, consensus.InitialBlockSubsidy, contract),
28 return types.NewTx(txData)
31 func mainNetGenesisBlock() *types.Block {
33 txStatus := bc.NewTransactionStatus()
34 if err := txStatus.SetStatus(0, false); err != nil {
35 log.Panicf(err.Error())
37 txStatusHash, err := types.TxStatusMerkleRoot(txStatus.VerifyStatus)
39 log.Panicf("fail on calc genesis tx status merkle root")
42 merkleRoot, err := types.TxMerkleRoot([]*bc.Tx{tx.Tx})
44 log.Panicf("fail on calc genesis tx merkel root")
47 block := &types.Block{
48 BlockHeader: types.BlockHeader{
52 Timestamp: 1524549600,
53 Bits: 2161727821137910632,
54 BlockCommitment: types.BlockCommitment{
55 TransactionsMerkleRoot: merkleRoot,
56 TransactionStatusHash: txStatusHash,
59 Transactions: []*types.Tx{tx},
64 func testNetGenesisBlock() *types.Block {
66 txStatus := bc.NewTransactionStatus()
67 if err := txStatus.SetStatus(0, false); err != nil {
68 log.Panicf(err.Error())
70 txStatusHash, err := types.TxStatusMerkleRoot(txStatus.VerifyStatus)
72 log.Panicf("fail on calc genesis tx status merkle root")
75 merkleRoot, err := types.TxMerkleRoot([]*bc.Tx{tx.Tx})
77 log.Panicf("fail on calc genesis tx merkel root")
80 block := &types.Block{
81 BlockHeader: types.BlockHeader{
85 Timestamp: 1528945000,
86 Bits: 2305843009214532812,
87 BlockCommitment: types.BlockCommitment{
88 TransactionsMerkleRoot: merkleRoot,
89 TransactionStatusHash: txStatusHash,
92 Transactions: []*types.Tx{tx},
97 func soloNetGenesisBlock() *types.Block {
99 txStatus := bc.NewTransactionStatus()
100 if err := txStatus.SetStatus(0, false); err != nil {
101 log.Panicf(err.Error())
103 txStatusHash, err := types.TxStatusMerkleRoot(txStatus.VerifyStatus)
105 log.Panicf("fail on calc genesis tx status merkle root")
108 merkleRoot, err := types.TxMerkleRoot([]*bc.Tx{tx.Tx})
110 log.Panicf("fail on calc genesis tx merkel root")
113 block := &types.Block{
114 BlockHeader: types.BlockHeader{
117 Nonce: 9253507043297,
118 Timestamp: 1528945000,
119 Bits: 2305843009214532812,
120 BlockCommitment: types.BlockCommitment{
121 TransactionsMerkleRoot: merkleRoot,
122 TransactionStatusHash: txStatusHash,
125 Transactions: []*types.Tx{tx},
130 // GenesisBlock will return genesis block
131 func GenesisBlock() *types.Block {
132 return map[string]func() *types.Block{
133 "main": mainNetGenesisBlock,
134 "test": testNetGenesisBlock,
135 "solo": soloNetGenesisBlock,
136 }[consensus.ActiveNetParams.Name]()