Skip to content

Commit

Permalink
fix: transaction.GetTransactionHash fixed to get full transaction bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrix10 authored and janaakhterov committed Nov 3, 2020
1 parent a608011 commit 2ab7cc3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,18 @@ func TransactionFromBytes(bytes []byte) Transaction {

func (transaction *Transaction) GetTransactionHash() map[AccountID][]byte {
hash := sha512.New384()
bytes, err := protobuf.Marshal(transaction.pbBody)
if err != nil {
// This should be unreachable
// From the documentation this appears to only be possible if there are missing proto types
panic(err)
}
hash.Write(bytes)

byteHash := hex.EncodeToString(hash.Sum(nil))

transactionHash := make(map[AccountID][]byte)

for _, node := range transaction.nodeIDs {
for i, node := range transaction.nodeIDs {
byt, err := protobuf.Marshal(transaction.transactions[i])
if err != nil {
// This should be unreachable
// From the documentation this appears to only be possible if there are missing proto types
panic(err)
}
hash.Write(byt)
byteHash := hex.EncodeToString(hash.Sum(nil))

transactionHash[node] = []byte(byteHash)
}

Expand Down

0 comments on commit 2ab7cc3

Please sign in to comment.