transaction

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvalidTransactionSize = -1

	// encoded public key length 0x21 || encoded public key (33 bytes) || OP_CHECKSIG(0xac)
	PublicKeyScriptLength = 35

	// 1byte m || 3 encoded public keys with leading 0x40 (34 bytes * 3) ||
	// 1byte n + 1byte OP_CHECKMULTISIG
	// FIXME: if want to support 1/2 multisig
	MinMultiSignCodeLength = 71
)

Variables

This section is empty.

Functions

func IsValidAttributeType

func IsValidAttributeType(usage TransactionAttributeUsage) bool

func VerifySignature

func VerifySignature(txn *Transaction) (bool, error)

Types

type BalanceTxInput

type BalanceTxInput struct {
	AssetID     common.Uint256
	Value       common.Fixed64
	ProgramHash common.Uint168
}

func (*BalanceTxInput) Deserialize

func (bi *BalanceTxInput) Deserialize(r io.Reader) error

func (*BalanceTxInput) Serialize

func (bi *BalanceTxInput) Serialize(w io.Writer)

type ILedgerStore

type ILedgerStore interface {
	GetTransaction(hash Uint256) (*Transaction, uint32, error)
}

ILedgerStore provides func with store package.

var TxStore ILedgerStore

type Payload

type Payload interface {
	//  Get payload data
	Data(version byte) []byte

	//Serialize payload data
	Serialize(w io.Writer, version byte) error

	Deserialize(r io.Reader, version byte) error
}

Payload define the func for loading the payload data base on payload type which have different struture

type Transaction

type Transaction struct {
	TxType         TransactionType
	PayloadVersion byte
	Payload        Payload
	Attributes     []*TxAttribute
	UTXOInputs     []*UTXOTxInput
	BalanceInputs  []*BalanceTxInput
	Outputs        []*TxOutput
	LockTime       uint32
	Programs       []*program.Program

	//Inputs/Outputs map base on Asset (needn't serialize)
	AssetOutputs      map[Uint256][]*TxOutput
	AssetInputAmount  map[Uint256]Fixed64
	AssetOutputAmount map[Uint256]Fixed64
	Fee               Fixed64
	FeePerKB          Fixed64
	// contains filtered or unexported fields
}

func NewCoinBaseTransaction

func NewCoinBaseTransaction(coinBasePayload *payload.CoinBase, currentHeight uint32) (*Transaction, error)

func (*Transaction) Deserialize

func (tx *Transaction) Deserialize(r io.Reader) error

deserialize the Transaction

func (*Transaction) DeserializeUnsigned

func (tx *Transaction) DeserializeUnsigned(r io.Reader) error

func (*Transaction) DeserializeUnsignedWithoutType

func (tx *Transaction) DeserializeUnsignedWithoutType(r io.Reader) error

func (*Transaction) GenerateAssetMaps

func (tx *Transaction) GenerateAssetMaps()

func (*Transaction) GetDataContent

func (tx *Transaction) GetDataContent() []byte

func (*Transaction) GetFee

func (tx *Transaction) GetFee(assetID Uint256) int64

func (*Transaction) GetMergedAssetIDValueFromOutputs

func (tx *Transaction) GetMergedAssetIDValueFromOutputs() TransactionResult

func (*Transaction) GetMergedAssetIDValueFromReference

func (tx *Transaction) GetMergedAssetIDValueFromReference() (TransactionResult, error)

func (*Transaction) GetMultiSignPublicKeys

func (tx *Transaction) GetMultiSignPublicKeys() ([][]byte, error)

func (*Transaction) GetOutputHashes

func (tx *Transaction) GetOutputHashes() ([]Uint168, error)

func (*Transaction) GetProgramHashes

func (tx *Transaction) GetProgramHashes() ([]Uint168, error)

func (*Transaction) GetPrograms

func (tx *Transaction) GetPrograms() []*program.Program

func (*Transaction) GetReference

func (tx *Transaction) GetReference() (map[*UTXOTxInput]*TxOutput, error)

func (*Transaction) GetSize

func (tx *Transaction) GetSize() int

func (*Transaction) GetTransactionCode

func (tx *Transaction) GetTransactionCode() ([]byte, error)

func (*Transaction) GetTransactionResults

func (tx *Transaction) GetTransactionResults() (TransactionResult, error)

func (*Transaction) GetTransactionType

func (tx *Transaction) GetTransactionType() (byte, error)

func (*Transaction) Hash

func (tx *Transaction) Hash() Uint256

func (*Transaction) IsCoinBaseTx

func (tx *Transaction) IsCoinBaseTx() bool

func (*Transaction) Serialize

func (tx *Transaction) Serialize(w io.Writer) error

Serialize the Transaction

func (*Transaction) SerializeUnsigned

func (tx *Transaction) SerializeUnsigned(w io.Writer) error

Serialize the Transaction data without contracts

func (*Transaction) SetHash

func (tx *Transaction) SetHash(hash Uint256)

func (*Transaction) SetPrograms

func (tx *Transaction) SetPrograms(programs []*program.Program)

type TransactionAttributeUsage

type TransactionAttributeUsage byte
const (
	Nonce          TransactionAttributeUsage = 0x00
	Script         TransactionAttributeUsage = 0x20
	Memo           TransactionAttributeUsage = 0x81
	Description    TransactionAttributeUsage = 0x90
	DescriptionUrl TransactionAttributeUsage = 0x91
	Confirmations  TransactionAttributeUsage = 0x92
)

type TransactionPool

type TransactionPool interface {

	//  add a transaction to the pool.
	Add(*Transaction) error

	//returns all transactions that were in the pool.
	Dump() ([]*Transaction, error)
}

TransactionPool provides storage for transactions in the pending transaction pool.

type TransactionResult

type TransactionResult map[common.Uint256]common.Fixed64

Key : AssetId common.Uint256 Value: Amount common.Fixed64

type TransactionType

type TransactionType byte

for different transaction types with different payload format and transaction process methods

const (
	CoinBase                TransactionType = 0x00
	RegisterAsset           TransactionType = 0x01
	TransferAsset           TransactionType = 0x02
	Record                  TransactionType = 0x03
	Deploy                  TransactionType = 0x04
	SideChainPow            TransactionType = 0x05
	RechargeToSideChain     TransactionType = 0x06
	WithdrawFromSideChain   TransactionType = 0x07
	TransferCrossChainAsset TransactionType = 0x08
)

type TxAttribute

type TxAttribute struct {
	Usage TransactionAttributeUsage
	Data  []byte
	Size  uint32
}

func NewTxAttribute

func NewTxAttribute(u TransactionAttributeUsage, d []byte) TxAttribute

func (*TxAttribute) Deserialize

func (tx *TxAttribute) Deserialize(r io.Reader) error

func (*TxAttribute) GetSize

func (u *TxAttribute) GetSize() uint32

func (*TxAttribute) Serialize

func (tx *TxAttribute) Serialize(w io.Writer) error

type TxOutput

type TxOutput struct {
	AssetID     common.Uint256
	Value       common.Fixed64
	OutputLock  uint32
	ProgramHash common.Uint168
}

func (*TxOutput) Deserialize

func (o *TxOutput) Deserialize(r io.Reader)

func (*TxOutput) Serialize

func (o *TxOutput) Serialize(w io.Writer)

type UTXOTxInput

type UTXOTxInput struct {

	//Indicate the previous Tx which include the UTXO output for usage
	ReferTxID common.Uint256

	//The index of output in the referTx output list
	ReferTxOutputIndex uint16

	// Sequence number
	Sequence uint32
}

func (*UTXOTxInput) Deserialize

func (ui *UTXOTxInput) Deserialize(r io.Reader) error

func (*UTXOTxInput) Equals

func (ui *UTXOTxInput) Equals(other *UTXOTxInput) bool

func (*UTXOTxInput) Serialize

func (ui *UTXOTxInput) Serialize(w io.Writer)

func (*UTXOTxInput) ToString

func (ui *UTXOTxInput) ToString() string

type UTXOUnspent

type UTXOUnspent struct {
	Txid  common.Uint256
	Index uint32
	Value common.Fixed64
}

func (*UTXOUnspent) Deserialize

func (uu *UTXOUnspent) Deserialize(r io.Reader) error

func (*UTXOUnspent) Serialize

func (uu *UTXOUnspent) Serialize(w io.Writer)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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