6 log "github.com/sirupsen/logrus"
8 "github.com/vapor/consensus"
9 "github.com/vapor/protocol/bc"
10 "github.com/vapor/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.NewIntraChainOutput(*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{
51 Timestamp: 1524549600,
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 if err := txStatus.SetStatus(0, false); err != nil {
66 log.Panicf(err.Error())
68 txStatusHash, err := types.TxStatusMerkleRoot(txStatus.VerifyStatus)
70 log.Panicf("fail on calc genesis tx status merkle root")
73 merkleRoot, err := types.TxMerkleRoot([]*bc.Tx{tx.Tx})
75 log.Panicf("fail on calc genesis tx merkel root")
78 block := &types.Block{
79 BlockHeader: types.BlockHeader{
82 Timestamp: 1528945000,
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 if err := txStatus.SetStatus(0, false); err != nil {
97 log.Panicf(err.Error())
99 txStatusHash, err := types.TxStatusMerkleRoot(txStatus.VerifyStatus)
101 log.Panicf("fail on calc genesis tx status merkle root")
104 merkleRoot, err := types.TxMerkleRoot([]*bc.Tx{tx.Tx})
106 log.Panicf("fail on calc genesis tx merkel root")
109 block := &types.Block{
110 BlockHeader: types.BlockHeader{
113 Timestamp: 1528945000,
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 "vapor": soloNetGenesisBlock,
131 }[consensus.ActiveNetParams.Name]()