builder

package
v3.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 7 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTransactionBuilder defines a generic error occurring within the TransactionBuilder.
	ErrTransactionBuilder = errors.New("transaction builder error")
)

Functions

This section is empty.

Types

type BlockBuilder

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

BlockBuilder is used to easily build up a Block.

func NewBlockBuilder

func NewBlockBuilder() *BlockBuilder

NewBlockBuilder creates a new BlockBuilder.

func (*BlockBuilder) Build

func (mb *BlockBuilder) Build() (*iotago.Block, error)

Build builds the Block or returns any error which occurred during the build steps.

func (*BlockBuilder) Parents

func (mb *BlockBuilder) Parents(parents iotago.BlockIDs) *BlockBuilder

Parents sets the parents.

func (*BlockBuilder) Payload

func (mb *BlockBuilder) Payload(payload iotago.Payload) *BlockBuilder

Payload sets the payload.

func (*BlockBuilder) ProofOfWork

func (mb *BlockBuilder) ProofOfWork(ctx context.Context, protoParas *iotago.ProtocolParameters, targetScore float64, numWorkers ...int) *BlockBuilder

ProofOfWork does the proof-of-work needed in order to satisfy the given target score. It can be canceled by canceling the given context. This function should normally appear as the last step before Build.

func (*BlockBuilder) ProtocolVersion

func (mb *BlockBuilder) ProtocolVersion(version byte) *BlockBuilder

ProtocolVersion sets the protocol version.

func (*BlockBuilder) Tips

func (mb *BlockBuilder) Tips(ctx context.Context, nodeAPI *nodeclient.Client) *BlockBuilder

Tips queries the node API for tips/parents and sets them accordingly.

type TransactionBuilder

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

TransactionBuilder is used to easily build up a Transaction.

func NewTransactionBuilder

func NewTransactionBuilder(networkID iotago.NetworkID) *TransactionBuilder

NewTransactionBuilder creates a new TransactionBuilder.

func (*TransactionBuilder) AddInput

func (b *TransactionBuilder) AddInput(input *TxInput) *TransactionBuilder

AddInput adds the given input to the builder.

func (*TransactionBuilder) AddOutput

func (b *TransactionBuilder) AddOutput(output iotago.Output) *TransactionBuilder

AddOutput adds the given output to the builder.

func (*TransactionBuilder) AddTaggedDataPayload

func (b *TransactionBuilder) AddTaggedDataPayload(payload *iotago.TaggedData) *TransactionBuilder

AddTaggedDataPayload adds the given TaggedData as the inner payload.

func (*TransactionBuilder) Build

Build sings the inputs with the given signer and returns the built payload.

func (*TransactionBuilder) BuildAndSwapToBlockBuilder

func (b *TransactionBuilder) BuildAndSwapToBlockBuilder(protoParas *iotago.ProtocolParameters, signer iotago.AddressSigner, txFunc TransactionFunc) *BlockBuilder

BuildAndSwapToBlockBuilder builds the transaction and then swaps to a BlockBuilder with the transaction set as its payload. txFunc can be nil.

type TransactionBuilderInputFilter

type TransactionBuilderInputFilter func(outputID iotago.OutputID, input iotago.Output) bool

TransactionBuilderInputFilter is a filter function which determines whether an input should be used or not. (returning true = pass). The filter can also be used to accumulate data over the set of inputs, i.e. the input sum etc.

type TransactionFunc

type TransactionFunc func(tx *iotago.Transaction)

TransactionFunc is a function which receives a Transaction as its parameter.

type TxInput

type TxInput struct {
	// The address which needs to be unlocked to spend this input.
	UnlockTarget iotago.Address `json:"address"`
	// The ID of the referenced input.
	InputID iotago.OutputID `json:"inputID"`
	// The output which is used as an input.
	Input iotago.Output `json:"input"`
}

TxInput defines an input with the address to unlock.

Jump to

Keyboard shortcuts

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