diff --git a/block.go b/block.go index b98c79c..65a0a6e 100644 --- a/block.go +++ b/block.go @@ -2,7 +2,6 @@ package main import ( "bytes" - "crypto/sha256" "encoding/gob" "log" "time" @@ -36,15 +35,14 @@ func NewGenesisBlock(coinbase *Transaction) *Block { // HashTransactions returns a hash of the transactions in the block func (b *Block) HashTransactions() []byte { - var txHashes [][]byte - var txHash [32]byte + var transactions [][]byte for _, tx := range b.Transactions { - txHashes = append(txHashes, tx.Hash()) + transactions = append(transactions, tx.Serialize()) } - txHash = sha256.Sum256(bytes.Join(txHashes, []byte{})) + mTree := NewMerkleTree(transactions) - return txHash[:] + return mTree.RootNode.Data } // Serialize serializes the block