txbuilder

package
v0.0.0-...-1c999d7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForEachOutput

func ForEachOutput(outs []*ledger.OutputDataWithID, fun func(o *Output, odata *ledger.OutputDataWithID) bool) error

func GetChainAccount

func GetChainAccount(chainID []byte, ind ledger.IndexerReader, state ledger.StateReader, desc ...bool) (*OutputWithChainID, []*OutputWithID, error)

func MakeChainTransferTransactionOutputs

func MakeChainTransferTransactionOutputs(par *TransferData) ([]byte, []*ledger.OutputDataWithID, error)

func MakeSimpleTransferTransactionOutputs

func MakeSimpleTransferTransactionOutputs(par *TransferData) ([]byte, []*ledger.OutputDataWithID, error)

func MakeTransferTransaction

func MakeTransferTransaction(par *TransferData) ([]byte, error)

func ValidationContextToString

func ValidationContextToString(v *state.TransactionContext) string

Types

type Output

type Output struct {
	// contains filtered or unexported fields
}

func NewOutput

func NewOutput() *Output

func OutputBasic

func OutputBasic(amount uint64, ts uint32, lock constraints.Lock) *Output

func OutputFromBytes

func OutputFromBytes(data []byte) (*Output, error)

func (*Output) Amount

func (o *Output) Amount() uint64

func (*Output) AsArray

func (o *Output) AsArray() *lazyslice.Array

func (*Output) Bytes

func (o *Output) Bytes() []byte

func (*Output) ChainConstraint

func (o *Output) ChainConstraint() (*constraints.ChainConstraint, byte)

ChainConstraint finds and parses chain constraint. Returns its constraintIndex or 0xff if not found

func (*Output) Clone

func (o *Output) Clone() *Output

func (*Output) Constraint

func (o *Output) Constraint(idx byte) []byte

func (*Output) ForEachConstraint

func (o *Output) ForEachConstraint(fun func(idx byte, constr []byte) bool)

func (*Output) Lock

func (o *Output) Lock() constraints.Lock

func (*Output) NumConstraints

func (o *Output) NumConstraints() int

func (*Output) PushConstraint

func (o *Output) PushConstraint(c []byte) (byte, error)

func (*Output) PutConstraint

func (o *Output) PutConstraint(c []byte, idx byte)

func (*Output) SenderAddressED25519

func (o *Output) SenderAddressED25519() (constraints.AddressED25519, bool)

func (*Output) TimeLock

func (o *Output) TimeLock() (uint32, bool)

func (*Output) Timestamp

func (o *Output) Timestamp() uint32

func (*Output) ToString

func (o *Output) ToString(prefix ...string) string

func (*Output) WithAmount

func (o *Output) WithAmount(amount uint64) *Output

func (*Output) WithLock

func (o *Output) WithLock(lock constraints.Lock) *Output

func (*Output) WithTimestamp

func (o *Output) WithTimestamp(ts uint32) *Output

type OutputWithChainID

type OutputWithChainID struct {
	OutputWithID
	ChainID                    [32]byte
	PredecessorConstraintIndex byte
}

func ParseChainConstraints

func ParseChainConstraints(outs []*ledger.OutputDataWithID) ([]*OutputWithChainID, error)

type OutputWithID

type OutputWithID struct {
	ID     ledger.OutputID
	Output *Output
}

func ParseAndSortOutputData

func ParseAndSortOutputData(outs []*ledger.OutputDataWithID, filter func(o *Output) bool, desc ...bool) ([]*OutputWithID, error)

type TransactionBuilder

type TransactionBuilder struct {
	ConsumedOutputs []*Output
	Transaction     *transaction
}

func NewTransactionBuilder

func NewTransactionBuilder() *TransactionBuilder

func (*TransactionBuilder) ConsumeOutput

func (txb *TransactionBuilder) ConsumeOutput(out *Output, oid ledger.OutputID) (byte, error)

func (*TransactionBuilder) InputCommitment

func (txb *TransactionBuilder) InputCommitment() [32]byte

func (*TransactionBuilder) InsertSimpleChainTransition

func (txb *TransactionBuilder) InsertSimpleChainTransition(inChainData *ledger.OutputDataWithChainID, ts uint32) error

InsertSimpleChainTransition inserts a simple chain transition. Takes output with chain constraint from parameters, Produces identical output, only modifies timestamp. Unlocks chain-input lock with signature reference

func (*TransactionBuilder) NumInputs

func (txb *TransactionBuilder) NumInputs() int

func (*TransactionBuilder) NumOutputs

func (txb *TransactionBuilder) NumOutputs() int

func (*TransactionBuilder) ProduceOutput

func (txb *TransactionBuilder) ProduceOutput(out *Output) (byte, error)

func (*TransactionBuilder) PushEndorsement

func (txb *TransactionBuilder) PushEndorsement(txid *ledger.TransactionID)

func (*TransactionBuilder) PutSignatureUnlock

func (txb *TransactionBuilder) PutSignatureUnlock(outputIndex, constraintIndex byte)

PutSignatureUnlock marker 0xff references signature of the transaction. It can be distinguished from any reference because it cannot be stringly less than any other reference

func (*TransactionBuilder) PutUnlockParams

func (txb *TransactionBuilder) PutUnlockParams(outputIndex, constraintIndex byte, unlockParamData []byte)

func (*TransactionBuilder) PutUnlockReference

func (txb *TransactionBuilder) PutUnlockReference(outputIndex, constraintIndex, referencedOutputIndex byte) error

PutUnlockReference references some preceding output

func (*TransactionBuilder) SignED25519

func (txb *TransactionBuilder) SignED25519(privKey ed25519.PrivateKey)

type TransferData

type TransferData struct {
	SenderPrivateKey ed25519.PrivateKey
	SenderPublicKey  ed25519.PublicKey
	SourceAccount    constraints.Accountable
	Outputs          []*OutputWithID
	ChainOutput      *OutputWithChainID
	Timestamp        uint32 // takes time.Now() if 0
	Lock             constraints.Lock
	Amount           uint64
	AdjustToMinimum  bool
	AddSender        bool
	AddConstraints   [][]byte
	UnlockData       []*UnlockData
}

func NewTransferData

func NewTransferData(senderKey ed25519.PrivateKey, sourceAccount constraints.Accountable, ts uint32) *TransferData

func (*TransferData) AdjustedAmount

func (t *TransferData) AdjustedAmount() uint64

AdjustedAmount adjust amount to minimum storage deposit requirements

func (*TransferData) WithAmount

func (t *TransferData) WithAmount(amount uint64, adjustToMinimum ...bool) *TransferData

func (*TransferData) WithChainOutput

func (t *TransferData) WithChainOutput(out *OutputWithChainID) *TransferData

func (*TransferData) WithConstraint

func (t *TransferData) WithConstraint(constr constraints.Constraint, idx ...byte) *TransferData

func (*TransferData) WithConstraintAtIndex

func (t *TransferData) WithConstraintAtIndex(constr constraints.Constraint) *TransferData

func (*TransferData) WithConstraintBinary

func (t *TransferData) WithConstraintBinary(constr []byte, idx ...byte) *TransferData

func (*TransferData) WithOutputs

func (t *TransferData) WithOutputs(outs []*OutputWithID) *TransferData

func (*TransferData) WithSender

func (t *TransferData) WithSender() *TransferData

func (*TransferData) WithTargetLock

func (t *TransferData) WithTargetLock(lock constraints.Lock) *TransferData

func (*TransferData) WithUnlockData

func (t *TransferData) WithUnlockData(consumedOutputIndex, constraintIndex byte, data []byte) *TransferData

type UnlockData

type UnlockData struct {
	OutputIndex     byte
	ConstraintIndex byte
	Data            []byte
}

type UnlockParams

type UnlockParams struct {
	// contains filtered or unexported fields
}

func NewUnlockBlock

func NewUnlockBlock() *UnlockParams

func (*UnlockParams) Bytes

func (u *UnlockParams) Bytes() []byte

Jump to

Keyboard shortcuts

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