transaction

package
v0.0.0-...-4701ab3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2019 License: LGPL-3.0 Imports: 8 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExceedSignatureCount = errors.New("exceed signature count")
)

transaction errors

Functions

func IsMainChain

func IsMainChain(ChainCoord *common.Coordinate) bool

IsMainChain returns that the target chain is the main chain or not

func MarshalID

func MarshalID(height uint32, index uint16, N uint16) uint64

MarshalID returns the packed id

func UnmarshalID

func UnmarshalID(id uint64) (uint32, uint16, uint16)

UnmarshalID returns the block height, the transaction index in the block, the output index in the transaction

Types

type Base

type Base struct {
	Type_      Type
	Timestamp_ uint64
}

Base is the parts of transaction functions that are not changed by derived one

func (*Base) ReadFrom

func (tx *Base) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (*Base) Timestamp

func (tx *Base) Timestamp() uint64

Timestamp returns the timestamp

func (*Base) Type

func (tx *Base) Type() Type

Type returns the type of the transaction

func (*Base) WriteTo

func (tx *Base) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type Signed

type Signed struct {
	TransactionHash hash.Hash256
	Signatures      []common.Signature
}

Signed is the signature of the transaction creator

func (*Signed) Hash

func (s *Signed) Hash() (hash.Hash256, error)

Hash returns the hash value of it

func (*Signed) ReadFrom

func (s *Signed) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (*Signed) WriteTo

func (s *Signed) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type Transaction

type Transaction interface {
	io.WriterTo
	io.ReaderFrom
	json.Marshaler
	Type() Type
	Timestamp() uint64
	Hash() hash.Hash256
	IsUTXO() bool
}

Transaction is an interface that defines common transaction functions

type TxIn

type TxIn struct {
	Height uint32
	Index  uint16
	N      uint16
}

TxIn represents the position of the UTXO

func NewTxIn

func NewTxIn(id uint64) *TxIn

NewTxIn returns a TxIn

func (*TxIn) Clone

func (in *TxIn) Clone() *TxIn

Clone returns the clonend value of it

func (*TxIn) ID

func (in *TxIn) ID() uint64

ID returns the packed id of the txin

func (*TxIn) ReadFrom

func (in *TxIn) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (*TxIn) WriteTo

func (in *TxIn) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type TxOut

type TxOut struct {
	Amount     *amount.Amount
	PublicHash common.PublicHash
}

TxOut represents recipient of the UTXO

func NewTxOut

func NewTxOut() *TxOut

NewTxOut returns a TxOut

func (*TxOut) Clone

func (out *TxOut) Clone() *TxOut

Clone returns the clonend value of it

func (*TxOut) MarshalJSON

func (tx *TxOut) MarshalJSON() ([]byte, error)

MarshalJSON is a marshaler function

func (*TxOut) ReadFrom

func (out *TxOut) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (*TxOut) WriteTo

func (out *TxOut) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

type Type

type Type uint8

Type is a transaction type

type UTXO

type UTXO struct {
	*TxIn
	*TxOut
}

UTXO represents usable coins in the UTXO model

func NewUTXO

func NewUTXO() *UTXO

NewUTXO returns a UTXO

func (*UTXO) Clone

func (utxo *UTXO) Clone() *UTXO

Clone returns the clonend value of it

func (*UTXO) ReadFrom

func (utxo *UTXO) ReadFrom(r io.Reader) (int64, error)

ReadFrom is a deserialization function

func (*UTXO) WriteTo

func (utxo *UTXO) WriteTo(w io.Writer) (int64, error)

WriteTo is a serialization function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL