mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-07-09 06:12:32 +00:00
[NOD-49] Exclude payload from transaction hash (#212)
This commit is contained in:
parent
a381e8672c
commit
ee44eb20de
@ -332,8 +332,8 @@ func (msg *MsgTx) TxHash() *daghash.Hash {
|
|||||||
// Ignore the error returns since the only way the encode could fail
|
// 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
|
// is being out of memory or due to nil pointers, both of which would
|
||||||
// cause a run-time panic.
|
// cause a run-time panic.
|
||||||
buf := bytes.NewBuffer(make([]byte, 0, msg.SerializeSize()))
|
buf := bytes.NewBuffer(make([]byte, 0, msg.serializeSize(txEncodingExcludeSubNetworkData)))
|
||||||
_ = msg.Serialize(buf)
|
_ = msg.serialize(buf, txEncodingExcludeSubNetworkData)
|
||||||
|
|
||||||
hash := daghash.Hash(daghash.DoubleHashH(buf.Bytes()))
|
hash := daghash.Hash(daghash.DoubleHashH(buf.Bytes()))
|
||||||
return &hash
|
return &hash
|
||||||
|
@ -180,7 +180,7 @@ func TestTxHashAndID(t *testing.T) {
|
|||||||
spew.Sprint(tx1ID), spew.Sprint(wantTxID1))
|
spew.Sprint(tx1ID), spew.Sprint(wantTxID1))
|
||||||
}
|
}
|
||||||
|
|
||||||
hash2Str := "37fb9ab8fc0cb68a8cc2a3c94edd26897aa445596a5c97bc459ca9815d67490b"
|
hash2Str := "b11924b7eeffea821522222576c53dc5b8ddd97602f81e5e124d2626646d74ca"
|
||||||
wantHash2, err := daghash.NewHashFromStr(hash2Str)
|
wantHash2, err := daghash.NewHashFromStr(hash2Str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("NewHashFromStr: %v", err)
|
t.Errorf("NewHashFromStr: %v", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user