package btcwire import ( "git.smesh.lol/nostrino/pkg/crypto/chainhash" ) // Tx is a raw transaction. This package does not parse transactions: the // payload is carried verbatim, which is all a compact-filter light client // needs to relay or hash it. type Tx struct { // Raw is the serialized transaction, without the frame header. Raw []byte } // EncodePayload returns the raw transaction bytes. The result aliases Raw. func (t *Tx) EncodePayload() ([]byte, error) { return t.Raw, nil } // DecodePayload stores the raw transaction bytes. The stored slice aliases b. func (t *Tx) DecodePayload(b []byte) error { t.Raw = b return nil } // TxID returns SHA256d of the raw transaction, in internal byte order. For a // transaction that spends no witness data the txid and wtxid are equal. func (t *Tx) TxID() chainhash.Hash { return chainhash.DoubleHashH(t.Raw) }