[NOD-49] Exclude payload from transaction hash (#212)

This commit is contained in:
Evgeny Khirin 2019-03-17 11:59:44 +02:00 committed by Ori Newman
parent a381e8672c
commit ee44eb20de
2 changed files with 3 additions and 3 deletions

View File

@ -332,8 +332,8 @@ func (msg *MsgTx) TxHash() *daghash.Hash {
// Ignore the error returns since the only way the encode could fail
// is being out of memory or due to nil pointers, both of which would
// cause a run-time panic.
buf := bytes.NewBuffer(make([]byte, 0, msg.SerializeSize()))
_ = msg.Serialize(buf)
buf := bytes.NewBuffer(make([]byte, 0, msg.serializeSize(txEncodingExcludeSubNetworkData)))
_ = msg.serialize(buf, txEncodingExcludeSubNetworkData)
hash := daghash.Hash(daghash.DoubleHashH(buf.Bytes()))
return &hash

View File

@ -180,7 +180,7 @@ func TestTxHashAndID(t *testing.T) {
spew.Sprint(tx1ID), spew.Sprint(wantTxID1))
}
hash2Str := "37fb9ab8fc0cb68a8cc2a3c94edd26897aa445596a5c97bc459ca9815d67490b"
hash2Str := "b11924b7eeffea821522222576c53dc5b8ddd97602f81e5e124d2626646d74ca"
wantHash2, err := daghash.NewHashFromStr(hash2Str)
if err != nil {
t.Errorf("NewHashFromStr: %v", err)