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 txStatus.SetStatus(0, false)
35 txStatusHash, err := bc.TxStatusMerkleRoot(txStatus.VerifyStatus)
37 log.Panicf("fail on calc genesis tx status merkle root")
40 merkleRoot, err := bc.TxMerkleRoot([]*bc.Tx{tx.Tx})
42 log.Panicf("fail on calc genesis tx merkel root")
45 block := &types.Block{
46 BlockHeader: types.BlockHeader{
50 Timestamp: 1524549600,
51 Bits: 2161727821137910632,
52 BlockCommitment: types.BlockCommitment{
53 TransactionsMerkleRoot: merkleRoot,
54 TransactionStatusHash: txStatusHash,
57 Transactions: []*types.Tx{tx},
62 func testNetGenesisBlock() *types.Block {
64 txStatus := bc.NewTransactionStatus()
65 txStatus.SetStatus(0, false)
66 txStatusHash, err := bc.TxStatusMerkleRoot(txStatus.VerifyStatus)
68 log.Panicf("fail on calc genesis tx status merkle root")
71 merkleRoot, err := bc.TxMerkleRoot([]*bc.Tx{tx.Tx})
73 log.Panicf("fail on calc genesis tx merkel root")
76 block := &types.Block{
77 BlockHeader: types.BlockHeader{
81 Timestamp: 1528945000,
82 Bits: 2305843009214532812,
83 BlockCommitment: types.BlockCommitment{
84 TransactionsMerkleRoot: merkleRoot,
85 TransactionStatusHash: txStatusHash,
88 Transactions: []*types.Tx{tx},
93 func soloNetGenesisBlock() *types.Block {
95 txStatus := bc.NewTransactionStatus()
96 txStatus.SetStatus(0, false)
97 txStatusHash, err := bc.TxStatusMerkleRoot(txStatus.VerifyStatus)
99 log.Panicf("fail on calc genesis tx status merkle root")
102 merkleRoot, err := bc.TxMerkleRoot([]*bc.Tx{tx.Tx})
104 log.Panicf("fail on calc genesis tx merkel root")
107 block := &types.Block{
108 BlockHeader: types.BlockHeader{
111 Nonce: 9253507043297,
112 Timestamp: 1528945000,
113 Bits: 2305843009214532812,
114 BlockCommitment: types.BlockCommitment{
115 TransactionsMerkleRoot: merkleRoot,
116 TransactionStatusHash: txStatusHash,
119 Transactions: []*types.Tx{tx},
124 // GenesisBlock will return genesis block
125 func GenesisBlock() *types.Block {
126 return map[string]func() *types.Block{
127 "main": mainNetGenesisBlock,
128 "test": testNetGenesisBlock,
129 "solo": soloNetGenesisBlock,
130 }[consensus.ActiveNetParams.Name]()