示例#1
0
文件: block.go 项目: ThePiachu/GoBit
//TODO: check
func GenerateGenesisBlock() *Block {

	b := new(Block)

	b.SetVersion(1)
	b.SetPrevBlockStrRev("0000000000000000000000000000000000000000000000000000000000000000")
	b.SetMerkleRootStrRev("4A5E1E4BAAB89F3A32518A88C31BC87F618F76673E2CC77AB2127B7AFDEDA33B")
	b.SetTimestamp(1231006505)
	b.SetBits(0x1d00ffff)
	b.SetNonce(2083236893)

	t := new(Tx)

	t.SetVersion(1)

	tin := new(TxIn)
	tout := new(TxOut)

	var op OutPoint

	op.SetHash(NewHashFromBig(big.NewInt(0)))
	op.SetIndex(4294967295) //-1

	tin.SetOutPoint(op)
	tin.SetSignature(mymath.String2Hex("04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73"))
	tin.SetSequence(0xFFFFFFFF)

	tout.SetValue(5000000000)
	tout.SetScriptStr("4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f", 0xAC)

	t.AddIn(tin)
	t.AddOut(tout)
	t.SetLockTime(0)

	b.AddTx(t)

	return b
}
示例#2
0
文件: block.go 项目: ThePiachu/GoBit
func (b *Block) SetMerkleRootStrRev(merkle string) {
	if len(merkle) == 64 {
		answer := mymath.String2Hex(merkle)
		copy(b.MerkleRoot[:], mymath.Rev(answer))
	}
}
示例#3
0
文件: block.go 项目: ThePiachu/GoBit
func (b *Block) SetPrevBlockStrRev(prev string) {
	if len(prev) == 32 {
		answer := mymath.String2Hex(prev)
		copy(b.PrevBlock[:], mymath.Rev(answer))
	}
}
示例#4
0
文件: tx.go 项目: ThePiachu/GoBit
func (to *TxOut) SetScriptStr(script string, opcode byte) {
	to.PkScript = mymath.AddByte(mymath.String2Hex(script), opcode)
	to.PkScriptLength = mymath.VarInt(len(to.PkScript))
}
示例#5
0
func (bh *BlockHeader) SetMerkleRootStr(merkle string) {
	if len(merkle) == 32 {
		answer := mymath.String2Hex(merkle)
		copy(bh.MerkleRoot[:], answer)
	}
}
示例#6
0
func (bh *BlockHeader) SetPrevBlockStr(prev string) {
	if len(prev) == 32 {
		answer := mymath.String2Hex(prev)
		copy(bh.PrevBlock[:], answer)
	}
}