Documentation ¶
Index ¶
- Constants
- type Tx
- func (tx *Tx) ByteStream() []byte
- func (tx *Tx) ConvertFromTxPb(pbTx *iproto.TxPb)
- func (tx *Tx) ConvertToTxPb() *iproto.TxPb
- func (tx *Tx) ConvertToUtxoPb() *iproto.UtxoMapPb
- func (tx *Tx) Deserialize(buf []byte) error
- func (tx *Tx) Hash() common.Hash32B
- func (tx *Tx) IsCoinbase() bool
- func (tx *Tx) Serialize() ([]byte, error)
- func (tx *Tx) TotalSize() uint32
- type TxInSorter
- type TxInput
- type TxOutSorter
- type TxOutput
Constants ¶
const ( // TxInputFixedSize defines the fixed size of transaction input TxInputFixedSize = 44 // ValueSizeInBytes defines the size of value in byte units ValueSizeInBytes = 8 // LockScriptSizeInBytes defines the size of lock script in byte units LockScriptSizeInBytes = 4 // VersionSizeInBytes defines the size of version in byte units VersionSizeInBytes = 4 // LockTimeSizeInBytes defines the size of lock time in byte units LockTimeSizeInBytes = 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tx ¶
type Tx struct { Version uint32 LockTime uint32 // transaction to be locked until this time // used by utxo-based model TxIn []*TxInput TxOut []*TxOutput }
Tx defines the struct of utxo-based transaction make sure the variable type and order of this struct is same as "type Tx" in blockchain.pb.go
func NewCoinbaseTx ¶
NewCoinbaseTx creates the coinbase transaction - a special type of transaction that does not require previously outputs.
func (*Tx) ByteStream ¶
ByteStream returns a raw byte stream of this transaction
func (*Tx) ConvertFromTxPb ¶
func (tx *Tx) ConvertFromTxPb(pbTx *iproto.TxPb)
ConvertFromTxPb converts protobuf's TxPb to Tx
func (*Tx) ConvertToTxPb ¶
func (tx *Tx) ConvertToTxPb() *iproto.TxPb
ConvertToTxPb converts Tx to protobuf's TxPb
func (*Tx) ConvertToUtxoPb ¶
func (tx *Tx) ConvertToUtxoPb() *iproto.UtxoMapPb
ConvertToUtxoPb creates a protobuf's UTXO
func (*Tx) Deserialize ¶
Deserialize parse the byte stream into Tx
func (*Tx) IsCoinbase ¶
IsCoinbase checks if it is a coinbase transaction by checking if Vin is empty
type TxInSorter ¶
type TxInSorter []*TxInput
TxInSorter is TxInput sorter that implements Sort interface
func (TxInSorter) Len ¶
func (sorter TxInSorter) Len() int
Sort Interface implementation for *TxInput slice
func (TxInSorter) Less ¶
func (sorter TxInSorter) Less(i, j int) bool
func (TxInSorter) Swap ¶
func (sorter TxInSorter) Swap(i, j int)
type TxInput ¶
type TxInput struct {
*iproto.TxInputPb
}
TxInput defines the transaction input protocol buffer
func NewTxInput ¶
NewTxInput returns a TxInput instance
func (*TxInput) ByteStream ¶
ByteStream returns a raw byte stream of transaction input
func (*TxInput) UnlockSuccess ¶
UnlockSuccess checks whether the TxInput can unlock the provided script
type TxOutSorter ¶
type TxOutSorter []*TxOutput
TxOutSorter is TxOutput sorter that implements Sort interface
func (TxOutSorter) Len ¶
func (sorter TxOutSorter) Len() int
Sort Interface implementation for *TxOuput slice
func (TxOutSorter) Less ¶
func (sorter TxOutSorter) Less(i, j int) bool
func (TxOutSorter) Swap ¶
func (sorter TxOutSorter) Swap(i, j int)
type TxOutput ¶
type TxOutput struct { *iproto.TxOutputPb // embedded // below fields only used internally, not part of serialize/deserialize OutIndex int32 // outIndex is needed when spending UTXO }
TxOutput defines the transaction output protocol buffer
func CreateTxOutput ¶
CreateTxOutput creates a new transaction output
func NewTxOutput ¶
NewTxOutput returns a TxOutput instance
func (*TxOutput) ByteStream ¶
ByteStream returns a raw byte stream of transaction output
func (*TxOutput) IsLockedWithKey ¶
IsLockedWithKey checks if the UTXO in output is locked with script