iotago

package module
v3.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 24 Imported by: 156

README

iota.go

Official Go library.

This library allows you to do the following:

  • Create blocks with tagged data and transaction payloads
  • Get blocks 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 blocks and transactions.

Creating Blocks:

import (
	"context"
	"time"

	iotago "github.com/iotaledger/iota.go/v3"
	"github.com/iotaledger/iota.go/v3/builder"
	"github.com/iotaledger/iota.go/v3/nodeclient"
)

func sendblockExample() error {
	// create a new node API client
	nodeHTTPAPIClient := nodeclient.New("https://example.com")

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

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

	// craft a tagged data payload
	taggedDataPayload := &iotago.TaggedData{
		Tag:  []byte("hello world"),
		Data: []byte{1, 2, 3, 4},
	}

	// get some tips from the node
	tipsResponse, err := nodeHTTPAPIClient.Tips(ctx)
	if err != nil {
		return err
	}

	tips, err := tipsResponse.Tips()
	if err != nil {
		return err
	}

	// get the current protocol parameters
	protoParas, err := info.ProtocolParameters()
	if err != nil {
		return err
	}

	// build a block by adding the paylod and the tips and then do local Proof-of-Work
	block, err := builder.NewBlockBuilder().
		Payload(taggedDataPayload).
		Parents(tips).
		ProofOfWork(ctx, protoParas, info.Protocol.MinPoWScore).
		Build()

	// submit the block to the node
	if _, err := nodeHTTPAPIClient.SubmitBlock(ctx, block, protoParas); err != nil {
		return err
	}

	return nil
}

Index

Constants

View Source
const (
	// AliasAddressBytesLength is the length of an Alias address.
	AliasAddressBytesLength = blake2b.Size256
	// 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 = blake2b.Size256
	// NFTAddressSerializedBytesSize is the size of a serialized NFT address with its type denoting byte.
	NFTAddressSerializedBytesSize = serializer.SmallTypeDenotationByteSize + NFTAddressBytesLength
)
View Source
const (
	// BlockIDLength defines the length of a block ID.
	BlockIDLength = blake2b.Size256
	// BlockBinSerializedMaxSize defines the maximum size of a block.
	BlockBinSerializedMaxSize = 32768
	// BlockMinParents defines the minimum amount of parents in a block.
	BlockMinParents = 1
	// BlockMaxParents defines the maximum amount of parents in a block.
	BlockMaxParents = 8
)
View Source
const (
	// MinMetadataLength defines the min length of the data within a MetadataFeature.
	MinMetadataLength = 1
	// MaxMetadataLength defines the max length of the data within a MetadataFeature.
	MaxMetadataLength = 8192
)
View Source
const (
	// MinTagLength defines the min. length of a tag feature tag.
	MinTagLength = 1
	// MaxTagLength defines the max. length of a tag feature tag.
	MaxTagLength = 64
)
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 = MaxOutputsCount - 1

	// UTXOInputSize is the size of a UTXO input: input type + tx id + index.
	UTXOInputSize = serializer.SmallTypeDenotationByteSize + TransactionIDLength + serializer.UInt16ByteSize
)
View Source
const (
	// MinMigratedFundsEntryDeposit defines the minimum amount a MigratedFundsEntry must deposit.
	MinMigratedFundsEntryDeposit = 1_000_000
	// LegacyTailTransactionHashLength denotes the length of a legacy transaction.
	LegacyTailTransactionHashLength = 49
	// MigratedFundsEntrySerializedBytesSize is the serialized size of a MigratedFundsEntry.
	MigratedFundsEntrySerializedBytesSize = LegacyTailTransactionHashLength + Ed25519AddressSerializedBytesSize + serializer.UInt64ByteSize
)
View Source
const (
	// MilestoneMerkleProofLength defines the length of a merkle proof within a milestone payload.
	MilestoneMerkleProofLength = 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
	// MaxSignaturesInAMilestone is the maximum amount of signatures in a milestone.
	MaxSignaturesInAMilestone = 255
	// MinSignaturesInAMilestone is the minimum amount of signatures in a milestone.
	MinSignaturesInAMilestone = 1
)
View Source
const (
	// MinMigratedFundsEntryCount defines the minimum amount of MigratedFundsEntry items within a ReceiptMilestoneOpt.
	MinMigratedFundsEntryCount = 1
	// MaxMigratedFundsEntryCount defines the maximum amount of MigratedFundsEntry items within a ReceiptMilestoneOpt.
	MaxMigratedFundsEntryCount = 127
)
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 = 64

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

	// 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

	// NativeTokenVByteCost defines the static virtual byte cost of a NativeToken.
	NativeTokenVByteCost = NativeTokenIDLength + Uint256ByteSize
)
View Source
const (
	// TransactionEssenceNormal denotes a standard transaction essence.
	TransactionEssenceNormal TransactionEssenceType = 1

	// MaxInputsCount defines the maximum amount of inputs within a TransactionEssence.
	MaxInputsCount = 128
	// MinInputsCount defines the minimum amount of inputs within a TransactionEssence.
	MinInputsCount = 1
	// MaxOutputsCount defines the maximum amount of outputs within a TransactionEssence.
	MaxOutputsCount = 128
	// MinOutputsCount defines the minimum amount of inputs within a TransactionEssence.
	MinOutputsCount = 1

	// InputsCommitmentLength defines the length of the inputs commitment hash.
	InputsCommitmentLength = blake2b.Size256
)
View Source
const (
	// AliasIDLength is the byte length of an AliasID.
	AliasIDLength = blake2b.Size256
)
View Source
const (
	// AliasUnlockSize defines the size of an AliasUnlock.
	AliasUnlockSize = 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 (
	// MaxParamsLength defines the max length of the data within a ProtocolParamsMilestoneOpt.
	MaxParamsLength = 8192
)
View Source
const (
	// 	NFTIDLength is the byte length of an NFTID.
	NFTIDLength = blake2b.Size256
)
View Source
const (
	// NFTUnlockSize defines the size of an NFTUnlock.
	NFTUnlockSize = serializer.SmallTypeDenotationByteSize + serializer.UInt16ByteSize
)
View Source
const (
	// OutputIDLength defines the length of an OutputID.
	OutputIDLength = TransactionIDLength + serializer.UInt16ByteSize
)
View Source
const (
	// ReferenceUnlockSize defines the size of a ReferenceUnlock.
	ReferenceUnlockSize = serializer.SmallTypeDenotationByteSize + serializer.UInt16ByteSize
)
View Source
const (
	// TaggedPayloadTagMaxLength defines the max length of the tag within a TaggedData payload.
	TaggedPayloadTagMaxLength = 64
)
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")
	// ErrUnsupportedInputType gets returned for unsupported input types.
	ErrUnsupportedInputType = errors.New("unsupported input type")
	// ErrUnsupportedFeatureType gets returned when an unsupported feature exists in a set.
	ErrUnsupportedFeatureType = errors.New("unsupported feature type")
	// ErrUnsupportedUnlockConditionType gets returned when an unsupported unlock condition exists in a set.
	ErrUnsupportedUnlockConditionType = errors.New("unsupported unlock condition type")
	// ErrUnsupportedMilestoneOptType gets returned when an unsupported milestone option exists in a set.
	ErrUnsupportedMilestoneOptType = errors.New("unsupported milestone option 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")
	// ErrUnknownFeatureType gets returned for unknown feature types.
	ErrUnknownFeatureType = errors.New("unknown feature type")
	// ErrUnknownMilestoneOptType gets returned for unknown milestone options types.
	ErrUnknownMilestoneOptType = errors.New("unknown milestone option type")
	// ErrUnknownUnlockConditionType gets returned for unknown unlock condition types.
	ErrUnknownUnlockConditionType = errors.New("unknown unlock condition 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")
	// ErrUnknownUnlockType gets returned for unknown unlock.
	ErrUnknownUnlockType = errors.New("unknown unlock 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 (
	// ErrNonUniqueFeatures gets returned when multiple Feature(s) with the same FeatureType exist within sets.
	ErrNonUniqueFeatures = errors.New("non unique features within outputs")
	// ErrInvalidFeatureTransition gets returned when a Feature's transition within a ChainConstrainedOutput is invalid.
	ErrInvalidFeatureTransition = errors.New("invalid feature transition")
)
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")
	// ErrMilestoneProducedSignaturesCountMismatch gets returned when a MilestoneSigningFunc produces less signatures than expected.
	ErrMilestoneProducedSignaturesCountMismatch = errors.New("produced and wanted signature count mismatch")
	// 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 = errors.New("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 = errors.New("non applicable public key found")
	// ErrMilestoneSignatureThresholdGreaterThanApplicablePublicKeySet gets returned when a min. signature threshold is greater than a given applicable public key set.
	ErrMilestoneSignatureThresholdGreaterThanApplicablePublicKeySet = errors.New("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 = errors.New("invalid milestone signature")
	// ErrMilestoneInMemorySignerPrivateKeyMissing gets returned when an InMemoryEd25519MilestoneSigner is missing a private key.
	ErrMilestoneInMemorySignerPrivateKeyMissing = errors.New("private key missing")
)
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 (
	// 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")
	// 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 (
	// 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")
	// ErrTypeIsNotSupportedRentStructure gets returned when a serializable was found to not be a supported RentStructure.
	ErrTypeIsNotSupportedRentStructure = errors.New("serializable is not a supported rent structure")
)
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 (
	// ErrSimpleTokenSchemeTransition gets returned when a SimpleTokenScheme transition is invalid.
	ErrSimpleTokenSchemeTransition = errors.New("simple token scheme transition invalid")
	// ErrSimpleTokenSchemeInvalidMaximumSupply gets returned when a SimpleTokenScheme's max supply is invalid.
	ErrSimpleTokenSchemeInvalidMaximumSupply = errors.New("simple token scheme's maximum supply is invalid")
	// ErrSimpleTokenSchemeInvalidMintedMeltedTokens gets returned when a SimpleTokenScheme's minted supply is invalid.
	ErrSimpleTokenSchemeInvalidMintedMeltedTokens = errors.New("simple token scheme's minted/melted tokens counters are invalid")
)
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 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")
	// ErrSenderFeatureNotUnlocked gets returned when an output contains a SenderFeature with an ident which is not unlocked.
	ErrSenderFeatureNotUnlocked = errors.New("sender feature is not unlocked")
	// ErrIssuerFeatureNotUnlocked gets returned when an output contains a IssuerFeature with an ident which is not unlocked.
	ErrIssuerFeatureNotUnlocked = errors.New("issuer feature 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 (
	// ErrInvalidInputsCommitment gets returned when the inputs commitment is invalid.
	ErrInvalidInputsCommitment = errors.New("invalid inputs commitment")
	// ErrTxEssenceNetworkIDInvalid gets returned when a network ID within a TransactionEssence is invalid.
	ErrTxEssenceNetworkIDInvalid = errors.New("invalid network ID")
	// ErrInputUTXORefsNotUnique gets returned if multiple inputs reference the same UTXO.
	ErrInputUTXORefsNotUnique = errors.New("inputs must each reference a unique UTXO")
	// 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 ID corresponds to address field")
	// 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")
	// ErrStorageDepositLessThanMinReturnOutputStorageDeposit gets returned when the storage deposit condition's amount is less than the min storage deposit for the return output.
	ErrStorageDepositLessThanMinReturnOutputStorageDeposit = errors.New("storage deposit return amount is less than the min storage deposit needed for the return output")
	// ErrStorageDepositExceedsTargetOutputDeposit gets returned when the storage deposit condition's amount exceeds the target output's deposit.
	ErrStorageDepositExceedsTargetOutputDeposit = errors.New("storage deposit return amount exceeds target output's deposit")
	// ErrMaxNativeTokensCountExceeded gets returned if outputs or transactions exceed the MaxNativeTokensCount.
	ErrMaxNativeTokensCountExceeded = errors.New("max native tokens count exceeded")
)
View Source
var (
	// ErrSigUnlockNotUnique gets returned if sig unlocks making part of a transaction aren't unique.
	ErrSigUnlockNotUnique = errors.New("signature unlock must be unique")
	// ErrReferentialUnlockInvalid gets returned when a ReferentialUnlock is invalid.
	ErrReferentialUnlockInvalid = errors.New("invalid referential unlock")
	// ErrSigUnlockHasNilSig gets returned if a signature unlock contains a nil signature.
	ErrSigUnlockHasNilSig = errors.New("signature is nil")
	// ErrTypeIsNotSupportedUnlock gets returned when a serializable was found to not be a supported Unlock.
	ErrTypeIsNotSupportedUnlock = errors.New("serializable is not a supported unlock")
)
View Source
var (
	// ErrNonUniqueUnlockConditions gets returned when multiple UnlockCondition(s) with the same UnlockConditionType exist within sets.
	ErrNonUniqueUnlockConditions = errors.New("non unique unlock conditions within outputs")
	// ErrTimelockNotExpired gets returned when timelocks in a UnlockConditionSet are not expired.
	ErrTimelockNotExpired = errors.New("timelock not expired")
	// ErrExpirationConditionZero gets returned when an ExpirationUnlockCondition has set the unix timestamp to zero.
	ErrExpirationConditionZero = errors.New("expiration condition is zero")
	// ErrTimelockConditionZero gets returned when a TimelockUnlockCondition has set the unix timestamp to zero.
	ErrTimelockConditionZero = errors.New("timelock condition is zero")
)
View Source
var (
	// ErrBlockExceedsMaxSize gets returned when a serialized block exceeds BlockBinSerializedMaxSize.
	ErrBlockExceedsMaxSize = errors.New("block exceeds max size")
)
View Source
var (
	// ErrInvalidJSON gets returned when invalid JSON is tried to get parsed.
	ErrInvalidJSON = errors.New("invalid json")
)
View Source
var (
	// ErrInvalidReceiptMilestoneOpt gets returned when a ReceiptMilestoneOpt is invalid.
	ErrInvalidReceiptMilestoneOpt = errors.New("invalid receipt")
)
View Source
var (
	// ErrMissingProtocolParas is returned when ProtocolParameters are missing for operations which require them.
	ErrMissingProtocolParas = errors.New("missing protocol 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 (
	// ErrNonUniqueMilestoneOpts gets returned when multiple MilestoneOpt(s) with the same MilestoneOptType exist within sets.
	ErrNonUniqueMilestoneOpts = errors.New("non unique milestone options")
)
View Source
var (
	// ErrProtocolParamsMilestoneOptInvalid gets returned when a ProtocolParamsMilestoneOpt is invalid.
	ErrProtocolParamsMilestoneOptInvalid = errors.New("invalid protocol params milestone option")
)
View Source
var (
	// ErrReceiptMustContainATreasuryTransaction gets returned if a ReceiptMilestoneOpt does not contain a TreasuryTransaction.
	ErrReceiptMustContainATreasuryTransaction = errors.New("receipt must contain a treasury transaction")
)
View Source
var (
	// ErrTaggedDataTagExceedsMaxSize gets returned when a TaggedData payload's tag exceeds TaggedPayloadTagMaxLength.
	ErrTaggedDataTagExceedsMaxSize = errors.New("tag exceeds max size")
)
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 (
	// ErrTypeIsNotSupportedMilestoneOpt gets returned when a serializable was found to not be a supported MilestoneOpt.
	ErrTypeIsNotSupportedMilestoneOpt = errors.New("serializable is not a supported milestone option")
)
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 a token scheme")
)

Functions

func AddressReadGuard

func AddressReadGuard(supportedAddr AddressTypeSet) serializer.SerializableReadGuardFunc

func AddressToJSONRawMsg

func AddressToJSONRawMsg(addr serializer.Serializable) (*json.RawMessage, error)

func AddressWriteGuard

func AddressWriteGuard(supportedAddr AddressTypeSet) serializer.SerializableWriteGuardFunc

checks whether the given Serializable is an Address and also supported AddressType.

func AliasOutputFeaturesArrayRules

func AliasOutputFeaturesArrayRules() serializer.ArrayRules

AliasOutputFeaturesArrayRules returns array rules defining the constraints on Features within an AliasOutput.

func AliasOutputImmutableFeaturesArrayRules

func AliasOutputImmutableFeaturesArrayRules() serializer.ArrayRules

AliasOutputImmutableFeaturesArrayRules returns array rules defining the constraints on immutable Features within an AliasOutput.

func BasicOutputFeaturesArrayRules

func BasicOutputFeaturesArrayRules() serializer.ArrayRules

BasicOutputFeaturesArrayRules returns array rules defining the constraints on Features within an BasicOutput.

func BasicOutputUnlockConditionsArrayRules

func BasicOutputUnlockConditionsArrayRules() serializer.ArrayRules

BasicOutputUnlockConditionsArrayRules returns array rules defining the constraints on UnlockConditions within an BasicOutput.

func BlockParentArrayRules

func BlockParentArrayRules() serializer.ArrayRules

BlockParentArrayRules returns array rules defining the constraints on a slice of block parent references.

func DecodeHex

func DecodeHex(s string) ([]byte, error)

DecodeHex decodes the given hex string to bytes. It expects the 0x prefix.

func DecodeUint256

func DecodeUint256(s string) (*big.Int, error)

DecodeUint256 decodes the little-endian hex encoded string to an uint256.

func DecodeUint64

func DecodeUint64(s string) (uint64, error)

DecodeUint64 decodes the base 10 string to an uint64.

func EncodeHex

func EncodeHex(b []byte) string

EncodeHex encodes the bytes string to a hex string. It always adds the 0x prefix if bytes are not empty.

func EncodeUint256

func EncodeUint256(n *big.Int) string

EncodeUint256 encodes the uint256 to a little-endian encoded hex string.

func EncodeUint64

func EncodeUint64(n uint64) string

EncodeUint64 encodes the uint64 to a base 10 string.

func FeatureUnchanged

func FeatureUnchanged(featType FeatureType, inFeatSet FeatureSet, outFeatSet FeatureSet) error

FeatureUnchanged checks whether the specified Feature type is unchanged between in and out. Unchanged also means that the block's existence is unchanged between both sets.

func FoundryOutputFeaturesArrayRules

func FoundryOutputFeaturesArrayRules() serializer.ArrayRules

FoundryOutputFeaturesArrayRules returns array rules defining the constraints on Features within an FoundryOutput.

func FoundryOutputImmutableFeaturesArrayRules

func FoundryOutputImmutableFeaturesArrayRules() serializer.ArrayRules

FoundryOutputImmutableFeaturesArrayRules returns array rules defining the constraints on immutable Features within an FoundryOutput.

func IsIssuerOnOutputUnlocked

func IsIssuerOnOutputUnlocked(output ChainConstrainedOutput, unlockedIdents UnlockedIdentities) error

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

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 MilestoneSignatureArrayRules

func MilestoneSignatureArrayRules() serializer.ArrayRules

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

func NFTOutputFeaturesArrayRules

func NFTOutputFeaturesArrayRules() serializer.ArrayRules

NFTOutputFeaturesArrayRules returns array rules defining the constraints on Features within an NFTOutput.

func NFTOutputImmutableFeaturesArrayRules

func NFTOutputImmutableFeaturesArrayRules() serializer.ArrayRules

NFTOutputImmutableFeaturesArrayRules returns array rules defining the constraints on immutable Features within an NFTOutput.

func NativeTokenArrayRules

func NativeTokenArrayRules() serializer.ArrayRules

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

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 SignatureReadGuard

func SignatureReadGuard(supportedSigs SignatureTypeSet) serializer.SerializableReadGuardFunc

func SignatureWriteGuard

func SignatureWriteGuard(supportedSigs SignatureTypeSet) serializer.SerializableWriteGuardFunc

checks whether the given Serializable is a Signature and also supported SignatureType.

func SyntacticallyValidateInputs

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

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

func SyntacticallyValidateOutputs

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

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

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 TransactionUnlocksArrayRules

func TransactionUnlocksArrayRules() serializer.ArrayRules

TransactionUnlocksArrayRules returns array rules defining the constraints on Unlocks within a Transaction.

func UnlockSelector

func UnlockSelector(unlockType uint32) (serializer.Serializable, error)

UnlockSelector implements SerializableSelectorFunc for unlock types.

func ValidateReceipt

func ValidateReceipt(receipt *ReceiptMilestoneOpt, prevTreasuryOutput *TreasuryOutput, totalSupply uint64) 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 ValidateUnlocks

func ValidateUnlocks(unlocks Unlocks, funcs ...UnlockValidatorFunc) error

ValidateUnlocks validates the unlocks by running them against the given UnlockValidatorFunc.

Types

type Address

type Address interface {
	serializer.SerializableWithSize
	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

	// Clone clones the Address.
	Clone() Address
}

Address describes a general address.

func AddressFromJSONRawMsg

func AddressFromJSONRawMsg(jRawMsg *json.RawMessage) (Address, error)

func AddressSelector

func AddressSelector(addressType uint32) (Address, error)

AddressSelector implements SerializableSelectorFunc for address types.

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 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.

const (
	// AddressEd25519 denotes an Ed25519 address.
	AddressEd25519 AddressType = 0
	// AddressAlias denotes an Alias address.
	AddressAlias AddressType = 8
	// AddressNFT denotes an NFT address.
	AddressNFT AddressType = 16
)

func (AddressType) String

func (addrType AddressType) String() string

type AddressTypeSet

type AddressTypeSet map[AddressType]struct{}

AddressTypeSet is a set of AddressType.

type AddressUnlockCondition

type AddressUnlockCondition struct {
	Address Address
}

AddressUnlockCondition is an UnlockCondition defining an identity which has to be unlocked.

func (*AddressUnlockCondition) Clone

func (*AddressUnlockCondition) Deserialize

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

func (*AddressUnlockCondition) Equal

func (*AddressUnlockCondition) MarshalJSON

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

func (*AddressUnlockCondition) Serialize

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

func (*AddressUnlockCondition) Size

func (s *AddressUnlockCondition) Size() int

func (*AddressUnlockCondition) Type

func (*AddressUnlockCondition) UnmarshalJSON

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

func (*AddressUnlockCondition) VBytes

func (s *AddressUnlockCondition) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

type AliasAddress

type AliasAddress [AliasAddressBytesLength]byte

AliasAddress defines an Alias address. An AliasAddress is the Blake2b-256 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) Clone

func (aliasAddr *AliasAddress) Clone() Address

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) Size

func (aliasAddr *AliasAddress) Size() int

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) VBytes

func (aliasAddr *AliasAddress) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

type AliasID

type AliasID [AliasIDLength]byte

AliasID is the identifier for an alias account. It is computed as the Blake2b-256 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

func (AliasID) ToHex

func (id AliasID) ToHex() string

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 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 unlock conditions on this output.
	Conditions UnlockConditions
	// The features on the output.
	Features Features
	// The immutable feature on the output.
	ImmutableFeatures Features
}

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) Clone

func (a *AliasOutput) Clone() Output

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) FeatureSet

func (a *AliasOutput) FeatureSet() FeatureSet

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 MetadataFeature can change.

func (*AliasOutput) GovernorAddress

func (a *AliasOutput) GovernorAddress() Address

func (*AliasOutput) Ident

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

func (*AliasOutput) ImmutableFeatureSet

func (a *AliasOutput) ImmutableFeatureSet() FeatureSet

func (*AliasOutput) MarshalJSON

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

func (*AliasOutput) NativeTokenList

func (a *AliasOutput) NativeTokenList() NativeTokens

func (*AliasOutput) Serialize

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

func (*AliasOutput) Size

func (a *AliasOutput) Size() int

func (*AliasOutput) StateController

func (a *AliasOutput) StateController() Address

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, SenderFeature and FoundryCounter can change.

func (*AliasOutput) Target

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

func (*AliasOutput) Type

func (a *AliasOutput) Type() OutputType

func (*AliasOutput) UnlockConditionSet

func (a *AliasOutput) UnlockConditionSet() UnlockConditionSet

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) VBytes

func (a *AliasOutput) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

func (*AliasOutput) ValidateStateTransition

func (a *AliasOutput) ValidateStateTransition(transType ChainTransitionType, next ChainConstrainedOutput, semValCtx *SemanticValidationContext) error
  • 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 AliasUnlock

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

AliasUnlock is an Unlock which references a previous unlock.

func (*AliasUnlock) Chainable

func (r *AliasUnlock) Chainable() bool

func (*AliasUnlock) Deserialize

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

func (*AliasUnlock) MarshalJSON

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

func (*AliasUnlock) Ref

func (r *AliasUnlock) Ref() uint16

func (*AliasUnlock) Serialize

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

func (*AliasUnlock) Size

func (r *AliasUnlock) Size() int

func (*AliasUnlock) SourceAllowed

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

func (*AliasUnlock) Type

func (r *AliasUnlock) Type() UnlockType

func (*AliasUnlock) UnmarshalJSON

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

type BasicOutput

type BasicOutput struct {
	// The amount of IOTA tokens held by the output.
	Amount uint64
	// The native tokens held by the output.
	NativeTokens NativeTokens
	// The unlock conditions on this output.
	Conditions UnlockConditions
	// The features on the output.
	Features Features
}

BasicOutput is an output type which can hold native tokens and features.

func (*BasicOutput) Clone

func (e *BasicOutput) Clone() Output

func (*BasicOutput) Deposit

func (e *BasicOutput) Deposit() uint64

func (*BasicOutput) Deserialize

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

func (*BasicOutput) FeatureSet

func (e *BasicOutput) FeatureSet() FeatureSet

func (*BasicOutput) Ident

func (e *BasicOutput) Ident() Address

func (*BasicOutput) IsSimpleTransfer

func (e *BasicOutput) IsSimpleTransfer() bool

IsSimpleTransfer tells whether this BasicOutput fulfills the criteria of being a simple transfer.

func (*BasicOutput) MarshalJSON

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

func (*BasicOutput) NativeTokenList

func (e *BasicOutput) NativeTokenList() NativeTokens

func (*BasicOutput) Serialize

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

func (*BasicOutput) Size

func (e *BasicOutput) Size() int

func (*BasicOutput) Type

func (e *BasicOutput) Type() OutputType

func (*BasicOutput) UnlockConditionSet

func (e *BasicOutput) UnlockConditionSet() UnlockConditionSet

func (*BasicOutput) UnlockableBy

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

func (*BasicOutput) UnmarshalJSON

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

func (*BasicOutput) VBytes

func (e *BasicOutput) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

type BasicOutputs

type BasicOutputs []*BasicOutput

BasicOutputs is a slice of BasicOutput(s).

type Block

type Block struct {
	// The protocol version under which this block operates.
	ProtocolVersion byte
	// The parents the block references.
	Parents BlockIDs
	// The inner payload of the block. Can be nil.
	Payload Payload
	// The nonce which lets this block fulfill the PoW requirements.
	Nonce uint64
}

Block represents a vertex in the Tangle.

func (*Block) Deserialize

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

func (*Block) ID

func (m *Block) ID() (BlockID, error)

ID computes the ID of the Block.

func (*Block) MarshalJSON

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

func (*Block) MustID

func (m *Block) MustID() BlockID

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

func (*Block) POW

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

POW computes the PoW score of the Block.

func (*Block) Serialize

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

func (*Block) UnmarshalJSON

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

type BlockID

type BlockID [BlockIDLength]byte

BlockID is the ID of a Block.

func BlockIDFromHexString

func BlockIDFromHexString(blockIDHex string) (BlockID, error)

BlockIDFromHexString converts the given block ID from its hex to BlockID representation.

func EmptyBlockID

func EmptyBlockID() BlockID

EmptyBlockID returns an empty BlockID.

func MustBlockIDFromHexString

func MustBlockIDFromHexString(blockIDHex string) BlockID

MustBlockIDFromHexString converts the given block ID from its hex to BlockID representation.

func (BlockID) Empty

func (id BlockID) Empty() bool

Empty tells whether the BlockID is empty.

func (BlockID) MarshalText

func (id BlockID) MarshalText() (text []byte, err error)

func (*BlockID) String

func (id *BlockID) String() string

func (BlockID) ToHex

func (id BlockID) ToHex() string

ToHex converts the given block ID to their hex representation.

func (*BlockID) UnmarshalText

func (id *BlockID) UnmarshalText(text []byte) error

type BlockIDs

type BlockIDs []BlockID

BlockIDs are IDs of blocks.

func BlockIDsFromHexString

func BlockIDsFromHexString(blockIDsHex []string) (BlockIDs, error)

BlockIDsFromHexString converts the given block IDs from their hex to BlockID representation.

func (BlockIDs) RemoveDupsAndSort

func (ids BlockIDs) RemoveDupsAndSort() BlockIDs

RemoveDupsAndSort removes duplicated BlockIDs and sorts the slice by the lexical ordering.

func (BlockIDs) ToHex

func (ids BlockIDs) ToHex() []string

ToHex converts the BlockIDs to their hex representation.

func (BlockIDs) ToSerializerType

func (ids BlockIDs) ToSerializerType() serializer.SliceOfArraysOf32Bytes

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

	// ImmutableFeatureSet returns the immutable FeatureSet this output contains.
	ImmutableFeatureSet() FeatureSet
}

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{}
	// ToHex returns the hex representation of the ChainID.
	ToHex() string
}

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

type ChainTransitionError

type ChainTransitionError struct {
	Inner error
	Msg   string
}

ChainTransitionError gets returned when a state transition validation fails for a ChainConstrainedOutput.

func (*ChainTransitionError) Error

func (i *ChainTransitionError) Error() string

func (*ChainTransitionError) Unwrap

func (i *ChainTransitionError) Unwrap() error

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 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 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) Clone

func (edAddr *Ed25519Address) Clone() Address

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) Size

func (edAddr *Ed25519Address) Size() int

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) VBytes

func (edAddr *Ed25519Address) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

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) Size

func (e *Ed25519Signature) Size() int

func (*Ed25519Signature) String

func (e *Ed25519Signature) String() string

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 ExpirationUnlockCondition

type ExpirationUnlockCondition struct {
	// The identity who is allowed to use the output after the expiration has happened.
	ReturnAddress Address
	// The unix time in second resolution at which the expiration happens.
	UnixTime uint32
}

ExpirationUnlockCondition is an unlock condition which puts a time constraint on whether the receiver or return identity can consume an output depending on the latest confirmed milestone's timestamp T:

  • only the receiver identity can consume the output, if T is before than the one defined in the condition.
  • only the return identity can consume the output, if T is at the same time or after the one defined in the condition.

func (*ExpirationUnlockCondition) Clone

func (*ExpirationUnlockCondition) Deserialize

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

func (*ExpirationUnlockCondition) Equal

func (*ExpirationUnlockCondition) MarshalJSON

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

func (*ExpirationUnlockCondition) Serialize

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

func (*ExpirationUnlockCondition) Size

func (s *ExpirationUnlockCondition) Size() int

func (*ExpirationUnlockCondition) Type

func (*ExpirationUnlockCondition) UnmarshalJSON

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

func (*ExpirationUnlockCondition) VBytes

func (s *ExpirationUnlockCondition) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

type ExternalUnlockParameters

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

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

type Feature

type Feature interface {
	serializer.SerializableWithSize
	NonEphemeralObject

	// Type returns the type of the Feature.
	Type() FeatureType

	// Equal tells whether this Feature is equal to other.
	Equal(other Feature) bool

	// Clone clones the Feature.
	Clone() Feature
}

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

func FeatureSelector

func FeatureSelector(featType uint32) (Feature, error)

FeatureSelector implements SerializableSelectorFunc for features.

type FeatureSet

type FeatureSet map[FeatureType]Feature

FeatureSet is a set of Feature(s).

func (FeatureSet) Clone

func (f FeatureSet) Clone() FeatureSet

Clone clones the FeatureSet.

func (FeatureSet) EveryTuple

func (f FeatureSet) EveryTuple(other FeatureSet, fun func(a Feature, b Feature) 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 (FeatureSet) IssuerFeature

func (f FeatureSet) IssuerFeature() *IssuerFeature

IssuerFeature returns the IssuerFeature in the set or nil.

func (FeatureSet) MetadataFeature

func (f FeatureSet) MetadataFeature() *MetadataFeature

MetadataFeature returns the MetadataFeature in the set or nil.

func (FeatureSet) SenderFeature

func (f FeatureSet) SenderFeature() *SenderFeature

SenderFeature returns the SenderFeature in the set or nil.

func (FeatureSet) TagFeature

func (f FeatureSet) TagFeature() *TagFeature

TagFeature returns the TagFeature in the set or nil.

type FeatureSetTransitionValidationFunc

type FeatureSetTransitionValidationFunc func(inSet FeatureSet, outSet FeatureSet) error

FeatureSetTransitionValidationFunc checks whether the Features transition from in to out is valid.

type FeatureType

type FeatureType byte

FeatureType defines the type of features.

const (
	// FeatureSender denotes a SenderFeature.
	FeatureSender FeatureType = iota
	// FeatureIssuer denotes an IssuerFeature.
	FeatureIssuer
	// FeatureMetadata denotes a MetadataFeature.
	FeatureMetadata
	// FeatureTag denotes a TagFeature.
	FeatureTag
)

func (FeatureType) String

func (featType FeatureType) String() string

type Features

type Features []Feature

Features is a slice of Feature(s).

func (Features) Clone

func (f Features) Clone() Features

Clone clones the Features.

func (Features) Equal

func (f Features) Equal(other Features) bool

Equal checks whether this slice is equal to other.

func (*Features) FromSerializables

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

func (Features) MustSet

func (f Features) MustSet() FeatureSet

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 Features slice does not contain the same FeatureType multiple times.

func (Features) Set

func (f Features) Set() (FeatureSet, error)

Set converts the slice into a FeatureSet. Returns an error if a FeatureType occurs multiple times.

func (Features) Size

func (f Features) Size() int

func (Features) ToSerializables

func (f Features) ToSerializables() serializer.Serializables

func (Features) VBytes

func (f Features) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

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) FoundrySerialNumber

func (fID FoundryID) FoundrySerialNumber() uint32

FoundrySerialNumber returns the serial number of the foundry.

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

func (FoundryID) ToHex

func (fID FoundryID) ToHex() string

type FoundryOutput

type FoundryOutput struct {
	// 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 token scheme this foundry uses.
	TokenScheme TokenScheme
	// The unlock conditions on this output.
	Conditions UnlockConditions
	// The feature on the output.
	Features Features
	// The immutable feature on the output.
	ImmutableFeatures Features
}

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

func (*FoundryOutput) Chain

func (f *FoundryOutput) Chain() ChainID

func (*FoundryOutput) Clone

func (f *FoundryOutput) Clone() Output

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) FeatureSet

func (f *FoundryOutput) FeatureSet() FeatureSet

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) ImmutableFeatureSet

func (f *FoundryOutput) ImmutableFeatureSet() FeatureSet

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) NativeTokenList

func (f *FoundryOutput) NativeTokenList() NativeTokens

func (*FoundryOutput) Serialize

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

func (*FoundryOutput) Size

func (f *FoundryOutput) Size() int

func (*FoundryOutput) Type

func (f *FoundryOutput) Type() OutputType

func (*FoundryOutput) UnlockConditionSet

func (f *FoundryOutput) UnlockConditionSet() UnlockConditionSet

func (*FoundryOutput) UnlockableBy

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

func (*FoundryOutput) UnmarshalJSON

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

func (*FoundryOutput) VBytes

func (f *FoundryOutput) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

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 GovernorAddressUnlockCondition

type GovernorAddressUnlockCondition struct {
	Address Address
}

GovernorAddressUnlockCondition is an UnlockCondition defining the governor identity for an AliasOutput.

func (*GovernorAddressUnlockCondition) Clone

func (*GovernorAddressUnlockCondition) Deserialize

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

func (*GovernorAddressUnlockCondition) Equal

func (*GovernorAddressUnlockCondition) MarshalJSON

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

func (*GovernorAddressUnlockCondition) Serialize

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

func (*GovernorAddressUnlockCondition) Size

func (*GovernorAddressUnlockCondition) Type

func (*GovernorAddressUnlockCondition) UnmarshalJSON

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

func (*GovernorAddressUnlockCondition) VBytes

type HexOutputIDs

type HexOutputIDs []string

HexOutputIDs is a slice of hex encoded OutputID strings.

func (HexOutputIDs) MustOutputIDs

func (ids HexOutputIDs) MustOutputIDs() OutputIDs

MustOutputIDs converts the hex strings into OutputIDs.

func (HexOutputIDs) OutputIDs

func (ids HexOutputIDs) OutputIDs() (OutputIDs, error)

OutputIDs converts the hex strings into OutputIDs.

type ImmutableAliasUnlockCondition

type ImmutableAliasUnlockCondition struct {
	Address *AliasAddress
}

ImmutableAliasUnlockCondition is an UnlockCondition defining an alias which has to be unlocked. Unlike the AddressUnlockCondition, this unlock condition is immutable for an output which contains it, meaning it also only applies to ChainConstrainedOutput(s).

func (*ImmutableAliasUnlockCondition) Clone

func (*ImmutableAliasUnlockCondition) Deserialize

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

func (*ImmutableAliasUnlockCondition) Equal

func (*ImmutableAliasUnlockCondition) MarshalJSON

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

func (*ImmutableAliasUnlockCondition) Serialize

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

func (*ImmutableAliasUnlockCondition) Size

func (*ImmutableAliasUnlockCondition) Type

func (*ImmutableAliasUnlockCondition) UnmarshalJSON

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

func (*ImmutableAliasUnlockCondition) VBytes

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 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.SerializableWithSize

	// 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
)

func (InputType) String

func (inputType InputType) String() string

type Inputs

type Inputs []Input

Inputs a slice of Input.

func (*Inputs) FromSerializables

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

func (Inputs) Size

func (in Inputs) Size() int

func (Inputs) ToSerializables

func (in Inputs) ToSerializables() serializer.Serializables

type InputsCommitment

type InputsCommitment = [InputsCommitmentLength]byte

InputsCommitment is a commitment to the inputs of a transaction.

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 IssuerFeature

type IssuerFeature struct {
	Address Address
}

IssuerFeature is a feature which associates an output with an issuer identity. Unlike the SenderFeature, the issuer identity only has to be unlocked when the ChainConstrainedOutput is first created, afterwards, the issuer feature 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 (*IssuerFeature) Clone

func (s *IssuerFeature) Clone() Feature

func (*IssuerFeature) Deserialize

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

func (*IssuerFeature) Equal

func (s *IssuerFeature) Equal(other Feature) bool

func (*IssuerFeature) MarshalJSON

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

func (*IssuerFeature) Serialize

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

func (*IssuerFeature) Size

func (s *IssuerFeature) Size() int

func (*IssuerFeature) Type

func (s *IssuerFeature) Type() FeatureType

func (*IssuerFeature) UnmarshalJSON

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

func (*IssuerFeature) VBytes

func (s *IssuerFeature) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

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.

func JsonOutputSelector

func JsonOutputSelector(ty int) (JSONSerializable, error)

JsonOutputSelector selects the json output implementation for the given type.

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 MetadataFeature

type MetadataFeature struct {
	Data []byte
}

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

func (*MetadataFeature) Clone

func (s *MetadataFeature) Clone() Feature

func (*MetadataFeature) Deserialize

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

func (*MetadataFeature) Equal

func (s *MetadataFeature) Equal(other Feature) bool

func (*MetadataFeature) MarshalJSON

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

func (*MetadataFeature) Serialize

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

func (*MetadataFeature) Size

func (s *MetadataFeature) Size() int

func (*MetadataFeature) Type

func (s *MetadataFeature) Type() FeatureType

func (*MetadataFeature) UnmarshalJSON

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

func (*MetadataFeature) VBytes

func (s *MetadataFeature) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

type MigratedFundsEntries

type MigratedFundsEntries []*MigratedFundsEntry

MigratedFundsEntries is a slice of MigratedFundsEntry.

func (MigratedFundsEntries) Clone

func (*MigratedFundsEntries) FromSerializables

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

func (MigratedFundsEntries) Size

func (o MigratedFundsEntries) Size() int

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) Clone

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 MilestoneIndex
	// The time at which this milestone was issued.
	Timestamp uint32
	// The protocol version under which this milestone operates.
	ProtocolVersion byte
	// The pointer to the previous milestone.
	// Zeroed if there wasn't a previous milestone.
	PreviousMilestoneID MilestoneID
	// The parents where this milestone attaches to.
	Parents BlockIDs
	// The merkle root of all directly/indirectly referenced blocks (their IDs) which
	// were newly included by this milestone.
	InclusionMerkleRoot MilestoneMerkleProof
	// The merkle root of all blocks (their IDs) carrying ledger state mutating transactions.
	AppliedMerkleRoot MilestoneMerkleProof
	// The metadata associated with this milestone.
	Metadata []byte
	// The milestone options carried with this milestone.
	Opts MilestoneOpts
	// The signatures held by the milestone.
	Signatures Signatures
}

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

func NewMilestone

func NewMilestone(index MilestoneIndex, timestamp uint32, protocolVersion byte, prevMsID MilestoneID, parents BlockIDs, inclMerkleProof MilestoneMerkleProof, appliedMerkleRoot MilestoneMerkleProof) *Milestone

NewMilestone creates a new unsigned Milestone.

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) MustID

func (m *Milestone) MustID() MilestoneID

MustID works like ID but panics if there is an 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(pubKeys []MilestonePublicKey, signingFunc MilestoneSigningFunc) error

Sign produces the signatures with the given envelope block and updates the Signatures field of the Milestone with the resulting signatures of the given MilestoneSigningFunc. pubKeys are passed to the given MilestoneSigningFunc so it can determine which signatures to produce.

func (*Milestone) Size

func (m *Milestone) Size() int

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.

func (MilestoneID) Empty

func (id MilestoneID) Empty() bool

Empty tells whether the MilestoneID is empty.

func (MilestoneID) MarshalText

func (id MilestoneID) MarshalText() (text []byte, err error)

func (*MilestoneID) String

func (id *MilestoneID) String() string

func (MilestoneID) ToHex

func (id MilestoneID) ToHex() string

ToHex converts the given milestone ID to their hex representation.

func (*MilestoneID) UnmarshalText

func (id *MilestoneID) UnmarshalText(text []byte) error

type MilestoneIndex

type MilestoneIndex = uint32

MilestoneIndex is the index of a Milestone.

type MilestoneMerkleProof

type MilestoneMerkleProof = [MilestoneMerkleProofLength]byte

MilestoneMerkleProof is the merkle root within a milestone.

type MilestoneOpt

type MilestoneOpt interface {
	serializer.SerializableWithSize

	// Type returns the type of the MilestoneOpt.
	Type() MilestoneOptType

	// Clone clones the MilestoneOpt.
	Clone() MilestoneOpt
}

MilestoneOpt is an object carried within a Milestone.

func MilestoneOptSelector

func MilestoneOptSelector(msOptType uint32) (MilestoneOpt, error)

MilestoneOptSelector implements SerializableSelectorFunc for milestone options.

type MilestoneOptSet

type MilestoneOptSet map[MilestoneOptType]MilestoneOpt

MilestoneOptSet is a set of MilestoneOpt(s).

func (MilestoneOptSet) Clone

func (set MilestoneOptSet) Clone() MilestoneOptSet

Clone clones the FeatureSet.

func (MilestoneOptSet) ProtocolParams

func (set MilestoneOptSet) ProtocolParams() *ProtocolParamsMilestoneOpt

ProtocolParams returns the ProtocolParamsMilestoneOpt in the set or nil.

func (MilestoneOptSet) Receipt

func (set MilestoneOptSet) Receipt() *ReceiptMilestoneOpt

Receipt returns the ReceiptMilestoneOpt in the set or nil.

type MilestoneOptType

type MilestoneOptType byte

MilestoneOptType defines the type of milestone options.

const (
	// MilestoneOptReceipt denotes a ReceiptMilestoneOpt milestone option.
	MilestoneOptReceipt MilestoneOptType = 0
	// MilestoneOptProtocolParams denotes a ProtocolParams milestone option.
	MilestoneOptProtocolParams MilestoneOptType = 1
)

func (MilestoneOptType) String

func (msOptType MilestoneOptType) String() string

type MilestoneOptTypeSet

type MilestoneOptTypeSet map[MilestoneOptType]struct{}

MilestoneOptTypeSet is a set of MilestoneOptType.

type MilestoneOpts

type MilestoneOpts []MilestoneOpt

MilestoneOpts is a slice of MilestoneOpt(s).

func (*MilestoneOpts) FromSerializables

func (m *MilestoneOpts) FromSerializables(seris serializer.Serializables)

func (MilestoneOpts) MustSet

func (m MilestoneOpts) MustSet() MilestoneOptSet

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 MilestoneOpts slice does not contain the same MilestoneOptType multiple times.

func (MilestoneOpts) Set

func (m MilestoneOpts) Set() (MilestoneOptSet, error)

Set converts the slice into a MilestoneOptSet. Returns an error if a MilestoneOpt occurs multiple times.

func (MilestoneOpts) Size

func (m MilestoneOpts) Size() int

func (MilestoneOpts) ToSerializables

func (m MilestoneOpts) ToSerializables() serializer.Serializables

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 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 NFTAddress

type NFTAddress [NFTAddressBytesLength]byte

NFTAddress defines an NFT address. An NFTAddress is the Blake2b-256 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) Clone

func (nftAddr *NFTAddress) Clone() Address

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) Size

func (nftAddr *NFTAddress) Size() int

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) VBytes

func (nftAddr *NFTAddress) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

type NFTID

type NFTID [NFTIDLength]byte

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

func NFTIDFromOutputID

func NFTIDFromOutputID(o OutputID) NFTID

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

func (NFTID) ToHex

func (nftID NFTID) ToHex() string

type NFTIDs

type NFTIDs []NFTID

NFTIDs are NFTID(s).

type NFTOutput

type NFTOutput struct {
	// 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
	// The unlock conditions on this output.
	Conditions UnlockConditions
	// The feature on the output.
	Features Features
	// The immutable feature on the output.
	ImmutableFeatures Features
}

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

func (*NFTOutput) Chain

func (n *NFTOutput) Chain() ChainID

func (*NFTOutput) Clone

func (n *NFTOutput) Clone() Output

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) FeatureSet

func (n *NFTOutput) FeatureSet() FeatureSet

func (*NFTOutput) Ident

func (n *NFTOutput) Ident() Address

func (*NFTOutput) ImmutableFeatureSet

func (n *NFTOutput) ImmutableFeatureSet() FeatureSet

func (*NFTOutput) MarshalJSON

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

func (*NFTOutput) NativeTokenList

func (n *NFTOutput) NativeTokenList() NativeTokens

func (*NFTOutput) Serialize

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

func (*NFTOutput) Size

func (n *NFTOutput) Size() int

func (*NFTOutput) Type

func (n *NFTOutput) Type() OutputType

func (*NFTOutput) UnlockConditionSet

func (n *NFTOutput) UnlockConditionSet() UnlockConditionSet

func (*NFTOutput) UnlockableBy

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

func (*NFTOutput) UnmarshalJSON

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

func (*NFTOutput) VBytes

func (n *NFTOutput) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

func (*NFTOutput) ValidateStateTransition

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

type NFTUnlock

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

NFTUnlock is an Unlock which references a previous unlock.

func (*NFTUnlock) Chainable

func (r *NFTUnlock) Chainable() bool

func (*NFTUnlock) Deserialize

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

func (*NFTUnlock) MarshalJSON

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

func (*NFTUnlock) Ref

func (r *NFTUnlock) Ref() uint16

func (*NFTUnlock) Serialize

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

func (*NFTUnlock) Size

func (r *NFTUnlock) Size() int

func (*NFTUnlock) SourceAllowed

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

func (*NFTUnlock) Type

func (r *NFTUnlock) Type() UnlockType

func (*NFTUnlock) UnmarshalJSON

func (r *NFTUnlock) 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) Size

func (n *NativeToken) Size() int

func (*NativeToken) UnmarshalJSON

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

func (*NativeToken) VBytes

func (n *NativeToken) VBytes(_ *RentStructure, _ VBytesFunc) VBytes

type NativeTokenID

type NativeTokenID = FoundryID

NativeTokenID is an identifier which uniquely identifies a NativeToken.

type NativeTokenSum

type NativeTokenSum map[NativeTokenID]*big.Int

NativeTokenSum is a mapping of NativeTokenID to a sum value.

func (NativeTokenSum) ValueOrBigInt0

func (sum NativeTokenSum) ValueOrBigInt0(id NativeTokenID) *big.Int

ValueOrBigInt0 returns the value for the given native token or a 0 big int.

type NativeTokenSumFunc

type NativeTokenSumFunc func(id NativeTokenID, aSum *big.Int, bSum *big.Int) error

NativeTokenSumFunc gets called with a NativeTokenID and the sums of input/output side.

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) Size

func (n NativeTokens) Size() int

func (NativeTokens) ToSerializables

func (n NativeTokens) ToSerializables() serializer.Serializables

func (NativeTokens) VBytes

func (n NativeTokens) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

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"
	PrefixDevnet  NetworkPrefix = "atoi"
	PrefixShimmer NetworkPrefix = "smr"
	PrefixTestnet NetworkPrefix = "rms"
)

Network prefixes.

type NonEphemeralObject

type NonEphemeralObject interface {
	// VBytes 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.
	VBytes(rentStruct *RentStructure, override VBytesFunc) VBytes
}

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.SerializableWithSize
	NonEphemeralObject

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

	// NativeTokenList returns the NativeToken this output defines.
	NativeTokenList() NativeTokens

	// UnlockConditionSet returns the UnlockConditionSet this output defines.
	UnlockConditionSet() UnlockConditionSet

	// FeatureSet returns the FeatureSet this output contains.
	FeatureSet() FeatureSet

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

	// Clone clones the Output.
	Clone() Output
}

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 MustOutputIDFromHex

func MustOutputIDFromHex(hexStr string) (OutputID, error)

MustOutputIDFromHex works like OutputIDFromHex but panics if an error is encountered.

func OutputIDFromHex

func OutputIDFromHex(hexStr string) (OutputID, error)

OutputIDFromHex creates a OutputID from the given hex encoded OututID data.

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) OrderedSet

func (outputIDs OutputIDs) OrderedSet(set OutputSet) Outputs

OrderedSet returns an Outputs slice ordered by this OutputIDs slice given a OutputSet.

func (OutputIDs) RemoveDupsAndSort

func (outputIDs OutputIDs) RemoveDupsAndSort() OutputIDs

RemoveDupsAndSort removes duplicated OutputIDs and sorts the slice by the lexical ordering.

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) Filter

func (outputSet OutputSet) Filter(f func(outputID OutputID, output Output) bool) OutputSet

Filter creates a new OutputSet with Outputs which pass the filter function f.

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
	// OutputBasic denotes an BasicOutput.
	OutputBasic OutputType = 3
	// OutputAlias denotes an AliasOutput.
	OutputAlias OutputType = 4
	// OutputFoundry denotes a FoundryOutput.
	OutputFoundry OutputType = 5
	// OutputNFT denotes an NFTOutput.
	OutputNFT OutputType = 6
)

func (OutputType) String

func (outputType OutputType) String() string

type Outputs

type Outputs []Output

Outputs is a slice of Output.

func (Outputs) ChainConstrainedOutputSet

func (outputs Outputs) ChainConstrainedOutputSet(txID TransactionID) ChainConstrainedOutputsSet

ChainConstrainedOutputSet returns a ChainConstrainedOutputsSet for all ChainConstrainedOutputs in Outputs.

func (Outputs) Commitment

func (outputs Outputs) Commitment() ([]byte, error)

Commitment computes a hash of the outputs slice to be used as a commitment.

func (Outputs) Filter

func (outputs Outputs) Filter(f OutputsFilterFunc) Outputs

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

func (*Outputs) FromSerializables

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

func (Outputs) MustCommitment

func (outputs Outputs) MustCommitment() []byte

MustCommitment works like Commitment but panics if there's an error.

func (Outputs) NativeTokenSum

func (outputs Outputs) NativeTokenSum() (NativeTokenSum, error)

NativeTokenSum sums up the different NativeTokens occurring within the given outputs.

func (Outputs) Size

func (outputs Outputs) Size() int

func (Outputs) ToOutputsByType

func (outputs Outputs) ToOutputsByType() OutputsByType

ToOutputsByType converts the Outputs slice to OutputsByType.

func (Outputs) ToSerializables

func (outputs 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) BasicOutputs

func (outputs OutputsByType) BasicOutputs() BasicOutputs

BasicOutputs returns a slice of Outputs which are BasicOutput.

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) 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() 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 OutputsSyntacticalChainConstrainedOutputUniqueness

func OutputsSyntacticalChainConstrainedOutputUniqueness() OutputsSyntacticalValidationFunc

func OutputsSyntacticalDepositAmount

func OutputsSyntacticalDepositAmount(protoParas *ProtocolParameters) 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 fulfills the minimum storage deposit as calculated from the virtual byte cost of the output
  • if the output contains a StorageDepositReturnUnlockCondition, it must "return" bigger equal than the minimum storage deposit required for the sender to send back the tokens.

func OutputsSyntacticalExpirationAndTimelock

func OutputsSyntacticalExpirationAndTimelock() OutputsSyntacticalValidationFunc

OutputsSyntacticalExpirationAndTimelock returns an OutputsSyntacticalValidationFunc which checks that: That ExpirationUnlockCondition and TimelockUnlockCondition does not have its unix criteria set to zero.

func OutputsSyntacticalFoundry

func OutputsSyntacticalFoundry() OutputsSyntacticalValidationFunc

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

  • Minted and melted supply is less equal MaximumSupply
  • MaximumSupply is not zero

func OutputsSyntacticalNFT

func OutputsSyntacticalNFT() OutputsSyntacticalValidationFunc

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

  • Address must be different from NFTAddress derived from NFTID

func OutputsSyntacticalNativeTokens

func OutputsSyntacticalNativeTokens() OutputsSyntacticalValidationFunc

OutputsSyntacticalNativeTokens returns an OutputsSyntacticalValidationFunc which checks that:

  • the sum of native tokens count across all outputs does not exceed MaxNativeTokensCount
  • each native token holds an amount bigger than zero

type Payload

type Payload interface {
	serializer.SerializableWithSize

	// 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 payload.

const (

	// PayloadTreasuryTransaction denotes a TreasuryTransaction.
	PayloadTreasuryTransaction PayloadType = 4
	// PayloadTaggedData denotes a TaggedData payload.
	PayloadTaggedData PayloadType = 5
	// PayloadTransaction denotes a Transaction.
	PayloadTransaction PayloadType = 6
	// PayloadMilestone denotes a Milestone.
	PayloadMilestone PayloadType = 7
)

func (PayloadType) String

func (payloadType PayloadType) String() string

type ProtocolParameters

type ProtocolParameters struct {
	// The version of the protocol running.
	Version byte
	// The human friendly name of the network.
	NetworkName string
	// The HRP prefix used for Bech32 addresses in the network.
	Bech32HRP NetworkPrefix
	// The minimum pow score of the network.
	MinPoWScore uint32
	// The below max depth parameter of the network.
	BelowMaxDepth uint8
	// The rent structure used by given node/network.
	RentStructure RentStructure
	// TokenSupply defines the current token supply on the network.
	TokenSupply uint64
}

ProtocolParameters defines the parameters of the protocol.

func (*ProtocolParameters) Deserialize

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

func (ProtocolParameters) MarshalJSON

func (p ProtocolParameters) MarshalJSON() ([]byte, error)

func (ProtocolParameters) NetworkID

func (p ProtocolParameters) NetworkID() NetworkID

func (*ProtocolParameters) Serialize

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

func (*ProtocolParameters) UnmarshalJSON

func (p *ProtocolParameters) UnmarshalJSON(data []byte) error

type ProtocolParamsMilestoneOpt

type ProtocolParamsMilestoneOpt struct {
	// The milestone index at which these protocol parameters become active.
	TargetMilestoneIndex MilestoneIndex
	// The protocol version.
	ProtocolVersion byte
	// The protocol parameters in binary form.
	Params []byte
}

ProtocolParamsMilestoneOpt is a MilestoneOpt defining changing protocol parameters.

func (*ProtocolParamsMilestoneOpt) Clone

func (*ProtocolParamsMilestoneOpt) Deserialize

func (p *ProtocolParamsMilestoneOpt) Deserialize(data []byte, deSeriMode serializer.DeSerializationMode, _ interface{}) (int, error)

func (*ProtocolParamsMilestoneOpt) MarshalJSON

func (p *ProtocolParamsMilestoneOpt) MarshalJSON() ([]byte, error)

func (*ProtocolParamsMilestoneOpt) Serialize

func (p *ProtocolParamsMilestoneOpt) Serialize(deSeriMode serializer.DeSerializationMode, _ interface{}) ([]byte, error)

func (*ProtocolParamsMilestoneOpt) Size

func (p *ProtocolParamsMilestoneOpt) Size() int

func (*ProtocolParamsMilestoneOpt) Type

func (*ProtocolParamsMilestoneOpt) UnmarshalJSON

func (p *ProtocolParamsMilestoneOpt) UnmarshalJSON(bytes []byte) error

type ReceiptBuilder

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

ReceiptBuilder is used to easily build up a ReceiptMilestoneOpt.

func NewReceiptBuilder

func NewReceiptBuilder(migratedAt MilestoneIndex) *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(protoParas *ProtocolParameters) (*ReceiptMilestoneOpt, error)

Build builds the ReceiptMilestoneOpt.

type ReceiptMilestoneOpt

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

ReceiptMilestoneOpt is a listing of migrated funds.

func (*ReceiptMilestoneOpt) Clone

func (r *ReceiptMilestoneOpt) Clone() MilestoneOpt

func (*ReceiptMilestoneOpt) Deserialize

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

func (*ReceiptMilestoneOpt) MarshalJSON

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

func (*ReceiptMilestoneOpt) Serialize

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

func (*ReceiptMilestoneOpt) Size

func (r *ReceiptMilestoneOpt) Size() int

func (*ReceiptMilestoneOpt) SortFunds

func (r *ReceiptMilestoneOpt) SortFunds()

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

func (*ReceiptMilestoneOpt) Sum

func (r *ReceiptMilestoneOpt) Sum() uint64

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

func (*ReceiptMilestoneOpt) Treasury

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

func (*ReceiptMilestoneOpt) Type

func (*ReceiptMilestoneOpt) UnmarshalJSON

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

type ReferenceUnlock

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

ReferenceUnlock is an Unlock which references a previous unlock.

func (*ReferenceUnlock) Chainable

func (r *ReferenceUnlock) Chainable() bool

func (*ReferenceUnlock) Deserialize

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

func (*ReferenceUnlock) MarshalJSON

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

func (*ReferenceUnlock) Ref

func (r *ReferenceUnlock) Ref() uint16

func (*ReferenceUnlock) Serialize

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

func (*ReferenceUnlock) Size

func (r *ReferenceUnlock) Size() int

func (*ReferenceUnlock) SourceAllowed

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

func (*ReferenceUnlock) Type

func (r *ReferenceUnlock) Type() UnlockType

func (*ReferenceUnlock) UnmarshalJSON

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

type ReferentialUnlock

type ReferentialUnlock interface {
	Unlock

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

ReferentialUnlock is an Unlock which references another Unlock.

type RentStructure

type RentStructure struct {
	// Defines the rent of a single virtual byte denoted in IOTA tokens.
	VByteCost uint32
	// 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 (r *RentStructure) CoversStateRent(object NonEphemeralObject, rent uint64) (uint64, error)

CoversStateRent tells whether given this NonEphemeralObject, the given rent fulfills 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) Deserialize

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

func (*RentStructure) MarshalJSON

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

func (*RentStructure) MinRent

func (r *RentStructure) MinRent(object NonEphemeralObject) uint64

MinRent returns the minimum rent to cover a given object.

func (*RentStructure) MinStorageDepositForReturnOutput

func (r *RentStructure) MinStorageDepositForReturnOutput(sender Address) uint64

MinStorageDepositForReturnOutput returns the minimum renting costs for an BasicOutput which returns a StorageDepositReturnUnlockCondition amount back to the origin sender.

func (*RentStructure) Serialize

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

func (*RentStructure) UnmarshalJSON

func (r *RentStructure) UnmarshalJSON(data []byte) error

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 inputs to the transaction.
	Inputs Outputs
	// 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 Unlocks carried by the transaction mapped by type.
	UnlocksByType UnlocksByType
}

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

func NewSemValiContextWorkingSet

func NewSemValiContextWorkingSet(t *Transaction, inputsSet 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 SenderFeature

type SenderFeature struct {
	Address Address
}

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

func (*SenderFeature) Clone

func (s *SenderFeature) Clone() Feature

func (*SenderFeature) Deserialize

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

func (*SenderFeature) Equal

func (s *SenderFeature) Equal(other Feature) bool

func (*SenderFeature) MarshalJSON

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

func (*SenderFeature) Serialize

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

func (*SenderFeature) Size

func (s *SenderFeature) Size() int

func (*SenderFeature) Type

func (s *SenderFeature) Type() FeatureType

func (*SenderFeature) UnmarshalJSON

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

func (*SenderFeature) VBytes

func (s *SenderFeature) VBytes(rentStruct *RentStructure, f VBytesFunc) VBytes

type Signature

type Signature interface {
	serializer.SerializableWithSize

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

Signature is a signature.

func SignatureFromJSONRawMsg

func SignatureFromJSONRawMsg(jRawMsg *json.RawMessage) (Signature, error)

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
)

func (SignatureType) String

func (sigType SignatureType) String() string

type SignatureTypeSet

type SignatureTypeSet map[SignatureType]struct{}

SignatureTypeSet is a set of SignatureType.

type SignatureUnlock

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

SignatureUnlock holds a signature which unlocks inputs.

func (*SignatureUnlock) Deserialize

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

func (*SignatureUnlock) MarshalJSON

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

func (*SignatureUnlock) Serialize

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

func (*SignatureUnlock) Size

func (s *SignatureUnlock) Size() int

func (*SignatureUnlock) Type

func (s *SignatureUnlock) Type() UnlockType

func (*SignatureUnlock) UnmarshalJSON

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

type Signatures

type Signatures []Signature

Signatures is a slice of Signature(s).

func (*Signatures) FromSerializables

func (sigs *Signatures) FromSerializables(seris serializer.Serializables)

func (Signatures) Len

func (sigs Signatures) Len() int

func (Signatures) Less

func (sigs Signatures) Less(i, j int) bool

func (Signatures) Swap

func (sigs Signatures) Swap(i, j int)

func (Signatures) ToSerializables

func (sigs Signatures) ToSerializables() serializer.Serializables

type SimpleTokenScheme

type SimpleTokenScheme struct {
	// The amount of tokens which has been minted.
	MintedTokens *big.Int
	// The amount of tokens which has been melted.
	MeltedTokens *big.Int
	// The maximum supply of tokens controlled.
	MaximumSupply *big.Int
}

SimpleTokenScheme is a TokenScheme which works with minted/melted/maximum supply counters.

func (*SimpleTokenScheme) Clone

func (s *SimpleTokenScheme) Clone() TokenScheme

func (*SimpleTokenScheme) Deserialize

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

func (*SimpleTokenScheme) MarshalJSON

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

func (*SimpleTokenScheme) Serialize

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

func (*SimpleTokenScheme) Size

func (s *SimpleTokenScheme) Size() int

func (*SimpleTokenScheme) StateTransition

func (s *SimpleTokenScheme) StateTransition(transType ChainTransitionType, nextState TokenScheme, in *big.Int, out *big.Int) error

func (*SimpleTokenScheme) SyntacticalValidation

func (s *SimpleTokenScheme) SyntacticalValidation() error

func (*SimpleTokenScheme) Type

func (*SimpleTokenScheme) UnmarshalJSON

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

func (*SimpleTokenScheme) VBytes

func (s *SimpleTokenScheme) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

type StateControllerAddressUnlockCondition

type StateControllerAddressUnlockCondition struct {
	Address Address
}

StateControllerAddressUnlockCondition is an UnlockCondition defining the state controller identity for an AliasOutput.

func (*StateControllerAddressUnlockCondition) Clone

func (*StateControllerAddressUnlockCondition) Deserialize

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

func (*StateControllerAddressUnlockCondition) Equal

func (*StateControllerAddressUnlockCondition) MarshalJSON

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

func (*StateControllerAddressUnlockCondition) Serialize

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

func (*StateControllerAddressUnlockCondition) Size

func (*StateControllerAddressUnlockCondition) Type

func (*StateControllerAddressUnlockCondition) UnmarshalJSON

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

func (*StateControllerAddressUnlockCondition) VBytes

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 StorageDepositReturnUnlockCondition

type StorageDepositReturnUnlockCondition struct {
	ReturnAddress Address
	Amount        uint64
}

StorageDepositReturnUnlockCondition is an unlock condition which defines the amount of tokens which must be sent back to the return identity, when the output in which it occurs in, is consumed. If a transaction consumes multiple outputs which have a StorageDepositReturnUnlockCondition, then on the output side at least the sum of all occurring StorageDepositReturnUnlockCondition(s) on the input side must be deposited to the designated return identity.

func (*StorageDepositReturnUnlockCondition) Clone

func (*StorageDepositReturnUnlockCondition) Deserialize

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

func (*StorageDepositReturnUnlockCondition) Equal

func (*StorageDepositReturnUnlockCondition) MarshalJSON

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

func (*StorageDepositReturnUnlockCondition) Serialize

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

func (*StorageDepositReturnUnlockCondition) Size

func (*StorageDepositReturnUnlockCondition) Type

func (*StorageDepositReturnUnlockCondition) UnmarshalJSON

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

func (*StorageDepositReturnUnlockCondition) VBytes

type TagFeature

type TagFeature struct {
	Tag []byte
}

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

func (*TagFeature) Clone

func (s *TagFeature) Clone() Feature

func (*TagFeature) Deserialize

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

func (*TagFeature) Equal

func (s *TagFeature) Equal(other Feature) bool

func (*TagFeature) MarshalJSON

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

func (*TagFeature) Serialize

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

func (*TagFeature) Size

func (s *TagFeature) Size() int

func (*TagFeature) Type

func (s *TagFeature) Type() FeatureType

func (*TagFeature) UnmarshalJSON

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

func (*TagFeature) VBytes

func (s *TagFeature) VBytes(rentStruct *RentStructure, f VBytesFunc) VBytes

type TaggedData

type TaggedData struct {
	// The tag to use to categorize the data.
	Tag []byte
	// The data within the payload.
	Data []byte
}

TaggedData is a payload which holds a tag and associated data.

func (*TaggedData) Deserialize

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

func (*TaggedData) MarshalJSON

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

func (*TaggedData) PayloadType

func (u *TaggedData) PayloadType() PayloadType

func (*TaggedData) Serialize

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

func (*TaggedData) Size

func (u *TaggedData) Size() int

func (*TaggedData) UnmarshalJSON

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

type TimelockUnlockCondition

type TimelockUnlockCondition struct {
	// The unix time in second resolution until which the timelock applies (inclusive).
	UnixTime uint32
}

TimelockUnlockCondition is an unlock condition 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 bigger than the one defined in the condition.

func (*TimelockUnlockCondition) Clone

func (*TimelockUnlockCondition) Deserialize

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

func (*TimelockUnlockCondition) Equal

func (*TimelockUnlockCondition) MarshalJSON

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

func (*TimelockUnlockCondition) Serialize

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

func (*TimelockUnlockCondition) Size

func (s *TimelockUnlockCondition) Size() int

func (*TimelockUnlockCondition) Type

func (*TimelockUnlockCondition) UnmarshalJSON

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

func (*TimelockUnlockCondition) VBytes

func (s *TimelockUnlockCondition) VBytes(rentStruct *RentStructure, _ VBytesFunc) VBytes

type TokenScheme

type TokenScheme interface {
	serializer.SerializableWithSize
	NonEphemeralObject

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

	// Clone clones the TokenScheme.
	Clone() TokenScheme

	// StateTransition validates the transition of the token scheme against its new state.
	StateTransition(transType ChainTransitionType, nextState TokenScheme, in *big.Int, out *big.Int) error

	// SyntacticalValidation validates the syntactical rules.
	SyntacticalValidation() error
}

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
)

func (TokenSchemeType) String

func (tokenSchemeType TokenSchemeType) String() string

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 UnlockConditions(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 UnlockConditions(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 UnlockConditions(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 Feature(s)).

type Transaction

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

Transaction is a transaction with its inputs, outputs and unlocks.

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) Size

func (t *Transaction) Size() int

func (*Transaction) UnmarshalJSON

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

type TransactionEssence

type TransactionEssence struct {
	// The network ID for which this essence is valid for.
	NetworkID NetworkID
	// The inputs of this transaction.
	Inputs Inputs `json:"inputs"`
	// The commitment to the referenced inputs.
	InputsCommitment InputsCommitment `json:"inputsCommitment"`
	// 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(inputsCommitment []byte, 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) Size

func (u *TransactionEssence) Size() int

func (*TransactionEssence) UnmarshalJSON

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

type TransactionEssenceType

type TransactionEssenceType = byte

TransactionEssenceType defines the type of transaction.

type TransactionID

type TransactionID [TransactionIDLength]byte

TransactionID is the ID of a Transaction.

func (TransactionID) ToHex

func (transactionID TransactionID) ToHex() string

ToHex converts the TransactionID to its hex representation.

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) Clone

func (ti *TreasuryInput) Clone() *TreasuryInput

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) Size

func (ti *TreasuryInput) Size() int

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
}

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

func (*TreasuryOutput) Clone

func (t *TreasuryOutput) Clone() Output

func (*TreasuryOutput) Deposit

func (t *TreasuryOutput) Deposit() uint64

func (*TreasuryOutput) Deserialize

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

func (*TreasuryOutput) FeatureSet

func (t *TreasuryOutput) FeatureSet() FeatureSet

func (*TreasuryOutput) MarshalJSON

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

func (*TreasuryOutput) NativeTokenList

func (t *TreasuryOutput) NativeTokenList() NativeTokens

func (*TreasuryOutput) Serialize

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

func (*TreasuryOutput) Size

func (t *TreasuryOutput) Size() int

func (*TreasuryOutput) Type

func (t *TreasuryOutput) Type() OutputType

func (*TreasuryOutput) UnlockConditionSet

func (t *TreasuryOutput) UnlockConditionSet() UnlockConditionSet

func (*TreasuryOutput) UnmarshalJSON

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

func (*TreasuryOutput) VBytes

func (t *TreasuryOutput) VBytes(_ *RentStructure, _ VBytesFunc) VBytes

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) Clone

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) Size

func (t *TreasuryTransaction) Size() int

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 unlocks 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 StorageDepositReturnUnlockCondition(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 and that the inputs commitment matches.

func TxSemanticNativeTokens

func TxSemanticNativeTokens() TxSemanticValidationFunc

TxSemanticNativeTokens validates following rules regarding NativeTokens:

  • The NativeTokens between Inputs / Outputs must be balanced or have a deficit on the output side 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 SenderFeature 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 TransactionID
	// 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) Equals

func (u *UTXOInput) Equals(other *UTXOInput) bool

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) Size

func (u *UTXOInput) Size() int

func (*UTXOInput) Type

func (u *UTXOInput) Type() InputType

func (*UTXOInput) UnmarshalJSON

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

type Unlock

type Unlock interface {
	serializer.SerializableWithSize

	// Type returns the type of the Unlock.
	Type() UnlockType
}

Unlock unlocks inputs of a Transaction.

type UnlockCondition

type UnlockCondition interface {
	serializer.SerializableWithSize
	NonEphemeralObject

	// Type returns the type of the UnlockCondition.
	Type() UnlockConditionType

	// Equal tells whether this UnlockCondition is equal to other.
	Equal(other UnlockCondition) bool

	// Clone clones the UnlockCondition.
	Clone() UnlockCondition
}

UnlockCondition is an abstract building block defining the unlock conditions of an Output.

func UnlockConditionSelector

func UnlockConditionSelector(unlockCondType uint32) (UnlockCondition, error)

UnlockConditionSelector implements SerializableSelectorFunc for unlock conditions.

type UnlockConditionSet

type UnlockConditionSet map[UnlockConditionType]UnlockCondition

UnlockConditionSet is a set of UnlockCondition(s).

func (UnlockConditionSet) Address

Address returns the AddressUnlockCondition in the set or nil.

func (UnlockConditionSet) Expiration

Expiration returns the ExpirationUnlockCondition in the set or nil.

func (UnlockConditionSet) GovernorAddress

GovernorAddress returns the GovernorAddressUnlockCondition in the set or nil.

func (UnlockConditionSet) HasExpirationCondition

func (f UnlockConditionSet) HasExpirationCondition() bool

HasExpirationCondition tells whether this set has an ExpirationUnlockCondition.

func (UnlockConditionSet) HasStorageDepositReturnCondition

func (f UnlockConditionSet) HasStorageDepositReturnCondition() bool

HasStorageDepositReturnCondition tells whether this set has a StorageDepositReturnUnlockCondition.

func (UnlockConditionSet) HasTimelockCondition

func (f UnlockConditionSet) HasTimelockCondition() bool

HasTimelockCondition tells whether this set has a TimelockUnlockCondition.

func (UnlockConditionSet) ImmutableAlias

ImmutableAlias returns the ImmutableAliasUnlockCondition in the set or nil.

func (UnlockConditionSet) StateControllerAddress

func (f UnlockConditionSet) StateControllerAddress() *StateControllerAddressUnlockCondition

StateControllerAddress returns the StateControllerAddressUnlockCondition in the set or nil.

func (UnlockConditionSet) StorageDepositReturn

func (f UnlockConditionSet) StorageDepositReturn() *StorageDepositReturnUnlockCondition

StorageDepositReturn returns the StorageDepositReturnUnlockCondition in the set or nil.

func (UnlockConditionSet) Timelock

Timelock returns the TimelockUnlockCondition in the set or nil.

func (UnlockConditionSet) TimelocksExpired

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

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

type UnlockConditionType

type UnlockConditionType byte

UnlockConditionType defines the type of UnlockCondition.

const (
	// UnlockConditionAddress denotes an AddressUnlockCondition.
	UnlockConditionAddress UnlockConditionType = iota
	// UnlockConditionStorageDepositReturn denotes a StorageDepositReturnUnlockCondition.
	UnlockConditionStorageDepositReturn
	// UnlockConditionTimelock denotes a TimelockUnlockCondition.
	UnlockConditionTimelock
	// UnlockConditionExpiration denotes an ExpirationUnlockCondition.
	UnlockConditionExpiration
	// UnlockConditionStateControllerAddress denotes a StateControllerAddressUnlockCondition.
	UnlockConditionStateControllerAddress
	// UnlockConditionGovernorAddress denotes a GovernorAddressUnlockCondition.
	UnlockConditionGovernorAddress
	// UnlockConditionImmutableAlias denotes an ImmutableAliasUnlockCondition.
	UnlockConditionImmutableAlias
)

func (UnlockConditionType) String

func (unlockCondType UnlockConditionType) String() string

type UnlockConditions

type UnlockConditions []UnlockCondition

UnlockConditions is a slice of UnlockCondition(s).

func (UnlockConditions) Clone

Clone clones the UnlockConditions.

func (*UnlockConditions) FromSerializables

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

func (UnlockConditions) MustSet

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

func (UnlockConditions) Set

Set converts the slice into an UnlockConditionSet. Returns an error if an UnlockConditionType occurs multiple times.

func (UnlockConditions) Size

func (f UnlockConditions) Size() int

func (UnlockConditions) ToSerializables

func (f UnlockConditions) ToSerializables() serializer.Serializables

func (UnlockConditions) VBytes

func (f UnlockConditions) VBytes(rentStruct *RentStructure, override VBytesFunc) VBytes

type UnlockType

type UnlockType byte

UnlockType defines a type of unlock.

const (
	// UnlockSignature denotes a SignatureUnlock.
	UnlockSignature UnlockType = iota
	// UnlockReference denotes a ReferenceUnlock.
	UnlockReference
	// UnlockAlias denotes an AliasUnlock.
	UnlockAlias
	// UnlockNFT denotes a NFTUnlock.
	UnlockNFT
)

func (UnlockType) String

func (unlockType UnlockType) String() string

type UnlockValidatorFunc

type UnlockValidatorFunc func(index int, unlock Unlock) error

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

func UnlocksSigUniqueAndRefValidator

func UnlocksSigUniqueAndRefValidator() UnlockValidatorFunc

UnlocksSigUniqueAndRefValidator returns a validator which checks that:

  1. SignatureUnlock(s) are unique
  2. ReferenceUnlock(s) reference a previous SignatureUnlock
  3. Following through AliasUnlock(s), NFTUnlock(s) refs results to a SignatureUnlock

type UnlockedIdentities

type UnlockedIdentities map[string]*UnlockedIdentity

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

func (UnlockedIdentities) AddUnlockedChain

func (unlockedIdents UnlockedIdentities) AddUnlockedChain(chainAddr ChainConstrainedAddress, inputIndex uint16)

AddUnlockedChain allocates an UnlockedIdentity for the given chain.

func (UnlockedIdentities) RefUnlock

func (unlockedIdents UnlockedIdentities) RefUnlock(identKey string, ref uint16, inputIndex uint16) error

RefUnlock performs a check whether the given ident is unlocked at ref and if so, adds the index of the input to the set of unlocked inputs by this identity.

func (UnlockedIdentities) SigUnlock

func (unlockedIdents UnlockedIdentities) SigUnlock(ident DirectUnlockableAddress, essence []byte, sig Signature, inputIndex uint16) error

SigUnlock performs a signature unlock check and adds the given ident to the set of unlocked identities if the signature is valid, otherwise returns an error.

func (UnlockedIdentities) String

func (unlockedIdents UnlockedIdentities) String() string

func (UnlockedIdentities) UnlockedBy

func (unlockedIdents UnlockedIdentities) UnlockedBy(inputIndex uint16, identKey string) bool

UnlockedBy checks whether the given input was unlocked either directly by a signature or indirectly through a ReferentialUnlock by the given identity.

type UnlockedIdentity

type UnlockedIdentity struct {
	// The source ident which got unlocked.
	Ident Address
	// The index at which this identity has been unlocked.
	UnlockedAt uint16
	// A set of input/unlock-block indices which referenced this unlocked identity.
	ReferencedBy map[uint16]struct{}
}

UnlockedIdentity represents an unlocked identity.

func (*UnlockedIdentity) String

func (unlockedIdent *UnlockedIdentity) String() string

type Unlocks

type Unlocks []Unlock

func (*Unlocks) FromSerializables

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

func (Unlocks) Size

func (o Unlocks) Size() int

func (Unlocks) ToSerializables

func (o Unlocks) ToSerializables() serializer.Serializables

func (Unlocks) ToUnlockByType

func (o Unlocks) ToUnlockByType() UnlocksByType

ToUnlockByType converts the Unlocks slice to UnlocksByType.

type UnlocksByType

type UnlocksByType map[UnlockType][]Unlock

UnlocksByType is a map of UnlockType(s) to slice of Unlock(s).

type VByteCostFactor

type VByteCostFactor byte

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 VBytes) VBytes

Multiply multiplies in with this factor.

func (VByteCostFactor) With

func (factor VByteCostFactor) With(other VByteCostFactor) VByteCostFactor

With joins two factors with each other.

type VBytes

type VBytes uint64

VBytes defines the type of the virtual byte costs.

type VBytesFunc

type VBytesFunc func(rentStruct *RentStructure) VBytes

VBytesFunc 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.

Jump to

Keyboard shortcuts

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