iotago

package module
v3.0.0-...-305da2a Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 25 Imported by: 0

README

iota.go

Official Go library.

This library allows you to do the following:

  • Create messages with indexation and transaction payloads
  • Get messages and outputs
  • Sign transactions
  • Generate addresses
  • Interact with an IOTA node
  • Act as a foundation for Go based node software

If you need to have more sophisticated account management, have a look at wallet.rs for which we also provide bindings in Python and JavaScript.

Requirements

This library was mainly tested with Go version 1.16.x

To use the library, we recommend you update Go to the latest stable version.

Using the library

Using the library is easy, just go get it as any other dependency:

go get github.com/iotaledger/iota.go/v3

API reference

You can read the API reference here.

Joining the discussion

If you want to get involved in the community, need help with setting up, have any issues or just want to discuss IOTA with other people, feel free to join our Discord in the #clients-dev and #clients-discussion channels.

License

The MIT license can be found here.

Documentation

Overview

Package iotago provides IOTA data models, a node API client and builders to craft messages and transactions.

Creating Messages

// create a new node API client
nodeHTTPAPIClient := iotago.NewNodeHTTPAPIClient("https://example.com")

// fetch the node's info to know the min. required PoW score
info, err := nodeHTTPAPIClient.Info()
if err != nil {
	return err
}

// craft an indexation payload
indexationPayload := &iotago.Indexation{
	Index: []byte("hello world"),
	Data:  []byte{1, 2, 3, 4},
}

ctx, cancelFunc := context.WithTimeout(context.Background(), 15*time.Second)
defer cancelFunc()

// build a message by fetching tips via the node API client and then do local Proof-of-Work
msg, err := iotago.NewMessageBuilder().
	Payload(indexationPayload).
	Tips(nodeHTTPAPIClient).
	ProofOfWork(ctx, info.MinPowScore).
	Build()

// submit the message to the node
if _, err := nodeHTTPAPIClient.SubmitMessage(msg); err != nil {
	return err
}

Index

Constants

View Source
const (
	// AddressEd25519 denotes an Ed25519 address.
	AddressEd25519 = 0
	// AddressAlias denotes an Alias address.
	AddressAlias = 8
	// AddressNFT denotes an NFT address.
	AddressNFT = 16
)
View Source
const (
	// AliasAddressBytesLength is the length of an Alias address.
	AliasAddressBytesLength = 20
	// AliasAddressSerializedBytesSize is the size of a serialized Alias address with its type denoting byte.
	AliasAddressSerializedBytesSize = serializer.SmallTypeDenotationByteSize + AliasAddressBytesLength
)
View Source
const (
	// Ed25519AddressBytesLength is the length of an Ed25519 address.
	Ed25519AddressBytesLength = blake2b.Size256
	// Ed25519AddressSerializedBytesSize is the size of a serialized Ed25519 address with its type denoting byte.
	Ed25519AddressSerializedBytesSize = serializer.SmallTypeDenotationByteSize + Ed25519AddressBytesLength
)
View Source
const (
	// NFTAddressBytesLength is the length of an NFT address.
	NFTAddressBytesLength = 20
	// NFTAddressSerializedBytesSize is the size of a serialized NFT address with its type denoting byte.
	NFTAddressSerializedBytesSize = serializer.SmallTypeDenotationByteSize + NFTAddressBytesLength
)
View Source
const (
	// IndexationBinSerializedMinSize is the minimum size of an Indexation.
	// 	type bytes + index prefix + one char + data length
	IndexationBinSerializedMinSize = serializer.TypeDenotationByteSize + serializer.UInt16ByteSize + serializer.OneByte + serializer.UInt32ByteSize
	// IndexationIndexMaxLength defines the max length of the index within an Indexation.
	IndexationIndexMaxLength = 64
	// IndexationIndexMinLength defines the min length of the index within an Indexation.
	IndexationIndexMinLength = 1
)
View Source
const (
	// TreasuryInputBytesLength is the length of a TreasuryInput.
	TreasuryInputBytesLength = blake2b.Size256
	// TreasuryInputSerializedBytesSize is the size of a serialized TreasuryInput with its type denoting byte.
	TreasuryInputSerializedBytesSize = serializer.SmallTypeDenotationByteSize + TreasuryInputBytesLength
)
View Source
const (
	// RefUTXOIndexMin is the minimum index of a referenced UTXO.
	RefUTXOIndexMin = 0
	// RefUTXOIndexMax is the maximum index of a referenced UTXO.
	RefUTXOIndexMax = 126

	// UTXOInputSize is the size of a UTXO input: input type + tx id + index
	UTXOInputSize = serializer.SmallTypeDenotationByteSize + TransactionIDLength + serializer.UInt16ByteSize
)
View Source
const (
	// MessageIDLength defines the length of a message ID.
	MessageIDLength = blake2b.Size256
	// MessageNetworkIDLength defines the length of the network ID in bytes.
	MessageNetworkIDLength = serializer.UInt64ByteSize
	// MessageBinSerializedMinSize defines the minimum size of a message: network ID + parent count + 1 parent + uint16 payload length + nonce
	MessageBinSerializedMinSize = MessageNetworkIDLength + serializer.OneByte + MessageIDLength + serializer.UInt32ByteSize + serializer.UInt64ByteSize
	// MessageBinSerializedMaxSize defines the maximum size of a message.
	MessageBinSerializedMaxSize = 32768
	// MinParentsInAMessage defines the minimum amount of parents in a message.
	MinParentsInAMessage = 1
	// MaxParentsInAMessage defines the maximum amount of parents in a message.
	MaxParentsInAMessage = 8
)
View Source
const (
	// MilestoneInclusionMerkleProofLength defines the length of the inclusion merkle proof within a milestone payload.
	MilestoneInclusionMerkleProofLength = blake2b.Size256
	// MilestoneSignatureLength defines the length of the milestone signature.
	MilestoneSignatureLength = ed25519.SignatureSize
	// MilestoneIDLength defines the length of a Milestone ID.
	MilestoneIDLength = blake2b.Size256
	// MilestonePublicKeyLength defines the length of a public key within a milestone.
	MilestonePublicKeyLength = ed25519.PublicKeySize
	// MilestoneBinSerializedMinSize defines the serialized size of a milestone payload.
	// 	payload type + index + timestamp + parent count + 1 parent + inclusion-merkle-proof + pubkeys-length + pubkey + sigs-length + sigs
	MilestoneBinSerializedMinSize = serializer.TypeDenotationByteSize + serializer.UInt32ByteSize + serializer.UInt64ByteSize + serializer.OneByte + MessageIDLength +
		MilestoneInclusionMerkleProofLength + serializer.OneByte + ed25519.PublicKeySize + serializer.OneByte + MilestoneSignatureLength
	// MaxSignaturesInAMilestone is the maximum amount of signatures in a milestone.
	MaxSignaturesInAMilestone = 255
	// MinSignaturesInAMilestone is the minimum amount of signatures in a milestone.
	MinSignaturesInAMilestone = 1
	// MaxPublicKeysInAMilestone is the maximum amount of public keys in a milestone.
	MaxPublicKeysInAMilestone = 255
	// MinPublicKeysInAMilestone is the minimum amount of public keys in a milestone.
	MinPublicKeysInAMilestone = 1
)
View Source
const (
	// MinNativeTokenCountPerOutput min number of different native tokens that can reside in one output.
	MinNativeTokenCountPerOutput = 0
	// MaxNativeTokenCountPerOutput max number of different native tokens that can reside in one output.
	MaxNativeTokenCountPerOutput = 256

	// MaxNativeTokensCount is the max number of native tokens which can occur in a transaction (sum input/output side).
	MaxNativeTokensCount = 256

	TokenTagLength = 12

	// Uint256ByteSize defines the size of an uint256.
	Uint256ByteSize = 32

	// NativeTokenIDLength is the byte length of a NativeTokenID consisting out of the FoundryID plus TokenTag.
	NativeTokenIDLength = FoundryIDLength + TokenTagLength

	// NativeTokenVByteCost defines the static virtual byte cost of a NativeToken.
	NativeTokenVByteCost = serializer.UInt16ByteSize + Uint256ByteSize
)
View Source
const (
	// NodeAPIRouteHealth is the route for querying a node's health status.
	NodeAPIRouteHealth = "/health"

	// NodeAPIRouteInfo is the route for getting the node info.
	// GET returns the node info.
	NodeAPIRouteInfo = "/api/v1/info"

	// NodeAPIRouteTips is the route for getting two tips.
	// GET returns the tips.
	NodeAPIRouteTips = "/api/v1/tips"

	// NodeAPIRouteMessageMetadata is the route for getting message metadata by its messageID.
	// GET returns message metadata (including info about "promotion/reattachment needed").
	NodeAPIRouteMessageMetadata = "/api/v1/messages/%s/metadata"

	// NodeAPIRouteMessageBytes is the route for getting message raw data by its messageID.
	// GET returns raw message data (bytes).
	NodeAPIRouteMessageBytes = "/api/v1/messages/%s/raw"

	// NodeAPIRouteMessageChildren is the route for getting message IDs of the children of a message, identified by its messageID.
	// GET returns the message IDs of all children.
	NodeAPIRouteMessageChildren = "/api/v1/messages/%s/children"

	// NodeAPIRouteMessages is the route for getting message IDs or creating new messages.
	// GET with query parameter (mandatory) returns all message IDs that fit these filter criteria (query parameters: "index").
	// POST creates a single new message and returns the new message ID.
	NodeAPIRouteMessages = "/api/v1/messages"

	// NodeAPIRouteMilestone is the route for getting a milestone by its milestoneIndex.
	// GET returns the milestone.
	NodeAPIRouteMilestone = "/api/v1/milestones/%s"

	// NodeAPIRouteMilestoneUTXOChanges is the route for getting all UTXO changes of a milestone by its milestoneIndex.
	// GET returns the output IDs of all UTXO changes.
	NodeAPIRouteMilestoneUTXOChanges = "/api/v1/milestones/%s/utxo-changes"

	// NodeAPIRouteOutput is the route for getting outputs by their outputID (transactionHash + outputIndex).
	// GET returns the output.
	NodeAPIRouteOutput = "/api/v1/outputs/%s"

	// NodeAPIRouteAddressBech32Balance is the route for getting the total balance of all unspent outputs of a Bech32 address.
	// GET returns the balance of all unspent outputs of this address.
	NodeAPIRouteAddressBech32Balance = "/api/v1/addresses/%s"

	// NodeAPIRouteAddressEd25519Balance is the route for getting the total balance of all unspent outputs of an ed25519 address.
	// The ed25519 address must be encoded in hex.
	// GET returns the balance of all unspent outputs of this address.
	NodeAPIRouteAddressEd25519Balance = "/api/v1/addresses/ed25519/%s"

	// NodeAPIRouteAddressBech32Outputs is the route for getting all output IDs for a Bech32 address.
	// GET returns the outputIDs for all outputs of this address (optional query parameters: "include-spent").
	NodeAPIRouteAddressBech32Outputs = "/api/v1/addresses/%s/outputs"

	// NodeAPIRouteAddressEd25519Outputs is the route for getting all output IDs for an ed25519 address.
	// The ed25519 address must be encoded in hex.
	// GET returns the outputIDs for all outputs of this address (optional query parameters: "include-spent").
	NodeAPIRouteAddressEd25519Outputs = "/api/v1/addresses/ed25519/%s/outputs"

	// NodeAPIRouteTreasury is the route for getting the current treasury.
	// GET returns the treasury.
	NodeAPIRouteTreasury = "/api/v1/treasury"

	// NodeAPIRouteReceipts is the route for getting all persisted receipts on a node.
	// GET returns the receipts.
	NodeAPIRouteReceipts = "/api/v1/receipts"

	// NodeAPIRouteReceiptsByMigratedAtIndex is the route for getting all persisted receipts for a given migrated at index on a node.
	// GET returns the receipts for the given migrated at index.
	NodeAPIRouteReceiptsByMigratedAtIndex = "/api/v1/receipts/%s"

	// NodeAPIRoutePeer is the route for getting peers by their peerID.
	// GET returns the peer
	// DELETE deletes the peer.
	NodeAPIRoutePeer = "/api/v1/peers/%s"

	// NodeAPIRoutePeers is the route for getting all peers of the node.
	// GET returns a list of all peers.
	// POST adds a new peer.
	NodeAPIRoutePeers = "/api/v1/peers"
)
View Source
const (
	// 	NFTIDLength = 20 is the byte length of an NFTID.
	NFTIDLength = 20
	// ImmutableMetadataMaxLength defines the max of a NFTOutput's immutable data.
	// TODO: replace with TBD value
	ImmutableMetadataMaxLength = 1000
)
View Source
const (
	// MinMigratedFundsEntryCount defines the minimum amount of MigratedFundsEntry items within a Receipt.
	MinMigratedFundsEntryCount = 1
	// MaxMigratedFundsEntryCount defines the maximum amount of MigratedFundsEntry items within a Receipt.
	MaxMigratedFundsEntryCount = 127
)
View Source
const (
	// TransactionEssenceNormal denotes a standard transaction essence.
	TransactionEssenceNormal TransactionEssenceType = iota

	// MaxInputsCount defines the maximum amount of inputs within a TransactionEssence.
	MaxInputsCount = 127
	// MinInputsCount defines the minimum amount of inputs within a TransactionEssence.
	MinInputsCount = 1
	// MaxOutputsCount defines the maximum amount of outputs within a TransactionEssence.
	MaxOutputsCount = 127
	// MinOutputsCount defines the minimum amount of inputs within a TransactionEssence.
	MinOutputsCount = 1
)
View Source
const (
	// AliasIDLength is the byte length of an AliasID.
	AliasIDLength = 20
)
View Source
const (
	// AliasUnlockBlockSize defines the size of an AliasUnlockBlock.
	AliasUnlockBlockSize = serializer.SmallTypeDenotationByteSize + serializer.UInt16ByteSize
)
View Source
const (
	// Ed25519SignatureSerializedBytesSize defines the size of a serialized Ed25519Signature with its type denoting byte and public key.
	Ed25519SignatureSerializedBytesSize = serializer.SmallTypeDenotationByteSize + ed25519.PublicKeySize + ed25519.SignatureSize
)
View Source
const (
	// FoundryIDLength is the byte length of a FoundryID consisting out of the alias address, serial number and token scheme.
	FoundryIDLength = AliasAddressSerializedBytesSize + serializer.UInt32ByteSize + serializer.OneByte
)
View Source
const (
	// MaxIndexationTagLength defines the max. length of an indexation tag.
	MaxIndexationTagLength = 64
)
View Source
const (
	// MaxMetadataLength defines the max length of the data within a MetadataFeatureBlock.
	// TODO: replace with TBD value
	MaxMetadataLength = 1000
)
View Source
const (
	// MinMigratedFundsEntryDeposit defines the minimum amount a MigratedFundsEntry must deposit.
	MinMigratedFundsEntryDeposit = 1_000_000
)
View Source
const (
	// NFTUnlockBlockSize defines the size of an NFTUnlockBlock.
	NFTUnlockBlockSize = serializer.SmallTypeDenotationByteSize + serializer.UInt16ByteSize
)
View Source
const (
	// OutputIDLength defines the length of an OutputID.
	OutputIDLength = TransactionIDLength + serializer.UInt16ByteSize
)
View Source
const (
	// ReferenceUnlockBlockSize defines the size of a ReferenceUnlockBlock.
	ReferenceUnlockBlockSize = serializer.SmallTypeDenotationByteSize + serializer.UInt16ByteSize
)
View Source
const (
	// TokenSupply is the IOTA token supply.
	TokenSupply = 2_779_530_283_277_761
)
View Source
const (
	// TransactionIDLength defines the length of a Transaction ID.
	TransactionIDLength = blake2b.Size256
)

Variables

View Source
var (
	// ErrAddressKeysNotMapped gets returned if the needed keys to sign a message are absent/not mapped.
	ErrAddressKeysNotMapped = errors.New("key(s) for address not mapped")
	// ErrAddressKeysWrongType gets returned if the specified keys to sign a message for a given address are of the wrong type.
	ErrAddressKeysWrongType = errors.New("key(s) for address are of wrong type")
)
View Source
var (
	// ErrUnsupportedPayloadType gets returned for unsupported payload types.
	ErrUnsupportedPayloadType = errors.New("unsupported payload type")
	// ErrUnsupportedObjectType gets returned for unsupported object types.
	ErrUnsupportedObjectType = errors.New("unsupported object type")
	// ErrUnsupportedFeatureBlockType gets returned when an unsupported feature block exists in a set.
	ErrUnsupportedFeatureBlockType = errors.New("unsupported feature block type")
	// ErrUnknownPayloadType gets returned for unknown payload types.
	ErrUnknownPayloadType = errors.New("unknown payload type")
	// ErrUnknownAddrType gets returned for unknown address types.
	ErrUnknownAddrType = errors.New("unknown address type")
	// ErrUnknownFeatureBlockType gets returned for unknown feature block types.
	ErrUnknownFeatureBlockType = errors.New("unknown feature block type")
	// ErrUnknownInputType gets returned for unknown input types.
	ErrUnknownInputType = errors.New("unknown input type")
	// ErrUnknownOutputType gets returned for unknown output types.
	ErrUnknownOutputType = errors.New("unknown output type")
	// ErrUnknownTokenSchemeType gets returned for unknown token scheme types.
	ErrUnknownTokenSchemeType = errors.New("unknown token scheme type")
	// ErrUnknownTransactionEssenceType gets returned for unknown transaction essence types.
	ErrUnknownTransactionEssenceType = errors.New("unknown transaction essence type")
	// ErrUnknownUnlockBlockType gets returned for unknown unlock blocks.
	ErrUnknownUnlockBlockType = errors.New("unknown unlock block type")
	// ErrUnknownSignatureType gets returned for unknown signature types.
	ErrUnknownSignatureType = errors.New("unknown signature type")
	// ErrDecodeJSONUint256Str gets returned when an uint256 string could not be decoded to a big.int.
	ErrDecodeJSONUint256Str = errors.New("could not deserialize JSON uint256 string to big.Int")
)
View Source
var (
	// ErrNonUniqueFeatureBlocks gets returned when multiple FeatureBlock(s) with the same FeatureBlock exist within sets.
	ErrNonUniqueFeatureBlocks = errors.New("non unique feature blocks within outputs")
	// ErrInvalidFeatureBlockTransition gets returned when a FeatureBlock's transition within a ChainConstrainedOutput is invalid.
	ErrInvalidFeatureBlockTransition = errors.New("invalid feature block transition")
	// ErrTimelockNotExpired gets returned when timelocks in a FeatureBlocksSet are not expired.
	ErrTimelockNotExpired = errors.New("timelock not expired")
)
View Source
var (
	// ErrIndexationFeatureBlockEmpty gets returned when an IndexationFeatureBlock is empty.
	ErrIndexationFeatureBlockEmpty = errors.New("indexation feature block data is empty")
	// ErrIndexationFeatureBlockTagExceedsMaxLength gets returned when an IndexationFeatureBlock tag exceeds MaxIndexationTagLength.
	ErrIndexationFeatureBlockTagExceedsMaxLength = errors.New("indexation feature block tag exceeds max length")
)
View Source
var (
	// ErrMetadataFeatureBlockEmpty gets returned when a MetadataFeatureBlock is empty.
	ErrMetadataFeatureBlockEmpty = errors.New("metadata feature block is empty")
	// ErrMetadataFeatureBlockDataExceedsMaxLength gets returned when a MetadataFeatureBlock's data exceeds MaxMetadataLength.
	ErrMetadataFeatureBlockDataExceedsMaxLength = errors.New("metadata feature block data exceeds max length")
)
View Source
var (
	// ErrIndexationIndexExceedsMaxSize gets returned when an Indexation's index exceeds IndexationIndexMaxLength.
	ErrIndexationIndexExceedsMaxSize = errors.New("index exceeds max size")
	// ErrIndexationIndexUnderMinSize gets returned when an Indexation's index is under IndexationIndexMinLength.
	ErrIndexationIndexUnderMinSize = errors.New("index is below min size")
)
View Source
var (
	// ErrRefUTXOIndexInvalid gets returned on invalid UTXO indices.
	ErrRefUTXOIndexInvalid = fmt.Errorf("the referenced UTXO index must be between %d and %d (inclusive)", RefUTXOIndexMin, RefUTXOIndexMax)

	// ErrTypeIsNotSupportedInput gets returned when a serializable was found to not be a supported Input.
	ErrTypeIsNotSupportedInput = errors.New("serializable is not a supported input")
)
View Source
var (
	// ErrMilestoneTooFewSignatures gets returned if a to be deserialized Milestone does not contain at least one signature.
	ErrMilestoneTooFewSignatures = errors.New("a milestone must hold at least one signature")
	// ErrMilestoneTooFewSignaturesForVerificationThreshold gets returned if there are less signatures within a Milestone than the min. threshold.
	ErrMilestoneTooFewSignaturesForVerificationThreshold = errors.New("too few signatures for verification")
	// ErrMilestoneTooFewPublicKeys gets returned if a to be deserialized Milestone does not contain at least one public key.
	ErrMilestoneTooFewPublicKeys = errors.New("a milestone must hold at least one public key")
	// ErrMilestoneProducedSignaturesCountMismatch gets returned when a MilestoneSigningFunc produces less signatures than expected.
	ErrMilestoneProducedSignaturesCountMismatch = errors.New("produced and wanted signature count mismatch")
	// ErrMilestoneSignaturesPublicKeyCountMismatch gets returned when the count of signatures and public keys within a Milestone don't match.
	ErrMilestoneSignaturesPublicKeyCountMismatch = errors.New("milestone signatures and public keys count must be equal")
	// ErrMilestoneTooManySignatures gets returned when a Milestone holds more than 255 signatures.
	ErrMilestoneTooManySignatures = fmt.Errorf("a milestone can hold max %d signatures", MaxSignaturesInAMilestone)
	// ErrMilestoneInvalidMinSignatureThreshold gets returned when an invalid min signatures threshold is given to the verification function.
	ErrMilestoneInvalidMinSignatureThreshold = fmt.Errorf("min threshold must be at least 1")
	// ErrMilestoneNonApplicablePublicKey gets returned when a Milestone contains a public key which isn't in the applicable public key set.
	ErrMilestoneNonApplicablePublicKey = fmt.Errorf("non applicable public key found")
	// ErrMilestoneSignatureThresholdGreaterThanApplicablePublicKeySet gets returned when a min. signature threshold is greater than a given applicable public key set.
	ErrMilestoneSignatureThresholdGreaterThanApplicablePublicKeySet = fmt.Errorf("the min. signature threshold must be less or equal the applicable public key set")
	// ErrMilestoneInvalidSignature gets returned when a Milestone's signature is invalid.
	ErrMilestoneInvalidSignature = fmt.Errorf("invalid milestone signature")
	// ErrMilestoneInMemorySignerPrivateKeyMissing gets returned when an InMemoryEd25519MilestoneSigner is missing a private key.
	ErrMilestoneInMemorySignerPrivateKeyMissing = fmt.Errorf("private key missing")
	// ErrMilestoneDuplicatedPublicKey gets returned when a Milestone contains duplicated public keys.
	ErrMilestoneDuplicatedPublicKey = fmt.Errorf("milestone contains duplicated public keys")
	// ErrMilestoneInvalidMinPoWScoreValues gets returned when the min. PoW score fields are invalid.
	ErrMilestoneInvalidMinPoWScoreValues = fmt.Errorf("invalid milestone min pow score values")
)
View Source
var (
	// ErrNativeTokenAmountLessThanEqualZero gets returned when a NativeToken.Amount is not bigger than 0.
	ErrNativeTokenAmountLessThanEqualZero = errors.New("native token must be a value bigger than zero")
	// ErrNativeTokenSumExceedsUint256 gets returned when a NativeToken.Amount addition results in a value bigger than the max value of a uint256.
	ErrNativeTokenSumExceedsUint256 = errors.New("native token sum exceeds max value of a uint256")
	// ErrNonUniqueNativeTokens gets returned when multiple NativeToken(s) with the same NativeTokenID exist within sets.
	ErrNonUniqueNativeTokens = errors.New("non unique native tokens")
	// ErrNativeTokenSumUnbalanced gets returned when two NativeTokenSum(s) are unbalanced.
	ErrNativeTokenSumUnbalanced = errors.New("native token sums are unbalanced")
)
View Source
var (
	// ErrHTTPBadRequest gets returned for 400 bad request HTTP responses.
	ErrHTTPBadRequest = errors.New("bad request")
	// ErrHTTPInternalServerError gets returned for 500 internal server error HTTP responses.
	ErrHTTPInternalServerError = errors.New("internal server error")
	// ErrHTTPNotFound gets returned for 404 not found error HTTP responses.
	ErrHTTPNotFound = errors.New("not found")
	// ErrHTTPUnauthorized gets returned for 401 unauthorized error HTTP responses.
	ErrHTTPUnauthorized = errors.New("unauthorized")
	// ErrHTTPUnknownError gets returned for unknown error HTTP responses.
	ErrHTTPUnknownError = errors.New("unknown error")
	// ErrHTTPNotImplemented gets returned for 501 not implemented error HTTP responses.
	ErrHTTPNotImplemented = errors.New("operation not implemented/supported/available")
)
View Source
var (
	// ErrTransDepIdentOutputNonUTXOChainID gets returned when a TransDepIdentOutput has a ChainID which is not a UTXOIDChainID.
	ErrTransDepIdentOutputNonUTXOChainID = errors.New("transition dependable ident outputs must have UTXO chain IDs")
	// ErrTransDepIdentOutputNextInvalid gets returned when a TransDepIdentOutput's next state is invalid.
	ErrTransDepIdentOutputNextInvalid = errors.New("transition dependable ident output's next output is invalid")
)
View Source
var (
	// ErrDepositAmountMustBeGreaterThanZero returned if the deposit amount of an output is less or equal zero.
	ErrDepositAmountMustBeGreaterThanZero = errors.New("deposit amount must be greater than zero")
	// ErrChainMissing gets returned when a chain is missing.
	ErrChainMissing = errors.New("chain missing")
	// ErrNonUniqueChainConstrainedOutputs gets returned when multiple ChainConstrainedOutputs(s) with the same ChainID exist within sets.
	ErrNonUniqueChainConstrainedOutputs = errors.New("non unique chain constrained outputs")
	// ErrInvalidChainStateTransition gets returned when a state transition validation fails for a ChainConstrainedOutput.
	ErrInvalidChainStateTransition = errors.New("invalid chain state transition")
	// ErrTypeIsNotSupportedOutput gets returned when a serializable was found to not be a supported Output.
	ErrTypeIsNotSupportedOutput = errors.New("serializable is not a supported output")
)
View Source
var (
	// ErrNonUniqueAliasOutputs gets returned when multiple AliasOutputs(s) with the same AliasID exist within sets.
	ErrNonUniqueAliasOutputs = errors.New("non unique aliases within outputs")
	// ErrInvalidAliasStateTransition gets returned when an alias is doing an invalid state transition.
	ErrInvalidAliasStateTransition = errors.New("invalid alias state transition")
	// ErrInvalidAliasGovernanceTransition gets returned when an alias is doing an invalid governance transition.
	ErrInvalidAliasGovernanceTransition = errors.New("invalid alias governance transition")
	// ErrAliasMissing gets returned when an alias is missing
	ErrAliasMissing = errors.New("alias is missing")
)
View Source
var (
	// ErrEd25519PubKeyAndAddrMismatch gets returned when an Ed25519Address and public key do not correspond to each other.
	ErrEd25519PubKeyAndAddrMismatch = errors.New("public key and address do not correspond to each other (Ed25519)")
	// ErrEd25519SignatureInvalid gets returned for invalid an Ed25519Signature.
	ErrEd25519SignatureInvalid = errors.New("signature is invalid (Ed25519)")
)
View Source
var (
	// ErrMissingUTXO gets returned if an UTXO is missing to commence a certain operation.
	ErrMissingUTXO = errors.New("missing utxo")
	// ErrInputOutputSumMismatch gets returned if a transaction does not spend the entirety of the inputs to the outputs.
	ErrInputOutputSumMismatch = errors.New("inputs and outputs do not spend/deposit the same amount")
	// ErrSignatureAndAddrIncompatible gets returned if an address of an input has a companion signature unlock block with the wrong signature type.
	ErrSignatureAndAddrIncompatible = errors.New("address and signature type are not compatible")
	// ErrInvalidInputUnlock gets returned when an input unlock is invalid.
	ErrInvalidInputUnlock = errors.New("invalid input unlock")
	// ErrSenderFeatureBlockNotUnlocked gets returned when an output contains a SenderFeatureBlock with an ident which is not unlocked.
	ErrSenderFeatureBlockNotUnlocked = errors.New("sender feature block is not unlocked")
	// ErrIssuerFeatureBlockNotUnlocked gets returned when an output contains a IssuerFeatureBlock with an ident which is not unlocked.
	ErrIssuerFeatureBlockNotUnlocked = errors.New("issuer feature block is not unlocked")
	// ErrReturnAmountNotFulFilled gets returned when a return amount in a transaction is not fulfilled by the output side.
	ErrReturnAmountNotFulFilled = errors.New("return amount not fulfilled")
	// ErrTypeIsNotSupportedEssence gets returned when a serializable was found to not be a supported essence.
	ErrTypeIsNotSupportedEssence = errors.New("serializable is not a supported essence")
)
View Source
var (
	// ErrTransactionBuilderUnsupportedAddress gets returned when an unsupported address type
	// is given for a builder operation.
	ErrTransactionBuilderUnsupportedAddress = errors.New("unsupported address type")
	// ErrTransactionBuilder defines a generic error occurring within the TransactionBuilder.
	ErrTransactionBuilder = errors.New("transaction builder error")
)
View Source
var (
	// ErrInputUTXORefsNotUnique gets returned if multiple inputs reference the same UTXO.
	ErrInputUTXORefsNotUnique = errors.New("inputs must each reference a unique UTXO")
	// ErrOutputRequiresSenderFeatureBlock gets returned if an output does not contain a SenderFeatureBlock even though another FeatureBlock requires it.
	ErrOutputRequiresSenderFeatureBlock = errors.New("output does not contain SenderFeatureBlock")
	// ErrAliasOutputNonEmptyState gets returned if an AliasOutput with zeroed AliasID contains state (counters non-zero etc.).
	ErrAliasOutputNonEmptyState = errors.New("alias output is not empty state")
	// ErrAliasOutputCyclicAddress gets returned if an AliasOutput's AliasID results into the same address as the State/Governance controller.
	ErrAliasOutputCyclicAddress = errors.New("alias output's AliasID corresponds to state and/or governance controller")
	// ErrNFTOutputCyclicAddress gets returned if an NFTOutput's NFTID results into the same address as the address field within the output.
	ErrNFTOutputCyclicAddress = errors.New("nft output's NFTID corresponds to address field")
	// ErrFoundryOutputInvalidMaximumSupply gets returned when a FoundryOutput's MaximumSupply is invalid.
	ErrFoundryOutputInvalidMaximumSupply = errors.New("foundry output's maximum supply is invalid")
	// ErrFoundryOutputInvalidCirculatingSupply gets returned when a FoundryOutput's CirculatingSupply is invalid.
	ErrFoundryOutputInvalidCirculatingSupply = errors.New("foundry output's circulating supply is invalid")
	// ErrOutputsSumExceedsTotalSupply gets returned if the sum of the output deposits exceeds the total supply of tokens.
	ErrOutputsSumExceedsTotalSupply = errors.New("accumulated output balance exceeds total supply")
	// ErrOutputDepositsMoreThanTotalSupply gets returned if an output deposits more than the total supply.
	ErrOutputDepositsMoreThanTotalSupply = errors.New("an output can not deposit more than the total supply")
	// ErrOutputReturnBlockIsMoreThanVBRent gets returned if an output defines within its DustDepositReturnFeatureBlock more
	// than what is needed to cover the virtual byte renting costs.
	ErrOutputReturnBlockIsMoreThanVBRent = errors.New("output's return feature block's amount is bigger than the minimum virtual byte rent cost")
	// ErrOutputReturnBlockIsLessThanMinDust gets returned if an output defines within its DustDepositReturnFeatureBlock less than the minimum dust deposit.
	ErrOutputReturnBlockIsLessThanMinDust = errors.New("output's return feature block's amount is less than the minimum dust amount")
	// ErrMaxNativeTokensCountExceeded gets returned if outputs or transactions exceed the MaxNativeTokensCount.
	ErrMaxNativeTokensCountExceeded = errors.New("max native tokens count exceeded")
)
View Source
var (
	// ErrSigUnlockBlocksNotUnique gets returned if unlock blocks making part of a transaction aren't unique.
	ErrSigUnlockBlocksNotUnique = errors.New("signature unlock blocks must be unique")
	// ErrReferentialUnlockBlockInvalid gets returned when a ReferentialUnlockBlock is invalid.
	ErrReferentialUnlockBlockInvalid = errors.New("invalid referential unlock block")
	// ErrSigUnlockBlockHasNilSig gets returned if a signature unlock block contains a nil signature.
	ErrSigUnlockBlockHasNilSig = errors.New("signature is nil")
	// ErrTypeIsNotSupportedUnlockBlock gets returned when a serializable was found to not be a supported UnlockBlock.
	ErrTypeIsNotSupportedUnlockBlock = errors.New("serializable is not a supported unlock block")
)
View Source
var (
	// ErrImmutableMetadataExceedsMaxLength gets returned when a NFTOutput's immutable data exceeds ImmutableMetadataMaxLength.
	ErrImmutableMetadataExceedsMaxLength = errors.New("NFT output's immutable metadata exceeds max length")
)
View Source
var (
	// ErrInvalidJSON gets returned when invalid JSON is tried to get parsed.
	ErrInvalidJSON = errors.New("invalid json")
)
View Source
var (
	// ErrInvalidReceipt gets returned when a receipt is invalid.
	ErrInvalidReceipt = errors.New("invalid receipt")
)
View Source
var (
	// ErrMessageExceedsMaxSize gets returned when a serialized message exceeds MessageBinSerializedMaxSize.
	ErrMessageExceedsMaxSize = errors.New("message exceeds max size")
)
View Source
var (
	// ErrMissingDeSerializationParas is returned when DeSerializationParameters are missing while
	// performing de/serialization on an object which requires them.
	ErrMissingDeSerializationParas = errors.New("missing de/serialization parameters")
)
View Source
var (
	// ErrNonUniqueFoundryOutputs gets returned when multiple FoundryOutput(s) with the same FoundryID exist within an OutputsByType.
	ErrNonUniqueFoundryOutputs = errors.New("non unique foundries within outputs")
)
View Source
var (
	// ErrReceiptMustContainATreasuryTransaction gets returned if a Receipt does not contain a TreasuryTransaction.
	ErrReceiptMustContainATreasuryTransaction = errors.New("receipt must contain a treasury transaction")
)
View Source
var (
	// ErrTypeIsNotSupportedAddress gets returned when a serializable was found to not be a supported Address.
	ErrTypeIsNotSupportedAddress = errors.New("serializable is not a supported address")
)
View Source
var (
	// ErrTypeIsNotSupportedPayload gets returned when a serializable was found to not be a supported Payload.
	ErrTypeIsNotSupportedPayload = errors.New("serializable is not a supported payload")
)
View Source
var (
	// ErrTypeIsNotSupportedSignature gets returned when a serializable was found to not be a supported Signature.
	ErrTypeIsNotSupportedSignature = errors.New("serializable is not a supported signature")
)
View Source
var (
	// ErrTypeIsNotSupportedTokenScheme gets returned when a serializable was found to not be a supported TokenScheme.
	ErrTypeIsNotSupportedTokenScheme = errors.New("serializable is not an address")
)
View Source
var (
	// ErrVByteRentNotCovered gets returned when a NonEphemeralObject does not cover the state rent
	// cost which are calculated from its virtual byte costs.
	ErrVByteRentNotCovered = errors.New("virtual byte rent costs not covered")
)

Functions

func AddressTypeToString

func AddressTypeToString(ty AddressType) string

AddressTypeToString returns the name for the given AddressType.

func AliasOutputFeatureBlocksArrayRules

func AliasOutputFeatureBlocksArrayRules() serializer.ArrayRules

AliasOutputFeatureBlocksArrayRules returns array rules defining the constraints on FeatureBlocks within an AliasOutput.

func ExtendedOutputFeatureBlocksArrayRules

func ExtendedOutputFeatureBlocksArrayRules() serializer.ArrayRules

ExtendedOutputFeatureBlocksArrayRules returns array rules defining the constraints on FeatureBlocks within an ExtendedOutput.

func FeatureBlockTypeToString

func FeatureBlockTypeToString(ty FeatureBlockType) string

FeatureBlockTypeToString returns the name of a FeatureBlock given the type.

func FoundryOutputFeatureBlocksArrayRules

func FoundryOutputFeatureBlocksArrayRules() serializer.ArrayRules

FoundryOutputFeatureBlocksArrayRules returns array rules defining the constraints on FeatureBlocks within an FoundryOutput.

func InputTypeToString

func InputTypeToString(ty InputType) string

InputTypeToString returns the name of an Input given the type.

func IsIssuerOnOutputUnlocked

func IsIssuerOnOutputUnlocked(output ChainConstrainedOutput, unlockedIdents UnlockedIdentities) error

IsIssuerOnOutputUnlocked checks whether the issuer in an IssuerFeatureBlock of this new ChainConstrainedOutput has been unlocked. This function is a no-op if the chain is not new, or it does not contain an IssuerFeatureBlock.

func IssuerBlockUnchanged

func IssuerBlockUnchanged(inState FeatureBlockOutput, outState FeatureBlockOutput) error

IssuerBlockUnchanged checks whether the IssuerFeatureBlock is unchanged between in and out, and that out does not suddenly have an issuer block.

func MessageIDToHexString

func MessageIDToHexString(msgID MessageID) string

MessageIDToHexString converts the given message ID to their hex representation.

func MessageParentArrayRules

func MessageParentArrayRules() serializer.ArrayRules

MessageParentArrayRules returns array rules defining the constraints on a slice of message parent references.

func MigratedFundEntriesArrayRules

func MigratedFundEntriesArrayRules() serializer.ArrayRules

MigratedFundEntriesArrayRules returns array rules defining the constraints of a slice of MigratedFundsEntry.

func MilestoneParentArrayRules

func MilestoneParentArrayRules() serializer.ArrayRules

MilestoneParentArrayRules returns array rules defining the constraints on a slice of milestone parent references.

func MilestonePublicKeyArrayRules

func MilestonePublicKeyArrayRules() serializer.ArrayRules

MilestonePublicKeyArrayRules returns array rules defining the constraints on a slice of public keys within a milestone.

func MilestoneSignatureArrayRules

func MilestoneSignatureArrayRules() serializer.ArrayRules

MilestoneSignatureArrayRules returns array rules defining the constraints on a slice of signatures within a milestone.

func NFTOutputFeatureBlocksArrayRules

func NFTOutputFeatureBlocksArrayRules() serializer.ArrayRules

NFTOutputFeatureBlocksArrayRules returns array rules defining the constraints on FeatureBlocks within an NFTOutput.

func NativeTokenArrayRules

func NativeTokenArrayRules() serializer.ArrayRules

NativeTokenArrayRules returns array rules defining the constraints on a slice of NativeTokens.

func NativeTokenSumBalancedWithDiff

func NativeTokenSumBalancedWithDiff(nativeTokenID NativeTokenID, inSums NativeTokenSum, outSums NativeTokenSum, circSupplyChange *big.Int) error

NativeTokenSumBalancedWithDiff checks whether the supply diff from the foundry state transition balances the in/out native token sums.

func OutputTypeToString

func OutputTypeToString(ty OutputType) string

OutputTypeToString returns the name of an Output given the type.

func ParseBech32

func ParseBech32(s string) (NetworkPrefix, Address, error)

ParseBech32 decodes a bech32 encoded string.

func PayloadSelector

func PayloadSelector(payloadType uint32) (serializer.Serializable, error)

PayloadSelector implements SerializableSelectorFunc for payload types.

func PayloadTypeToString

func PayloadTypeToString(ty PayloadType) string

PayloadTypeToString returns the name of a Payload given the type.

func SignatureTypeToString

func SignatureTypeToString(ty SignatureType) string

SignatureTypeToString returns the name of a Signature given the type.

func TokenSchemeTypeToString

func TokenSchemeTypeToString(ty TokenSchemeType) string

TokenSchemeTypeToString returns a name for the given TokenScheme type.

func TransactionEssenceInputsArrayRules

func TransactionEssenceInputsArrayRules() serializer.ArrayRules

TransactionEssenceInputsArrayRules returns array rules defining the constraints on Inputs within a TransactionEssence.

func TransactionEssenceOutputsArrayRules

func TransactionEssenceOutputsArrayRules() serializer.ArrayRules

TransactionEssenceOutputsArrayRules returns array rules defining the constraints on Outputs within a TransactionEssence.

func TransactionUnlockBlocksArrayRules

func TransactionUnlockBlocksArrayRules() serializer.ArrayRules

TransactionUnlockBlocksArrayRules returns array rules defining the constraints on UnlockBlocks within a Transaction.

func UnlockBlockSelector

func UnlockBlockSelector(unlockBlockType uint32) (serializer.Serializable, error)

UnlockBlockSelector implements SerializableSelectorFunc for unlock block types.

func UnlockBlockTypeToString

func UnlockBlockTypeToString(ty UnlockBlockType) string

UnlockBlockTypeToString returns a name for the given UnlockBlock type.

func ValidateInputs

func ValidateInputs(inputs Inputs, funcs ...InputsSyntacticalValidationFunc) error

ValidateInputs validates the inputs by running them against the given InputsSyntacticalValidationFunc(s).

func ValidateOutputs

func ValidateOutputs(outputs Outputs, funcs ...OutputsSyntacticalValidationFunc) error

ValidateOutputs validates the outputs by running them against the given OutputsSyntacticalValidationFunc(s).

func ValidateReceipt

func ValidateReceipt(receipt *Receipt, prevTreasuryOutput *TreasuryOutput) error

ValidateReceipt validates whether given the following receipt:

  • None of the MigratedFundsEntry objects deposits more than the max supply and deposits at least MinMigratedFundsEntryDeposit tokens.
  • The sum of all migrated fund entries is not bigger than the total supply.
  • The previous unspent TreasuryOutput minus the sum of all migrated funds equals the amount of the new TreasuryOutput.

This function panics if the receipt is nil, the receipt does not include any migrated fund entries or the given treasury output is nil.

func ValidateUnlockBlocks

func ValidateUnlockBlocks(unlockBlocks UnlockBlocks, funcs ...UnlockBlockValidatorFunc) error

ValidateUnlockBlocks validates the unlock blocks by running them against the given UnlockBlockValidatorFunc.

Types

type AddPeerRequest

type AddPeerRequest struct {
	// The libp2p multi address of the peer.
	MultiAddress string `json:"multiAddress"`
	// The alias of to iditify the peer.
	Alias *string `json:"alias,omitempty"`
}

AddPeerRequest defines the request for a POST peer REST API call.

type Address

type Address interface {
	serializer.Serializable
	NonEphemeralObject
	fmt.Stringer

	// Type returns the type of the address.
	Type() AddressType

	// Bech32 encodes the address as a bech32 string.
	Bech32(hrp NetworkPrefix) string

	// Equal checks whether other is equal to this Address.
	Equal(other Address) bool

	// Key returns a string which can be used to index the Address in a map.
	Key() string
}

Address describes a general address.

func AddressSelector

func AddressSelector(addressType uint32) (Address, error)

AddressSelector implements SerializableSelectorFunc for address types.

type AddressBalanceResponse

type AddressBalanceResponse struct {
	// The type of the address.
	AddressType byte `json:"addressType"`
	// The hex encoded address.
	Address string `json:"address"`
	// The balance of the address.
	Balance uint64 `json:"balance"`
	// The ledger index at which this balance was queried at.
	LedgerIndex uint64 `json:"ledgerIndex"`
}

AddressBalanceResponse defines the response of a GET addresses REST API call.

type AddressKeys

type AddressKeys struct {
	// The target address.
	Address Address `json:"address"`
	// The signing keys.
	Keys interface{} `json:"keys"`
}

AddressKeys pairs an address and its source key(s).

func NewAddressKeysForEd25519Address

func NewAddressKeysForEd25519Address(addr *Ed25519Address, prvKey ed25519.PrivateKey) AddressKeys

NewAddressKeysForEd25519Address returns new AddressKeys for Ed25519Address.

type AddressOutputsResponse

type AddressOutputsResponse struct {
	// The type of the address.
	AddressType byte `json:"addressType"`
	// The hex encoded address.
	Address string `json:"address"`
	// The maximum count of results that are returned by the node.
	MaxResults uint32 `json:"maxResults"`
	// The actual count of results that are returned.
	Count uint32 `json:"count"`
	// The output IDs (transaction ID + output index) of the outputs on this address.
	OutputIDs []OutputIDHex `json:"outputIDs"`
	// The ledger index at which these outputs where available at.
	LedgerIndex uint64 `json:"ledgerIndex"`
}

AddressOutputsResponse defines the response of a GET outputs by address REST API call.

type AddressSigner

type AddressSigner interface {
	// Sign produces the signature for the given message.
	Sign(addr Address, msg []byte) (signature Signature, err error)
}

AddressSigner produces signatures for messages which get verified against a given address.

func NewInMemoryAddressSigner

func NewInMemoryAddressSigner(addrKeys ...AddressKeys) AddressSigner

NewInMemoryAddressSigner creates a new InMemoryAddressSigner holding the given AddressKeys.

type AddressSignerFunc

type AddressSignerFunc func(addr Address, msg []byte) (signature serializer.Serializable, err error)

AddressSignerFunc implements the AddressSigner interface.

func (AddressSignerFunc) Sign

func (s AddressSignerFunc) Sign(addr Address, msg []byte) (signature serializer.Serializable, err error)

type AddressType

type AddressType = byte

AddressType defines the type of addresses.

type AddressTypeSet

type AddressTypeSet map[AddressType]struct{}

AddressTypeSet is a set of AddressType.

type AliasAddress

type AliasAddress [AliasAddressBytesLength]byte

AliasAddress defines an Alias address. An AliasAddress is the Blake2b-160 hash of the OutputID which created it.

func AliasAddressFromOutputID

func AliasAddressFromOutputID(outputID OutputID) AliasAddress

AliasAddressFromOutputID returns the alias address computed from a given OutputID.

func MustParseAliasAddressFromHexString

func MustParseAliasAddressFromHexString(hexAddr string) *AliasAddress

MustParseAliasAddressFromHexString parses the given hex string into an AliasAddress. It panics if the hex address is invalid.

func ParseAliasAddressFromHexString

func ParseAliasAddressFromHexString(hexAddr string) (*AliasAddress, error)

ParseAliasAddressFromHexString parses the given hex string into an AliasAddress.

func (*AliasAddress) AliasID

func (aliasAddr *AliasAddress) AliasID() AliasID

func (*AliasAddress) Bech32

func (aliasAddr *AliasAddress) Bech32(hrp NetworkPrefix) string

func (*AliasAddress) Chain

func (aliasAddr *AliasAddress) Chain() ChainID

func (*AliasAddress) Deserialize

func (aliasAddr *AliasAddress) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*AliasAddress) Equal

func (aliasAddr *AliasAddress) Equal(other Address) bool

func (*AliasAddress) Key

func (aliasAddr *AliasAddress) Key() string

func (*AliasAddress) MarshalJSON

func (aliasAddr *AliasAddress) MarshalJSON() ([]byte, error)

func (*AliasAddress) Serialize

func (aliasAddr *AliasAddress) Serialize(_ serializer.DeSerializationMode, deSeriCtx interface{}) (data []byte, err error)

func (*AliasAddress) String

func (aliasAddr *AliasAddress) String() string

func (*AliasAddress) Type

func (aliasAddr *AliasAddress) Type() AddressType

func (*AliasAddress) UnmarshalJSON

func (aliasAddr *AliasAddress) UnmarshalJSON(bytes []byte) error

func (*AliasAddress) VByteCost

func (aliasAddr *AliasAddress) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

type AliasID

type AliasID [AliasIDLength]byte

AliasID is the identifier for an alias account. It is computed as the Blake2b-160 hash of the OutputID of the output which created the account.

func AliasIDFromOutputID

func AliasIDFromOutputID(outputID OutputID) AliasID

AliasIDFromOutputID returns the AliasID computed from a given OutputID.

func (AliasID) Addressable

func (id AliasID) Addressable() bool

func (AliasID) Empty

func (id AliasID) Empty() bool

func (AliasID) FromOutputID

func (id AliasID) FromOutputID(in OutputID) ChainID

func (AliasID) Key

func (id AliasID) Key() interface{}

func (AliasID) Matches

func (id AliasID) Matches(other ChainID) bool

func (AliasID) String

func (id AliasID) String() string

func (AliasID) ToAddress

func (id AliasID) ToAddress() ChainConstrainedAddress

type AliasOutput

type AliasOutput struct {
	// The amount of IOTA tokens held by the output.
	Amount uint64
	// The native tokens held by the output.
	NativeTokens NativeTokens
	// The identifier for this alias account.
	AliasID AliasID
	// The entity which is allowed to control this alias account state.
	StateController Address
	// The entity which is allowed to govern this alias account.
	GovernanceController Address
	// The index of the state.
	StateIndex uint32
	// The state of the alias account which can only be mutated by the state controller.
	StateMetadata []byte
	// The counter that denotes the number of foundries created by this alias account.
	FoundryCounter uint32
	// The feature blocks which modulate the constraints on the output.
	Blocks FeatureBlocks
}

AliasOutput is an output type which represents an alias account.

func (*AliasOutput) AliasEmpty

func (a *AliasOutput) AliasEmpty() bool

func (*AliasOutput) Chain

func (a *AliasOutput) Chain() ChainID

func (*AliasOutput) Deposit

func (a *AliasOutput) Deposit() uint64

func (*AliasOutput) Deserialize

func (a *AliasOutput) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*AliasOutput) FeatureBlocks

func (a *AliasOutput) FeatureBlocks() FeatureBlocks

func (*AliasOutput) GovernanceSTVF

func (a *AliasOutput) GovernanceSTVF(nextAliasOutput *AliasOutput, semValCtx *SemanticValidationContext) error

GovernanceSTVF checks whether the governance transition with other is valid. Under a governance transition, only the StateController, GovernanceController and MetadataFeatureBlock can change.

func (*AliasOutput) Ident

func (a *AliasOutput) Ident(nextState TransDepIdentOutput) (Address, error)

func (*AliasOutput) MarshalJSON

func (a *AliasOutput) MarshalJSON() ([]byte, error)

func (*AliasOutput) NativeTokenSet

func (a *AliasOutput) NativeTokenSet() NativeTokens

func (*AliasOutput) Serialize

func (a *AliasOutput) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*AliasOutput) StateSTVF

func (a *AliasOutput) StateSTVF(nextAliasOutput *AliasOutput, semValCtx *SemanticValidationContext) error

StateSTVF checks whether the state transition with other is valid. Under a state transition, only Amount, NativeTokens, StateIndex, StateMetadata and FoundryCounter can change.

func (*AliasOutput) Target

func (a *AliasOutput) Target() (serializer.Serializable, error)

func (*AliasOutput) Type

func (a *AliasOutput) Type() OutputType

func (*AliasOutput) UnlockableBy

func (a *AliasOutput) UnlockableBy(ident Address, next TransDepIdentOutput, extParas *ExternalUnlockParameters) (bool, error)

func (*AliasOutput) UnmarshalJSON

func (a *AliasOutput) UnmarshalJSON(bytes []byte) error

func (*AliasOutput) VByteCost

func (a *AliasOutput) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

func (*AliasOutput) ValidateStateTransition

func (a *AliasOutput) ValidateStateTransition(transType ChainTransitionType, next ChainConstrainedOutput, semValCtx *SemanticValidationContext) error

TODO: document transitions

  • For output AliasOutput(s) with non-zeroed AliasID, there must be a corresponding input AliasOutput where either its AliasID is zeroed and StateIndex and FoundryCounter are zero or an input AliasOutput with the same AliasID.
  • On alias state transitions:
  • The StateIndex must be incremented by 1
  • Only Amount, NativeTokens, StateIndex, StateMetadata and FoundryCounter can be mutated
  • On alias governance transition:
  • Only StateController (must be mutated), GovernanceController and the MetadataBlock can be mutated

type AliasOutputs

type AliasOutputs []*AliasOutput

AliasOutputs is a slice of AliasOutput(s).

func (AliasOutputs) Every

func (outputs AliasOutputs) Every(f func(output *AliasOutput) bool) int

Every checks whether every element passes f. Returns either -1 if all elements passed f or the index of the first element which didn't

type AliasOutputsSet

type AliasOutputsSet map[AliasID]*AliasOutput

AliasOutputsSet is a set of AliasOutput(s).

func (AliasOutputsSet) EveryTuple

func (set AliasOutputsSet) EveryTuple(other AliasOutputsSet, f func(in *AliasOutput, out *AliasOutput) error) error

EveryTuple runs f for every key which exists in both this set and other.

func (AliasOutputsSet) Includes

func (set AliasOutputsSet) Includes(other AliasOutputsSet) error

Includes checks whether all aliases included in other exist in this set.

func (AliasOutputsSet) Merge

Merge merges other with this set in a new set. Returns an error if an alias isn't unique across both sets.

type AliasUnlockBlock

type AliasUnlockBlock struct {
	// The other unlock block this AliasUnlockBlock references to.
	Reference uint16
}

AliasUnlockBlock is an UnlockBlock which references a previous unlock block.

func (*AliasUnlockBlock) Chainable

func (r *AliasUnlockBlock) Chainable() bool

func (*AliasUnlockBlock) Deserialize

func (r *AliasUnlockBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*AliasUnlockBlock) MarshalJSON

func (r *AliasUnlockBlock) MarshalJSON() ([]byte, error)

func (*AliasUnlockBlock) Ref

func (r *AliasUnlockBlock) Ref() uint16

func (*AliasUnlockBlock) Serialize

func (r *AliasUnlockBlock) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*AliasUnlockBlock) SourceAllowed

func (r *AliasUnlockBlock) SourceAllowed(address Address) bool

func (*AliasUnlockBlock) Type

func (*AliasUnlockBlock) UnmarshalJSON

func (r *AliasUnlockBlock) UnmarshalJSON(bytes []byte) error

type ChainConstrainedAddress

type ChainConstrainedAddress interface {
	Address
	Chain() ChainID
}

ChainConstrainedAddress is a type of Address representing ownership of an output by a ChainConstrainedOutput.

type ChainConstrainedOutput

type ChainConstrainedOutput interface {
	Output
	// Chain returns the ChainID to which this Output belongs to.
	Chain() ChainID
	// ValidateStateTransition runs a StateTransitionValidationFunc with next.
	// Next is nil if transType is ChainTransitionTypeGenesis or ChainTransitionTypeDestroy.
	ValidateStateTransition(transType ChainTransitionType, next ChainConstrainedOutput, semValCtx *SemanticValidationContext) error
}

ChainConstrainedOutput is a type of Output which represents a chain of state transitions.

type ChainConstrainedOutputs

type ChainConstrainedOutputs []ChainConstrainedOutput

ChainConstrainedOutputs is a slice of ChainConstrainedOutput.

type ChainConstrainedOutputsSet

type ChainConstrainedOutputsSet map[ChainID]ChainConstrainedOutput

ChainConstrainedOutputsSet is a map of ChainID to ChainConstrainedOutput.

func (ChainConstrainedOutputsSet) EveryTuple

EveryTuple runs f for every key which exists in both this set and other.

func (ChainConstrainedOutputsSet) Includes

Includes checks whether all chains included in other exist in this set.

func (ChainConstrainedOutputsSet) Merge

Merge merges other with this set in a new set. Returns an error if a chain isn't unique across both sets.

type ChainID

type ChainID interface {
	// Matches checks whether other matches this ChainID.
	Matches(other ChainID) bool
	// Addressable tells whether this ChainID can be converted into a ChainConstrainedAddress.
	Addressable() bool
	// ToAddress converts this ChainID into an ChainConstrainedAddress.
	ToAddress() ChainConstrainedAddress
	// Empty tells whether the ChainID is empty.
	Empty() bool
	// Key returns a key to use to index this ChainID.
	Key() interface{}
}

ChainID represents the chain ID of a chain created by a ChainConstrainedOutput.

type ChainTransitionType

type ChainTransitionType byte

ChainTransitionType defines the type of transition a ChainConstrainedOutput is doing.

const (
	// ChainTransitionTypeGenesis indicates that the chain is in its genesis, aka it is new.
	ChainTransitionTypeGenesis ChainTransitionType = iota
	// ChainTransitionTypeStateChange indicates that the chain is state transitioning.
	ChainTransitionTypeStateChange
	// ChainTransitionTypeDestroy indicates that the chain is being destroyed.
	ChainTransitionTypeDestroy
)

type ChildrenResponse

type ChildrenResponse struct {
	// The hex encoded message ID of the message.
	MessageID string `json:"messageId"`
	// The maximum count of results that are returned by the node.
	MaxResults uint32 `json:"maxResults"`
	// The actual count of results that are returned.
	Count uint32 `json:"count"`
	// The hex encoded message IDs of the children of this message.
	Children []string `json:"childrenMessageIds"`
}

ChildrenResponse defines the response of a GET children REST API call.

type DeSerializationParameters

type DeSerializationParameters struct {
	// Used to determine the validity of Outputs by checking whether
	// they fulfil the virtual byte rent cost given their deposit value.
	RentStructure *RentStructure
}

DeSerializationParameters defines parameters which must be given into de/serialization context if de/serialization is executed with syntactical validation.

type DirectUnlockableAddress

type DirectUnlockableAddress interface {
	Address
	// Unlock unlocks this DirectUnlockableAddress given the Signature.
	Unlock(msg []byte, sig Signature) error
}

DirectUnlockableAddress is a type of Address which can be directly unlocked.

type DustDepositReturnFeatureBlock

type DustDepositReturnFeatureBlock struct {
	Amount uint64
}

DustDepositReturnFeatureBlock is a feature block which defines the amount of tokens which must be sent back to the sender identity, when the output in which it occurs in, is consumed. This block must have a companion SenderFeatureBlock occurring in the same output from which the sender identity can be extracted from. If a transaction consumes multiple outputs which have a DustDepositReturnFeatureBlock, then on the output side at least the sum of all occurring DustDepositReturnFeatureBlock(s) on the input side must be deposited to the designated origin sender.

func (*DustDepositReturnFeatureBlock) Deserialize

func (s *DustDepositReturnFeatureBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*DustDepositReturnFeatureBlock) Equal

func (*DustDepositReturnFeatureBlock) MarshalJSON

func (s *DustDepositReturnFeatureBlock) MarshalJSON() ([]byte, error)

func (*DustDepositReturnFeatureBlock) Serialize

func (s *DustDepositReturnFeatureBlock) Serialize(_ serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*DustDepositReturnFeatureBlock) Type

func (*DustDepositReturnFeatureBlock) UnmarshalJSON

func (s *DustDepositReturnFeatureBlock) UnmarshalJSON(bytes []byte) error

func (*DustDepositReturnFeatureBlock) VByteCost

func (s *DustDepositReturnFeatureBlock) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

type Ed25519Address

type Ed25519Address [Ed25519AddressBytesLength]byte

Ed25519Address defines an Ed25519 address. An Ed25519Address is the Blake2b-256 hash of an Ed25519 public key.

func Ed25519AddressFromPubKey

func Ed25519AddressFromPubKey(pubKey ed25519.PublicKey) Ed25519Address

Ed25519AddressFromPubKey returns the address belonging to the given Ed25519 public key.

func MustParseEd25519AddressFromHexString

func MustParseEd25519AddressFromHexString(hexAddr string) *Ed25519Address

MustParseEd25519AddressFromHexString parses the given hex string into an Ed25519Address. It panics if the hex address is invalid.

func ParseEd25519AddressFromHexString

func ParseEd25519AddressFromHexString(hexAddr string) (*Ed25519Address, error)

ParseEd25519AddressFromHexString parses the given hex string into an Ed25519Address.

func (*Ed25519Address) Bech32

func (edAddr *Ed25519Address) Bech32(hrp NetworkPrefix) string

func (*Ed25519Address) Deserialize

func (edAddr *Ed25519Address) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*Ed25519Address) Equal

func (edAddr *Ed25519Address) Equal(other Address) bool

func (*Ed25519Address) Key

func (edAddr *Ed25519Address) Key() string

func (*Ed25519Address) MarshalJSON

func (edAddr *Ed25519Address) MarshalJSON() ([]byte, error)

func (*Ed25519Address) Serialize

func (edAddr *Ed25519Address) Serialize(_ serializer.DeSerializationMode, deSeriCtx interface{}) (data []byte, err error)

func (*Ed25519Address) String

func (edAddr *Ed25519Address) String() string

func (*Ed25519Address) Type

func (edAddr *Ed25519Address) Type() AddressType

func (*Ed25519Address) Unlock

func (edAddr *Ed25519Address) Unlock(msg []byte, sig Signature) error

func (*Ed25519Address) UnmarshalJSON

func (edAddr *Ed25519Address) UnmarshalJSON(bytes []byte) error

func (*Ed25519Address) VByteCost

func (edAddr *Ed25519Address) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

type Ed25519Signature

type Ed25519Signature struct {
	// The public key used to verify the given signature.
	PublicKey [ed25519.PublicKeySize]byte
	// The signature.
	Signature [ed25519.SignatureSize]byte
}

Ed25519Signature defines an Ed25519 signature.

func (*Ed25519Signature) Deserialize

func (e *Ed25519Signature) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*Ed25519Signature) MarshalJSON

func (e *Ed25519Signature) MarshalJSON() ([]byte, error)

func (*Ed25519Signature) Serialize

func (e *Ed25519Signature) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*Ed25519Signature) Type

func (e *Ed25519Signature) Type() SignatureType

func (*Ed25519Signature) UnmarshalJSON

func (e *Ed25519Signature) UnmarshalJSON(bytes []byte) error

func (*Ed25519Signature) Valid

func (e *Ed25519Signature) Valid(msg []byte, addr *Ed25519Address) error

Valid verifies whether given the message and Ed25519 address, the signature is valid.

type ExpirationMilestoneIndexFeatureBlock

type ExpirationMilestoneIndexFeatureBlock struct {
	MilestoneIndex uint32
}

ExpirationMilestoneIndexFeatureBlock is a feature block which puts a time constraint on whether the receiver or sender identity can consume an output depending on the latest confirmed milestone index X:

  • only the receiver can consume the output, if X is smaller than the one defined in the timelock
  • only the sender can consume the output, if X is bigger-equal than the one defined in the timelock

As this feature block needs a sender identity for its functionality, this block must have a companion SenderFeatureBlock present in the output.

func (*ExpirationMilestoneIndexFeatureBlock) Deserialize

func (s *ExpirationMilestoneIndexFeatureBlock) Deserialize(data []byte, _ serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*ExpirationMilestoneIndexFeatureBlock) Equal

func (*ExpirationMilestoneIndexFeatureBlock) MarshalJSON

func (s *ExpirationMilestoneIndexFeatureBlock) MarshalJSON() ([]byte, error)

func (*ExpirationMilestoneIndexFeatureBlock) Serialize

func (s *ExpirationMilestoneIndexFeatureBlock) Serialize(_ serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*ExpirationMilestoneIndexFeatureBlock) Type

func (*ExpirationMilestoneIndexFeatureBlock) UnmarshalJSON

func (s *ExpirationMilestoneIndexFeatureBlock) UnmarshalJSON(bytes []byte) error

func (*ExpirationMilestoneIndexFeatureBlock) VByteCost

type ExpirationUnixFeatureBlock

type ExpirationUnixFeatureBlock struct {
	// UnixTime is the second resolution unix time.
	UnixTime uint64
}

ExpirationUnixFeatureBlock is a feature block which puts a time constraint on whether the receiver or sender identity can consume an output depending on the latest confirmed milestone's timestamp T:

  • only the receiver can consume the output, if T is before than the one defined in the timelock
  • only the sender can consume the output, if T is at the same time or after the one defined in the timelock

As this feature block needs a sender identity for its functionality, this block must have a companion SenderFeatureBlock present in the output.

func (*ExpirationUnixFeatureBlock) Deserialize

func (s *ExpirationUnixFeatureBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*ExpirationUnixFeatureBlock) Equal

func (*ExpirationUnixFeatureBlock) MarshalJSON

func (s *ExpirationUnixFeatureBlock) MarshalJSON() ([]byte, error)

func (*ExpirationUnixFeatureBlock) Serialize

func (s *ExpirationUnixFeatureBlock) Serialize(_ serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*ExpirationUnixFeatureBlock) Type

func (*ExpirationUnixFeatureBlock) UnmarshalJSON

func (s *ExpirationUnixFeatureBlock) UnmarshalJSON(bytes []byte) error

func (*ExpirationUnixFeatureBlock) VByteCost

func (s *ExpirationUnixFeatureBlock) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

type ExtendedOutput

type ExtendedOutput struct {
	// The deposit address.
	Address Address
	// The amount of IOTA tokens held by the output.
	Amount uint64
	// The native tokens held by the output.
	NativeTokens NativeTokens
	// The feature blocks which modulate the constraints on the output.
	Blocks FeatureBlocks
}

ExtendedOutput is an output type which can hold native tokens and feature blocks.

func (*ExtendedOutput) Deposit

func (e *ExtendedOutput) Deposit() uint64

func (*ExtendedOutput) Deserialize

func (e *ExtendedOutput) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*ExtendedOutput) FeatureBlocks

func (e *ExtendedOutput) FeatureBlocks() FeatureBlocks

func (*ExtendedOutput) Ident

func (e *ExtendedOutput) Ident() Address

func (*ExtendedOutput) MarshalJSON

func (e *ExtendedOutput) MarshalJSON() ([]byte, error)

func (*ExtendedOutput) NativeTokenSet

func (e *ExtendedOutput) NativeTokenSet() NativeTokens

func (*ExtendedOutput) Serialize

func (e *ExtendedOutput) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*ExtendedOutput) Type

func (e *ExtendedOutput) Type() OutputType

func (*ExtendedOutput) UnlockableBy

func (e *ExtendedOutput) UnlockableBy(ident Address, extParas *ExternalUnlockParameters) bool

func (*ExtendedOutput) UnmarshalJSON

func (e *ExtendedOutput) UnmarshalJSON(bytes []byte) error

func (*ExtendedOutput) VByteCost

func (e *ExtendedOutput) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

type ExternalUnlockParameters

type ExternalUnlockParameters struct {
	// The confirmed milestone index.
	ConfMsIndex uint32
	// The confirmed unix epoch time in seconds.
	ConfUnix uint64
}

ExternalUnlockParameters defines a palette of external system parameters which are used to determine whether an Output can be unlocked.

type FeatureBlock

type FeatureBlock interface {
	serializer.Serializable
	NonEphemeralObject

	// Type returns the type of the FeatureBlock.
	Type() FeatureBlockType
	// Equal tells whether this FeatureBlock is equal to other.
	Equal(other FeatureBlock) bool
}

FeatureBlock is an abstract building block extending the features of an Output.

func FeatureBlockSelector

func FeatureBlockSelector(featBlockType uint32) (FeatureBlock, error)

FeatureBlockSelector implements SerializableSelectorFunc for feature blocks.

type FeatureBlockOutput

type FeatureBlockOutput interface {
	// FeatureBlocks returns the feature blocks this output defines.
	FeatureBlocks() FeatureBlocks
}

FeatureBlockOutput is a type of Output which can hold FeatureBlock.

type FeatureBlockSetTransitionValidationFunc

type FeatureBlockSetTransitionValidationFunc func(inSet FeatureBlocksSet, outSet FeatureBlocksSet) error

FeatureBlockSetTransitionValidationFunc checks whether the FeatureBlocks transition from in to out is valid.

type FeatureBlockType

type FeatureBlockType byte

FeatureBlockType defines the type of feature blocks.

const (
	// FeatureBlockSender denotes a SenderFeatureBlock.
	FeatureBlockSender FeatureBlockType = iota
	// FeatureBlockIssuer denotes an IssuerFeatureBlock.
	FeatureBlockIssuer
	// FeatureBlockDustDepositReturn denotes a DustDepositReturnFeatureBlock.
	FeatureBlockDustDepositReturn
	// FeatureBlockTimelockMilestoneIndex denotes a TimelockMilestoneIndexFeatureBlock.
	FeatureBlockTimelockMilestoneIndex
	// FeatureBlockTimelockUnix denotes a TimelockUnixFeatureBlock.
	FeatureBlockTimelockUnix
	// FeatureBlockExpirationMilestoneIndex denotes an ExpirationMilestoneIndexFeatureBlock.
	FeatureBlockExpirationMilestoneIndex
	// FeatureBlockExpirationUnix denotes an ExpirationUnixFeatureBlock.
	FeatureBlockExpirationUnix
	// FeatureBlockMetadata denotes a MetadataFeatureBlock.
	FeatureBlockMetadata
	// FeatureBlockIndexation denotes an IndexationFeatureBlock.
	FeatureBlockIndexation
)

type FeatureBlocks

type FeatureBlocks []FeatureBlock

FeatureBlocks is a slice of FeatureBlock(s).

func (FeatureBlocks) Equal

func (f FeatureBlocks) Equal(other FeatureBlocks) bool

Equal checks whether this slice is equal to other.

func (*FeatureBlocks) FromSerializables

func (f *FeatureBlocks) FromSerializables(seris serializer.Serializables)

func (FeatureBlocks) HasConstraints

func (f FeatureBlocks) HasConstraints() bool

HasConstraints tells whether any FeatureBlock is present which creates spending constraints.

func (FeatureBlocks) MustSet

func (f FeatureBlocks) MustSet() FeatureBlocksSet

MustSet works like Set but panics if an error occurs. This function is therefore only safe to be called when it is given, that a FeatureBlocks slice does not contain the same FeatureBlockType multiple times.

func (FeatureBlocks) Set

Set converts the slice into a FeatureBlocksSet. Returns an error if a FeatureBlockType occurs multiple times.

func (FeatureBlocks) ToSerializables

func (f FeatureBlocks) ToSerializables() serializer.Serializables

func (FeatureBlocks) VByteCost

func (f FeatureBlocks) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

type FeatureBlocksSet

type FeatureBlocksSet map[FeatureBlockType]FeatureBlock

FeatureBlocksSet is a set of FeatureBlock(s).

func (FeatureBlocksSet) DustDepositReturnFeatureBlock

func (f FeatureBlocksSet) DustDepositReturnFeatureBlock() *DustDepositReturnFeatureBlock

DustDepositReturnFeatureBlock returns the DustDepositReturnFeatureBlock in the set or nil.

func (FeatureBlocksSet) EveryTuple

func (f FeatureBlocksSet) EveryTuple(other FeatureBlocksSet, fun func(a FeatureBlock, b FeatureBlock) error) (bool, error)

EveryTuple runs f for every key which exists in both this set and other. Returns a bool indicating whether all element of this set existed on the other set.

func (FeatureBlocksSet) ExpirationMilestoneIndexFeatureBlock

func (f FeatureBlocksSet) ExpirationMilestoneIndexFeatureBlock() *ExpirationMilestoneIndexFeatureBlock

ExpirationMilestoneIndexFeatureBlock returns the ExpirationMilestoneIndexFeatureBlock in the set or nil.

func (FeatureBlocksSet) ExpirationUnixFeatureBlock

func (f FeatureBlocksSet) ExpirationUnixFeatureBlock() *ExpirationUnixFeatureBlock

ExpirationUnixFeatureBlock returns the ExpirationUnixFeatureBlock in the set or nil.

func (FeatureBlocksSet) HasExpirationBlocks

func (f FeatureBlocksSet) HasExpirationBlocks() bool

HasExpirationBlocks tells whether this set has any feature block putting an expiration constraint.

func (FeatureBlocksSet) IndexationFeatureBlock

func (f FeatureBlocksSet) IndexationFeatureBlock() *IndexationFeatureBlock

IndexationFeatureBlock returns the IndexationFeatureBlock in the set or nil.

func (FeatureBlocksSet) IssuerFeatureBlock

func (f FeatureBlocksSet) IssuerFeatureBlock() *IssuerFeatureBlock

IssuerFeatureBlock returns the IssuerFeatureBlock in the set or nil.

func (FeatureBlocksSet) MetadataFeatureBlock

func (f FeatureBlocksSet) MetadataFeatureBlock() *MetadataFeatureBlock

MetadataFeatureBlock returns the MetadataFeatureBlock in the set or nil.

func (FeatureBlocksSet) SenderFeatureBlock

func (f FeatureBlocksSet) SenderFeatureBlock() *SenderFeatureBlock

SenderFeatureBlock returns the SenderFeatureBlock in the set or nil.

func (FeatureBlocksSet) TimelockMilestoneIndexFeatureBlock

func (f FeatureBlocksSet) TimelockMilestoneIndexFeatureBlock() *TimelockMilestoneIndexFeatureBlock

TimelockMilestoneIndexFeatureBlock returns the TimelockMilestoneIndexFeatureBlock in the set or nil.

func (FeatureBlocksSet) TimelockUnixFeatureBlock

func (f FeatureBlocksSet) TimelockUnixFeatureBlock() *TimelockUnixFeatureBlock

TimelockUnixFeatureBlock returns the TimelockUnixFeatureBlock in the set or nil.

func (FeatureBlocksSet) TimelocksExpired

func (f FeatureBlocksSet) TimelocksExpired(extParas *ExternalUnlockParameters) error

TimelocksExpired tells whether FeatureBlock(s) in this slice which impose a timelock are expired in relation to the given ExternalUnlockParameters.

type FoundryID

type FoundryID [FoundryIDLength]byte

FoundryID defines the identifier for a foundry consisting out of the address, serial number and TokenScheme.

func (FoundryID) Addressable

func (fID FoundryID) Addressable() bool

func (FoundryID) Empty

func (fID FoundryID) Empty() bool

func (FoundryID) Key

func (fID FoundryID) Key() interface{}

func (FoundryID) Matches

func (fID FoundryID) Matches(other ChainID) bool

func (FoundryID) String

func (fID FoundryID) String() string

func (FoundryID) ToAddress

func (fID FoundryID) ToAddress() ChainConstrainedAddress

type FoundryOutput

type FoundryOutput struct {
	// The alias controlling the foundry.
	Address Address
	// The amount of IOTA tokens held by the output.
	Amount uint64
	// The native tokens held by the output.
	NativeTokens NativeTokens
	// The serial number of the foundry.
	SerialNumber uint32
	// The tag which is always the last 12 bytes of the tokens generated by this foundry.
	TokenTag TokenTag
	// The circulating supply of tokens controlled by this foundry.
	CirculatingSupply *big.Int
	// The maximum supply of tokens controlled by this foundry.
	MaximumSupply *big.Int
	// The token scheme this foundry uses.
	TokenScheme TokenScheme
	// The feature blocks which modulate the constraints on the output.
	Blocks FeatureBlocks
}

FoundryOutput is an output type which controls the supply of user defined native tokens.

func (*FoundryOutput) Chain

func (f *FoundryOutput) Chain() ChainID

func (*FoundryOutput) Deposit

func (f *FoundryOutput) Deposit() uint64

func (*FoundryOutput) Deserialize

func (f *FoundryOutput) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*FoundryOutput) FeatureBlocks

func (f *FoundryOutput) FeatureBlocks() FeatureBlocks

func (*FoundryOutput) ID

func (f *FoundryOutput) ID() (FoundryID, error)

ID returns the FoundryID of this FoundryOutput.

func (*FoundryOutput) Ident

func (f *FoundryOutput) Ident() Address

func (*FoundryOutput) MarshalJSON

func (f *FoundryOutput) MarshalJSON() ([]byte, error)

func (*FoundryOutput) MustID

func (f *FoundryOutput) MustID() FoundryID

MustID works like ID but panics if an error occurs.

func (*FoundryOutput) MustNativeTokenID

func (f *FoundryOutput) MustNativeTokenID() NativeTokenID

MustNativeTokenID works like NativeTokenID but panics if there is an error.

func (*FoundryOutput) NativeTokenID

func (f *FoundryOutput) NativeTokenID() (NativeTokenID, error)

NativeTokenID returns the NativeTokenID this FoundryOutput operates on.

func (*FoundryOutput) NativeTokenSet

func (f *FoundryOutput) NativeTokenSet() NativeTokens

func (*FoundryOutput) Serialize

func (f *FoundryOutput) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*FoundryOutput) Type

func (f *FoundryOutput) Type() OutputType

func (*FoundryOutput) UnlockableBy

func (f *FoundryOutput) UnlockableBy(ident Address, extParas *ExternalUnlockParameters) bool

func (*FoundryOutput) UnmarshalJSON

func (f *FoundryOutput) UnmarshalJSON(bytes []byte) error

func (*FoundryOutput) VByteCost

func (f *FoundryOutput) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

func (*FoundryOutput) ValidateStateTransition

func (f *FoundryOutput) ValidateStateTransition(transType ChainTransitionType, next ChainConstrainedOutput, semValCtx *SemanticValidationContext) error

type FoundryOutputs

type FoundryOutputs []*FoundryOutput

FoundryOutputs is a slice of FoundryOutput(s).

type FoundryOutputsSet

type FoundryOutputsSet map[FoundryID]*FoundryOutput

FoundryOutputsSet is a set of FoundryOutput(s).

type GossipHeartbeat

type GossipHeartbeat struct {
	// The solid milestone of the node.
	SolidMilestoneIndex uint32 `json:"solidMilestoneIndex"`
	// The milestone index at which the node pruned its data.
	PrunedMilestoneIndex uint32 `json:"prunedMilestoneIndex"`
	// The latest known milestone index by the node.
	LatestMilestoneIndex uint32 `json:"latestMilestoneIndex"`
	// The amount of currently connected neighbors.
	ConnectedNeighbors int `json:"connectedNeighbors"`
	// The amount of currently connected neighbors who also
	// are synchronized with the network.
	SyncedNeighbors int `json:"syncedNeighbors"`
}

GossipHeartbeat represents a gossip heartbeat message. Peers send each other this gossip protocol message when their state is updated, such as when:

  • a new milestone was received
  • the solid milestone changed
  • the node performed pruning of data

type GossipInfo

type GossipInfo struct {
	// The last received heartbeat by the given node.
	Heartbeat *GossipHeartbeat `json:"heartbeat"`
	// The metrics about sent and received protocol messages.
	Metrics PeerGossipMetrics `json:"metrics"`
}

GossipInfo represents information about an ongoing gossip protocol.

type HTTPErrorResponseEnvelope

type HTTPErrorResponseEnvelope struct {
	Error struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

HTTPErrorResponseEnvelope defines the error response schema for node API responses.

type HTTPOkResponseEnvelope

type HTTPOkResponseEnvelope struct {
	// The encapsulated json data.
	Data interface{} `json:"data"`
}

HTTPOkResponseEnvelope defines the ok response schema for node API responses.

type InMemoryAddressSigner

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

InMemoryAddressSigner implements AddressSigner by holding keys simply in-memory.

func (*InMemoryAddressSigner) Sign

func (s *InMemoryAddressSigner) Sign(addr Address, msg []byte) (signature Signature, err error)

type Indexation

type Indexation struct {
	// The index to use to index the enclosing message and data.
	Index []byte `json:"index"`
	// The data within the payload.
	Data []byte `json:"data"`
}

Indexation is a payload which holds an index and associated data.

func (*Indexation) Deserialize

func (u *Indexation) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*Indexation) MarshalJSON

func (u *Indexation) MarshalJSON() ([]byte, error)

func (*Indexation) PayloadType

func (u *Indexation) PayloadType() PayloadType

func (*Indexation) Serialize

func (u *Indexation) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*Indexation) UnmarshalJSON

func (u *Indexation) UnmarshalJSON(bytes []byte) error

type IndexationFeatureBlock

type IndexationFeatureBlock struct {
	Tag []byte
}

IndexationFeatureBlock is a feature block which allows to additionally tag an output by a user defined value.

func (*IndexationFeatureBlock) Deserialize

func (s *IndexationFeatureBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*IndexationFeatureBlock) Equal

func (s *IndexationFeatureBlock) Equal(other FeatureBlock) bool

func (*IndexationFeatureBlock) MarshalJSON

func (s *IndexationFeatureBlock) MarshalJSON() ([]byte, error)

func (*IndexationFeatureBlock) Serialize

func (s *IndexationFeatureBlock) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*IndexationFeatureBlock) Type

func (*IndexationFeatureBlock) UnmarshalJSON

func (s *IndexationFeatureBlock) UnmarshalJSON(bytes []byte) error

func (*IndexationFeatureBlock) VByteCost

func (s *IndexationFeatureBlock) VByteCost(costStruct *RentStructure, f VByteCostFunc) uint64

func (*IndexationFeatureBlock) ValidTagSize

func (s *IndexationFeatureBlock) ValidTagSize() error

type IndexedUTXOReferencer

type IndexedUTXOReferencer interface {
	Input

	// Ref returns the UTXO this Input references.
	Ref() OutputID
	// Index returns the output index of the UTXO this Input references.
	Index() uint16
}

IndexedUTXOReferencer is a type of Input which references a UTXO by the transaction ID and output index.

type Input

type Input interface {
	serializer.Serializable

	// Type returns the type of Input.
	Type() InputType
}

Input references a UTXO.

func InputSelector

func InputSelector(inputType uint32) (Input, error)

InputSelector implements SerializableSelectorFunc for input types.

type InputType

type InputType byte

InputType defines the type of inputs.

const (
	// InputUTXO is a type of input which references an unspent transaction output.
	InputUTXO InputType = iota
	// InputTreasury is a type of input which references a milestone which generated a treasury output.
	InputTreasury
)

type Inputs

type Inputs []Input

Inputs a slice of Input.

func (*Inputs) FromSerializables

func (in *Inputs) FromSerializables(seris serializer.Serializables)

func (Inputs) ToSerializables

func (in Inputs) ToSerializables() serializer.Serializables

type InputsSyntacticalValidationFunc

type InputsSyntacticalValidationFunc func(index int, input Input) error

InputsSyntacticalValidationFunc which given the index of an input and the input itself, runs syntactical validations and returns an error if any should fail.

func InputsSyntacticalIndicesWithinBounds

func InputsSyntacticalIndicesWithinBounds() InputsSyntacticalValidationFunc

InputsSyntacticalIndicesWithinBounds returns an InputsSyntacticalValidationFunc which checks that the UTXO ref index is within bounds.

func InputsSyntacticalUnique

func InputsSyntacticalUnique() InputsSyntacticalValidationFunc

InputsSyntacticalUnique returns an InputsSyntacticalValidationFunc which checks that every input has a unique UTXO ref.

type IssuerFeatureBlock

type IssuerFeatureBlock struct {
	Address Address
}

IssuerFeatureBlock is a feature block which associates an output with an issuer identity. Unlike the SenderFeatureBlock, the issuer identity only has to be unlocked when the state machine type of output is first created, afterwards, the issuer block must not change, meaning that subsequent outputs must always define the same issuer identity (the identity does not need to be unlocked anymore though).

func (*IssuerFeatureBlock) Deserialize

func (s *IssuerFeatureBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*IssuerFeatureBlock) Equal

func (s *IssuerFeatureBlock) Equal(other FeatureBlock) bool

func (*IssuerFeatureBlock) MarshalJSON

func (s *IssuerFeatureBlock) MarshalJSON() ([]byte, error)

func (*IssuerFeatureBlock) Serialize

func (s *IssuerFeatureBlock) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*IssuerFeatureBlock) Type

func (*IssuerFeatureBlock) UnmarshalJSON

func (s *IssuerFeatureBlock) UnmarshalJSON(bytes []byte) error

func (*IssuerFeatureBlock) VByteCost

func (s *IssuerFeatureBlock) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

type JSONObjectEnvelope

type JSONObjectEnvelope struct {
	Type int `json:"type"`
}

JSONObjectEnvelope defines the envelope for looking-ahead an object's type before deserializing it to its actual object.

type JSONSerializable

type JSONSerializable interface {
	// ToSerializable returns the Serializable form of the JSONSerializable.
	ToSerializable() (serializer.Serializable, error)
}

JSONSerializable is an object which can return a Serializable.

func DeserializeObjectFromJSON

func DeserializeObjectFromJSON(raw *json.RawMessage, selector JSONSerializableSelectorFunc) (JSONSerializable, error)

DeserializeObjectFromJSON reads out the type of the given raw json message, then selects the appropriate object type and deserializes the given *json.RawMessage into it.

type JSONSerializableSelectorFunc

type JSONSerializableSelectorFunc func(ty int) (JSONSerializable, error)

JSONSerializableSelectorFunc is a function that given a type int, returns an empty instance of the given underlying type. If the type doesn't resolve, an error is returned.

type LegacyTailTransactionHash

type LegacyTailTransactionHash = [49]byte

LegacyTailTransactionHash represents the bytes of a T5B1 encoded legacy tail transaction hash.

type Message

type Message struct {
	// The network ID for which this message is meant for.
	NetworkID uint64
	// The parents the message references.
	Parents MessageIDs
	// The inner payload of the message. Can be nil.
	Payload Payload
	// The nonce which lets this message fulfill the PoW requirements.
	Nonce uint64
}

Message can carry a payload and references two other messages.

func (*Message) Deserialize

func (m *Message) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*Message) ID

func (m *Message) ID() (*MessageID, error)

ID computes the ID of the Message.

func (*Message) MarshalJSON

func (m *Message) MarshalJSON() ([]byte, error)

func (*Message) MustID

func (m *Message) MustID() MessageID

MustID works like ID but panics if the MessageID can't be computed.

func (*Message) POW

func (m *Message) POW() (float64, error)

POW computes the PoW score of the Message.

func (*Message) Serialize

func (m *Message) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*Message) UnmarshalJSON

func (m *Message) UnmarshalJSON(bytes []byte) error

type MessageBuilder

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

MessageBuilder is used to easily build up a Message.

func NewMessageBuilder

func NewMessageBuilder() *MessageBuilder

NewMessageBuilder creates a new MessageBuilder.

func (*MessageBuilder) Build

func (mb *MessageBuilder) Build() (*Message, error)

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

func (*MessageBuilder) NetworkID

func (mb *MessageBuilder) NetworkID(networkID uint64) *MessageBuilder

NetworkID sets the network ID for which this message is meant for.

func (*MessageBuilder) NetworkIDFromString

func (mb *MessageBuilder) NetworkIDFromString(networkIDStr string) *MessageBuilder

NetworkIDFromString sets the network ID for which this message is meant for.

func (*MessageBuilder) Parents

func (mb *MessageBuilder) Parents(parents [][]byte) *MessageBuilder

Parents sets the parents of the message.

func (*MessageBuilder) ParentsMessageIDs

func (mb *MessageBuilder) ParentsMessageIDs(parents MessageIDs) *MessageBuilder

ParentsMessageIDs sets the parents of the message.

func (*MessageBuilder) Payload

func (mb *MessageBuilder) Payload(payload Payload) *MessageBuilder

Payload sets the payload to embed within the message.

func (*MessageBuilder) ProofOfWork

func (mb *MessageBuilder) ProofOfWork(ctx context.Context, deSeriPara *DeSerializationParameters, targetScore float64, numWorkers ...int) *MessageBuilder

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

func (*MessageBuilder) Tips

Tips uses the given NodeHTTPAPIClient to query for parents to use.

type MessageID

type MessageID = [MessageIDLength]byte

MessageID is the ID of a Message.

func MessageIDFromHexString

func MessageIDFromHexString(messageIDHex string) (MessageID, error)

MessageIDFromHexString converts the given message IDs from their hex to MessageID representation.

func MustMessageIDFromHexString

func MustMessageIDFromHexString(messageIDHex string) MessageID

MustMessageIDFromHexString converts the given message IDs from their hex to MessageID representation.

type MessageIDs

type MessageIDs = []MessageID

MessageIDs are IDs of messages.

type MessageIDsByIndexResponse

type MessageIDsByIndexResponse struct {
	// The index of the messages.
	Index string `json:"index"`
	// The maximum count of results that are returned by the node.
	MaxResults uint32 `json:"maxResults"`
	// The actual count of results that are returned.
	Count uint32 `json:"count"`
	// The hex encoded message IDs of the found messages with this index.
	MessageIDs []string `json:"messageIds"`
}

MessageIDsByIndexResponse defines the response of a GET messages REST API call.

type MessageMetadataResponse

type MessageMetadataResponse struct {
	// The hex encoded message ID of the message.
	MessageID string `json:"messageId"`
	// The hex encoded message IDs of the parents the message references.
	Parents []string `json:"parentMessageIds"`
	// Whether the message is solid.
	Solid bool `json:"isSolid"`
	// The milestone index that references this message.
	ReferencedByMilestoneIndex *uint32 `json:"referencedByMilestoneIndex,omitempty"`
	// If this message represents a milestone this is the milestone index
	MilestoneIndex *uint32 `json:"milestoneIndex,omitempty"`
	// The ledger inclusion state of the transaction payload.
	LedgerInclusionState *string `json:"ledgerInclusionState,omitempty"`
	// Whether the message should be promoted.
	ShouldPromote *bool `json:"shouldPromote,omitempty"`
	// Whether the message should be reattached.
	ShouldReattach *bool `json:"shouldReattach,omitempty"`
	// The reason why this message is marked as conflicting.
	ConflictReason uint8 `json:"conflictReason,omitempty"`
}

MessageMetadataResponse defines the response of a GET message metadata REST API call.

type MetadataFeatureBlock

type MetadataFeatureBlock struct {
	Data []byte
}

MetadataFeatureBlock is a feature block which simply holds binary data to be freely interpreted by higher layer applications.

func (*MetadataFeatureBlock) Deserialize

func (s *MetadataFeatureBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*MetadataFeatureBlock) Equal

func (s *MetadataFeatureBlock) Equal(other FeatureBlock) bool

func (*MetadataFeatureBlock) MarshalJSON

func (s *MetadataFeatureBlock) MarshalJSON() ([]byte, error)

func (*MetadataFeatureBlock) Serialize

func (s *MetadataFeatureBlock) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*MetadataFeatureBlock) Type

func (*MetadataFeatureBlock) UnmarshalJSON

func (s *MetadataFeatureBlock) UnmarshalJSON(bytes []byte) error

func (*MetadataFeatureBlock) VByteCost

func (s *MetadataFeatureBlock) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

func (*MetadataFeatureBlock) ValidDataSize

func (s *MetadataFeatureBlock) ValidDataSize() error

type MigratedFundsEntries

type MigratedFundsEntries []*MigratedFundsEntry

MigratedFundsEntries is a slice of MigratedFundsEntry.

func (*MigratedFundsEntries) FromSerializables

func (o *MigratedFundsEntries) FromSerializables(seris serializer.Serializables)

func (MigratedFundsEntries) ToSerializables

func (o MigratedFundsEntries) ToSerializables() serializer.Serializables

type MigratedFundsEntry

type MigratedFundsEntry struct {
	// The tail transaction hash of the migration bundle.
	TailTransactionHash LegacyTailTransactionHash
	// The target address of the migrated funds.
	Address Address
	// The amount of the deposit.
	Deposit uint64
}

MigratedFundsEntry are funds which were migrated from a legacy network.

func (*MigratedFundsEntry) Deserialize

func (m *MigratedFundsEntry) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*MigratedFundsEntry) MarshalJSON

func (m *MigratedFundsEntry) MarshalJSON() ([]byte, error)

func (*MigratedFundsEntry) Serialize

func (m *MigratedFundsEntry) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*MigratedFundsEntry) UnmarshalJSON

func (m *MigratedFundsEntry) UnmarshalJSON(bytes []byte) error

type Milestone

type Milestone struct {
	// The index of this milestone.
	Index uint32
	// The time at which this milestone was issued.
	Timestamp uint64
	// The parents where this milestone attaches to.
	Parents MilestoneParentMessageIDs
	// The inclusion merkle proof of included/newly confirmed transaction IDs.
	InclusionMerkleProof MilestoneInclusionMerkleProof
	// The next minimum PoW score to use after NextPoWScoreMilestoneIndex is hit.
	NextPoWScore uint32
	// The milestone index at which the PoW score changes to NextPoWScore.
	NextPoWScoreMilestoneIndex uint32
	// The public keys validating the signatures of the milestone.
	PublicKeys []MilestonePublicKey
	// The inner payload of the milestone. Can be nil or a Receipt.
	Receipt serializer.Serializable
	// The signatures held by the milestone.
	Signatures []MilestoneSignature
}

Milestone represents a special payload which defines the inclusion set of other messages in the Tangle.

func NewMilestone

func NewMilestone(index uint32, timestamp uint64, parents MilestoneParentMessageIDs, inclMerkleProof MilestoneInclusionMerkleProof, pubKeys []MilestonePublicKey) (*Milestone, error)

NewMilestone creates a new Milestone. It automatically orders the given public keys by their byte order.

func (*Milestone) Deserialize

func (m *Milestone) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*Milestone) Essence

func (m *Milestone) Essence() ([]byte, error)

Essence returns the essence bytes (the bytes to be signed) of the Milestone.

func (*Milestone) ID

func (m *Milestone) ID() (*MilestoneID, error)

ID computes the ID of the Milestone.

func (*Milestone) MarshalJSON

func (m *Milestone) MarshalJSON() ([]byte, error)

func (*Milestone) PayloadType

func (m *Milestone) PayloadType() PayloadType

func (*Milestone) Serialize

func (m *Milestone) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*Milestone) Sign

func (m *Milestone) Sign(signingFunc MilestoneSigningFunc) error

Sign produces the signatures with the given envelope message and updates the Signatures field of the Milestone with the resulting signatures of the given MilestoneSigningFunc.

func (*Milestone) UnmarshalJSON

func (m *Milestone) UnmarshalJSON(bytes []byte) error

func (*Milestone) VerifySignatures

func (m *Milestone) VerifySignatures(minSigThreshold int, applicablePubKeys MilestonePublicKeySet) error

VerifySignatures verifies that min. minSigThreshold signatures occur in the Milestone and that all signatures within it are valid with respect to the given applicable public key set. The public key set must only contain keys applicable for the given Milestone index. The caller must only call this function on a Milestone which was deserialized with validation.

type MilestoneID

type MilestoneID = [MilestoneIDLength]byte

MilestoneID is the ID of a Milestone.

type MilestoneInclusionMerkleProof

type MilestoneInclusionMerkleProof = [MilestoneInclusionMerkleProofLength]byte

MilestoneInclusionMerkleProof is the inclusion merkle proof data of a milestone.

type MilestoneParentMessageID

type MilestoneParentMessageID = MessageID

MilestoneParentMessageID is a reference to a parent message.

type MilestoneParentMessageIDs

type MilestoneParentMessageIDs = []MilestoneParentMessageID

MilestoneParentMessageIDs are references to parent messages.

type MilestonePublicKey

type MilestonePublicKey = [MilestonePublicKeyLength]byte

MilestonePublicKey is a public key within a Milestone.

type MilestonePublicKeyMapping

type MilestonePublicKeyMapping = map[MilestonePublicKey]ed25519.PrivateKey

MilestonePublicKeyMapping is a mapping from a public key to a private key.

type MilestonePublicKeySet

type MilestonePublicKeySet = map[MilestonePublicKey]struct{}

MilestonePublicKeySet is a set of unique MilestonePublicKey.

type MilestoneResponse

type MilestoneResponse struct {
	// The index of the milestone.
	Index uint32 `json:"index"`
	// The hex encoded message ID of the message.
	MessageID string `json:"messageId"`
	// The unix time of the milestone payload.
	Time int64 `json:"timestamp"`
}

MilestoneResponse defines the response of a GET milestones REST API call.

type MilestoneSignature

type MilestoneSignature = [MilestoneSignatureLength]byte

MilestoneSignature is a signature within a Milestone.

type MilestoneSigningFunc

type MilestoneSigningFunc func(pubKeys []MilestonePublicKey, msEssence []byte) ([]MilestoneSignature, error)

MilestoneSigningFunc is a function which produces a set of signatures for the given Milestone essence data. The given public keys dictate in which order the returned signatures must occur.

func InMemoryEd25519MilestoneSigner

func InMemoryEd25519MilestoneSigner(prvKeys MilestonePublicKeyMapping) MilestoneSigningFunc

InMemoryEd25519MilestoneSigner is a function which uses the provided Ed25519 MilestonePublicKeyMapping to produce signatures for the Milestone essence data.

func InsecureRemoteEd25519MilestoneSigner

func InsecureRemoteEd25519MilestoneSigner(remoteEndpoint string) MilestoneSigningFunc

InsecureRemoteEd25519MilestoneSigner is a function which uses a remote RPC server via an insecure connection to produce signatures for the Milestone essence data. You must only use this function if the remote lives on the same host as the caller.

type MilestoneUTXOChangesResponse

type MilestoneUTXOChangesResponse struct {
	// The index of the milestone.
	Index uint32 `json:"index"`
	// The output IDs (transaction hash + output index) of the newly created outputs.
	CreatedOutputs []string `json:"createdOutputs"`
	// The output IDs (transaction hash + output index) of the consumed (spent) outputs.
	ConsumedOutputs []string `json:"consumedOutputs"`
}

MilestoneUTXOChangesResponse defines the response of a GET milestone UTXO changes REST API call.

type NFTAddress

type NFTAddress [NFTAddressBytesLength]byte

NFTAddress defines an NFT address. An NFTAddress is the Blake2b-160 hash of the OutputID which created it.

func MustParseNFTAddressFromHexString

func MustParseNFTAddressFromHexString(hexAddr string) *NFTAddress

MustParseNFTAddressFromHexString parses the given hex string into an NFTAddress. It panics if the hex address is invalid.

func NFTAddressFromOutputID

func NFTAddressFromOutputID(outputID OutputID) NFTAddress

NFTAddressFromOutputID returns the NFT address computed from a given OutputID.

func ParseNFTAddressFromHexString

func ParseNFTAddressFromHexString(hexAddr string) (*NFTAddress, error)

ParseNFTAddressFromHexString parses the given hex string into an NFTAddress.

func (*NFTAddress) Bech32

func (nftAddr *NFTAddress) Bech32(hrp NetworkPrefix) string

func (*NFTAddress) Chain

func (nftAddr *NFTAddress) Chain() ChainID

func (*NFTAddress) Deserialize

func (nftAddr *NFTAddress) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*NFTAddress) Equal

func (nftAddr *NFTAddress) Equal(other Address) bool

func (*NFTAddress) Key

func (nftAddr *NFTAddress) Key() string

func (*NFTAddress) MarshalJSON

func (nftAddr *NFTAddress) MarshalJSON() ([]byte, error)

func (*NFTAddress) NFTID

func (nftAddr *NFTAddress) NFTID() NFTID

func (*NFTAddress) Serialize

func (nftAddr *NFTAddress) Serialize(_ serializer.DeSerializationMode, deSeriCtx interface{}) (data []byte, err error)

func (*NFTAddress) String

func (nftAddr *NFTAddress) String() string

func (*NFTAddress) Type

func (nftAddr *NFTAddress) Type() AddressType

func (*NFTAddress) UnmarshalJSON

func (nftAddr *NFTAddress) UnmarshalJSON(bytes []byte) error

func (*NFTAddress) VByteCost

func (nftAddr *NFTAddress) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

type NFTID

type NFTID [NFTIDLength]byte

NFTID is the identifier for an NFT. It is computed as the Blake2b-160 hash of the OutputID of the output which created the NFT.

func (NFTID) Addressable

func (nftID NFTID) Addressable() bool

func (NFTID) Empty

func (nftID NFTID) Empty() bool

func (NFTID) FromOutputID

func (nftID NFTID) FromOutputID(id OutputID) ChainID

func (NFTID) Key

func (nftID NFTID) Key() interface{}

func (NFTID) Matches

func (nftID NFTID) Matches(other ChainID) bool

func (NFTID) String

func (nftID NFTID) String() string

func (NFTID) ToAddress

func (nftID NFTID) ToAddress() ChainConstrainedAddress

type NFTOutput

type NFTOutput struct {
	// The actual address.
	Address Address
	// The amount of IOTA tokens held by the output.
	Amount uint64
	// The native tokens held by the output.
	NativeTokens NativeTokens
	// The identifier of this NFT.
	NFTID NFTID
	// Arbitrary immutable binary data attached to this NFT.
	ImmutableMetadata []byte
	// The feature blocks which modulate the constraints on the output.
	Blocks FeatureBlocks
}

NFTOutput is an output type used to implement non-fungible tokens.

func (*NFTOutput) Chain

func (n *NFTOutput) Chain() ChainID

func (*NFTOutput) Deposit

func (n *NFTOutput) Deposit() uint64

func (*NFTOutput) Deserialize

func (n *NFTOutput) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*NFTOutput) FeatureBlocks

func (n *NFTOutput) FeatureBlocks() FeatureBlocks

func (*NFTOutput) Ident

func (n *NFTOutput) Ident() Address

func (*NFTOutput) MarshalJSON

func (n *NFTOutput) MarshalJSON() ([]byte, error)

func (*NFTOutput) NativeTokenSet

func (n *NFTOutput) NativeTokenSet() NativeTokens

func (*NFTOutput) Serialize

func (n *NFTOutput) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*NFTOutput) Type

func (n *NFTOutput) Type() OutputType

func (*NFTOutput) UnlockableBy

func (n *NFTOutput) UnlockableBy(ident Address, extParas *ExternalUnlockParameters) bool

func (*NFTOutput) UnmarshalJSON

func (n *NFTOutput) UnmarshalJSON(bytes []byte) error

func (*NFTOutput) VByteCost

func (n *NFTOutput) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

func (*NFTOutput) ValidateStateTransition

func (n *NFTOutput) ValidateStateTransition(transType ChainTransitionType, next ChainConstrainedOutput, semValCtx *SemanticValidationContext) error

type NFTUnlockBlock

type NFTUnlockBlock struct {
	// The other unlock block this NFTUnlockBlock references to.
	Reference uint16
}

NFTUnlockBlock is an UnlockBlock which references a previous unlock block.

func (*NFTUnlockBlock) Chainable

func (r *NFTUnlockBlock) Chainable() bool

func (*NFTUnlockBlock) Deserialize

func (r *NFTUnlockBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*NFTUnlockBlock) MarshalJSON

func (r *NFTUnlockBlock) MarshalJSON() ([]byte, error)

func (*NFTUnlockBlock) Ref

func (r *NFTUnlockBlock) Ref() uint16

func (*NFTUnlockBlock) Serialize

func (r *NFTUnlockBlock) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*NFTUnlockBlock) SourceAllowed

func (r *NFTUnlockBlock) SourceAllowed(address Address) bool

func (*NFTUnlockBlock) Type

func (r *NFTUnlockBlock) Type() UnlockBlockType

func (*NFTUnlockBlock) UnmarshalJSON

func (r *NFTUnlockBlock) UnmarshalJSON(bytes []byte) error

type NativeToken

type NativeToken struct {
	ID     NativeTokenID
	Amount *big.Int
}

NativeToken represents a token which resides natively on the ledger.

func (*NativeToken) Clone

func (n *NativeToken) Clone() *NativeToken

Clone clones the NativeToken.

func (*NativeToken) Deserialize

func (n *NativeToken) Deserialize(data []byte, _ serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*NativeToken) Equal

func (n *NativeToken) Equal(other *NativeToken) bool

Equal checks whether other is equal to this NativeToken.

func (*NativeToken) MarshalJSON

func (n *NativeToken) MarshalJSON() ([]byte, error)

func (*NativeToken) Serialize

func (n *NativeToken) Serialize(_ serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*NativeToken) UnmarshalJSON

func (n *NativeToken) UnmarshalJSON(bytes []byte) error

func (*NativeToken) VByteCost

func (n *NativeToken) VByteCost(_ *RentStructure, _ VByteCostFunc) uint64

type NativeTokenID

type NativeTokenID [NativeTokenIDLength]byte

NativeTokenID is an identifier which uniquely identifies a NativeToken.

func (NativeTokenID) FoundryID

func (ntID NativeTokenID) FoundryID() FoundryID

FoundryID returns the FoundryID to which this NativeTokenID belongs to.

func (NativeTokenID) String

func (ntID NativeTokenID) String() string

type NativeTokenOutput

type NativeTokenOutput interface {
	Output
	// NativeTokenSet returns the NativeToken this output defines.
	NativeTokenSet() NativeTokens
}

NativeTokenOutput is a type of Output which can hold NativeToken.

type NativeTokenOutputs

type NativeTokenOutputs []NativeTokenOutput

NativeTokenOutputs is a slice of NativeTokenOutput(s).

func (NativeTokenOutputs) Sum

func (ntOutputs NativeTokenOutputs) Sum() (NativeTokenSum, int, error)

Sum sums up the different NativeTokens occurring within the given outputs. limit defines the max amount of native tokens which are allowewd

type NativeTokenSum

type NativeTokenSum map[NativeTokenID]*big.Int

NativeTokenSum is a mapping of NativeTokenID to a sum value.

func (NativeTokenSum) Balanced

func (nts NativeTokenSum) Balanced(other NativeTokenSum) error

Balanced checks whether the set of NativeTokens are balanced between the two NativeTokenSum. This function is only appropriate for checking NativeToken balances if there are no underlying foundry state transitions.

type NativeTokens

type NativeTokens []*NativeToken

NativeTokens is a set of NativeToken.

func (NativeTokens) Clone

func (n NativeTokens) Clone() NativeTokens

Clone clones this slice of NativeToken(s).

func (NativeTokens) Equal

func (n NativeTokens) Equal(other NativeTokens) bool

Equal checks whether other is equal to this slice.

func (*NativeTokens) FromSerializables

func (n *NativeTokens) FromSerializables(seris serializer.Serializables)

func (NativeTokens) MustSet

func (n NativeTokens) MustSet() NativeTokensSet

MustSet works like Set but panics if an error occurs. This function is therefore only safe to be called when it is given, that a NativeTokens slice does not contain the same NativeTokenID multiple times.

func (NativeTokens) Set

func (n NativeTokens) Set() (NativeTokensSet, error)

Set converts the slice into a NativeTokenSet. Returns an error if a NativeTokenID occurs multiple times.

func (NativeTokens) ToSerializables

func (n NativeTokens) ToSerializables() serializer.Serializables

func (NativeTokens) VByteCost

func (n NativeTokens) VByteCost(costStruct *RentStructure, override VByteCostFunc) uint64

type NativeTokensSet

type NativeTokensSet map[NativeTokenID]*NativeToken

NativeTokensSet is a set of NativeToken(s).

type NetworkID

type NetworkID = uint64

NetworkID defines the ID of the network on which entities operate on.

func NetworkIDFromString

func NetworkIDFromString(networkIDStr string) NetworkID

NetworkIDFromString returns the network ID string's numerical representation.

type NetworkPrefix

type NetworkPrefix string

NetworkPrefix denotes the different network prefixes.

const (
	PrefixMainnet NetworkPrefix = "iota"
	PrefixTestnet NetworkPrefix = "atoi"
)

Network prefixes.

type NodeHTTPAPIClient

type NodeHTTPAPIClient struct {
	// The base URL for all API calls.
	BaseURL string
	// contains filtered or unexported fields
}

NodeHTTPAPIClient is a client for node HTTP REST API endpoints.

func NewNodeHTTPAPIClient

func NewNodeHTTPAPIClient(baseURL string, deSeriParas *DeSerializationParameters, opts ...NodeHTTPAPIClientOption) *NodeHTTPAPIClient

NewNodeHTTPAPIClient returns a new NodeHTTPAPIClient with the given BaseURL.

func (*NodeHTTPAPIClient) AddPeer

func (api *NodeHTTPAPIClient) AddPeer(ctx context.Context, multiAddress string, alias ...string) (*PeerResponse, error)

AddPeer adds a new peer by libp2p multi address with optional alias.

func (*NodeHTTPAPIClient) BalanceByBech32Address

func (api *NodeHTTPAPIClient) BalanceByBech32Address(ctx context.Context, bech32Addr string) (*AddressBalanceResponse, error)

BalanceByBech32Address returns the balance of the given Bech32 address.

func (*NodeHTTPAPIClient) BalanceByEd25519Address

func (api *NodeHTTPAPIClient) BalanceByEd25519Address(ctx context.Context, addr *Ed25519Address) (*AddressBalanceResponse, error)

BalanceByEd25519Address returns the balance of an Ed25519 address.

func (*NodeHTTPAPIClient) ChildrenByMessageID

func (api *NodeHTTPAPIClient) ChildrenByMessageID(ctx context.Context, msgID MessageID) (*ChildrenResponse, error)

ChildrenByMessageID get a message by its message ID from the node.

func (*NodeHTTPAPIClient) Do

func (api *NodeHTTPAPIClient) Do(ctx context.Context, method string, route string, reqObj interface{}, resObj interface{}) (*http.Response, error)

func (*NodeHTTPAPIClient) Health

func (api *NodeHTTPAPIClient) Health(ctx context.Context) (bool, error)

Health returns whether the given node is healthy.

func (*NodeHTTPAPIClient) Info

Info gets the info of the node.

func (*NodeHTTPAPIClient) MessageByMessageID

func (api *NodeHTTPAPIClient) MessageByMessageID(ctx context.Context, msgID MessageID) (*Message, error)

MessageByMessageID get a message by its message ID from the node.

func (*NodeHTTPAPIClient) MessageIDsByIndex

func (api *NodeHTTPAPIClient) MessageIDsByIndex(ctx context.Context, index []byte) (*MessageIDsByIndexResponse, error)

MessageIDsByIndex gets message IDs filtered by index from the node.

func (*NodeHTTPAPIClient) MessageMetadataByMessageID

func (api *NodeHTTPAPIClient) MessageMetadataByMessageID(ctx context.Context, msgID MessageID) (*MessageMetadataResponse, error)

MessageMetadataByMessageID gets the metadata of a message by its message ID from the node.

func (*NodeHTTPAPIClient) MilestoneByIndex

func (api *NodeHTTPAPIClient) MilestoneByIndex(ctx context.Context, index uint32) (*MilestoneResponse, error)

MilestoneByIndex gets a milestone by its index.

func (*NodeHTTPAPIClient) MilestoneUTXOChangesByIndex

func (api *NodeHTTPAPIClient) MilestoneUTXOChangesByIndex(ctx context.Context, index uint32) (*MilestoneUTXOChangesResponse, error)

MilestoneUTXOChangesByIndex returns all UTXO changes of a milestone by its milestoneIndex.

func (*NodeHTTPAPIClient) OutputByID

func (api *NodeHTTPAPIClient) OutputByID(ctx context.Context, outputID OutputID) (*NodeOutputResponse, error)

OutputByID gets an outputs by its ID from the node.

func (*NodeHTTPAPIClient) OutputIDsByBech32Address

func (api *NodeHTTPAPIClient) OutputIDsByBech32Address(ctx context.Context, bech32Addr string, includeSpentOutputs bool) (*AddressOutputsResponse, error)

OutputIDsByBech32Address gets output IDs of outputs residing on the given Bech32 address. Per default only unspent outputs IDs are returned. Set includeSpentOutputs to true to also return spent output IDs.

func (*NodeHTTPAPIClient) OutputIDsByEd25519Address

func (api *NodeHTTPAPIClient) OutputIDsByEd25519Address(ctx context.Context, addr *Ed25519Address, includeSpentOutputs bool) (*AddressOutputsResponse, error)

OutputIDsByEd25519Address gets output IDs of outputs residing on the given Ed25519Address. Per default only unspent output IDs are returned. Set includeSpentOutputs to true to also return spent output IDs.

func (*NodeHTTPAPIClient) OutputsByBech32Address

func (api *NodeHTTPAPIClient) OutputsByBech32Address(ctx context.Context, bech32Addr string, includeSpentOutputs bool) (*AddressOutputsResponse, map[*UTXOInput]Output, error)

OutputsByBech32Address gets the outputs residing on the given Bech32 address. Per default only unspent outputs are returned. Set includeSpentOutputs to true to also return spent outputs.

func (*NodeHTTPAPIClient) OutputsByEd25519Address

func (api *NodeHTTPAPIClient) OutputsByEd25519Address(ctx context.Context, addr *Ed25519Address, includeSpentOutputs bool) (*AddressOutputsResponse, map[*UTXOInput]Output, error)

OutputsByEd25519Address gets the outputs residing on the given Ed25519Address. Per default only unspent outputs are returned. Set includeSpentOutputs to true to also return spent outputs.

func (*NodeHTTPAPIClient) PeerByID

func (api *NodeHTTPAPIClient) PeerByID(ctx context.Context, id string) (*PeerResponse, error)

PeerByID gets a peer by its identifier.

func (*NodeHTTPAPIClient) Peers

func (api *NodeHTTPAPIClient) Peers(ctx context.Context) ([]*PeerResponse, error)

Peers returns a list of all peers.

func (*NodeHTTPAPIClient) Receipts

func (api *NodeHTTPAPIClient) Receipts(ctx context.Context) ([]*ReceiptTuple, error)

Receipts gets all receipts persisted on the node.

func (*NodeHTTPAPIClient) ReceiptsByMigratedAtIndex

func (api *NodeHTTPAPIClient) ReceiptsByMigratedAtIndex(ctx context.Context, index uint32) ([]*ReceiptTuple, error)

ReceiptsByMigratedAtIndex gets all receipts for the given migrated at index persisted on the node.

func (*NodeHTTPAPIClient) RemovePeerByID

func (api *NodeHTTPAPIClient) RemovePeerByID(ctx context.Context, id string) error

RemovePeerByID removes a peer by its identifier.

func (*NodeHTTPAPIClient) SubmitMessage

func (api *NodeHTTPAPIClient) SubmitMessage(ctx context.Context, m *Message) (*Message, error)

SubmitMessage submits the given Message to the node. The node will take care of filling missing information. This function returns the finalized message created by the node.

func (*NodeHTTPAPIClient) Tips

Tips gets the two tips from the node.

func (*NodeHTTPAPIClient) Treasury

func (api *NodeHTTPAPIClient) Treasury(ctx context.Context) (*TreasuryResponse, error)

Treasury gets the current treasury.

type NodeHTTPAPIClientOption

type NodeHTTPAPIClientOption func(opts *NodeHTTPAPIClientOptions)

NodeHTTPAPIClientOption is a function setting a NodeHTTPAPIClient option.

func WithNodeHTTPAPIClientHTTPClient

func WithNodeHTTPAPIClientHTTPClient(httpClient *http.Client) NodeHTTPAPIClientOption

WithNodeHTTPAPIClientHTTPClient sets the used HTTP Client.

func WithNodeHTTPAPIClientUserInfo

func WithNodeHTTPAPIClientUserInfo(userInfo *url.Userinfo) NodeHTTPAPIClientOption

WithNodeHTTPAPIClientUserInfo sets the Userinfo used to add basic auth "Authorization" headers to the requests.

type NodeHTTPAPIClientOptions

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

NodeHTTPAPIClientOptions define options for the NodeHTTPAPIClient.

type NodeInfoResponse

type NodeInfoResponse struct {
	// The name of the node software.
	Name string `json:"name"`
	// The semver version of the node software.
	Version string `json:"version"`
	// Whether the node is healthy.
	IsHealthy bool `json:"isHealthy"`
	// The human friendly name of the network ID on which the node operates on.
	NetworkID string `json:"networkId"`
	// The HRP prefix used for Bech32 addresses in the node's network.
	Bech32HRP string `json:"bech32HRP"`
	// The minimum pow score of the network.
	MinPowScore float64 `json:"minPoWScore"`
	// The current rate of new messages per second.
	MessagesPerSecond float64 `json:"messagesPerSecond"`
	// The current rate of referenced messages per second.
	ReferencedMessagesPerSecond float64 `json:"referencedMessagesPerSecond"`
	// The ratio of referenced messages in relation to new messages of the last confirmed milestone.
	ReferencedRate float64 `json:"referencedRate"`
	// The timestamp of the latest known milestone.
	LatestMilestoneTimestamp int64 `json:"latestMilestoneTimestamp"`
	// The latest known milestone index.
	LatestMilestoneIndex uint32 `json:"latestMilestoneIndex"`
	// The current confirmed milestone's index.
	ConfirmedMilestoneIndex uint32 `json:"confirmedMilestoneIndex"`
	// The milestone index at which the last pruning commenced.
	PruningIndex uint32 `json:"pruningIndex"`
	// The features this node exposes.
	Features []string `json:"features"`
}

NodeInfoResponse defines the response of a GET info REST API call.

type NodeOutputResponse

type NodeOutputResponse struct {
	// The hex encoded message ID of the message.
	MessageID string `json:"messageId"`
	// The hex encoded transaction id from which this output originated.
	TransactionID string `json:"transactionId"`
	// The index of the output.
	OutputIndex uint16 `json:"outputIndex"`
	// Whether this output is spent.
	Spent bool `json:"isSpent"`
	// The ledger index at which this output was available at.
	LedgerIndex uint64 `json:"ledgerIndex"`
	// The output in its serialized form.
	RawOutput *json.RawMessage `json:"output"`
}

NodeOutputResponse defines the response of a GET outputs REST API call.

func (*NodeOutputResponse) Output

func (nor *NodeOutputResponse) Output() (Output, error)

Output deserializes the RawOutput to an Output.

func (*NodeOutputResponse) TxID

func (nor *NodeOutputResponse) TxID() (*TransactionID, error)

TxID returns the TransactionID.

type NodeTipsResponse

type NodeTipsResponse struct {
	// The hex encoded message IDs of the tips.
	TipsHex []string `json:"tipMessageIds"`
}

NodeTipsResponse defines the response of a GET tips REST API call.

func (*NodeTipsResponse) Tips

func (ntr *NodeTipsResponse) Tips() (MessageIDs, error)

Tips returns the hex encoded tips as MessageIDs.

type NonEphemeralObject

type NonEphemeralObject interface {
	// VByteCost returns the cost this object has in terms of taking up
	// virtual and physical space within the data set needed to implement the IOTA protocol.
	// The override parameter acts as an escape hatch in case the cost needs to be adjusted
	// according to some external properties outside the NonEphemeralObject.
	VByteCost(costStruct *RentStructure, override VByteCostFunc) uint64
}

NonEphemeralObject is an object which can not be pruned by nodes as it makes up an integral part to execute the IOTA protocol. This kind of objects are associated with costs in terms of the resources they take up.

type Output

type Output interface {
	serializer.Serializable
	NonEphemeralObject

	// Deposit returns the amount this Output deposits.
	Deposit() uint64

	// Type returns the type of the output.
	Type() OutputType
}

Output defines a unit of output of a transaction.

func OutputSelector

func OutputSelector(outputType uint32) (Output, error)

OutputSelector implements SerializableSelectorFunc for output types.

type OutputID

type OutputID [OutputIDLength]byte

OutputID defines the identifier for an UTXO which consists out of the referenced TransactionID and the output's index.

func OutputIDFromTransactionIDAndIndex

func OutputIDFromTransactionIDAndIndex(txID TransactionID, index uint16) OutputID

OutputIDFromTransactionIDAndIndex creates a OutputID from the given TransactionID and index.

func (OutputID) Index

func (outputID OutputID) Index() uint16

Index returns the index of the Output this OutputID references.

func (OutputID) ToHex

func (outputID OutputID) ToHex() string

ToHex converts the OutputID to its hex representation.

func (OutputID) TransactionID

func (outputID OutputID) TransactionID() TransactionID

TransactionID returns the TransactionID of the Output this OutputID references.

func (OutputID) UTXOInput

func (outputID OutputID) UTXOInput() *UTXOInput

UTXOInput creates a UTXOInput from this OutputID.

type OutputIDHex

type OutputIDHex string

OutputIDHex is the hex representation of an output ID.

func (OutputIDHex) AsUTXOInput

func (oih OutputIDHex) AsUTXOInput() (*UTXOInput, error)

AsUTXOInput converts the hex output ID to a UTXOInput.

func (OutputIDHex) MustAsUTXOInput

func (oih OutputIDHex) MustAsUTXOInput() *UTXOInput

MustAsUTXOInput converts the hex output ID to a UTXOInput. It panics if the hex output ID is invalid.

func (OutputIDHex) MustSplitParts

func (oih OutputIDHex) MustSplitParts() (*TransactionID, uint16)

MustSplitParts returns the transaction ID and output index parts of the hex output ID. It panics if the hex output ID is invalid.

func (OutputIDHex) SplitParts

func (oih OutputIDHex) SplitParts() (*TransactionID, uint16, error)

SplitParts returns the transaction ID and output index parts of the hex output ID.

type OutputIDs

type OutputIDs []OutputID

OutputIDs is a slice of OutputID.

func (OutputIDs) ToHex

func (outputIDs OutputIDs) ToHex() []string

ToHex converts all UTXOInput to their hex string representation.

func (OutputIDs) UTXOInputs

func (outputIDs OutputIDs) UTXOInputs() Inputs

UTXOInputs converts the OutputIDs slice to Inputs.

type OutputSet

type OutputSet map[OutputID]Output

OutputSet is a map of the OutputID to Output.

func (OutputSet) ChainConstrainedOutputSet

func (outputSet OutputSet) ChainConstrainedOutputSet() ChainConstrainedOutputsSet

ChainConstrainedOutputSet returns a ChainConstrainedOutputsSet for all ChainConstrainedOutputs in the OutputSet.

func (OutputSet) NewAliases

func (outputSet OutputSet) NewAliases() AliasOutputsSet

NewAliases returns an AliasOutputsSet for all AliasOutputs which are new.

type OutputType

type OutputType byte

OutputType defines the type of outputs.

const (
	// OutputTreasury denotes the type of the TreasuryOutput.
	OutputTreasury OutputType = 2
	// OutputExtended denotes an ExtendedOutput.
	OutputExtended OutputType = 3
	// OutputAlias denotes an AliasOutput.
	OutputAlias OutputType = 4
	// OutputFoundry denotes a FoundryOutput.
	OutputFoundry OutputType = 5
	// OutputNFT denotes an NFTOutput.
	OutputNFT OutputType = 6
)

type Outputs

type Outputs []Output

Outputs is a slice of Output.

func (Outputs) ChainConstrainedOutputSet

func (o Outputs) ChainConstrainedOutputSet(txID TransactionID) ChainConstrainedOutputsSet

ChainConstrainedOutputSet returns a ChainConstrainedOutputsSet for all ChainConstrainedOutputs in Outputs.

func (Outputs) Filter

func (o Outputs) Filter(f OutputsFilterFunc) Outputs

Filter returns Outputs (retained order) passing the given OutputsFilterFunc.

func (*Outputs) FromSerializables

func (o *Outputs) FromSerializables(seris serializer.Serializables)

func (Outputs) ToOutputsByType

func (o Outputs) ToOutputsByType() OutputsByType

ToOutputsByType converts the Outputs slice to OutputsByType.

func (Outputs) ToSerializables

func (o Outputs) ToSerializables() serializer.Serializables

type OutputsByType

type OutputsByType map[OutputType][]Output

OutputsByType is a map of OutputType(s) to slice of Output(s).

func (OutputsByType) AliasOutputs

func (outputs OutputsByType) AliasOutputs() AliasOutputs

AliasOutputs returns a slice of Outputs which are AliasOutput.

func (OutputsByType) ChainConstrainedOutputs

func (outputs OutputsByType) ChainConstrainedOutputs() ChainConstrainedOutputs

ChainConstrainedOutputs returns a slice of Outputs which are ChainConstrainedOutput.

func (OutputsByType) ChainConstrainedOutputsSet

func (outputs OutputsByType) ChainConstrainedOutputsSet() (ChainConstrainedOutputsSet, error)

ChainConstrainedOutputsSet returns a map of ChainID to ChainConstrainedOutput. If multiple ChainConstrainedOutput(s) exist for a given ChainID, an error is returned.

func (OutputsByType) FoundryOutputs

func (outputs OutputsByType) FoundryOutputs() FoundryOutputs

FoundryOutputs returns a slice of Outputs which are FoundryOutput.

func (OutputsByType) FoundryOutputsSet

func (outputs OutputsByType) FoundryOutputsSet() (FoundryOutputsSet, error)

FoundryOutputsSet returns a map of FoundryID to FoundryOutput. If multiple FoundryOutput(s) exist for a given FoundryID, an error is returned.

func (OutputsByType) NativeTokenOutputs

func (outputs OutputsByType) NativeTokenOutputs() NativeTokenOutputs

NativeTokenOutputs returns a slice of Outputs which are NativeTokenOutput.

func (OutputsByType) NonNewAliasOutputsSet

func (outputs OutputsByType) NonNewAliasOutputsSet() (AliasOutputsSet, error)

NonNewAliasOutputsSet returns a map of AliasID to AliasOutput. If multiple AliasOutput(s) exist for a given AliasID, an error is returned. The produced set does not include AliasOutputs of which their AliasID are zeroed.

type OutputsFilterFunc

type OutputsFilterFunc func(output Output) bool

OutputsFilterFunc is a predicate function operating on an Output.

func OutputsFilterByType

func OutputsFilterByType(ty OutputType) OutputsFilterFunc

OutputsFilterByType is an OutputsFilterFunc which filters Outputs by OutputType.

type OutputsSyntacticalValidationFunc

type OutputsSyntacticalValidationFunc func(index int, output Output) error

OutputsSyntacticalValidationFunc which given the index of an output and the output itself, runs syntactical validations and returns an error if any should fail.

func OutputsSyntacticalAlias

func OutputsSyntacticalAlias(txID *TransactionID) OutputsSyntacticalValidationFunc

OutputsSyntacticalAlias returns an OutputsSyntacticalValidationFunc which checks that AliasOutput(s)':

  • StateIndex/FoundryCounter are zero if the AliasID is zeroed
  • StateController and GovernanceController must be different from AliasAddress derived from AliasID

func OutputsSyntacticalDepositAmount

func OutputsSyntacticalDepositAmount(rentStruct *RentStructure) OutputsSyntacticalValidationFunc

OutputsSyntacticalDepositAmount returns an OutputsSyntacticalValidationFunc which checks that:

  • every output deposits more than zero
  • every output deposits less than the total supply
  • the sum of deposits does not exceed the total supply
  • the deposit fulfils the minimum deposit as calculated from the virtual byte cost of the output
  • if the output contains a DustDepositReturnFeatureBlock, it must "return" bigger equal than the minimum dust deposit and must be less equal the minimum virtual byte rent cost for the output.

func OutputsSyntacticalFoundry

func OutputsSyntacticalFoundry() OutputsSyntacticalValidationFunc

OutputsSyntacticalFoundry returns an OutputsSyntacticalValidationFunc which checks that FoundryOutput(s)':

  • CirculatingSupply is less equal MaximumSupply
  • MaximumSupply is not zero

func OutputsSyntacticalNFT

func OutputsSyntacticalNFT(txID *TransactionID) OutputsSyntacticalValidationFunc

OutputsSyntacticalNFT returns an OutputsSyntacticalValidationFunc which checks that NFTOutput(s)':

  • Address must be different from NFTAddress derived from NFTID

func OutputsSyntacticalNativeTokensCount

func OutputsSyntacticalNativeTokensCount() OutputsSyntacticalValidationFunc

OutputsSyntacticalNativeTokensCount returns an OutputsSyntacticalValidationFunc which checks that:

  • the sum of native tokens count across all outputs does not exceed MaxNativeTokensCount

func OutputsSyntacticalSenderFeatureBlockRequirement

func OutputsSyntacticalSenderFeatureBlockRequirement() OutputsSyntacticalValidationFunc

OutputsSyntacticalSenderFeatureBlockRequirement returns an OutputsSyntacticalValidationFunc which checks that:

  • if an output contains a SenderFeatureBlock if another FeatureBlock (example DustDepositReturnFeatureBlock) requires it

type Payload

type Payload interface {
	serializer.Serializable

	// PayloadType returns the type of the payload.
	PayloadType() PayloadType
}

Payload is an object which can be embedded into other objects.

type PayloadType

type PayloadType uint32

PayloadType denotes a type of a payload.

const (
	// PayloadTransaction denotes a Transaction.
	PayloadTransaction PayloadType = iota
	// PayloadMilestone denotes a Milestone.
	PayloadMilestone
	// PayloadIndexation denotes an Indexation.
	PayloadIndexation
	// PayloadReceipt denotes a Receipt.
	PayloadReceipt
	// PayloadTreasuryTransaction denotes a TreasuryTransaction.
	PayloadTreasuryTransaction
)

type PeerGossipMetrics

type PeerGossipMetrics struct {
	// The total amount of received new messages.
	NewMessages uint32 `json:"newMessages"`
	// The total amount of received known messages.
	KnownMessages uint32 `json:"knownMessages"`
	// The total amount of received messages.
	ReceivedMessages uint32 `json:"receivedMessages"`
	// The total amount of received message requests.
	ReceivedMessageRequests uint32 `json:"receivedMessageRequests"`
	// The total amount of received milestone requests.
	ReceivedMilestoneRequests uint32 `json:"receivedMilestoneRequests"`
	// The total amount of received heartbeats.
	ReceivedHeartbeats uint32 `json:"receivedHeartbeats"`
	// The total amount of sent messages.
	SentMessages uint32 `json:"sentMessages"`
	// The total amount of sent message request.
	SentMessageRequests uint32 `json:"sentMessageRequests"`
	// The total amount of sent milestone request.
	SentMilestoneRequests uint32 `json:"sentMilestoneRequests"`
	// The total amount of sent heartbeats.
	SentHeartbeats uint32 `json:"sentHeartbeats"`
	// The total amount of packets which couldn't be sent.
	DroppedPackets uint32 `json:"droppedPackets"`
}

PeerGossipMetrics defines the peer gossip metrics.

type PeerResponse

type PeerResponse struct {
	// The libp2p identifier of the peer.
	ID string `json:"id"`
	// The libp2p multi addresses of the peer.
	MultiAddresses []string `json:"multiAddresses"`
	// The alias to identify the peer.
	Alias *string `json:"alias,omitempty"`
	// The relation (static, autopeered) of the peer.
	Relation string `json:"relation"`
	// Whether the peer is connected.
	Connected bool `json:"connected"`
	// The gossip related information about this peer.
	Gossip *GossipInfo `json:"gossip,omitempty"`
}

PeerResponse defines the response of a GET peer REST API call.

type RawDataEnvelope

type RawDataEnvelope struct {
	// The encapsulated binary data.
	Data []byte
}

RawDataEnvelope is used internally to encapsulate binary data.

type Receipt

type Receipt struct {
	// The milestone index at which the funds were migrated in the legacy network.
	MigratedAt uint32
	// Whether this Receipt is the final one for a given migrated at index.
	Final bool
	// The funds which were migrated with this Receipt.
	Funds MigratedFundsEntries
	// The TreasuryTransaction used to fund the funds.
	Transaction *TreasuryTransaction
}

Receipt is a listing of migrated funds.

func (*Receipt) Deserialize

func (r *Receipt) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*Receipt) MarshalJSON

func (r *Receipt) MarshalJSON() ([]byte, error)

func (*Receipt) PayloadType

func (r *Receipt) PayloadType() PayloadType

func (*Receipt) Serialize

func (r *Receipt) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*Receipt) SortFunds

func (r *Receipt) SortFunds()

SortFunds sorts the funds within the receipt after their serialized binary form in lexical order.

func (*Receipt) Sum

func (r *Receipt) Sum() uint64

Sum returns the sum of all MigratedFundsEntry items within the Receipt.

func (*Receipt) Treasury

func (r *Receipt) Treasury() *TreasuryTransaction

Treasury returns the TreasuryTransaction within the receipt or nil if none is contained. This function panics if the Receipt.Transaction is not nil and not a TreasuryTransaction.

func (*Receipt) UnmarshalJSON

func (r *Receipt) UnmarshalJSON(bytes []byte) error

type ReceiptBuilder

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

ReceiptBuilder is used to easily build up a Receipt.

func NewReceiptBuilder

func NewReceiptBuilder(migratedAt uint32) *ReceiptBuilder

NewReceiptBuilder creates a new ReceiptBuilder.

func (*ReceiptBuilder) AddEntry

func (rb *ReceiptBuilder) AddEntry(entry *MigratedFundsEntry) *ReceiptBuilder

AddEntry adds the given MigratedFundsEntry to the receipt.

func (*ReceiptBuilder) AddTreasuryTransaction

func (rb *ReceiptBuilder) AddTreasuryTransaction(tx *TreasuryTransaction) *ReceiptBuilder

AddTreasuryTransaction adds the given TreasuryTransaction to the receipt. This function overrides the previously added TreasuryTransaction.

func (*ReceiptBuilder) Build

func (rb *ReceiptBuilder) Build(deSeriParas *DeSerializationParameters) (*Receipt, error)

Build builds the Receipt.

type ReceiptTuple

type ReceiptTuple struct {
	Receipt        *Receipt `json:"receipt"`
	MilestoneIndex uint32   `json:"milestoneIndex"`
}

ReceiptTuple represents a receipt and the milestone index in which it was contained.

type ReceiptsResponse

type ReceiptsResponse struct {
	Receipts []*ReceiptTuple `json:"receipts"`
}

ReceiptsResponse defines the response for receipts GET related REST API calls.

type ReferenceUnlockBlock

type ReferenceUnlockBlock struct {
	// The other unlock block this ReferenceUnlockBlock references to.
	Reference uint16
}

ReferenceUnlockBlock is an UnlockBlock which references a previous unlock block.

func (*ReferenceUnlockBlock) Chainable

func (r *ReferenceUnlockBlock) Chainable() bool

func (*ReferenceUnlockBlock) Deserialize

func (r *ReferenceUnlockBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*ReferenceUnlockBlock) MarshalJSON

func (r *ReferenceUnlockBlock) MarshalJSON() ([]byte, error)

func (*ReferenceUnlockBlock) Ref

func (r *ReferenceUnlockBlock) Ref() uint16

func (*ReferenceUnlockBlock) Serialize

func (r *ReferenceUnlockBlock) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*ReferenceUnlockBlock) SourceAllowed

func (r *ReferenceUnlockBlock) SourceAllowed(address Address) bool

func (*ReferenceUnlockBlock) Type

func (*ReferenceUnlockBlock) UnmarshalJSON

func (r *ReferenceUnlockBlock) UnmarshalJSON(bytes []byte) error

type ReferentialUnlockBlock

type ReferentialUnlockBlock interface {
	UnlockBlock

	// Ref returns the index of the UnlockBlock this ReferentialUnlockBlock references.
	Ref() uint16
	// Chainable indicates whether this block can reference another ReferentialUnlockBlock.
	Chainable() bool
	// SourceAllowed tells whether the given Address is allowed to be the source of this ReferentialUnlockBlock.
	SourceAllowed(address Address) bool
}

ReferentialUnlockBlock is an UnlockBlock which references another UnlockBlock.

type RentStructure

type RentStructure struct {
	// Defines the rent of a single virtual byte denoted in IOTA tokens.
	VByteCost uint64
	// Defines the factor to be used for data only fields.
	VBFactorData VByteCostFactor
	// defines the factor to be used for key/lookup generating fields.
	VBFactorKey VByteCostFactor
}

RentStructure defines the parameters of rent cost calculations on objects which take node resources.

func (*RentStructure) CoversStateRent

func (vbcs *RentStructure) CoversStateRent(object NonEphemeralObject, rent uint64) (uint64, error)

CoversStateRent tells whether given this NonEphemeralObject, the given rent fulfils the renting costs by examining the virtual bytes cost of the object. Returns the minimum rent computed and an error if it is not covered by rent.

func (*RentStructure) MinDustDeposit

func (vbcs *RentStructure) MinDustDeposit(sender Address) uint64

MinDustDeposit returns the minimum renting costs for an ExtendedOutput which returns a DustDepositReturnFeatureBlock amount back to the origin sender.

type SemValiContextWorkingSet

type SemValiContextWorkingSet struct {
	// The identities which are successfully unlocked from the input side.
	UnlockedIdents UnlockedIdentities
	// The mapping of OutputID to the actual Outputs.
	InputSet OutputSet
	// The mapping of inputs' OutputID to the index.
	InputIDToIndex map[OutputID]uint16
	// The transaction for which this semantic validation happens.
	Tx *Transaction
	// The message which signatures are signing.
	EssenceMsgToSign []byte
	// The inputs of the transaction mapped by type.
	InputsByType OutputsByType
	// The ChainConstrainedOutput(s) at the input side.
	InChains ChainConstrainedOutputsSet
	// The sum of NativeTokens at the input side.
	InNativeTokens NativeTokenSum
	// The Outputs of the transaction mapped by type.
	OutputsByType OutputsByType
	// The ChainConstrainedOutput(s) at the output side.
	OutChains ChainConstrainedOutputsSet
	// The sum of NativeTokens at the output side.
	OutNativeTokens NativeTokenSum
	// The UnlockBlocks carried by the transaction mapped by type.
	UnlockBlocksByType UnlockBlocksByType
}

SemValiContextWorkingSet contains fields which get automatically populated by the library during the semantic validation of a Transaction.

func NewSemValiContextWorkingSet

func NewSemValiContextWorkingSet(t *Transaction, inputs OutputSet) (*SemValiContextWorkingSet, error)

func (*SemValiContextWorkingSet) UTXOInputAtIndex

func (workingSet *SemValiContextWorkingSet) UTXOInputAtIndex(inputIndex uint16) *UTXOInput

UTXOInputAtIndex retrieves the UTXOInput at the given index. Caller must ensure that the index is valid.

type SemanticValidationContext

type SemanticValidationContext struct {
	ExtParas *ExternalUnlockParameters

	// The working set which is auto. populated during the semantic validation.
	WorkingSet *SemValiContextWorkingSet
}

SemanticValidationContext defines the context under which a semantic validation for a Transaction is happening.

type SenderFeatureBlock

type SenderFeatureBlock struct {
	Address Address
}

SenderFeatureBlock is a feature block which associates an output with a sender identity. The sender identity needs to be unlocked in the transaction for the SenderFeatureBlock block to be valid.

func (*SenderFeatureBlock) Deserialize

func (s *SenderFeatureBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*SenderFeatureBlock) Equal

func (s *SenderFeatureBlock) Equal(other FeatureBlock) bool

func (*SenderFeatureBlock) MarshalJSON

func (s *SenderFeatureBlock) MarshalJSON() ([]byte, error)

func (*SenderFeatureBlock) Serialize

func (s *SenderFeatureBlock) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*SenderFeatureBlock) Type

func (*SenderFeatureBlock) UnmarshalJSON

func (s *SenderFeatureBlock) UnmarshalJSON(bytes []byte) error

func (*SenderFeatureBlock) VByteCost

func (s *SenderFeatureBlock) VByteCost(costStruct *RentStructure, f VByteCostFunc) uint64

type Signature

type Signature interface {
	serializer.Serializable

	// Type returns the type of the Signature.
	Type() SignatureType
}

Signature is a signature.

func SignatureSelector

func SignatureSelector(sigType uint32) (Signature, error)

SignatureSelector implements SerializableSelectorFunc for signature types.

type SignatureType

type SignatureType byte

SignatureType defines the type of signature.

const (
	// SignatureEd25519 denotes an Ed25519Signature.
	SignatureEd25519 SignatureType = iota
)

type SignatureUnlockBlock

type SignatureUnlockBlock struct {
	// The signature of this unlock block.
	Signature Signature `json:"signature"`
}

SignatureUnlockBlock holds a signature which unlocks inputs.

func (*SignatureUnlockBlock) Deserialize

func (s *SignatureUnlockBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*SignatureUnlockBlock) MarshalJSON

func (s *SignatureUnlockBlock) MarshalJSON() ([]byte, error)

func (*SignatureUnlockBlock) Serialize

func (s *SignatureUnlockBlock) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*SignatureUnlockBlock) Type

func (*SignatureUnlockBlock) UnmarshalJSON

func (s *SignatureUnlockBlock) UnmarshalJSON(bytes []byte) error

type SimpleTokenScheme

type SimpleTokenScheme struct{}

SimpleTokenScheme is a token scheme which checks that the TokenTag within a foundry matches the token ID of native tokens held by the foundry.

func (*SimpleTokenScheme) Deserialize

func (s *SimpleTokenScheme) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*SimpleTokenScheme) MarshalJSON

func (s *SimpleTokenScheme) MarshalJSON() ([]byte, error)

func (*SimpleTokenScheme) Serialize

func (s *SimpleTokenScheme) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*SimpleTokenScheme) Type

func (*SimpleTokenScheme) UnmarshalJSON

func (s *SimpleTokenScheme) UnmarshalJSON(bytes []byte) error

func (*SimpleTokenScheme) VByteCost

func (s *SimpleTokenScheme) VByteCost(costStruct *RentStructure, override VByteCostFunc) uint64

type StateTransitionValidationFunc

type StateTransitionValidationFunc func(current ChainConstrainedOutput, next ChainConstrainedOutput) error

StateTransitionValidationFunc is a function which given the current and next chain state, validates the state transition.

type TimelockMilestoneIndexFeatureBlock

type TimelockMilestoneIndexFeatureBlock struct {
	MilestoneIndex uint32
}

TimelockMilestoneIndexFeatureBlock is a feature block which puts a time constraint on an output depending on the latest confirmed milestone index X:

  • the output can only be consumed, if X is bigger than the one defined in the timelock.

func (*TimelockMilestoneIndexFeatureBlock) Deserialize

func (s *TimelockMilestoneIndexFeatureBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*TimelockMilestoneIndexFeatureBlock) Equal

func (*TimelockMilestoneIndexFeatureBlock) MarshalJSON

func (s *TimelockMilestoneIndexFeatureBlock) MarshalJSON() ([]byte, error)

func (*TimelockMilestoneIndexFeatureBlock) Serialize

func (s *TimelockMilestoneIndexFeatureBlock) Serialize(_ serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*TimelockMilestoneIndexFeatureBlock) Type

func (*TimelockMilestoneIndexFeatureBlock) UnmarshalJSON

func (s *TimelockMilestoneIndexFeatureBlock) UnmarshalJSON(bytes []byte) error

func (*TimelockMilestoneIndexFeatureBlock) VByteCost

type TimelockUnixFeatureBlock

type TimelockUnixFeatureBlock struct {
	// UnixTime is the second resolution unix time.
	UnixTime uint64
}

TimelockUnixFeatureBlock is a feature block which puts a time constraint on an output depending on the latest confirmed milestone's timestamp T:

  • the output can only be consumed, if T is after the one defined in the timelock

func (*TimelockUnixFeatureBlock) Deserialize

func (s *TimelockUnixFeatureBlock) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*TimelockUnixFeatureBlock) Equal

func (s *TimelockUnixFeatureBlock) Equal(other FeatureBlock) bool

func (*TimelockUnixFeatureBlock) MarshalJSON

func (s *TimelockUnixFeatureBlock) MarshalJSON() ([]byte, error)

func (*TimelockUnixFeatureBlock) Serialize

func (s *TimelockUnixFeatureBlock) Serialize(_ serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*TimelockUnixFeatureBlock) Type

func (*TimelockUnixFeatureBlock) UnmarshalJSON

func (s *TimelockUnixFeatureBlock) UnmarshalJSON(bytes []byte) error

func (*TimelockUnixFeatureBlock) VByteCost

func (s *TimelockUnixFeatureBlock) VByteCost(costStruct *RentStructure, _ VByteCostFunc) uint64

type ToBeSignedUTXOInput

type ToBeSignedUTXOInput struct {
	// The address to which this input belongs to.
	Address Address `json:"address"`
	// The actual UTXO input.
	Input *UTXOInput `json:"input"`
}

ToBeSignedUTXOInput defines a UTXO input which needs to be signed.

type TokenScheme

type TokenScheme interface {
	serializer.Serializable
	NonEphemeralObject

	// Type returns the type of the TokenScheme.
	Type() TokenSchemeType
}

TokenScheme defines a scheme for to be used for an OutputFoundry.

func TokenSchemeSelector

func TokenSchemeSelector(tokenSchemeType uint32) (TokenScheme, error)

TokenSchemeSelector implements SerializableSelectorFunc for token scheme types.

type TokenSchemeType

type TokenSchemeType byte

TokenSchemeType defines the type of token schemes.

const (
	// TokenSchemeSimple denotes a type of output which is locked by a signature and deposits onto a single address.
	TokenSchemeSimple TokenSchemeType = iota
)

type TokenTag

type TokenTag = [TokenTagLength]byte

TokenTag is a tag holding some additional data which might be interpreted by higher layers.

type TransDepIdentOutput

type TransDepIdentOutput interface {
	ChainConstrainedOutput
	// Ident computes the identity to which this output is locked to by examining
	// the transition to the next output state. If next is nil, then this TransDepIdentOutput
	// treats the ident computation as being for ChainTransitionTypeDestroy.
	Ident(next TransDepIdentOutput) (Address, error)
	// UnlockableBy tells whether the given ident can unlock this Output
	// while also taking into consideration constraints enforced by FeatureBlock(s) within this Output
	// and the next state of this TransDepIdentOutput. To indicate that this TransDepIdentOutput
	// is to be destroyed, pass nil as next.
	UnlockableBy(ident Address, next TransDepIdentOutput, extParas *ExternalUnlockParameters) (bool, error)
}

TransDepIdentOutput is a type of Output where the identity to unlock is dependent on the transition the output does (without considering FeatureBlock(s)).

type TransIndepIdentOutput

type TransIndepIdentOutput interface {
	Output
	// Ident returns the default identity to which this output is locked to.
	Ident() Address
	// UnlockableBy tells whether the given ident can unlock this Output
	// while also taking into consideration constraints enforced by FeatureBlock(s) within this Output (if any).
	UnlockableBy(ident Address, extParas *ExternalUnlockParameters) bool
}

TransIndepIdentOutput is a type of Output where the identity to unlock is independent of any transition the output does (without considering FeatureBlock(s)).

type Transaction

type Transaction struct {
	// The transaction essence, respectively the transfer part of a Transaction.
	Essence *TransactionEssence
	// The unlock blocks defining the unlocking data for the inputs within the Essence.
	UnlockBlocks UnlockBlocks
}

Transaction is a transaction with its inputs, outputs and unlock blocks.

func (*Transaction) Deserialize

func (t *Transaction) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*Transaction) ID

func (t *Transaction) ID() (*TransactionID, error)

ID computes the ID of the Transaction.

func (*Transaction) MarshalJSON

func (t *Transaction) MarshalJSON() ([]byte, error)

func (*Transaction) OutputsSet

func (t *Transaction) OutputsSet() (OutputSet, error)

OutputsSet returns an OutputSet from the Transaction's outputs, mapped by their OutputID.

func (*Transaction) PayloadType

func (t *Transaction) PayloadType() PayloadType

func (*Transaction) SemanticallyValidate

func (t *Transaction) SemanticallyValidate(svCtx *SemanticValidationContext, inputs OutputSet, semValFuncs ...TxSemanticValidationFunc) error

SemanticallyValidate semantically validates the Transaction by checking that the semantic rules applied to the inputs and outputs are fulfilled. Semantic validation must only be executed on Transaction(s) which are syntactically valid.

func (*Transaction) Serialize

func (t *Transaction) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(bytes []byte) error

type TransactionBuilder

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

TransactionBuilder is used to easily build up a Transaction.

func NewTransactionBuilder

func NewTransactionBuilder() *TransactionBuilder

NewTransactionBuilder creates a new TransactionBuilder.

func (*TransactionBuilder) AddIndexationPayload

func (b *TransactionBuilder) AddIndexationPayload(payload *Indexation) *TransactionBuilder

AddIndexationPayload adds the given Indexation as the inner payload.

func (*TransactionBuilder) AddInput

AddInput adds the given input to the builder.

func (*TransactionBuilder) AddInputsViaNodeQuery

func (b *TransactionBuilder) AddInputsViaNodeQuery(ctx context.Context, addr Address, nodeHTTPAPIClient *NodeHTTPAPIClient, filter TransactionBuilderInputFilter) *TransactionBuilder

AddInputsViaNodeQuery adds any unspent outputs by the given address as an input to the built transaction if it passes the filter function. It is the caller's job to ensure that the limit of returned outputs on the queried node is enough high for the application's purpose. filter can be nil.

func (*TransactionBuilder) AddOutput

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

AddOutput adds the given output to the builder.

func (*TransactionBuilder) Build

func (b *TransactionBuilder) Build(deSeriParas *DeSerializationParameters, signer AddressSigner) (*Transaction, error)

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

func (*TransactionBuilder) BuildAndSwapToMessageBuilder

func (b *TransactionBuilder) BuildAndSwapToMessageBuilder(deSeriParas *DeSerializationParameters, signer AddressSigner, txFunc TransactionFunc) *MessageBuilder

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

type TransactionBuilderInputFilter

type TransactionBuilderInputFilter func(utxoInput *UTXOInput, input 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 TransactionEssence

type TransactionEssence struct {
	// The inputs of this transaction.
	Inputs Inputs `json:"inputs"`
	// The outputs of this transaction.
	Outputs Outputs `json:"outputs"`
	// The optional embedded payload.
	Payload Payload `json:"payload"`
}

TransactionEssence is the essence part of a Transaction.

func TransactionEssenceSelector

func TransactionEssenceSelector(txType uint32) (*TransactionEssence, error)

TransactionEssenceSelector implements SerializableSelectorFunc for transaction essence types.

func (*TransactionEssence) Deserialize

func (u *TransactionEssence) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*TransactionEssence) MarshalJSON

func (u *TransactionEssence) MarshalJSON() ([]byte, error)

func (*TransactionEssence) Serialize

func (u *TransactionEssence) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (data []byte, err error)

func (*TransactionEssence) Sign

func (u *TransactionEssence) Sign(addrKeys ...AddressKeys) ([]Signature, error)

Sign produces signatures signing the essence for every given AddressKeys. The produced signatures are in the same order as the AddressKeys.

func (*TransactionEssence) SigningMessage

func (u *TransactionEssence) SigningMessage() ([]byte, error)

SigningMessage returns the to be signed message.

func (*TransactionEssence) UnmarshalJSON

func (u *TransactionEssence) UnmarshalJSON(bytes []byte) error

type TransactionEssenceType

type TransactionEssenceType = byte

TransactionEssenceType defines the type of transaction.

type TransactionFunc

type TransactionFunc func(tx *Transaction)

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

type TransactionID

type TransactionID = [TransactionIDLength]byte

TransactionID is the ID of a Transaction.

type TransactionIDs

type TransactionIDs []TransactionID

TransactionIDs are IDs of transactions.

type TreasuryInput

type TreasuryInput [32]byte

TreasuryInput is an input which references a milestone which generated a TreasuryOutput.

func (*TreasuryInput) Deserialize

func (ti *TreasuryInput) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*TreasuryInput) MarshalJSON

func (ti *TreasuryInput) MarshalJSON() ([]byte, error)

func (*TreasuryInput) Serialize

func (ti *TreasuryInput) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (data []byte, err error)

func (*TreasuryInput) Type

func (ti *TreasuryInput) Type() InputType

func (*TreasuryInput) UnmarshalJSON

func (ti *TreasuryInput) UnmarshalJSON(bytes []byte) error

type TreasuryOutput

type TreasuryOutput struct {
	// The currently residing funds in the treasury.
	Amount uint64 `json:"deposit"`
}

TreasuryOutput is an output which holds the treasury of a network.

func (*TreasuryOutput) Deposit

func (t *TreasuryOutput) Deposit() uint64

func (*TreasuryOutput) Deserialize

func (t *TreasuryOutput) Deserialize(data []byte, _ serializer.DeSerializationMode, _ interface{}) (int, error)

func (*TreasuryOutput) MarshalJSON

func (t *TreasuryOutput) MarshalJSON() ([]byte, error)

func (*TreasuryOutput) Serialize

func (t *TreasuryOutput) Serialize(_ serializer.DeSerializationMode, _ interface{}) ([]byte, error)

func (*TreasuryOutput) Type

func (t *TreasuryOutput) Type() OutputType

func (*TreasuryOutput) UnmarshalJSON

func (t *TreasuryOutput) UnmarshalJSON(bytes []byte) error

func (*TreasuryOutput) VByteCost

func (t *TreasuryOutput) VByteCost(_ *RentStructure, _ VByteCostFunc) uint64

type TreasuryResponse

type TreasuryResponse struct {
	MilestoneID string `json:"milestoneId"`
	Amount      uint64 `json:"amount"`
}

TreasuryResponse defines the response of a GET treasury REST API call.

type TreasuryTransaction

type TreasuryTransaction struct {
	// The input of this transaction.
	Input *TreasuryInput
	// The output of this transaction.
	Output *TreasuryOutput
}

TreasuryTransaction represents a transaction which moves funds from the treasury.

func (*TreasuryTransaction) Deserialize

func (t *TreasuryTransaction) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*TreasuryTransaction) MarshalJSON

func (t *TreasuryTransaction) MarshalJSON() ([]byte, error)

func (*TreasuryTransaction) Serialize

func (t *TreasuryTransaction) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) ([]byte, error)

func (*TreasuryTransaction) UnmarshalJSON

func (t *TreasuryTransaction) UnmarshalJSON(bytes []byte) error

type TxSemanticValidationFunc

type TxSemanticValidationFunc func(svCtx *SemanticValidationContext) error

TxSemanticValidationFunc is a function which given the context, input, outputs and unlock blocks runs a specific semantic validation. The function might also modify the SemanticValidationContext in order to supply information to subsequent TxSemanticValidationFunc(s).

func TxSemanticDeposit

func TxSemanticDeposit() TxSemanticValidationFunc

TxSemanticDeposit validates that the IOTA tokens are balanced from the input/output side. It additionally also incorporates the check whether return amounts via DustDepositReturnFeatureBlock(s) for specified identities are fulfilled from the output side.

func TxSemanticInputUnlocks

func TxSemanticInputUnlocks() TxSemanticValidationFunc

TxSemanticInputUnlocks produces the UnlockedIdentities which will be set into the given SemanticValidationContext and verifies that inputs are correctly unlocked.

func TxSemanticNativeTokens

func TxSemanticNativeTokens() TxSemanticValidationFunc

TxSemanticNativeTokens validates following rules regarding NativeTokens:

  • The NativeTokens between Inputs / Outputs must be balanced in terms of circulating supply adjustments if there is no foundry state transition for a given NativeToken.
  • Max MaxNativeTokensCount native tokens within inputs + outputs

func TxSemanticOutputsSender

func TxSemanticOutputsSender() TxSemanticValidationFunc

TxSemanticOutputsSender validates that for SenderFeatureBlock occurring on the output side, the given identity is unlocked on the input side.

func TxSemanticSTVFOnChains

func TxSemanticSTVFOnChains() TxSemanticValidationFunc

TxSemanticSTVFOnChains executes StateTransitionValidationFunc(s) on ChainConstrainedOutput(s).

func TxSemanticTimelock

func TxSemanticTimelock() TxSemanticValidationFunc

TxSemanticTimelock validates that the inputs' timelocks are expired.

type UTXOIDChainID

type UTXOIDChainID interface {
	FromOutputID(id OutputID) ChainID
}

UTXOIDChainID is a ChainID which gets produced by taking an OutputID.

type UTXOInput

type UTXOInput struct {
	// The transaction ID of the referenced transaction.
	TransactionID [TransactionIDLength]byte
	// The output index of the output on the referenced transaction.
	TransactionOutputIndex uint16
}

UTXOInput references an unspent transaction output by the Transaction's ID and the corresponding index of the Output.

func (*UTXOInput) Deserialize

func (u *UTXOInput) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (int, error)

func (*UTXOInput) ID

func (u *UTXOInput) ID() OutputID

ID returns the OutputID.

func (*UTXOInput) Index

func (u *UTXOInput) Index() uint16

func (*UTXOInput) MarshalJSON

func (u *UTXOInput) MarshalJSON() ([]byte, error)

func (*UTXOInput) Ref

func (u *UTXOInput) Ref() OutputID

func (*UTXOInput) Serialize

func (u *UTXOInput) Serialize(deSeriMode serializer.DeSerializationMode, deSeriCtx interface{}) (data []byte, err error)

func (*UTXOInput) Type

func (u *UTXOInput) Type() InputType

func (*UTXOInput) UnmarshalJSON

func (u *UTXOInput) UnmarshalJSON(bytes []byte) error

type UnlockBlock

type UnlockBlock interface {
	serializer.Serializable

	// Type returns the type of the UnlockBlock.
	Type() UnlockBlockType
}

UnlockBlock is a block of data which unlocks inputs of a Transaction.

type UnlockBlockType

type UnlockBlockType byte

UnlockBlockType defines a type of unlock block.

const (
	// UnlockBlockSignature denotes a SignatureUnlockBlock.
	UnlockBlockSignature UnlockBlockType = iota
	// UnlockBlockReference denotes a ReferenceUnlockBlock.
	UnlockBlockReference
	// UnlockBlockAlias denotes an AliasUnlockBlock.
	UnlockBlockAlias
	// UnlockBlockNFT denotes a NFTUnlockBlock.
	UnlockBlockNFT
)

type UnlockBlockValidatorFunc

type UnlockBlockValidatorFunc func(index int, unlockBlock UnlockBlock) error

UnlockBlockValidatorFunc which given the index and the UnlockBlock itself, runs validations and returns an error if any should fail.

func UnlockBlocksSigUniqueAndRefValidator

func UnlockBlocksSigUniqueAndRefValidator() UnlockBlockValidatorFunc

UnlockBlocksSigUniqueAndRefValidator returns a validator which checks that:

  1. SignatureUnlockBlock(s) are unique
  2. ReferenceUnlockBlock(s) reference a previous SignatureUnlockBlock
  3. Following through AliasUnlockBlock(s), NFTUnlockBlock(s) refs results to a SignatureUnlockBlock

type UnlockBlocks

type UnlockBlocks []UnlockBlock

func (*UnlockBlocks) FromSerializables

func (o *UnlockBlocks) FromSerializables(seris serializer.Serializables)

func (UnlockBlocks) ToSerializables

func (o UnlockBlocks) ToSerializables() serializer.Serializables

func (UnlockBlocks) ToUnlockBlocksByType

func (o UnlockBlocks) ToUnlockBlocksByType() UnlockBlocksByType

ToUnlockBlocksByType converts the UnlockBlocks slice to UnlockBlocksByType.

type UnlockBlocksByType

type UnlockBlocksByType map[UnlockBlockType][]UnlockBlock

UnlockBlocksByType is a map of UnlockBlockType(s) to slice of UnlockBlock(s).

type UnlockedIdentities

type UnlockedIdentities map[string]UnlockedIndices

UnlockedIdentities defines a set of identities which are unlocked from the input side of a Transaction. The value represent the index of the unlock block which unlocked the identity.

func (UnlockedIdentities) AddInputUnlockedBy

func (unlockedIdents UnlockedIdentities) AddInputUnlockedBy(identKey string, inputIndex uint16)

AddInputUnlockedBy adds an entry defining that the given identity unlocked an input at the given index.

type UnlockedIndices

type UnlockedIndices map[uint16]struct{}

UnlockedIndices is a set of unlocked indices of outputs an identity unlocked.

func (UnlockedIndices) Unlocked

func (indices UnlockedIndices) Unlocked(x uint16) bool

Unlocked tells whether x is in this set.

type VByteCostFactor

type VByteCostFactor uint64

VByteCostFactor defines the type of the virtual byte cost factor.

const (
	// VByteCostFactorData defines the multiplier for data fields.
	VByteCostFactorData VByteCostFactor = 1
	// VByteCostFactorKey defines the multiplier for fields which can act as keys for lookups.
	VByteCostFactorKey VByteCostFactor = 10
)

func (VByteCostFactor) Multiply

func (factor VByteCostFactor) Multiply(in uint64) uint64

Multiply multiplies in with this factor.

func (VByteCostFactor) With

func (factor VByteCostFactor) With(other VByteCostFactor) VByteCostFactor

With joins two factors with each other.

type VByteCostFunc

type VByteCostFunc func(costStruct *RentStructure) uint64

VByteCostFunc is a function which computes the virtual byte cost of a NonEphemeralObject.

Directories

Path Synopsis
Package bech32 implements bech32 encoding and decoding.
Package bech32 implements bech32 encoding and decoding.
internal/base32
Package base32 implements the conversion for bytes (base256) to base32.
Package base32 implements the conversion for bytes (base256) to base32.
Package ed25519 implements an Ed25519 Verify function for use in consensus-critical contexts.
Package ed25519 implements an Ed25519 Verify function for use in consensus-critical contexts.
Package pow implements the Curl-based proof of work for arbitrary binary data.
Package pow implements the Curl-based proof of work for arbitrary binary data.
Package units provides functions for converting different units of IOTAs.
Package units provides functions for converting different units of IOTAs.
x
Package iotagox provides experimental APIs which are not stable.
Package iotagox provides experimental APIs which are not stable.

Jump to

Keyboard shortcuts

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