bundle

package
v1.0.0-beta.15....-0de5f12 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package bundle provides primitives to create and validate bundles.

Index

Constants

This section is empty.

Variables

View Source
var EmptyTransfer = Transfer{
	Message: NullSignatureMessageFragmentTrytes,
	Value:   0,
	Tag:     NullTagTrytes,
	Address: NullAddressWithChecksum,
}

EmptyTransfer is a transfer with 9s initialized values.

Functions

func PadTag

func PadTag(tag Trytes) Trytes

PadTag pads the given trytes up to the length of a tag.

func TailTransactionHash

func TailTransactionHash(bndl Bundle) Hash

TailTransactionHash returns the tail transaction's hash.

func ValidBundle

func ValidBundle(bundle Bundle) error

ValidBundle checks if a bundle is syntactically valid. Validates signatures and overall structure.

func ValidateBundleSignatures

func ValidateBundleSignatures(bundle Bundle) (bool, error)

ValidateBundleSignatures validates all signatures of the given bundle. Use ValidBundle() if you want to validate the overall structure of the bundle and the signatures.

Types

type Bundle

type Bundle = transaction.Transactions

Bundle represents grouped together transactions for creating a transfer.

func AddEntry

func AddEntry(txs Bundle, bndlEntry BundleEntry) Bundle

AddEntry adds a new entry to the bundle. It automatically adds additional transactions if the signature message fragments don't fit into one transaction.

func AddTrytes

func AddTrytes(bndl Bundle, fragments []Trytes, offset int) Bundle

AddTrytes adds the given fragments to the txs in the bundle starting from the specified offset.

func Finalize

func Finalize(bundle Bundle) (Bundle, error)

Finalize finalizes the bundle by calculating the bundle hash and setting it on each transaction bundle hash field.

type BundleEntries

type BundleEntries = []BundleEntry

BundleEntries are a slice of BundleEntry.

func TransfersToBundleEntries

func TransfersToBundleEntries(timestamp uint64, transfers ...Transfer) (BundleEntries, error)

TransfersToBundleEntries translates transfers to bundle entries.

type BundleEntry

type BundleEntry struct {
	// The amount of transactions to fulfill this entry.
	Length uint64
	// The address used for this entry.
	Address Hash
	// The value for this entry.
	Value int64
	// The tag for this entry.
	Tag Trytes
	// The timestamp for this entry.
	Timestamp uint64
	// One or multiple signature message fragments.
	SignatureMessageFragments []Trytes
}

BundleEntry is an object which gets translated into one or multiple transactions when used in conjunction with AddEntry().

type Bundles

type Bundles []Bundle

Bundles are a slice of Bundle.

func GroupTransactionsIntoBundles

func GroupTransactionsIntoBundles(txs transaction.Transactions) Bundles

GroupTransactionsIntoBundles groups the given transactions into groups of bundles. Note that the same bundle can exist in the return slice multiple times, though they are reattachments of the same transfer.

type BundlesByTimestamp

type BundlesByTimestamp Bundles

BundlesByTimestamp are sorted bundles by attachment timestamp.

func (BundlesByTimestamp) Len

func (a BundlesByTimestamp) Len() int

ignore

func (BundlesByTimestamp) Less

func (a BundlesByTimestamp) Less(i int, j int) bool

ignore

func (BundlesByTimestamp) Swap

func (a BundlesByTimestamp) Swap(i int, j int)

ignore

type Transfer

type Transfer struct {
	Address Hash
	Value   uint64
	Message Trytes
	Tag     Trytes
}

Transfer represents the data/value to transfer to an address.

type Transfers

type Transfers []Transfer

Transfers are a slice of Transfer.

Jump to

Keyboard shortcuts

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