From 2ab7cc3d434bf196a1c4a9e0cf03a38f30b8fa9c Mon Sep 17 00:00:00 2001 From: Andrei Kuzmiankov Date: Fri, 30 Oct 2020 04:49:24 -0700 Subject: [PATCH] fix: transaction.GetTransactionHash fixed to get full transaction bytes --- transaction.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/transaction.go b/transaction.go index ba2f99462..f3dd44931 100644 --- a/transaction.go +++ b/transaction.go @@ -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) }