transaction

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2018 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)

func (BalanceTxInput) String

func (self BalanceTxInput) String() string

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)

func (*Transaction) String

func (tx *Transaction) String() string

type TransactionAttributeUsage

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

func (TransactionAttributeUsage) Name

func (self TransactionAttributeUsage) Name() string

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
	SideMining    TransactionType = 0x05
)

func (TransactionType) Name

func (self TransactionType) Name() string

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

func (TxAttribute) String

func (self TxAttribute) String() string

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) error

func (*TxOutput) Serialize

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

func (TxOutput) String

func (self TxOutput) String() string

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) String

func (self UTXOTxInput) String() string

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