wtxmgr: when creating a TxRecord don't compute txid manually

This fixes a bug introduced by the new segwit behavior upstream in
btcd. Previously it was a nice optimization to skip the extra
serialization, and compute the txid manually from the serialized
transaction.

However, with segwit, doing that will generate an invalid txid, since
txid’s should ignore any witness data. Therefore, we now fallback to
using msgTx.TxSha() which serializes the transaction without witness
data before calculating the txid.
This commit is contained in:
Olaoluwa Osuntokun 2016-04-25 12:41:29 -07:00
parent d88739df8f
commit 7cb1b47140

View file

@ -111,8 +111,9 @@ func NewTxRecordFromMsgTx(msgTx *wire.MsgTx, received time.Time) (*TxRecord, err
MsgTx: *msgTx,
Received: received,
SerializedTx: buf.Bytes(),
Hash: msgTx.TxSha(),
}
copy(rec.Hash[:], chainhash.DoubleHashB(rec.SerializedTx))
return rec, nil
}