transaction

package
v0.0.0-...-a0055f1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransactionTypeLength   = 1
	BlockNumberLength       = 4
	TransactionNumberLength = 4
	OutputNumberLength      = 1
	AddressLength           = 20
	ValueLength             = 32
	VLength                 = 1
	RLength                 = 32
	SLength                 = 32

	TransactionTypeSplit = byte(0x01)
	TransactionTypeMerge = byte(0x02)
	TransactionTypeFund  = byte(0x04)
)

Variables

View Source
var EmptyAddress = common.Address{}

Functions

func CreateCorrespondingUTXOIndexForInput

func CreateCorrespondingUTXOIndexForInput(tx *SignedTransaction, inputNumber int) ([UTXOIndexLength]byte, error)

func CreateFdbUTXOIndexForInput

func CreateFdbUTXOIndexForInput(db fdb.Database, tx *SignedTransaction, inputNumber int) (subspace.Subspace, error)

func CreateShortUTXOIndexForOutput

func CreateShortUTXOIndexForOutput(tx *SignedTransaction, blockNumber uint32, transactionNumber uint32, outputNumber int) ([]byte, error)

func CreateUTXOIndexForOutput

func CreateUTXOIndexForOutput(tx *SignedTransaction, blockNumber uint32, transactionNumber uint32, outputNumber int) ([UTXOIndexLength]byte, error)

Types

type HumanReadableUTXOdetails

type HumanReadableUTXOdetails struct {
	Owner             string
	BlockNumber       uint32
	TransactionNumber uint32
	OutputNumber      uint8
	Value             string
}

func ParseIndexIntoUTXOdetails

func ParseIndexIntoUTXOdetails(index [UTXOIndexLength]byte) HumanReadableUTXOdetails

type NumberedTransaction

type NumberedTransaction struct {
	TransactionNumber [TransactionNumberLength]byte
	SignedTransaction *SignedTransaction
}

TransactionInput is one of the inputs into Plasma transaction

func NewNumberedTransaction

func NewNumberedTransaction(signedTX *SignedTransaction, transactionNumber uint32) (*NumberedTransaction, error)

func (*NumberedTransaction) DecodeRLP

func (tx *NumberedTransaction) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt from an RLP stream.

func (*NumberedTransaction) EncodeRLP

func (tx *NumberedTransaction) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt into an RLP stream. If no post state is present, byzantium fork is assumed.

func (*NumberedTransaction) GetRaw

func (tx *NumberedTransaction) GetRaw() ([]byte, error)

func (*NumberedTransaction) Validate

func (tx *NumberedTransaction) Validate() error

signature is [R || S || V]

type ParsedTransactionResult

type ParsedTransactionResult struct {
	From           []byte
	UtxoIndexes    []UTXOindex
	SpendingRecord []byte
	ShardID        []byte
}

type ShortUTXOdetails

type ShortUTXOdetails struct {
	BlockNumber       uint32
	TransactionNumber uint32
	OutputNumber      uint8
}

func ParseUTXOindexNumberIntoDetails

func ParseUTXOindexNumberIntoDetails(indexBN *types.BigInt) (*ShortUTXOdetails, error)

type SignedTransaction

type SignedTransaction struct {
	UnsignedTransaction *UnsignedTransaction
	V                   [VLength]byte
	R                   [RLength]byte
	S                   [SLength]byte

	RawValue []byte
	// contains filtered or unexported fields
}

TransactionInput is one of the inputs into Plasma transaction

func CreateRawFundingTX

func CreateRawFundingTX(to common.Address,
	value *types.BigInt,
	depositIndex *types.BigInt,
	signingKey []byte) (*SignedTransaction, error)

func NewSignedTransaction

func NewSignedTransaction(unsignedTX *UnsignedTransaction, v []byte, r []byte, s []byte) (*SignedTransaction, error)

func (*SignedTransaction) DecodeRLP

func (tx *SignedTransaction) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt from an RLP stream.

func (*SignedTransaction) EncodeRLP

func (tx *SignedTransaction) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt into an RLP stream. If no post state is present, byzantium fork is assumed.

func (*SignedTransaction) GetFrom

func (tx *SignedTransaction) GetFrom() (common.Address, error)

func (*SignedTransaction) GetRaw

func (tx *SignedTransaction) GetRaw() ([]byte, error)

func (*SignedTransaction) Sign

func (tx *SignedTransaction) Sign(privateKey []byte) error

func (*SignedTransaction) Validate

func (tx *SignedTransaction) Validate() error

signature is [R || S || V]

type SpendingRecord

type SpendingRecord struct {
	SpendingTransaction *SignedTransaction
	OutputIndexes       [][UTXOIndexLength]byte
}

func NewSpendingRecord

func NewSpendingRecord(tx *SignedTransaction, outputIndexes [][UTXOIndexLength]byte) *SpendingRecord

func (*SpendingRecord) DecodeRLP

func (tx *SpendingRecord) DecodeRLP(s *rlp.Stream) error

func (*SpendingRecord) EncodeRLP

func (tx *SpendingRecord) EncodeRLP(w io.Writer) error

type TransactionInput

type TransactionInput struct {
	BlockNumber       [BlockNumberLength]byte
	TransactionNumber [TransactionNumberLength]byte
	OutputNumber      [OutputNumberLength]byte
	Value             [ValueLength]byte
}

TransactionInput is one of the inputs into Plasma transaction

func (*TransactionInput) DecodeRLP

func (input *TransactionInput) DecodeRLP(s *rlp.Stream) error

func (*TransactionInput) EncodeRLP

func (input *TransactionInput) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt into an RLP stream. If no post state is present, byzantium fork is assumed.

func (*TransactionInput) GetReferedUTXO

func (input *TransactionInput) GetReferedUTXO() *types.BigInt

func (*TransactionInput) GetValue

func (input *TransactionInput) GetValue() *types.BigInt

func (*TransactionInput) SetFields

func (input *TransactionInput) SetFields(blockNumber *types.BigInt, transactionNumber *types.BigInt, outputNumber *types.BigInt, value *types.BigInt) error

SetFields creates a new input sturcture

type TransactionOutput

type TransactionOutput struct {
	OutputNumber [OutputNumberLength]byte
	To           [AddressLength]byte
	Value        [ValueLength]byte
}

TransactionInput is one of the inputs into Plasma transaction

func (*TransactionOutput) DecodeRLP

func (output *TransactionOutput) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt from an RLP stream.

func (*TransactionOutput) EncodeRLP

func (output *TransactionOutput) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt into an RLP stream. If no post state is present, byzantium fork is assumed.

func (*TransactionOutput) GetToAddress

func (output *TransactionOutput) GetToAddress() common.Address

Get address as Ethereum Address type

func (*TransactionOutput) GetValue

func (output *TransactionOutput) GetValue() *types.BigInt

func (*TransactionOutput) SetFields

func (output *TransactionOutput) SetFields(outputNumber *types.BigInt, address common.Address, value *types.BigInt) error

SetFields creates a new input sturcture

type TransactionParser

type TransactionParser struct {
	ConcurrencyLimit int
	// contains filtered or unexported fields
}

func NewTransactionParser

func NewTransactionParser(concurrency int) *TransactionParser

func (*TransactionParser) Parse

type UTXOindex

type UTXOindex struct {
	Key   []byte
	Value []byte
}

type UnsignedTransaction

type UnsignedTransaction struct {
	TransactionType [TransactionTypeLength]byte
	Inputs          []*TransactionInput
	Outputs         []*TransactionOutput
}

TransactionInput is one of the inputs into Plasma transaction

func NewUnsignedTransaction

func NewUnsignedTransaction(txType byte, inputs []*TransactionInput, outputs []*TransactionOutput) (*UnsignedTransaction, error)

func (*UnsignedTransaction) DecodeRLP

func (tx *UnsignedTransaction) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder, and loads the consensus fields of a receipt from an RLP stream.

func (*UnsignedTransaction) EncodeRLP

func (tx *UnsignedTransaction) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder, and flattens the consensus fields of a receipt into an RLP stream. If no post state is present, byzantium fork is assumed.

func (*UnsignedTransaction) GetHash

func (tx *UnsignedTransaction) GetHash() (common.Hash, error)

func (*UnsignedTransaction) Validate

func (tx *UnsignedTransaction) Validate() error

Jump to

Keyboard shortcuts

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