iotago

package module
v4.0.0-...-3659144 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 32 Imported by: 95

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

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

Index

Constants

View Source
const (
	// AccountAddressBytesLength is the length of an AccountAddress.
	AccountAddressBytesLength = blake2b.Size256
	// AccountAddressSerializedBytesSize is the size of a serialized AccountAddress with its type denoting byte.
	AccountAddressSerializedBytesSize = serializer.SmallTypeDenotationByteSize + AccountAddressBytesLength
)
View Source
const (
	// AnchorAddressBytesLength is the length of an AnchorAddress.
	AnchorAddressBytesLength = blake2b.Size256
	// AnchorAddressSerializedBytesSize is the size of a serialized AnchorAddress with its type denoting byte.
	AnchorAddressSerializedBytesSize = serializer.SmallTypeDenotationByteSize + AnchorAddressBytesLength
)
View Source
const (
	// Ed25519AddressBytesLength is the length of an Ed25519Address.
	Ed25519AddressBytesLength = blake2b.Size256
	// Ed25519AddressSerializedBytesSize is the size of a serialized Ed25519Address with its type denoting byte.
	Ed25519AddressSerializedBytesSize = serializer.SmallTypeDenotationByteSize + Ed25519AddressBytesLength
)
View Source
const (
	// ImplicitAccountCreationAddressBytesLength is the length of an ImplicitAccountCreationAddress.
	ImplicitAccountCreationAddressBytesLength = blake2b.Size256
	// ImplicitAccountCreationAddressSerializedBytesSize is the size of a serialized ImplicitAccountCreationAddress with its type denoting byte.
	ImplicitAccountCreationAddressSerializedBytesSize = serializer.SmallTypeDenotationByteSize + ImplicitAccountCreationAddressBytesLength
)
View Source
const (
	AddressWeightSerializedBytesSize = serializer.OneByte
	AddressMultiIDLength             = serializer.OneByte + blake2b.Size256
)
View Source
const (
	// NFTAddressBytesLength is the length of an NFTAddress.
	NFTAddressBytesLength = blake2b.Size256
	// NFTAddressSerializedBytesSize is the size of a serialized NFTAddress with its type denoting byte.
	NFTAddressSerializedBytesSize = serializer.SmallTypeDenotationByteSize + NFTAddressBytesLength
)
View Source
const (
	// MaxBlockSize defines the maximum size of a block in bytes.
	MaxBlockSize = 32768
	// BasicBlockMaxParents defines the maximum number of parents in a basic block.
	BasicBlockMaxParents = 8
	// ValidationBlockMaxParents defines the maximum number of parents in a ValidationBlock.
	ValidationBlockMaxParents = 50

	// block type + strong parents count + weak parents count + shallow like parents count + payload type + mana.
	BasicBlockSizeEmptyParentsAndEmptyPayload = serializer.OneByte + serializer.OneByte + serializer.OneByte + serializer.OneByte + serializer.TypeDenotationByteSize + ManaSize
)
View Source
const (
	Ed25519PublicKeyHashBytesLength          = blake2b.Size256
	Ed25519PublicKeyHashBlockIssuerKeyLength = serializer.SmallTypeDenotationByteSize + Ed25519PublicKeyHashBytesLength
)

Ed25519PublicKeyHashBytesLength is the length of an Ed25519 public key hash.

View Source
const (
	EpochIndexLength = serializer.UInt32ByteSize
	MaxEpochIndex    = EpochIndex(math.MaxUint32)
)
View Source
const (
	// MinBlockIssuerKeysCount is the minimum amount of block issuer keys allowed for a BlockIssuerFeature.
	MinBlockIssuerKeysCount = 1
	// MaxBlockIssuerKeysCount is the maximum amount of block issuer keys allowed for a BlockIssuerFeature.
	MaxBlockIssuerKeysCount = 128
)
View Source
const (
	// Uint256ByteSize defines the size of an uint256.
	Uint256ByteSize = 32

	// NativeTokenIDLength is the byte length of a NativeTokenID which is the same thing as a FoundryID.
	NativeTokenIDLength = FoundryIDLength
)
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
)
View Source
const (
	FoundrySerialNumberLength = serializer.UInt32ByteSize
	FoundryTokenSchemeLength  = serializer.OneByte
	// FoundryIDLength is the byte length of a FoundryID consisting out of the account address, serial number and token scheme.
	FoundryIDLength = AccountAddressSerializedBytesSize + FoundrySerialNumberLength + FoundryTokenSchemeLength
)
View Source
const (

	// OutputIndexLength defines the length of an OutputIndex.
	OutputIndexLength = serializer.UInt16ByteSize
	// OutputIDLength defines the length of an OutputID.
	OutputIDLength = TransactionIDLength + OutputIndexLength
)
View Source
const (
	SlotIndexLength = serializer.UInt32ByteSize
	MaxSlotIndex    = SlotIndex(math.MaxUint32)
)
View Source
const (
	// MaxOutputsCount defines the maximum amount of outputs within a Transaction.
	MaxOutputsCount = 128
	// MinOutputsCount defines the minimum amount of inputs within a Transaction.
	MinOutputsCount = 1
)
View Source
const (
	// MinContextInputsCount defines the minimum amount of context inputs within a Transaction.
	MinContextInputsCount = 0
	// MaxContextInputsCount defines the maximum amount of context inputs within a Transaction.
	MaxContextInputsCount = 128
	// MaxInputsCount defines the maximum amount of inputs within a Transaction.
	MaxInputsCount = 128
	// MinInputsCount defines the minimum amount of inputs within a Transaction.
	MinInputsCount = 1

	// MinAllotmentCount defines the minimum amount of allotments within a Transaction.
	MinAllotmentCount = 0
	// MaxAllotmentCount defines the maximum amount of allotments within a Transaction.
	MaxAllotmentCount = 128
)
View Source
const (
	// AccountIDLength defines the length of an AccountID.
	AccountIDLength = blake2b.Size256
)
View Source
const (
	// AnchorIDLength defines the length of an AnchorID.
	AnchorIDLength = blake2b.Size256
)
View Source
const BaseTokenSize = 8

BaseTokenSize is the size in bytes that is used by BaseToken.

View Source
const BlockHeaderLength = serializer.OneByte + serializer.UInt64ByteSize + serializer.UInt64ByteSize + CommitmentIDLength + SlotIndexLength + AccountIDLength

version + networkID + time + commitmentID + slot + accountID.

View Source
const (
	BlockIDLength = IdentifierLength + SlotIndexLength
)
View Source
const (
	CommitmentIDLength = IdentifierLength + SlotIndexLength
)
View Source
const (
	// 	DelegationIDLength is the byte length of a DelegationID.
	DelegationIDLength = blake2b.Size256
)
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 (
	// IdentifierLength defines the length of an Identifier.
	IdentifierLength = blake2b.Size256
)
View Source
const ManaSize = 8

ManaSize is the size in bytes that is used by Mana.

View Source
const MaxBaseToken = BaseToken(math.MaxUint64)
View Source
const MaxBlockIssuanceCredits = BlockIssuanceCredits(math.MaxInt64)
View Source
const MaxMana = Mana(math.MaxUint64)
View Source
const MaxMetadataMapSize = 8192

The maximum a metadata map may have (excluding the type byte of the feature).

View Source
const (
	// MaxPayloadSize defines the maximum size of a basic block payload.
	// MaxPayloadSize = MaxBlockSize - block header - empty basic block - one strong parent - block signature.
	MaxPayloadSize = MaxBlockSize - BlockHeaderLength - BasicBlockSizeEmptyParentsAndEmptyPayload - BlockIDLength - Ed25519SignatureSerializedBytesSize
)
View Source
const (
	// NFTIDLength is the byte length of an NFTID.
	NFTIDLength = blake2b.Size256
)
View Source
const (
	SignedTransactionIDLength = IdentifierLength + SlotIndexLength
)
View Source
const (
	TransactionIDLength = IdentifierLength + SlotIndexLength
)
View Source
const VersionLength = 1

Variables

View Source
var (
	// ErrInvalidAddressType gets returned when an address type is invalid.
	ErrInvalidAddressType = ierrors.New("invalid address type")
	// ErrInvalidRestrictedAddress gets returned when a RestrictedAddress is invalid.
	ErrInvalidRestrictedAddress = ierrors.New("invalid restricted address")
	// ErrInvalidNestedAddressType gets returned when a nested address inside a MultiAddress or RestrictedAddress is invalid.
	ErrInvalidNestedAddressType = ierrors.New("invalid nested address type")
	// ErrImplicitAccountCreationAddressInInvalidUnlockCondition gets returned when a Implicit Account Creation Address
	// is placed in an unlock condition where it is disallowed.
	ErrImplicitAccountCreationAddressInInvalidUnlockCondition = ierrors.New("implicit account creation address in unlock condition where it is disallowed")
	// ErrImplicitAccountCreationAddressInInvalidOutput gets returned when a ImplicitAccountCreationAddress
	// is placed in an output where it is disallowed.
	ErrImplicitAccountCreationAddressInInvalidOutput = ierrors.New("implicit account creation address in output where it is disallowed")
	// ErrAddressCannotReceiveNativeTokens gets returned if Native Tokens are sent to an address without that capability.
	ErrAddressCannotReceiveNativeTokens = ierrors.New("address cannot receive native tokens")
	// ErrAddressCannotReceiveMana gets returned if Mana is sent to an address without that capability.
	ErrAddressCannotReceiveMana = ierrors.New("address cannot receive mana")
	// ErrAddressCannotReceiveTimelockUnlockCondition gets returned if an output with a
	// TimelockUnlockCondition is sent to an address without that capability.
	ErrAddressCannotReceiveTimelockUnlockCondition = ierrors.New("address cannot receive outputs with timelock unlock condition")
	// ErrAddressCannotReceiveExpirationUnlockCondition gets returned if an output with a
	// ExpirationUnlockCondition is sent to an address without that capability.
	ErrAddressCannotReceiveExpirationUnlockCondition = ierrors.New("address cannot receive outputs with expiration unlock condition")
	// ErrAddressCannotReceiveStorageDepositReturnUnlockCondition gets returned if an output with a
	// StorageDepositReturnUnlockCondition is sent to an address without that capability.
	ErrAddressCannotReceiveStorageDepositReturnUnlockCondition = ierrors.New("address cannot receive outputs with storage deposit return unlock condition")
	// ErrAddressCannotReceiveAccountOutput gets returned if an AccountOutput is sent to an address without that capability.
	ErrAddressCannotReceiveAccountOutput = ierrors.New("address cannot receive account outputs")
	// ErrAddressCannotReceiveAnchorOutput gets returned if an AnchorOutput is sent to an address without that capability.
	ErrAddressCannotReceiveAnchorOutput = ierrors.New("address cannot receive anchor outputs")
	// ErrAddressCannotReceiveNFTOutput gets returned if an NFTOutput is sent to an address without that capability.
	ErrAddressCannotReceiveNFTOutput = ierrors.New("address cannot receive nft outputs")
	// ErrAddressCannotReceiveDelegationOutput gets returned if a DelegationOutput is sent to an address without that capability.
	ErrAddressCannotReceiveDelegationOutput = ierrors.New("address cannot receive delegation outputs")
)
View Source
var (
	ErrMultiAddressWeightInvalid    = ierrors.New("multi address weight invalid")
	ErrMultiAddressThresholdInvalid = ierrors.New("multi address treshold invalid")
)
View Source
var (
	// ErrAddressKeysNotMapped gets returned if the needed keys to sign a message are absent/not mapped.
	ErrAddressKeysNotMapped = ierrors.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 = ierrors.New("key(s) for address are of wrong type")
)
View Source
var (
	ErrWeakParentsInvalid                 = ierrors.New("weak parents must be disjunct to the rest of the parents")
	ErrTransactionCreationSlotTooRecent   = ierrors.New("a block cannot contain a transaction with creation slot more recent than the block's issuing time")
	ErrCommitmentTooOld                   = ierrors.New("a block cannot commit to a slot that is older than the block's slot minus maxCommittableAge")
	ErrCommitmentTooRecent                = ierrors.New("a block cannot commit to a slot that is more recent than the block's slot minus minCommittableAge")
	ErrCommitmentInputTooOld              = ierrors.New("a block cannot contain a commitment input with index older than the block's slot minus maxCommittableAge")
	ErrCommitmentInputTooRecent           = ierrors.New("a block cannot contain a commitment input with index more recent than the block's slot minus minCommittableAge")
	ErrInvalidBlockVersion                = ierrors.New("block has invalid protocol version")
	ErrBlockMaxSizeExceeded               = ierrors.New("block exceeds the max size")
	ErrCommitmentInputNewerThanCommitment = ierrors.New("a block cannot contain a commitment input with index newer than the commitment index")
	ErrBlockNetworkIDInvalid              = ierrors.New("invalid network ID in block header")
	ErrHighestSupportedVersionTooSmall    = ierrors.New("highest supported version must be greater equal the block's protocol version")
)
View Source
var (
	// ErrBlockParentNotFound gets returned when the block parent could not be found.
	ErrBlockParentNotFound = ierrors.New("block parent not found")
	// ErrBlockIssuingTimeNonMonotonic gets returned when the block issuing time is not monotonically increasing compared to the block's parents.
	ErrBlockIssuingTimeNonMonotonic = ierrors.New("block issuing time is not monotonically increasing compared to parents")
	// ErrIssuerAccountNotFound gets returned when the issuer account could not be found.
	ErrIssuerAccountNotFound = ierrors.New("could not retrieve account information for block issuer")
	// ErrBurnedInsufficientMana gets returned when the issuer account burned insufficient Mana for a block.
	ErrBurnedInsufficientMana = ierrors.New("block issuer account burned insufficient Mana")
	// ErrRMCNotFound gets returned when the RMC could not be found from the slot commitment.
	ErrRMCNotFound = ierrors.New("could not retrieve RMC for slot commitment")
	// ErrFailedToCalculateManaCost gets returned when the Mana cost could not be calculated.
	ErrFailedToCalculateManaCost = ierrors.New("could not calculate Mana cost for block")
	// ErrAccountExpired gets returned when the account is expired.
	ErrAccountExpired = ierrors.New("account expired")
	// ErrInvalidSignature gets returned when the signature is invalid.
	ErrInvalidSignature = ierrors.New("invalid signature")
)

Errors used for block failures.

View Source
var (
	// ErrUTXOInputInvalid gets returned when the UTXO input is invalid.
	ErrUTXOInputInvalid = ierrors.New("UTXO input is invalid")
	// ErrCommitmentInputMissing gets returned when the commitment has not been provided when needed.
	ErrCommitmentInputMissing = ierrors.New("commitment input required with reward or BIC input")
	// ErrCommitmentInputReferenceInvalid gets returned when the commitment input references an invalid commitment.
	ErrCommitmentInputReferenceInvalid = ierrors.New("commitment input references an invalid or non-existent commitment")
	// ErrBICInputReferenceInvalid gets returned when the BIC input is invalid.
	ErrBICInputReferenceInvalid = ierrors.New("BIC input reference cannot be loaded")
	// ErrRewardInputReferenceInvalid gets returned when the reward input does not reference a staking account or a delegation output.
	ErrRewardInputReferenceInvalid = ierrors.New("reward input does not reference a staking account or a delegation output")
	// ErrStakingRewardCalculationFailure gets returned when the validator reward could not be calculated due to storage issues or overflow.
	ErrStakingRewardCalculationFailure = ierrors.New("staking rewards could not be calculated due to storage issues or overflow")
	// ErrDelegationRewardCalculationFailure gets returned when the delegation reward could not be calculated due to storage issues or overflow.
	ErrDelegationRewardCalculationFailure = ierrors.New("delegation rewards could not be calculated due to storage issues or overflow")
	// ErrTxConflictRejected gets returned when the transaction was conflicting and the transaction was rejected.
	ErrTxConflictRejected = ierrors.New("transaction was conflicting and was rejected")
	// ErrTxOrphaned gets returned when the transaction was orphaned.
	ErrTxOrphaned = ierrors.New("transaction was orphaned")
	// ErrInputAlreadySpent gets returned when the input is already spent.
	ErrInputAlreadySpent = ierrors.New("input already spent")
)

Errors that can occur before the transaction is executed.

View Source
var (
	// ErrNonUniqueFeatures gets returned when multiple Feature(s) with the same FeatureType exist within sets.
	ErrNonUniqueFeatures = ierrors.New("non unique features within outputs")
	// ErrInvalidFeatureTransition gets returned when a Feature's transition within a ChainOutput is invalid.
	ErrInvalidFeatureTransition = ierrors.New("invalid feature transition")
	// ErrInvalidMetadataKey gets returned when a MetadataFeature's key is invalid.
	ErrInvalidMetadataKey = ierrors.New("invalid metadata key")
	// ErrInvalidStateMetadataKey gets returned when a StateMetadataFeature's key is invalid.
	ErrInvalidStateMetadataKey = ierrors.New("invalid state metadata key")
	// ErrMetadataExceedsMaxSize gets returned when a StateMetadataFeature or MetadataFeature exceeds the max size.
	ErrMetadataExceedsMaxSize = ierrors.New("metadata exceeds max allowed size")
)
View Source
var (
	// ErrBlockIssuerCommitmentInputMissing gets returned when no commitment input was passed in a TX containing a Block Issuer Feature.
	ErrBlockIssuerCommitmentInputMissing = ierrors.New("commitment input missing for block issuer feature")
	// ErrBlockIssuanceCreditInputMissing gets returned when a transaction containing an account with a block issuer feature
	// does not have a Block Issuance Credit Input.
	ErrBlockIssuanceCreditInputMissing = ierrors.New("block issuance credit input missing for account with block issuer feature")
	// ErrBlockIssuerNotExpired gets returned when an unexpired block issuer feature is removed.
	ErrBlockIssuerNotExpired = ierrors.New("block issuer feature has not expired")
	// ErrBlockIssuerExpiryTooEarly gets returned when the expiry slot in a block issuer feature is set too early.
	ErrBlockIssuerExpiryTooEarly = ierrors.New("block issuer feature expiry set too early")
	// ErrManaMovedOffBlockIssuerAccount gets returned when mana is moved off block issuer accounts.
	ErrManaMovedOffBlockIssuerAccount = ierrors.New("mana cannot be moved off block issuer accounts except with manalocks")
	// ErrAccountLocked gets returned when an account has negative block issuance credits.
	ErrAccountLocked = ierrors.New("account is locked due to negative block issuance credits")
)
View Source
var (
	// ErrNativeTokenAmountLessThanEqualZero gets returned when a NativeToken.Amount is not bigger than 0.
	ErrNativeTokenAmountLessThanEqualZero = ierrors.New("native token amount must be greater than zero")
	// ErrNativeTokenSumExceedsUint256 gets returned when a NativeToken.Amount addition results in a value bigger than the max value of a uint256.
	ErrNativeTokenSumExceedsUint256 = ierrors.New("native token sum exceeds max value of a uint256")
	// ErrNativeTokenSumUnbalanced gets returned when two NativeTokenSum(s) are unbalanced.
	ErrNativeTokenSumUnbalanced = ierrors.New("native token sum is unbalanced")
	// ErrFoundryIDNativeTokenIDMismatch gets returned when a native token features exists in a foundry output but the IDs mismatch.
	ErrFoundryIDNativeTokenIDMismatch = ierrors.New("native token ID in foundry output must match the foundry ID")
	// ErrNativeTokenSetInvalid gets returned when the provided native tokens are invalid.
	ErrNativeTokenSetInvalid = ierrors.New("provided native tokens are invalid")
)
View Source
var (
	// ErrStakingStartEpochInvalid gets returned when a new Staking Feature's start epoch
	// is not set to the epoch of the transaction.
	ErrStakingStartEpochInvalid = ierrors.New("staking start epoch must be the epoch of the transaction")
	// ErrStakingEndEpochTooEarly gets returned when a new Staking Feature's end epoch
	// is not at least set to the transaction epoch plus the unbonding period.
	ErrStakingEndEpochTooEarly = ierrors.New("staking end epoch must be set to the transaction epoch plus the unbonding period")
	// ErrStakingBlockIssuerFeatureMissing gets returned when an account contains a Staking Feature
	// but no Block Issuer Feature.
	ErrStakingBlockIssuerFeatureMissing = ierrors.New("block issuer feature missing for account with staking feature")
	// ErrStakingFeatureRemovedBeforeUnbonding gets returned when a staking feature is removed before the end of the unbonding period.
	ErrStakingFeatureRemovedBeforeUnbonding = ierrors.New("staking feature can only be removed after the unbonding period")
	// ErrStakingFeatureModifiedBeforeUnbonding gets returned when a staking feature's start epoch, fixed cost or
	// staked amount are modified before the unboding period.
	ErrStakingFeatureModifiedBeforeUnbonding = ierrors.New("staking start epoch, fixed cost and staked amount cannot be modified while bonded")
	// ErrStakingRewardInputMissing get returned when a staking feature is removed or reset without a reward input.
	ErrStakingRewardInputMissing = ierrors.New("staking feature removal or resetting requires a reward input")
	// ErrStakingRewardClaimingInvalid gets returned when mana rewards are claimed without removing or resetting the staking feature.
	ErrStakingRewardClaimingInvalid = ierrors.New("staking feature must be removed or reset in order to claim rewards")
	// ErrStakingCommitmentInputMissing gets returned when no commitment input was passed in a TX containing a staking feature.
	ErrStakingCommitmentInputMissing = ierrors.New("staking feature validation requires a commitment input")
)
View Source
var (
	// ErrOwnerTransitionDependentOutputNonUTXOChainID gets returned when a OwnerTransitionDependentOutput has a ChainID which is not a UTXOIDChainID.
	ErrOwnerTransitionDependentOutputNonUTXOChainID = ierrors.New("owner transition dependent outputs must have UTXO chain IDs")
	// ErrOwnerTransitionDependentOutputNextInvalid gets returned when a OwnerTransitionDependentOutput's next state is invalid.
	ErrOwnerTransitionDependentOutputNextInvalid = ierrors.New("owner transition dependent output's next output is invalid")
	// ErrArrayValidationOrderViolatesLexicalOrder gets returned if the array elements are not in lexical order.
	ErrArrayValidationOrderViolatesLexicalOrder = ierrors.New("array elements must be in their lexical order")
	// ErrArrayValidationViolatesUniqueness gets returned if the array elements are not unique.
	ErrArrayValidationViolatesUniqueness = ierrors.New("array elements must be unique")
)
View Source
var (
	// ErrAmountMustBeGreaterThanZero gets returned if the base token amount of an output is less or equal zero.
	ErrAmountMustBeGreaterThanZero = ierrors.New("base token amount must be greater than zero")
	// ErrChainMissing gets returned when a chain is missing.
	ErrChainMissing = ierrors.New("chain missing")
	// ErrNonUniqueChainOutputs gets returned when multiple ChainOutputs(s) with the same ChainID exist within sets.
	ErrNonUniqueChainOutputs = ierrors.New("non unique chain outputs")
	// ErrNewChainOutputHasNonZeroedID gets returned when a new chain output has a non-zeroed ID.
	ErrNewChainOutputHasNonZeroedID = ierrors.New("new chain output has non-zeroed ID")
	// ErrChainOutputImmutableFeaturesChanged gets returned when a chain output's immutable features are modified in a transition.
	ErrChainOutputImmutableFeaturesChanged = ierrors.New("immutable features in chain output modified during transition")
)
View Source
var (
	// ErrImplicitAccountDestructionDisallowed gets returned if an implicit account is destroyed, which is not allowed.
	ErrImplicitAccountDestructionDisallowed = ierrors.New("cannot destroy implicit account; must be transitioned to account")
	// ErrMultipleImplicitAccountCreationAddresses gets return when there is more than one
	// Implicit Account Creation Address on the input side of a transaction.
	ErrMultipleImplicitAccountCreationAddresses = ierrors.New("multiple implicit account creation addresses on the input side")
	// ErrAccountInvalidFoundryCounter gets returned when the foundry counter in an account decreased
	// or did not increase by the number of new foundries.
	ErrAccountInvalidFoundryCounter = ierrors.New("foundry counter in account decreased or did not increase by the number of new foundries")
)
View Source
var (
	// ErrAnchorInvalidStateTransition gets returned when an anchor is doing an invalid state transition.
	ErrAnchorInvalidStateTransition = ierrors.New("invalid anchor state transition")
	// ErrAnchorInvalidGovernanceTransition gets returned when an anchor is doing an invalid governance transition.
	ErrAnchorInvalidGovernanceTransition = ierrors.New("invalid anchor governance transition")
	// ErrAnchorMissing gets returned when an anchor is missing.
	ErrAnchorMissing = ierrors.New("anchor is missing")
)
View Source
var (
	// ErrDelegationCommitmentInputMissing gets returned when no commitment input was passed in a TX containing a Delegation Output.
	ErrDelegationCommitmentInputMissing = ierrors.New("delegation output validation requires a commitment input")
	// ErrDelegationRewardInputMissing gets returned when no reward input was passed in a TX destroying a Delegation Output.
	ErrDelegationRewardInputMissing = ierrors.New("delegation output cannot be destroyed without a reward input")
	// ErrDelegationRewardsClaimingInvalid gets returned when it is invalid to claim rewards from a delegation output.
	ErrDelegationRewardsClaimingInvalid = ierrors.New("invalid delegation mana rewards claiming")
	// ErrDelegationOutputTransitionedTwice gets returned when a delegation output is attempted to be transitioned twice.
	ErrDelegationOutputTransitionedTwice = ierrors.New("delegation output attempted to be transitioned twice")
	// ErrDelegationModified gets returned when a delegation output's immutable fields are modified.
	ErrDelegationModified = ierrors.New("delegated amount, validator ID and start epoch cannot be modified")
	// ErrDelegationStartEpochInvalid gets returned when a delegation output's start epoch is not set correctly
	// relative to the slot of the current epoch in which the voting power is calculated.
	ErrDelegationStartEpochInvalid = ierrors.New("delegation output has invalid start epoch")
	// ErrDelegationAmountMismatch gets returned when a delegation output's delegated amount is not equal to the amount.
	ErrDelegationAmountMismatch = ierrors.New("delegated amount does not match amount")
	// ErrDelegationEndEpochNotZero gets returned when a delegation output's end epoch is not zero at genesis.
	ErrDelegationEndEpochNotZero = ierrors.New("end epoch must be set to zero at output genesis")
	// ErrDelegationEndEpochInvalid gets returned when a delegation output's end epoch is not set correctly
	// relative to the slot of the current epoch in which the voting power is calculated.
	ErrDelegationEndEpochInvalid = ierrors.New("delegation end epoch does not match current epoch")
	// ErrDelegationValidatorAddressEmpty gets returned when the Validator Address in a Delegation Output is empty.
	ErrDelegationValidatorAddressEmpty = ierrors.New("delegation output's validator address is empty")
)
View Source
var (
	// ErrFoundryTransitionWithoutAccount gets returned when a foundry output is transitioned
	// without an accompanying account on the input or output side.
	ErrFoundryTransitionWithoutAccount = ierrors.New("foundry output transitioned without accompanying account on input or output side")
	// ErrFoundrySerialInvalid gets returned when the foundry output's serial number is invalid.
	ErrFoundrySerialInvalid = ierrors.New("foundry output serial number is invalid")
)
View Source
var (
	// ErrEd25519PubKeyAndAddrMismatch gets returned when an Ed25519Address and public key do not correspond to each other.
	ErrEd25519PubKeyAndAddrMismatch = ierrors.New("public key and address do not correspond to each other (Ed25519)")
	// ErrEd25519SignatureInvalid gets returned for invalid an Ed25519Signature.
	ErrEd25519SignatureInvalid = ierrors.New("signature is invalid (Ed25519)")
)
View Source
var (
	// ErrInputOutputBaseTokenMismatch gets returned if a transaction does not spend the entirety of the inputs to the outputs.
	ErrInputOutputBaseTokenMismatch = ierrors.New("inputs and outputs do not spend/deposit the same amount of base tokens")
	// ErrManaOverflow gets returned when there is an under- or overflow in Mana calculations.
	ErrManaOverflow = ierrors.New("under- or overflow in Mana calculations")
	// ErrInputUnlockCountMismatch gets returned when the unlock count and input count mismatch.
	ErrInputUnlockCountMismatch = ierrors.New("unlock count and input count mismatch")
	// ErrSignatureAndAddrIncompatible gets returned if an address of an input has a companion signature unlock with the wrong signature type.
	ErrSignatureAndAddrIncompatible = ierrors.New("address and signature type are not compatible")
	// ErrSenderFeatureNotUnlocked gets returned when an output contains a SenderFeature with an address which is not unlocked.
	ErrSenderFeatureNotUnlocked = ierrors.New("sender feature is not unlocked")
	// ErrIssuerFeatureNotUnlocked gets returned when an output contains a IssuerFeature with an address which is not unlocked.
	ErrIssuerFeatureNotUnlocked = ierrors.New("issuer feature is not unlocked")
	// ErrReturnAmountNotFulFilled gets returned when a return amount in a transaction is not fulfilled by the output side.
	ErrReturnAmountNotFulFilled = ierrors.New("return amount not fulfilled")
	// ErrInputOutputManaMismatch gets returned if Mana is not balanced across inputs and outputs/allotments.
	ErrInputOutputManaMismatch = ierrors.New("inputs and outputs do not contain the same amount of Mana")
	// ErrInputCreationAfterTxCreation gets returned if an input has creation slot after the transaction creation slot.
	ErrInputCreationAfterTxCreation = ierrors.New("input creation slot after tx creation slot")
)
View Source
var (
	// ErrStorageDepositNotCovered gets returned when a NonEphemeralObject does not cover the minimum deposit
	// which is calculated from its storage score.
	ErrStorageDepositNotCovered = ierrors.New("minimum storage deposit not covered")
	// ErrTypeIsNotSupportedStorageScoreStructure gets returned when a serializable was found to not be a supported StorageScoreStructure.
	ErrTypeIsNotSupportedStorageScoreStructure = ierrors.New("serializable is not a supported storage score structure")
)
View Source
var (
	// ErrSimpleTokenSchemeTransition gets returned when a SimpleTokenScheme transition is invalid.
	ErrSimpleTokenSchemeTransition = ierrors.New("simple token scheme transition invalid")
	// ErrSimpleTokenSchemeMintedMeltedTokenDecrease gets returned when a SimpleTokenScheme's minted/melted tokens decreased.
	ErrSimpleTokenSchemeMintedMeltedTokenDecrease = ierrors.New("simple token scheme's minted or melted tokens decreased")
	// ErrSimpleTokenSchemeMintingInvalid gets returned when a SimpleTokenScheme's minted tokens did not increase by the minted amount or melted tokens changed.
	ErrSimpleTokenSchemeMintingInvalid = ierrors.New("simple token scheme's minted tokens did not increase by the minted amount or melted tokens changed")
	// ErrSimpleTokenSchemeMeltingInvalid gets returned when a SimpleTokenScheme's melted tokens did not increase by the melted amount or minted tokens changed.
	ErrSimpleTokenSchemeMeltingInvalid = ierrors.New("simple token scheme's melted tokens did not increase by the melted amount or minted tokens changed")
	// ErrSimpleTokenSchemeMaximumSupplyChanged gets returned when a SimpleTokenScheme's maximum supply changes during a transition.
	ErrSimpleTokenSchemeMaximumSupplyChanged = ierrors.New("simple token scheme's maximum supply cannot change during transition")
	// ErrSimpleTokenSchemeInvalidMaximumSupply gets returned when a SimpleTokenScheme's max supply is invalid.
	ErrSimpleTokenSchemeInvalidMaximumSupply = ierrors.New("simple token scheme's maximum supply is invalid")
	// ErrSimpleTokenSchemeInvalidMintedMeltedTokens gets returned when a SimpleTokenScheme's minted/melted supply is invalid.
	ErrSimpleTokenSchemeInvalidMintedMeltedTokens = ierrors.New("simple token scheme's minted/melted tokens counters are invalid")
	// ErrSimpleTokenSchemeGenesisInvalid gets returned when a newly created simple token scheme's melted tokens are not zero
	// or minted tokens do not equal native token amount in transaction.
	ErrSimpleTokenSchemeGenesisInvalid = ierrors.New("newly created simple token scheme's melted tokens are not zero or minted tokens do not equal native token amount in transaction")
)
View Source
var (
	// ErrTxTypeInvalid gets returned for invalid transaction type.
	ErrTxTypeInvalid = ierrors.New("transaction type is invalid")
	// ErrTxEssenceNetworkIDInvalid gets returned when a network ID within a Transaction is invalid.
	ErrTxEssenceNetworkIDInvalid = ierrors.New("invalid network ID")
	// ErrTxEssenceCapabilitiesInvalid gets returned when the capabilities within a Transaction are invalid.
	ErrTxEssenceCapabilitiesInvalid = ierrors.New("invalid transaction capabilities")
	// ErrInputUTXORefsNotUnique gets returned if multiple inputs reference the same UTXO.
	ErrInputUTXORefsNotUnique = ierrors.New("inputs must each reference a unique UTXO")
	// ErrInputRewardIndexExceedsMaxInputsCount gets returned if a reward input references an index greater than max inputs count.
	ErrInputRewardIndexExceedsMaxInputsCount = ierrors.New("reward input references an index greater than max inputs count")
	// ErrAccountOutputNonEmptyState gets returned if an AccountOutput with zeroed AccountID contains state (counters non-zero etc.).
	ErrAccountOutputNonEmptyState = ierrors.New("account output is not empty state")
	// ErrAccountOutputCyclicAddress gets returned if an AccountOutput's AccountID results into the same address as the address field within the output.
	ErrAccountOutputCyclicAddress = ierrors.New("account output's ID corresponds to address field")
	// ErrAccountOutputAmountLessThanStakedAmount gets returned if an AccountOutput's amount is less than the StakedAmount field of its staking feature.
	ErrAccountOutputAmountLessThanStakedAmount = ierrors.New("account output's amount is less than the staked amount")
	// ErrAnchorOutputNonEmptyState gets returned if an AnchorOutput with zeroed AnchorID contains state (counters non-zero etc.).
	ErrAnchorOutputNonEmptyState = ierrors.New("anchor output is not empty state")
	// ErrAnchorOutputCyclicAddress gets returned if an AnchorOutput's AnchorID results into the same address as the State/Governance controller.
	ErrAnchorOutputCyclicAddress = ierrors.New("anchor output's AnchorID 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 = ierrors.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 = ierrors.New("accumulated output balance exceeds total supply")
	// ErrStorageDepositLessThanMinReturnOutputStorageDeposit gets returned when the storage deposit condition's amount is less than the min storage deposit for the return output.
	ErrStorageDepositLessThanMinReturnOutputStorageDeposit = ierrors.New("storage deposit return amount is less than the min storage deposit needed for the return output")
	// ErrStorageDepositExceedsTargetOutputAmount gets returned when the storage deposit condition's amount exceeds the target output's base token amount.
	ErrStorageDepositExceedsTargetOutputAmount = ierrors.New("storage deposit return amount exceeds target output's base token amount")
	// ErrMaxManaExceeded gets returned when the sum of stored mana in all outputs or the sum of Mana in all allotments exceeds the maximum Mana value.
	ErrMaxManaExceeded = ierrors.New("max mana value exceeded")
	// ErrManaDecayCreationIndexExceedsTargetIndex gets returned when the creation slot/epoch index
	// exceeds the target slot/epoch index in mana decay.
	ErrManaDecayCreationIndexExceedsTargetIndex = ierrors.New("mana decay creation slot/epoch index exceeds target slot/epoch index")
)
View Source
var (
	// ErrTxCapabilitiesNativeTokenBurningNotAllowed gets returned when native tokens are burned in a transaction but it was not allowed by the capabilities.
	ErrTxCapabilitiesNativeTokenBurningNotAllowed = ierrors.New("native token burning is not allowed by the transaction capabilities")
	// ErrTxCapabilitiesManaBurningNotAllowed gets returned when mana is burned in a transaction but it was not allowed by the capabilities.
	ErrTxCapabilitiesManaBurningNotAllowed = ierrors.New("mana burning is not allowed by the transaction capabilities")
	// ErrTxCapabilitiesAccountDestructionNotAllowed gets returned when an account is destroyed in a transaction but it was not allowed by the capabilities.
	ErrTxCapabilitiesAccountDestructionNotAllowed = ierrors.New("account destruction is not allowed by the transaction capabilities")
	// ErrTxCapabilitiesAnchorDestructionNotAllowed gets returned when an anchor is destroyed in a transaction but it was not allowed by the capabilities.
	ErrTxCapabilitiesAnchorDestructionNotAllowed = ierrors.New("anchor destruction is not allowed by the transaction capabilities")
	// ErrTxCapabilitiesFoundryDestructionNotAllowed gets returned when a foundry is destroyed in a transaction but it was not allowed by the capabilities.
	ErrTxCapabilitiesFoundryDestructionNotAllowed = ierrors.New("foundry destruction is not allowed by the transaction capabilities")
	// ErrTxCapabilitiesNFTDestructionNotAllowed gets returned when a NFT is destroyed in a transaction but it was not allowed by the capabilities.
	ErrTxCapabilitiesNFTDestructionNotAllowed = ierrors.New("NFT destruction is not allowed by the transaction capabilities")
)
View Source
var (
	// ErrSignatureUnlockNotUnique gets returned if sig unlocks making part of a transaction aren't unique.
	ErrSignatureUnlockNotUnique = ierrors.New("signature unlock must be unique")
	// ErrUnlockSignatureInvalid gets returned when a signature in an unlock is invalid.
	ErrUnlockSignatureInvalid = ierrors.New("signature in unlock is invalid")
	// ErrMultiUnlockNotUnique gets returned if multi unlocks making part of a transaction aren't unique.
	ErrMultiUnlockNotUnique = ierrors.New("multi unlock must be unique")
	// ErrMultiAddressUnlockThresholdNotReached gets returned if multi address unlock threshold was not reached.
	ErrMultiAddressUnlockThresholdNotReached = ierrors.New("multi address unlock threshold not reached")
	// ErrMultiAddressLengthUnlockLengthMismatch gets returned if multi address length and multi unlock length do not match.
	ErrMultiAddressLengthUnlockLengthMismatch = ierrors.New("multi address length and multi unlock length do not match")
	// ErrReferentialUnlockInvalid gets returned when a ReferentialUnlock is invalid.
	ErrReferentialUnlockInvalid = ierrors.New("invalid referential unlock")
	// ErrSignatureUnlockHasNilSignature gets returned if a signature unlock contains a nil signature.
	ErrSignatureUnlockHasNilSignature = ierrors.New("signature is nil")
	// ErrNestedMultiUnlock gets returned when a MultiUnlock is nested inside a MultiUnlock.
	ErrNestedMultiUnlock = ierrors.New("multi unlocks can't be nested")
	// ErrEmptyUnlockOutsideMultiUnlock gets returned when an empty unlock was not nested inside of a multi unlock.
	ErrEmptyUnlockOutsideMultiUnlock = ierrors.New("empty unlocks are only allowed inside of a multi unlock")
	// ErrChainAddressUnlockInvalid gets returned when an invalid unlock for chain addresses is encountered.
	ErrChainAddressUnlockInvalid = ierrors.New("invalid unlock for chain address")
	// ErrDirectUnlockableAddressUnlockInvalid gets returned when an invalid unlock for direct unlockable addresses is encountered.
	ErrDirectUnlockableAddressUnlockInvalid = ierrors.New("invalid unlock for direct unlockable address")
	// ErrMultiAddressUnlockInvalid gets returned when an invalid unlock for multi addresses is encountered.
	ErrMultiAddressUnlockInvalid = ierrors.New("invalid unlock for multi address")
)
View Source
var (
	// ErrNonUniqueUnlockConditions gets returned when multiple UnlockCondition(s) with the same UnlockConditionType exist within sets.
	ErrNonUniqueUnlockConditions = ierrors.New("non unique unlock conditions within outputs")
	// ErrTimelockNotExpired gets returned when timelocks in a UnlockConditionSet are not expired.
	ErrTimelockNotExpired = ierrors.New("timelock not expired")
	// ErrExpirationConditionZero gets returned when an ExpirationUnlockCondition has set the slot index to zero.
	ErrExpirationConditionZero = ierrors.New("expiration condition is zero")
	// ErrTimelockConditionZero gets returned when a TimelockUnlockCondition has set the slot index to zero.
	ErrTimelockConditionZero = ierrors.New("timelock condition is zero")
	// ErrTimelockCommitmentInputMissing gets returned when a TX containing a TimelockUnlockCondition
	// does not have a commitment input.
	ErrTimelockCommitmentInputMissing = ierrors.New("transaction's containing a timelock condition require a commitment input")
	// ErrExpirationCommitmentInputMissing gets returned when a TX containing an ExpirationUnlockCondition
	// does not have a commitment input.
	ErrExpirationCommitmentInputMissing = ierrors.New("transaction's containing an expiration condition require a commitment input")
	// ErrExpirationNotUnlockable gets returned when a ExpirationUnlockCondition cannot be unlocked by return address or the owner.
	ErrExpirationNotUnlockable = ierrors.New("expiration unlock condition cannot be unlocked")
)
View Source
var (
	// BlockIDAliases contains a dictionary of identifiers associated to their human-readable alias.
	BlockIDAliases = make(map[BlockID]string)
)
View Source
var (
	// CommitmentIDAliases contains a dictionary of identifiers associated to their human-readable alias.
	CommitmentIDAliases = make(map[CommitmentID]string)
)
View Source
var (
	EmptyAccountID = AccountID{}
)
View Source
var (
	EmptyAnchorID = AnchorID{}
)
View Source
var (
	EmptyBlockID = BlockID{}
)
View Source
var (
	EmptyCommitmentID = CommitmentID{}
)
View Source
var (
	EmptyIdentifier = Identifier{}
)
View Source
var (
	EmptyOutputID = OutputID{}
)
View Source
var (
	EmptySignedTransactionID = SignedTransactionID{}
)
View Source
var (
	EmptyTransactionID = TransactionID{}
)
View Source
var (
	// ErrBitmaskTrailingZeroBytes gets returned when the trailing bytes of a bitmask are zero.
	ErrBitmaskTrailingZeroBytes = ierrors.New("bitmask trailing bytes are zero")
)
View Source
var (
	// ErrRefUTXOIndexInvalid gets returned on invalid UTXO indices.
	ErrRefUTXOIndexInvalid = ierrors.Errorf("the referenced UTXO index must be between %d and %d (inclusive)", RefUTXOIndexMin, RefUTXOIndexMax)
)
View Source
var (
	// OutputIDAliases contains a dictionary of identifiers associated to their human-readable alias.
	OutputIDAliases = make(map[OutputID]string)
)
View Source
var (
	// SignedTransactionIDAliases contains a dictionary of identifiers associated to their human-readable alias.
	SignedTransactionIDAliases = make(map[SignedTransactionID]string)
)
View Source
var (
	// TransactionIDAliases contains a dictionary of identifiers associated to their human-readable alias.
	TransactionIDAliases = make(map[TransactionID]string)
)

Functions

func APIByterFactory

func APIByterFactory[T any](api API) func(value T) *APIByter[T]

func AttestationFromBytes

func AttestationFromBytes(apiProvider APIProvider) func(bytes []byte) (attestation *Attestation, consumedBytes int, err error)

func BitMaskHasBit

func BitMaskHasBit(bm []byte, bit uint) bool

func BitMaskNonTrailingZeroBytesValidatorFunc

func BitMaskNonTrailingZeroBytesValidatorFunc(bm []byte) error

BitMaskNonTrailingZeroBytesValidatorFunc checks that the trailing bytes of the bitmask are not zero.

func BitMaskSetBit

func BitMaskSetBit(bm []byte, bit uint) []byte

func BlockFromBytes

func BlockFromBytes(apiProvider APIProvider) func(bytes []byte) (block *Block, consumedBytes int, err error)

func CommonSerixAPI

func CommonSerixAPI() *serix.API

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 IsValidAccountID

func IsValidAccountID(b []byte) error

IsValidAccountID returns an error if the passed bytes are not a valid AccountID, otherwise nil.

func IsValidAnchorID

func IsValidAnchorID(b []byte) error

IsValidAnchorID returns an error if the passed bytes are not a valid AnchorID, otherwise nil.

func IsValidBlockID

func IsValidBlockID(b []byte) error

IsValidBlockID returns an error if the passed bytes are not a valid BlockID, otherwise nil.

func IsValidCommitmentID

func IsValidCommitmentID(b []byte) error

IsValidCommitmentID returns an error if the passed bytes are not a valid CommitmentID, otherwise nil.

func IsValidIdentifier

func IsValidIdentifier(b []byte) error

IsValidIdentifier returns an error if the passed bytes are not a valid Identifier, otherwise nil.

func IsValidOutputID

func IsValidOutputID(b []byte) error

IsValidOutputID returns an error if the passed bytes are not a valid OutputID, otherwise nil.

func IsValidSignedTransactionID

func IsValidSignedTransactionID(b []byte) error

IsValidSignedTransactionID returns an error if the passed bytes are not a valid SignedTransactionID, otherwise nil.

func IsValidTransactionID

func IsValidTransactionID(b []byte) error

IsValidTransactionID returns an error if the passed bytes are not a valid TransactionID, otherwise nil.

func OutputIDProofFromBytes

func OutputIDProofFromBytes(api API) func([]byte) (*OutputIDProof, int, error)

func ParseBech32

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

ParseBech32 decodes a bech32 encoded string.

func SliceValidator

func SliceValidator[T any](
	slice []T,
	elementValidationFuncs ...ElementValidationFunc[T],
) error

SliceValidator iterates over a slice and calls elementValidationFunc on each element, returning the first error it encounters, if any.

func SliceValidatorMapper

func SliceValidatorMapper[U, T any](
	slice []U,
	mapper func(U) T,
	elementValidationFuncs ...ElementValidationFunc[T],
) error

SliceValidatorMapper iterates over a slice and calls elementValidationFunc on each element, after mapping it with mapper and returning the first error it encounters, if any.

func SyntacticallyValidateOutputs

func SyntacticallyValidateOutputs(outputs TxEssenceOutputs, funcs ...ElementValidationFunc[Output]) error

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

func UnregisterAccountIDAliases

func UnregisterAccountIDAliases()

UnregisterAccountIDAliases allows to unregister all previously registered aliases.

func UnregisterAnchorIDAliases

func UnregisterAnchorIDAliases()

UnregisterAnchorIDAliases allows to unregister all previously registered aliases.

func UnregisterIdentifierAliases

func UnregisterIdentifierAliases()

UnregisterIdentifierAliases allows to unregister all previously registered aliases.

func ValidateUnlocks

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

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

func VerifyProof

func VerifyProof(proof *merklehasher.Proof[Identifier], proofedRoot Identifier, treeRoot Identifier) bool

func WithAPIForMissingVersionCallback

func WithAPIForMissingVersionCallback(callback func(protocolParameters ProtocolParameters) (API, error)) options.Option[EpochBasedProvider]

func WithAddressCanReceiveAccountOutputs

func WithAddressCanReceiveAccountOutputs(canReceiveAccountOutputs bool) options.Option[AddressCapabilitiesOptions]

func WithAddressCanReceiveAnchorOutputs

func WithAddressCanReceiveAnchorOutputs(canReceiveAnchorOutputs bool) options.Option[AddressCapabilitiesOptions]

func WithAddressCanReceiveAnything

func WithAddressCanReceiveAnything() options.Option[AddressCapabilitiesOptions]

func WithAddressCanReceiveDelegationOutputs

func WithAddressCanReceiveDelegationOutputs(canReceiveDelegationOutputs bool) options.Option[AddressCapabilitiesOptions]

func WithAddressCanReceiveMana

func WithAddressCanReceiveMana(canReceiveMana bool) options.Option[AddressCapabilitiesOptions]

func WithAddressCanReceiveNFTOutputs

func WithAddressCanReceiveNFTOutputs(canReceiveNFTOutputs bool) options.Option[AddressCapabilitiesOptions]

func WithAddressCanReceiveNativeTokens

func WithAddressCanReceiveNativeTokens(canReceiveNativeTokens bool) options.Option[AddressCapabilitiesOptions]

func WithAddressCanReceiveOutputsWithExpirationUnlockCondition

func WithAddressCanReceiveOutputsWithExpirationUnlockCondition(canReceiveOutputsWithExpirationUnlockCondition bool) options.Option[AddressCapabilitiesOptions]

func WithAddressCanReceiveOutputsWithStorageDepositReturnUnlockCondition

func WithAddressCanReceiveOutputsWithStorageDepositReturnUnlockCondition(canReceiveOutputsWithStorageDepositReturnUnlockCondition bool) options.Option[AddressCapabilitiesOptions]

func WithAddressCanReceiveOutputsWithTimelockUnlockCondition

func WithAddressCanReceiveOutputsWithTimelockUnlockCondition(canReceiveOutputsWithTimelockUnlockCondition bool) options.Option[AddressCapabilitiesOptions]

func WithChainSwitchingThreshold

func WithChainSwitchingThreshold(chainSwitchingThreshold uint8) options.Option[V3ProtocolParameters]

func WithCongestionControlOptions

func WithCongestionControlOptions(minReferenceManaCost Mana, rmcIncrease Mana, rmcDecrease Mana, rmcIncreaseThreshold WorkScore, rmcDecreaseThreshold WorkScore, schedulerRate WorkScore, maxBufferSize uint32, maxValBufferSize uint32) options.Option[V3ProtocolParameters]

func WithLivenessOptions

func WithLivenessOptions(livenessThresholdLowerBoundInSeconds uint16, livenessThresholdUpperBoundInSeconds uint16, minCommittableAge SlotIndex, maxCommittableAge SlotIndex, epochNearingThreshold SlotIndex) options.Option[V3ProtocolParameters]

func WithNetworkOptions

func WithNetworkOptions(networkName string, hrp NetworkPrefix) options.Option[V3ProtocolParameters]

func WithRewardsOptions

func WithRewardsOptions(profitMarginExponent, poolCoefficientExponent, rewardToGenerationRatio uint8, retentionPeriod uint16) options.Option[V3ProtocolParameters]

func WithStakingOptions

func WithStakingOptions(unbondingPeriod EpochIndex, validationBlocksPerSlot uint8, punishmentEpochs EpochIndex) options.Option[V3ProtocolParameters]

func WithStorageOptions

func WithStorageOptions(storageCost BaseToken, factorData StorageScoreFactor, offsetOutputOverhead, offsetEd25519BlockIssuerKey, offsetStakingFeature, offsetDelegation StorageScore) options.Option[V3ProtocolParameters]

func WithSupplyOptions

func WithSupplyOptions(baseTokenSupply BaseToken, bitsCount uint8, generationRate uint8, generationRateExponent uint8, decayFactorsExponent uint8, decayFactorEpochsSumExponent uint8, annualDecayFactorPercentage uint8) options.Option[V3ProtocolParameters]

func WithTargetCommitteeSize

func WithTargetCommitteeSize(targetCommitteeSize uint8) options.Option[V3ProtocolParameters]

func WithTimeProviderOptions

func WithTimeProviderOptions(genesisSlot SlotIndex, genesisTimestamp int64, slotDurationInSeconds uint8, slotsPerEpochExponent uint8) options.Option[V3ProtocolParameters]

func WithTransactionCanBurnMana

func WithTransactionCanBurnMana(canBurnMana bool) options.Option[TransactionCapabilitiesOptions]

func WithTransactionCanBurnNativeTokens

func WithTransactionCanBurnNativeTokens(canBurnNativeTokens bool) options.Option[TransactionCapabilitiesOptions]

func WithTransactionCanDestroyAccountOutputs

func WithTransactionCanDestroyAccountOutputs(canDestroyAccountOutputs bool) options.Option[TransactionCapabilitiesOptions]

func WithTransactionCanDestroyAnchorOutputs

func WithTransactionCanDestroyAnchorOutputs(canDestroyAnchorOutputs bool) options.Option[TransactionCapabilitiesOptions]

func WithTransactionCanDestroyFoundryOutputs

func WithTransactionCanDestroyFoundryOutputs(canDestroyFoundryOutputs bool) options.Option[TransactionCapabilitiesOptions]

func WithTransactionCanDestroyNFTOutputs

func WithTransactionCanDestroyNFTOutputs(canDestroyNFTOutputs bool) options.Option[TransactionCapabilitiesOptions]

func WithVersion

func WithVersion(version Version) options.Option[V3ProtocolParameters]

func WithVersionSignalingOptions

func WithVersionSignalingOptions(windowSize uint8, windowTargetRatio uint8, activationOffset uint8) options.Option[V3ProtocolParameters]

func WithWorkScoreOptions

func WithWorkScoreOptions(
	dataByte WorkScore,
	block WorkScore,
	input WorkScore,
	contextInput WorkScore,
	output WorkScore,
	nativeToken WorkScore,
	staking WorkScore,
	blockIssuer WorkScore,
	allotment WorkScore,
	signatureEd25519 WorkScore,
) options.Option[V3ProtocolParameters]

Types

type API

type API interface {
	// Encode encodes the given object to bytes.
	Encode(obj any, opts ...serix.Option) ([]byte, error)
	// Decode decodes the given bytes into object.
	Decode(b []byte, obj any, opts ...serix.Option) (int, error)
	// JSONEncode encodes the given object to its json representation.
	JSONEncode(obj any, opts ...serix.Option) ([]byte, error)
	// JSONDecode decodes the json data into object.
	JSONDecode(jsonData []byte, obj any, opts ...serix.Option) error
	// Underlying returns the underlying serix.API instance.
	Underlying() *serix.API
	// Version returns the version of the protocol this API is used with.
	Version() Version
	// ProtocolParameters returns the protocol parameters this API is used with.
	ProtocolParameters() ProtocolParameters
	// StorageScoreStructure returns the storage score structure used by the protocol.
	StorageScoreStructure() *StorageScoreStructure
	// TimeProvider returns the underlying time provider used.
	TimeProvider() *TimeProvider
	// ManaDecayProvider returns the underlying mana decay provider used.
	ManaDecayProvider() *ManaDecayProvider
	// MaxBlockWork returns the maximum block work score.
	MaxBlockWork() WorkScore
}

API handles en/decoding of IOTA protocol objects.

func APIFromContext

func APIFromContext(ctx context.Context) API

func LatestAPI

func LatestAPI(protoParams ProtocolParameters) API

LatestAPI creates a new API instance conforming to the latest IOTA protocol version.

func V3API

func V3API(protoParams ProtocolParameters) API

V3API instantiates an API instance with types registered conforming to protocol version 3 (iota-core 1.0) of the IOTA protocol.

type APIByter

type APIByter[T any] struct {
	API   API
	Value T `serix:",inlined"`
}

func (*APIByter[T]) Bytes

func (a *APIByter[T]) Bytes() ([]byte, error)

func (*APIByter[T]) SetDeserializationContext

func (a *APIByter[T]) SetDeserializationContext(ctx context.Context)

type APIProvider

type APIProvider interface {
	// APIForVersion returns the API for the given version.
	APIForVersion(version Version) (API, error)

	// APIForTime returns the API for the given time.
	APIForTime(ts time.Time) API

	// APIForSlot returns the API for the given slot.
	APIForSlot(slot SlotIndex) API

	// APIForEpoch returns the API for the given epoch.
	APIForEpoch(epoch EpochIndex) API

	// CommittedAPI returns the API for the last committed slot.
	CommittedAPI() API

	// LatestAPI returns the API for the latest supported protocol version.
	LatestAPI() API
}

func SingleVersionProvider

func SingleVersionProvider(api API) APIProvider

type AccountAddress

type AccountAddress [AccountAddressBytesLength]byte

AccountAddress defines an AccountAddress. An AccountAddress is the Blake2b-256 hash of the OutputID which created it.

func AccountAddressFromOutputID

func AccountAddressFromOutputID(outputID OutputID) *AccountAddress

AccountAddressFromOutputID returns the AccountAddress computed from a given OutputID.

func AccountAddressFromReader

func AccountAddressFromReader(reader io.Reader) (*AccountAddress, error)

AccountAddressFromReader parses the AccountAddress from the given reader.

func (*AccountAddress) AccountID

func (addr *AccountAddress) AccountID() AccountID

func (*AccountAddress) Bech32

func (addr *AccountAddress) Bech32(hrp NetworkPrefix) string

func (*AccountAddress) ChainID

func (addr *AccountAddress) ChainID() ChainID

func (*AccountAddress) Clone

func (addr *AccountAddress) Clone() Address

func (*AccountAddress) Equal

func (addr *AccountAddress) Equal(other Address) bool

func (*AccountAddress) ID

func (addr *AccountAddress) ID() []byte

func (*AccountAddress) Key

func (addr *AccountAddress) Key() string

func (*AccountAddress) Size

func (addr *AccountAddress) Size() int

func (*AccountAddress) StorageScore

func (*AccountAddress) String

func (addr *AccountAddress) String() string

func (*AccountAddress) Type

func (addr *AccountAddress) Type() AddressType

type AccountID

type AccountID [AccountIDLength]byte

AccountID is a 32 byte hash value.

func AccountIDFromBytes

func AccountIDFromBytes(bytes []byte) (AccountID, int, error)

func AccountIDFromData

func AccountIDFromData(data []byte) AccountID

AccountIDFromData returns a new AccountID for the given data by hashing it with blake2b.

func AccountIDFromHexString

func AccountIDFromHexString(hex string) (AccountID, error)

AccountIDFromHexString converts the hex to an AccountID representation.

func AccountIDFromOutputID

func AccountIDFromOutputID(outputID OutputID) AccountID

AccountIDFromOutputID returns the AccountID computed from a given OutputID.

func MustAccountIDFromHexString

func MustAccountIDFromHexString(hex string) AccountID

MustAccountIDFromHexString converts the hex to an AccountID representation.

func (AccountID) Addressable

func (a AccountID) Addressable() bool

Addressable tells whether this ChainID can be converted into a ChainAddress.

func (AccountID) Alias

func (a AccountID) Alias() (alias string)

Alias returns the human-readable alias of the AccountID (or the hex encoded bytes if no alias was set).

func (AccountID) Bytes

func (a AccountID) Bytes() ([]byte, error)

func (AccountID) Empty

func (a AccountID) Empty() bool

Empty tells whether the AccountID is empty.

func (AccountID) FromOutputID

func (a AccountID) FromOutputID(in OutputID) ChainID

FromOutputID returns the ChainID computed from a given OutputID.

func (AccountID) MarshalText

func (a AccountID) MarshalText() (text []byte, err error)

func (AccountID) Matches

func (a AccountID) Matches(other ChainID) bool

Matches checks whether other matches this ChainID.

func (AccountID) RegisterAlias

func (a AccountID) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the AccountID which will be used as a replacement for the String method.

func (AccountID) String

func (a AccountID) String() string

func (AccountID) ToAddress

func (a AccountID) ToAddress() ChainAddress

ToAddress converts this ChainID into an ChainAddress.

func (AccountID) ToHex

func (a AccountID) ToHex() string

ToHex converts the AccountID to its hex representation.

func (*AccountID) UnmarshalText

func (a *AccountID) UnmarshalText(text []byte) error

func (AccountID) UnregisterAlias

func (a AccountID) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

type AccountIDs

type AccountIDs []AccountID

type AccountOutput

type AccountOutput struct {
	// The amount of IOTA tokens held by the output.
	Amount BaseToken `serix:""`
	// The stored mana held by the output.
	Mana Mana `serix:""`
	// The identifier for this account.
	AccountID AccountID `serix:""`
	// The counter that denotes the number of foundries created by this account.
	FoundryCounter uint32 `serix:""`
	// The unlock conditions on this output.
	UnlockConditions AccountOutputUnlockConditions `serix:",omitempty"`
	// The features on the output.
	Features AccountOutputFeatures `serix:",omitempty"`
	// The immutable feature on the output.
	ImmutableFeatures AccountOutputImmFeatures `serix:",omitempty"`
}

AccountOutput is an output type which represents an account.

func (*AccountOutput) BaseTokenAmount

func (a *AccountOutput) BaseTokenAmount() BaseToken

func (*AccountOutput) ChainID

func (a *AccountOutput) ChainID() ChainID

func (*AccountOutput) Clone

func (a *AccountOutput) Clone() Output

func (*AccountOutput) Equal

func (a *AccountOutput) Equal(other Output) bool

func (*AccountOutput) FeatureSet

func (a *AccountOutput) FeatureSet() FeatureSet

func (*AccountOutput) ImmutableFeatureSet

func (a *AccountOutput) ImmutableFeatureSet() FeatureSet

func (*AccountOutput) Owner

func (a *AccountOutput) Owner() Address

func (*AccountOutput) Size

func (a *AccountOutput) Size() int

func (*AccountOutput) StorageScore

func (a *AccountOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*AccountOutput) StoredMana

func (a *AccountOutput) StoredMana() Mana

func (*AccountOutput) Target

func (a *AccountOutput) Target() (Address, error)

func (*AccountOutput) Type

func (a *AccountOutput) Type() OutputType

func (*AccountOutput) UnlockConditionSet

func (a *AccountOutput) UnlockConditionSet() UnlockConditionSet

func (*AccountOutput) UnlockableBy

func (a *AccountOutput) UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool

func (*AccountOutput) WorkScore

func (a *AccountOutput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type AccountOutputFeature

type AccountOutputFeature interface{ Feature }

type AccountOutputFeatures

type AccountOutputFeatures = Features[AccountOutputFeature]

type AccountOutputImmFeature

type AccountOutputImmFeature interface{ Feature }

type AccountOutputImmFeatures

type AccountOutputImmFeatures = Features[AccountOutputImmFeature]

type AccountOutputUnlockCondition

type AccountOutputUnlockCondition interface{ UnlockCondition }

type AccountUnlock

type AccountUnlock struct {
	// The other input/unlock this AccountUnlock references to.
	Reference uint16 `serix:""`
}

AccountUnlock is an Unlock which references a previous input/unlock.

func (*AccountUnlock) Chainable

func (r *AccountUnlock) Chainable() bool

func (*AccountUnlock) Clone

func (r *AccountUnlock) Clone() Unlock

func (*AccountUnlock) ReferencedInputIndex

func (r *AccountUnlock) ReferencedInputIndex() uint16

func (*AccountUnlock) Size

func (r *AccountUnlock) Size() int

func (*AccountUnlock) SourceAllowed

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

func (*AccountUnlock) Type

func (r *AccountUnlock) Type() UnlockType

func (*AccountUnlock) WorkScore

func (r *AccountUnlock) WorkScore(_ *WorkScoreParameters) (WorkScore, error)

type Address

type Address interface {
	Sizer
	NonEphemeralObject
	fmt.Stringer
	constraints.Cloneable[Address]
	constraints.Equalable[Address]

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

	// ID returns the address ID, which is the concatenation of type prefix
	// and the unique identifier of the address.
	ID() []byte

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

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

Address describes a general address.

func AddressFromBytes

func AddressFromBytes(bytes []byte) (Address, int, error)

func AddressFromReader

func AddressFromReader(reader io.ReadSeeker) (Address, error)

func MultiAddressFromReader

func MultiAddressFromReader(reader io.ReadSeeker) (Address, error)

MultiAddressFromReader parses the MultiAddress from the given reader.

func RestrictedAddressFromReader

func RestrictedAddressFromReader(reader io.ReadSeeker) (Address, error)

RestrictedAddressFromBytes parses the RestrictedAddress from the given reader.

type AddressCapabilities

type AddressCapabilities interface {
	CannotReceiveNativeTokens() bool
	CannotReceiveMana() bool
	CannotReceiveOutputsWithTimelockUnlockCondition() bool
	CannotReceiveOutputsWithExpirationUnlockCondition() bool
	CannotReceiveOutputsWithStorageDepositReturnUnlockCondition() bool
	CannotReceiveAccountOutputs() bool
	CannotReceiveAnchorOutputs() bool
	CannotReceiveNFTOutputs() bool
	CannotReceiveDelegationOutputs() bool
}

type AddressCapabilitiesBitMask

type AddressCapabilitiesBitMask []byte

func AddressCapabilitiesBitMaskFromBytes

func AddressCapabilitiesBitMaskFromBytes(bytes []byte) (AddressCapabilitiesBitMask, int, error)

func (AddressCapabilitiesBitMask) CannotReceiveAccountOutputs

func (bm AddressCapabilitiesBitMask) CannotReceiveAccountOutputs() bool

func (AddressCapabilitiesBitMask) CannotReceiveAnchorOutputs

func (bm AddressCapabilitiesBitMask) CannotReceiveAnchorOutputs() bool

func (AddressCapabilitiesBitMask) CannotReceiveDelegationOutputs

func (bm AddressCapabilitiesBitMask) CannotReceiveDelegationOutputs() bool

func (AddressCapabilitiesBitMask) CannotReceiveMana

func (bm AddressCapabilitiesBitMask) CannotReceiveMana() bool

func (AddressCapabilitiesBitMask) CannotReceiveNFTOutputs

func (bm AddressCapabilitiesBitMask) CannotReceiveNFTOutputs() bool

func (AddressCapabilitiesBitMask) CannotReceiveNativeTokens

func (bm AddressCapabilitiesBitMask) CannotReceiveNativeTokens() bool

func (AddressCapabilitiesBitMask) CannotReceiveOutputsWithExpirationUnlockCondition

func (bm AddressCapabilitiesBitMask) CannotReceiveOutputsWithExpirationUnlockCondition() bool

func (AddressCapabilitiesBitMask) CannotReceiveOutputsWithStorageDepositReturnUnlockCondition

func (bm AddressCapabilitiesBitMask) CannotReceiveOutputsWithStorageDepositReturnUnlockCondition() bool

func (AddressCapabilitiesBitMask) CannotReceiveOutputsWithTimelockUnlockCondition

func (bm AddressCapabilitiesBitMask) CannotReceiveOutputsWithTimelockUnlockCondition() bool

func (AddressCapabilitiesBitMask) Clone

func (AddressCapabilitiesBitMask) Size

func (bm AddressCapabilitiesBitMask) Size() int

type AddressCapabilitiesOptions

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

AddressCapabilitiesOptions defines the possible capabilities of an AddressCapabilitiesBitMask.

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.

func NewAddressKeysForImplicitAccountCreationAddress

func NewAddressKeysForImplicitAccountCreationAddress(addr *ImplicitAccountCreationAddress, prvKey ed25519.PrivateKey) AddressKeys

NewAddressKeysForImplicitAccountCreationAddress returns new AddressKeys for ImplicitAccountCreationAddress.

func NewAddressKeysForRestrictedEd25519Address

func NewAddressKeysForRestrictedEd25519Address(addr *RestrictedAddress, prvKey ed25519.PrivateKey) (AddressKeys, error)

NewAddressKeysForRestrictedEd25519Address returns new AddressKeys for a restricted Ed25519Address.

type AddressSigner

type AddressSigner interface {
	// SignerUIDForAddress returns the signer unique identifier for a given address.
	// This can be used to identify the uniqueness of the signer in the unlocks (e.g. unique public key).
	SignerUIDForAddress(addr Address) (Identifier, error)
	// Sign produces the signature for the given message.
	Sign(addr Address, msg []byte) (signature Signature, err error)
	// EmptySignatureForAddress returns an empty signature for the given address.
	// This can be used to calculate the WorkScore of transactions without actually signing the transaction.
	EmptySignatureForAddress(addr Address) (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.

func NewInMemoryAddressSignerFromEd25519PrivateKeys

func NewInMemoryAddressSignerFromEd25519PrivateKeys(privKeys ...ed25519.PrivateKey) AddressSigner

NewInMemoryAddressSignerFromEd25519PrivateKey creates a new InMemoryAddressSigner for the Ed25519Address derived from the public key of the given private key as well as the related ImplicitAccountCreationAddress.

type AddressSignerFunc

type AddressSignerFunc func(addr Address, msg []byte) (signature Signature, err error)

AddressSignerFunc implements the AddressSigner interface.

func (AddressSignerFunc) Sign

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

type AddressType

type AddressType byte

AddressType defines the type of addresses.

const (
	// AddressEd25519 denotes an Ed25519 address.
	AddressEd25519 AddressType = 0
	// AddressAccount denotes an Account address.
	AddressAccount AddressType = 8
	// AddressNFT denotes an NFT address.
	AddressNFT AddressType = 16
	// AddressAnchor denotes an Anchor address.
	AddressAnchor AddressType = 24
	// AddressImplicitAccountCreation denotes an Ed25519 address that can only be used to create an implicit account.
	AddressImplicitAccountCreation AddressType = 32
	// AddressMulti denotes a multi address.
	AddressMulti AddressType = 40
	// AddressRestricted denotes a restricted address that has a capability bitmask.
	AddressRestricted AddressType = 48
)

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 `serix:""`
}

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

func (*AddressUnlockCondition) Clone

func (*AddressUnlockCondition) Compare

func (s *AddressUnlockCondition) Compare(other UnlockCondition) int

func (*AddressUnlockCondition) Equal

func (*AddressUnlockCondition) Size

func (s *AddressUnlockCondition) Size() int

func (*AddressUnlockCondition) StorageScore

func (s *AddressUnlockCondition) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*AddressUnlockCondition) Type

func (*AddressUnlockCondition) WorkScore

type AddressWithWeight

type AddressWithWeight struct {
	Address Address `serix:""`
	Weight  byte    `serix:""`
}

AddressWithWeight is an Address with a weight used for threshold calculation in a MultiAddress.

func (*AddressWithWeight) Compare

func (a *AddressWithWeight) Compare(other *AddressWithWeight) int

func (*AddressWithWeight) Size

func (a *AddressWithWeight) Size() int

type AddressesWithWeight

type AddressesWithWeight []*AddressWithWeight

AddressesWithWeight is a set of AddressWithWeight.

func (AddressesWithWeight) Sort

func (a AddressesWithWeight) Sort()

Sort sorts the addresses in lexical order.

type Allotment

type Allotment struct {
	AccountID AccountID `serix:""`
	Mana      Mana      `serix:""`
}

Allotment is a struct that represents a list of account IDs and an allotted value.

func (*Allotment) Clone

func (a *Allotment) Clone() *Allotment

func (*Allotment) Compare

func (a *Allotment) Compare(other *Allotment) int

type Allotments

type Allotments []*Allotment

Allotments is a slice of Allotment.

func (Allotments) Clone

func (a Allotments) Clone() Allotments

func (Allotments) Get

func (a Allotments) Get(id AccountID) Mana

func (Allotments) Size

func (a Allotments) Size() int

func (Allotments) Sort

func (a Allotments) Sort()

Sort sorts the allotments in lexical order.

func (Allotments) WorkScore

func (a Allotments) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type AnchorAddress

type AnchorAddress [AnchorAddressBytesLength]byte

AnchorAddress defines an AnchorAddress. An AnchorAddress is the Blake2b-256 hash of the OutputID which created it.

func AnchorAddressFromOutputID

func AnchorAddressFromOutputID(outputID OutputID) *AnchorAddress

AnchorAddressFromOutputID returns the AnchorAddress computed from a given OutputID.

func AnchorAddressFromReader

func AnchorAddressFromReader(reader io.Reader) (*AnchorAddress, error)

AnchorAddressFromReader parses the AnchorAddress from the given reader.

func (*AnchorAddress) AnchorID

func (addr *AnchorAddress) AnchorID() AnchorID

func (*AnchorAddress) Bech32

func (addr *AnchorAddress) Bech32(hrp NetworkPrefix) string

func (*AnchorAddress) ChainID

func (addr *AnchorAddress) ChainID() ChainID

func (*AnchorAddress) Clone

func (addr *AnchorAddress) Clone() Address

func (*AnchorAddress) Equal

func (addr *AnchorAddress) Equal(other Address) bool

func (*AnchorAddress) ID

func (addr *AnchorAddress) ID() []byte

func (*AnchorAddress) Key

func (addr *AnchorAddress) Key() string

func (*AnchorAddress) Size

func (addr *AnchorAddress) Size() int

func (*AnchorAddress) StorageScore

func (*AnchorAddress) String

func (addr *AnchorAddress) String() string

func (*AnchorAddress) Type

func (addr *AnchorAddress) Type() AddressType

type AnchorID

type AnchorID [AnchorIDLength]byte

AnchorID is a 32 byte hash value.

func AnchorIDFromBytes

func AnchorIDFromBytes(bytes []byte) (AnchorID, int, error)

func AnchorIDFromData

func AnchorIDFromData(data []byte) AnchorID

AnchorIDFromData returns a new AnchorID for the given data by hashing it with blake2b.

func AnchorIDFromHexString

func AnchorIDFromHexString(hex string) (AnchorID, error)

AnchorIDFromHexString converts the hex to an AnchorID representation.

func AnchorIDFromOutputID

func AnchorIDFromOutputID(outputID OutputID) AnchorID

AnchorIDFromOutputID returns the AnchorID computed from a given OutputID.

func MustAnchorIDFromHexString

func MustAnchorIDFromHexString(hex string) AnchorID

MustAnchorIDFromHexString converts the hex to an AnchorID representation.

func (AnchorID) Addressable

func (a AnchorID) Addressable() bool

Addressable tells whether this ChainID can be converted into a ChainAddress.

func (AnchorID) Alias

func (a AnchorID) Alias() (alias string)

Alias returns the human-readable alias of the AnchorID (or the hex encoded bytes if no alias was set).

func (AnchorID) Bytes

func (a AnchorID) Bytes() ([]byte, error)

func (AnchorID) Empty

func (a AnchorID) Empty() bool

Empty tells whether the AnchorID is empty.

func (AnchorID) FromOutputID

func (a AnchorID) FromOutputID(in OutputID) ChainID

FromOutputID returns the ChainID computed from a given OutputID.

func (AnchorID) MarshalText

func (a AnchorID) MarshalText() (text []byte, err error)

func (AnchorID) Matches

func (a AnchorID) Matches(other ChainID) bool

Matches checks whether other matches this ChainID.

func (AnchorID) RegisterAlias

func (a AnchorID) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the AnchorID which will be used as a replacement for the String method.

func (AnchorID) String

func (a AnchorID) String() string

func (AnchorID) ToAddress

func (a AnchorID) ToAddress() ChainAddress

ToAddress converts this ChainID into an ChainAddress.

func (AnchorID) ToHex

func (a AnchorID) ToHex() string

ToHex converts the AnchorID to its hex representation.

func (*AnchorID) UnmarshalText

func (a *AnchorID) UnmarshalText(text []byte) error

func (AnchorID) UnregisterAlias

func (a AnchorID) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

type AnchorIDs

type AnchorIDs []AnchorID

type AnchorOutput

type AnchorOutput struct {
	// The amount of IOTA tokens held by the output.
	Amount BaseToken `serix:""`
	// The stored mana held by the output.
	Mana Mana `serix:""`
	// The identifier for this anchor.
	AnchorID AnchorID `serix:""`
	// The index of the state.
	StateIndex uint32 `serix:""`
	// The unlock conditions on this output.
	UnlockConditions AnchorOutputUnlockConditions `serix:",omitempty"`
	// The features on the output.
	Features AnchorOutputFeatures `serix:",omitempty"`
	// The immutable feature on the output.
	ImmutableFeatures AnchorOutputImmFeatures `serix:",omitempty"`
}

AnchorOutput is an output type which represents an anchor.

func (*AnchorOutput) BaseTokenAmount

func (a *AnchorOutput) BaseTokenAmount() BaseToken

func (*AnchorOutput) ChainID

func (a *AnchorOutput) ChainID() ChainID

func (*AnchorOutput) Clone

func (a *AnchorOutput) Clone() Output

func (*AnchorOutput) Equal

func (a *AnchorOutput) Equal(other Output) bool

func (*AnchorOutput) FeatureSet

func (a *AnchorOutput) FeatureSet() FeatureSet

func (*AnchorOutput) GovernorAddress

func (a *AnchorOutput) GovernorAddress() Address

func (*AnchorOutput) ImmutableFeatureSet

func (a *AnchorOutput) ImmutableFeatureSet() FeatureSet

func (*AnchorOutput) Owner

func (*AnchorOutput) Size

func (a *AnchorOutput) Size() int

func (*AnchorOutput) StateController

func (a *AnchorOutput) StateController() Address

func (*AnchorOutput) StorageScore

func (a *AnchorOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*AnchorOutput) StoredMana

func (a *AnchorOutput) StoredMana() Mana

func (*AnchorOutput) Target

func (a *AnchorOutput) Target() (Address, error)

func (*AnchorOutput) Type

func (a *AnchorOutput) Type() OutputType

func (*AnchorOutput) UnlockConditionSet

func (a *AnchorOutput) UnlockConditionSet() UnlockConditionSet

func (*AnchorOutput) UnlockableBy

func (a *AnchorOutput) UnlockableBy(addr Address, next OwnerTransitionDependentOutput, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) (bool, error)

func (*AnchorOutput) WorkScore

func (a *AnchorOutput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type AnchorOutputFeature

type AnchorOutputFeature interface{ Feature }

type AnchorOutputFeatures

type AnchorOutputFeatures = Features[AnchorOutputFeature]

type AnchorOutputImmFeature

type AnchorOutputImmFeature interface{ Feature }

type AnchorOutputImmFeatures

type AnchorOutputImmFeatures = Features[AnchorOutputImmFeature]

type AnchorOutputUnlockCondition

type AnchorOutputUnlockCondition interface{ UnlockCondition }

type AnchorUnlock

type AnchorUnlock struct {
	// The other input/unlock this AnchorUnlock references to.
	Reference uint16 `serix:""`
}

AnchorUnlock is an Unlock which references a previous input/unlock.

func (*AnchorUnlock) Chainable

func (r *AnchorUnlock) Chainable() bool

func (*AnchorUnlock) Clone

func (r *AnchorUnlock) Clone() Unlock

func (*AnchorUnlock) ReferencedInputIndex

func (r *AnchorUnlock) ReferencedInputIndex() uint16

func (*AnchorUnlock) Size

func (r *AnchorUnlock) Size() int

func (*AnchorUnlock) SourceAllowed

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

func (*AnchorUnlock) Type

func (r *AnchorUnlock) Type() UnlockType

func (*AnchorUnlock) WorkScore

func (r *AnchorUnlock) WorkScore(_ *WorkScoreParameters) (WorkScore, error)

type ApplicationPayload

type ApplicationPayload interface {
	Payload
}

type Attestation

type Attestation struct {
	API       API
	Header    BlockHeader `serix:""`
	BodyHash  Identifier  `serix:""`
	Signature Signature   `serix:""`
}

func NewAttestation

func NewAttestation(api API, block *Block) *Attestation

func (*Attestation) BlockID

func (a *Attestation) BlockID() (BlockID, error)

func (*Attestation) Bytes

func (a *Attestation) Bytes() ([]byte, error)

func (*Attestation) Compare

func (a *Attestation) Compare(other *Attestation) int

func (*Attestation) SetDeserializationContext

func (a *Attestation) SetDeserializationContext(ctx context.Context)

func (*Attestation) Slot

func (a *Attestation) Slot() SlotIndex

func (*Attestation) VerifySignature

func (a *Attestation) VerifySignature() (valid bool, err error)

type Attestations

type Attestations = []*Attestation

Attestations is a slice of Attestation.

type BaseToken

type BaseToken uint64

BaseToken defines the unit of the base token of the network.

type BasicBlockBody

type BasicBlockBody struct {
	API API

	// The parents the block references.
	StrongParents      BlockIDs `serix:",lenPrefix=uint8,minLen=1,maxLen=8"`
	WeakParents        BlockIDs `serix:",lenPrefix=uint8,minLen=0,maxLen=8,omitempty"`
	ShallowLikeParents BlockIDs `serix:",lenPrefix=uint8,minLen=0,maxLen=8,omitempty"`

	// The inner payload of the block. Can be nil.
	Payload ApplicationPayload `serix:",optional,omitempty"`

	MaxBurnedMana Mana `serix:""`
}

BasicBlockBody represents a basic vertex in the Tangle/BlockDAG.

func (*BasicBlockBody) Hash

func (b *BasicBlockBody) Hash() (Identifier, error)

func (*BasicBlockBody) SetDeserializationContext

func (b *BasicBlockBody) SetDeserializationContext(ctx context.Context)

func (*BasicBlockBody) ShallowLikeParentIDs

func (b *BasicBlockBody) ShallowLikeParentIDs() BlockIDs

func (*BasicBlockBody) Size

func (b *BasicBlockBody) Size() int

func (*BasicBlockBody) StrongParentIDs

func (b *BasicBlockBody) StrongParentIDs() BlockIDs

func (*BasicBlockBody) Type

func (b *BasicBlockBody) Type() BlockBodyType

func (*BasicBlockBody) WeakParentIDs

func (b *BasicBlockBody) WeakParentIDs() BlockIDs

func (*BasicBlockBody) WorkScore

func (b *BasicBlockBody) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type BasicOutput

type BasicOutput struct {
	// The amount of IOTA tokens held by the output.
	Amount BaseToken `serix:""`
	// The stored mana held by the output.
	Mana Mana `serix:""`
	// The unlock conditions on this output.
	UnlockConditions BasicOutputUnlockConditions `serix:",omitempty"`
	// The features on the output.
	Features BasicOutputFeatures `serix:",omitempty"`
}

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

func (*BasicOutput) BaseTokenAmount

func (e *BasicOutput) BaseTokenAmount() BaseToken

func (*BasicOutput) Clone

func (e *BasicOutput) Clone() Output

func (*BasicOutput) Equal

func (e *BasicOutput) Equal(other Output) bool

func (*BasicOutput) FeatureSet

func (e *BasicOutput) FeatureSet() FeatureSet

func (*BasicOutput) IsSimpleTransfer

func (e *BasicOutput) IsSimpleTransfer() bool

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

func (*BasicOutput) Owner

func (e *BasicOutput) Owner() Address

func (*BasicOutput) Size

func (e *BasicOutput) Size() int

func (*BasicOutput) StorageScore

func (e *BasicOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*BasicOutput) StoredMana

func (e *BasicOutput) StoredMana() Mana

func (*BasicOutput) Type

func (e *BasicOutput) Type() OutputType

func (*BasicOutput) UnlockConditionSet

func (e *BasicOutput) UnlockConditionSet() UnlockConditionSet

func (*BasicOutput) UnlockableBy

func (e *BasicOutput) UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool

func (*BasicOutput) WorkScore

func (e *BasicOutput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type BasicOutputFeature

type BasicOutputFeature interface{ Feature }

type BasicOutputFeatures

type BasicOutputFeatures = Features[BasicOutputFeature]

type BasicOutputUnlockCondition

type BasicOutputUnlockCondition interface{ UnlockCondition }

type BasicOutputs

type BasicOutputs []*BasicOutput

BasicOutputs is a slice of BasicOutput(s).

type Block

type Block struct {
	API       API
	Header    BlockHeader `serix:""`
	Body      BlockBody   `serix:""`
	Signature Signature   `serix:""`
}

func (*Block) ForEachParent

func (b *Block) ForEachParent(consumer func(parent Parent))

ForEachParent executes a consumer func for each parent.

func (*Block) ID

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

ID computes the ID of the Block.

func (*Block) IDWithBlockIdentifier

func (b *Block) IDWithBlockIdentifier(blockIdentifier Identifier) BlockID

func (*Block) ManaCost

func (b *Block) ManaCost(rmc Mana) (Mana, error)

ManaCost returns the cost of the block in Mana, which is the given rmc multiplied by the block's workscore.

func (*Block) MustID

func (b *Block) MustID() BlockID

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

func (*Block) Parents

func (b *Block) Parents() (parents []BlockID)

func (*Block) ParentsWithType

func (b *Block) ParentsWithType() (parents []Parent)

func (*Block) SetDeserializationContext

func (b *Block) SetDeserializationContext(ctx context.Context)

func (*Block) Sign

func (b *Block) Sign(signer AddressSigner, addr Address) (Signature, error)

Sign produces a signature by signing the signing message of the block.

func (*Block) SigningMessage

func (b *Block) SigningMessage() ([]byte, error)

SigningMessage returns the to be signed message. The BlockHeader and Block are separately hashed and concatenated to enable the verification of the signature for an Attestation where only the BlockHeader and the hash of Block is known.

func (*Block) Size

func (b *Block) Size() int

Size returns the size of the block in bytes.

func (*Block) Slot

func (b *Block) Slot() SlotIndex

Slot returns the SlotIndex of the Block.

func (*Block) VerifySignature

func (b *Block) VerifySignature() (valid bool, err error)

VerifySignature verifies the Signature of the block.

func (*Block) WorkScore

func (b *Block) WorkScore() (WorkScore, error)

type BlockBody

type BlockBody interface {
	Type() BlockBodyType

	StrongParentIDs() BlockIDs
	WeakParentIDs() BlockIDs
	ShallowLikeParentIDs() BlockIDs

	Hash() (Identifier, error)

	ProcessableObject
	Sizer
	// contains filtered or unexported methods
}

type BlockBodyType

type BlockBodyType byte

BlockBodyType denotes a type of Block Body.

const (
	BlockBodyTypeBasic      BlockBodyType = 0
	BlockBodyTypeValidation BlockBodyType = 1
)

type BlockHeader

type BlockHeader struct {
	ProtocolVersion Version   `serix:""`
	NetworkID       NetworkID `serix:""`

	IssuingTime         time.Time    `serix:""`
	SlotCommitmentID    CommitmentID `serix:""`
	LatestFinalizedSlot SlotIndex    `serix:""`

	IssuerID AccountID `serix:""`
}

func (*BlockHeader) Hash

func (b *BlockHeader) Hash(api API) (Identifier, error)

func (*BlockHeader) Size

func (b *BlockHeader) Size() int

type BlockID

type BlockID [BlockIDLength]byte

BlockID is a 32 byte hash value together with an 4 byte slot index.

func BlockIDFromBytes

func BlockIDFromBytes(b []byte) (BlockID, int, error)

BlockIDFromBytes returns a new BlockID represented by the passed bytes.

func BlockIDFromHexString

func BlockIDFromHexString(hex string) (BlockID, error)

BlockIDFromHexString converts the hex to a BlockID representation.

func BlockIDRepresentingData

func BlockIDRepresentingData(slot SlotIndex, data []byte) BlockID

BlockIDRepresentingData returns a new BlockID for the given data by hashing it with blake2b and associating it with the given slot index.

func MustBlockIDFromHexString

func MustBlockIDFromHexString(hex string) BlockID

MustBlockIDFromHexString converts the hex to a BlockID representation.

func NewBlockID

func NewBlockID(slot SlotIndex, idBytes Identifier) BlockID

func (BlockID) Alias

func (b BlockID) Alias() (alias string)

Alias returns the human-readable alias of the Identifier (or the base58 encoded bytes of no alias was set).

func (BlockID) Bytes

func (b BlockID) Bytes() ([]byte, error)

func (BlockID) Compare

func (b BlockID) Compare(other BlockID) int

Compare compares two BlockIDs.

func (BlockID) Empty

func (b BlockID) Empty() bool

Empty tells whether the BlockID is empty.

func (BlockID) Identifier

func (b BlockID) Identifier() Identifier

func (BlockID) Index

func (b BlockID) Index() SlotIndex

Index returns a slot index to conform with hive's IndexedID interface.

func (BlockID) MarshalText

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

func (BlockID) RegisterAlias

func (b BlockID) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the Identifier which will be used as a replacement for the String method.

func (BlockID) Slot

func (b BlockID) Slot() SlotIndex

func (BlockID) String

func (b BlockID) String() string

func (BlockID) ToHex

func (b BlockID) ToHex() string

ToHex converts the Identifier to its hex representation.

func (*BlockID) UnmarshalText

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

func (BlockID) UnregisterAlias

func (b BlockID) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

type BlockIDs

type BlockIDs []BlockID

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

func (ids BlockIDs) Sort()

Sort sorts the BlockIDs lexically and in-place.

func (BlockIDs) ToHex

func (ids BlockIDs) ToHex() []string

ToHex converts the BlockIDs to their hex representation.

type BlockIssuanceCreditInput

type BlockIssuanceCreditInput struct {
	AccountID AccountID `serix:""`
}

func (*BlockIssuanceCreditInput) Clone

func (*BlockIssuanceCreditInput) Compare

func (b *BlockIssuanceCreditInput) Compare(other ContextInput) int

func (*BlockIssuanceCreditInput) IsReadOnly

func (b *BlockIssuanceCreditInput) IsReadOnly() bool

func (*BlockIssuanceCreditInput) Size

func (b *BlockIssuanceCreditInput) Size() int

func (*BlockIssuanceCreditInput) Type

func (*BlockIssuanceCreditInput) WorkScore

func (b *BlockIssuanceCreditInput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type BlockIssuanceCredits

type BlockIssuanceCredits int64

BlockIssuanceCredits defines the type of block issuance credits.

type BlockIssuerFeature

type BlockIssuerFeature struct {
	ExpirySlot      SlotIndex       `serix:""`
	BlockIssuerKeys BlockIssuerKeys `serix:",lenPrefix=uint8"`
}

BlockIssuerFeature is a feature which indicates that this account can issue blocks. The feature includes a block issuer address as well as an expiry slot.

func (*BlockIssuerFeature) Clone

func (s *BlockIssuerFeature) Clone() Feature

func (*BlockIssuerFeature) Compare

func (s *BlockIssuerFeature) Compare(other Feature) int

func (*BlockIssuerFeature) Equal

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

func (*BlockIssuerFeature) Size

func (s *BlockIssuerFeature) Size() int

func (*BlockIssuerFeature) StorageScore

func (s *BlockIssuerFeature) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*BlockIssuerFeature) Type

func (s *BlockIssuerFeature) Type() FeatureType

func (*BlockIssuerFeature) WorkScore

func (s *BlockIssuerFeature) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type BlockIssuerKey

type BlockIssuerKey interface {
	Sizer
	NonEphemeralObject
	constraints.Cloneable[BlockIssuerKey]
	constraints.Equalable[BlockIssuerKey]
	constraints.Comparable[BlockIssuerKey]
	serializer.Byter

	// Type returns the BlockIssuerKeyType.
	Type() BlockIssuerKeyType
}

BlockIssuerKey is a key that is allowed to issue blocks from an account with a BlockIssuerFeature.

func BlockIssuerKeyFromBytes

func BlockIssuerKeyFromBytes(bytes []byte) (BlockIssuerKey, int, error)

func BlockIssuerKeyFromReader

func BlockIssuerKeyFromReader(reader io.ReadSeeker) (BlockIssuerKey, error)

type BlockIssuerKeyType

type BlockIssuerKeyType byte

BlockIssuerKeyType defines the type of block issuer key.

const (
	// BlockIssuerKeyPublicKeyHash denotes a Ed25519PublicKeyHashBlockIssuerKey.
	BlockIssuerKeyPublicKeyHash BlockIssuerKeyType = iota
)

type BlockIssuerKeys

type BlockIssuerKeys []BlockIssuerKey

BlockIssuerKeys are the keys allowed to issue blocks from an account with a BlockIssuerFeature.

func BlockIssuerKeysFromReader

func BlockIssuerKeysFromReader(reader io.ReadSeeker) (BlockIssuerKeys, error)

func NewBlockIssuerKeys

func NewBlockIssuerKeys(blockIssuerKey ...BlockIssuerKey) BlockIssuerKeys

func (*BlockIssuerKeys) Add

func (keys *BlockIssuerKeys) Add(key BlockIssuerKey)

Add adds a new block issuer key if it doesn't exist yet.

func (BlockIssuerKeys) Bytes

func (keys BlockIssuerKeys) Bytes() ([]byte, error)

func (BlockIssuerKeys) Clone

func (keys BlockIssuerKeys) Clone() BlockIssuerKeys

func (BlockIssuerKeys) Equal

func (keys BlockIssuerKeys) Equal(other BlockIssuerKeys) bool

func (BlockIssuerKeys) Has

func (keys BlockIssuerKeys) Has(key BlockIssuerKey) bool

Has checks if a block issuer key exists.

func (*BlockIssuerKeys) Remove

func (keys *BlockIssuerKeys) Remove(key BlockIssuerKey)

Remove removes a block issuer key in case it exists.

func (BlockIssuerKeys) Size

func (keys BlockIssuerKeys) Size() int

Size returns the size of the block issuer key when serialized.

func (BlockIssuerKeys) Sort

func (keys BlockIssuerKeys) Sort()

Sort sorts the BlockIssuerKeys in place.

func (BlockIssuerKeys) StorageScore

func (keys BlockIssuerKeys) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

type CandidacyAnnouncement

type CandidacyAnnouncement struct {
}

CandidacyAnnouncement is a payload which is used to indicate candidacy for committee selection for the next epoch.

func (*CandidacyAnnouncement) Clone

func (u *CandidacyAnnouncement) Clone() Payload

func (*CandidacyAnnouncement) PayloadType

func (u *CandidacyAnnouncement) PayloadType() PayloadType

func (*CandidacyAnnouncement) Size

func (u *CandidacyAnnouncement) Size() int

func (*CandidacyAnnouncement) WorkScore

func (u *CandidacyAnnouncement) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type ChainAddress

type ChainAddress interface {
	Address
	ChainID() ChainID
}

ChainAddress is a type of Address representing ownership of an output by a ChainOutput.

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 ChainAddress.
	Addressable() bool
	// ToAddress converts this ChainID into an ChainAddress.
	ToAddress() ChainAddress
	// Empty tells whether the ChainID is empty.
	Empty() bool
	// ToHex returns the hex representation of the ChainID.
	ToHex() string
}

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

type ChainOutput

type ChainOutput interface {
	Output
	// ChainID returns the ChainID to which this Output belongs to.
	ChainID() ChainID
}

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

type ChainOutputImmutable

type ChainOutputImmutable interface {
	ChainOutput
	// ImmutableFeatureSet returns the immutable FeatureSet this output contains.
	ImmutableFeatureSet() FeatureSet
}

ChainOutputImmutable is a type of Output which represents a chain of state transitions with immutable features.

type ChainOutputSet

type ChainOutputSet map[ChainID]ChainOutput

ChainOutputSet is a map of ChainID to ChainOutput.

type ChainTransitionType

type ChainTransitionType byte

ChainTransitionType defines the type of transition a ChainOutput 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 Commitment

type Commitment struct {
	ProtocolVersion      Version      `serix:""`
	Slot                 SlotIndex    `serix:""`
	PreviousCommitmentID CommitmentID `serix:""`
	RootsID              Identifier   `serix:""`
	CumulativeWeight     uint64       `serix:""`
	ReferenceManaCost    Mana         `serix:""`
}

func NewCommitment

func NewCommitment(version Version, slot SlotIndex, prevID CommitmentID, rootsID Identifier, cumulativeWeight uint64, rmc Mana) *Commitment

func NewEmptyCommitment

func NewEmptyCommitment(api API) *Commitment

func (*Commitment) Equals

func (c *Commitment) Equals(other *Commitment) bool

func (*Commitment) ID

func (c *Commitment) ID() (CommitmentID, error)

func (*Commitment) MustID

func (c *Commitment) MustID() CommitmentID

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

func (*Commitment) Size

func (c *Commitment) Size() int

func (*Commitment) String

func (c *Commitment) String() string

func (*Commitment) Type

func (c *Commitment) Type() ContextInputType

type CommitmentID

type CommitmentID [CommitmentIDLength]byte

CommitmentID is a 32 byte hash value together with an 4 byte slot index.

func CommitmentIDFromBytes

func CommitmentIDFromBytes(b []byte) (CommitmentID, int, error)

CommitmentIDFromBytes returns a new CommitmentID represented by the passed bytes.

func CommitmentIDFromHexString

func CommitmentIDFromHexString(hex string) (CommitmentID, error)

CommitmentIDFromHexString converts the hex to a CommitmentID representation.

func CommitmentIDRepresentingData

func CommitmentIDRepresentingData(slot SlotIndex, data []byte) CommitmentID

CommitmentIDRepresentingData returns a new CommitmentID for the given data by hashing it with blake2b and associating it with the given slot index.

func MustCommitmentIDFromHexString

func MustCommitmentIDFromHexString(hex string) CommitmentID

MustCommitmentIDFromHexString converts the hex to a CommitmentID representation.

func NewCommitmentID

func NewCommitmentID(slot SlotIndex, idBytes Identifier) CommitmentID

func (CommitmentID) Alias

func (c CommitmentID) Alias() (alias string)

Alias returns the human-readable alias of the Identifier (or the base58 encoded bytes of no alias was set).

func (CommitmentID) Bytes

func (c CommitmentID) Bytes() ([]byte, error)

func (CommitmentID) Compare

func (c CommitmentID) Compare(other CommitmentID) int

Compare compares two CommitmentIDs.

func (CommitmentID) Empty

func (c CommitmentID) Empty() bool

Empty tells whether the CommitmentID is empty.

func (CommitmentID) Identifier

func (c CommitmentID) Identifier() Identifier

func (CommitmentID) Index

func (c CommitmentID) Index() SlotIndex

Index returns a slot index to conform with hive's IndexedID interface.

func (CommitmentID) MarshalText

func (c CommitmentID) MarshalText() (text []byte, err error)

func (CommitmentID) RegisterAlias

func (c CommitmentID) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the Identifier which will be used as a replacement for the String method.

func (CommitmentID) Slot

func (c CommitmentID) Slot() SlotIndex

func (CommitmentID) String

func (c CommitmentID) String() string

func (CommitmentID) ToHex

func (c CommitmentID) ToHex() string

ToHex converts the Identifier to its hex representation.

func (*CommitmentID) UnmarshalText

func (c *CommitmentID) UnmarshalText(text []byte) error

func (CommitmentID) UnregisterAlias

func (c CommitmentID) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

type CommitmentIDs

type CommitmentIDs []CommitmentID

func CommitmentIDsFromHexString

func CommitmentIDsFromHexString(CommitmentIDsHex []string) (CommitmentIDs, error)

CommitmentIDsFromHexString converts the given block IDs from their hex to CommitmentID representation.

func (CommitmentIDs) RemoveDupsAndSort

func (ids CommitmentIDs) RemoveDupsAndSort() CommitmentIDs

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

func (CommitmentIDs) Sort

func (ids CommitmentIDs) Sort()

Sort sorts the CommitmentIDs lexically and in-place.

func (CommitmentIDs) ToHex

func (ids CommitmentIDs) ToHex() []string

ToHex converts the CommitmentIDs to their hex representation.

type CommitmentInput

type CommitmentInput struct {
	CommitmentID CommitmentID `serix:""`
}

func (*CommitmentInput) Clone

func (c *CommitmentInput) Clone() ContextInput

func (*CommitmentInput) Compare

func (c *CommitmentInput) Compare(other ContextInput) int

func (*CommitmentInput) IsReadOnly

func (c *CommitmentInput) IsReadOnly() bool

func (*CommitmentInput) Size

func (c *CommitmentInput) Size() int

func (*CommitmentInput) Type

func (*CommitmentInput) WorkScore

func (c *CommitmentInput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type CongestionControlParameters

type CongestionControlParameters struct {
	// MinReferenceManaCost is the minimum value of the reference Mana cost.
	MinReferenceManaCost Mana `serix:""`
	// Increase is the increase step size of the reference Mana cost.
	Increase Mana `serix:""`
	// Decrease is the decrease step size of the reference Mana cost.
	Decrease Mana `serix:""`
	// IncreaseThreshold is the threshold for increasing the reference Mana cost.
	// This value should be between 0 and SchedulerRate*SlotDurationInSeconds.
	IncreaseThreshold WorkScore `serix:""`
	// DecreaseThreshold is the threshold for decreasing the reference Mana cost.
	// This value should be between 0 and SchedulerRate*SlotDurationInSeconds and must be less than or equal to IncreaseThreshold.
	DecreaseThreshold WorkScore `serix:""`
	// SchedulerRate is the rate at which the scheduler runs in workscore units per second.
	SchedulerRate WorkScore `serix:""`
	// MaxBufferSize is the maximum number of blocks in the DRR buffer.
	MaxBufferSize uint32 `serix:""`
	// MaxValidaitonBufferSize is the maximum number of blocks in the validation buffer.
	MaxValidationBufferSize uint32 `serix:""`
}

func (*CongestionControlParameters) Equals

type ContextInput

type ContextInput interface {
	Sizer
	constraints.Cloneable[ContextInput]
	constraints.Comparable[ContextInput]
	ProcessableObject

	// Type returns the type of ContextInput.
	Type() ContextInputType
}

ContextInput provides an additional contextual input for transaction validation.

type ContextInputType

type ContextInputType byte

ContextInputType defines the type of context inputs.

const (
	// ContextInputCommitment is a type of input which references a commitment.
	ContextInputCommitment ContextInputType = iota
	// ContextInputBlockIssuanceCredit is a type of input which references the block issuance credit from a specific account and commitment, the latter being provided by a commitment input.
	ContextInputBlockIssuanceCredit
	// ContextInputReward is a type of input which references an Account or Delegation Input for which to claim rewards.
	ContextInputReward
)

func (ContextInputType) String

func (inputType ContextInputType) String() string

type ContextInputs

type ContextInputs[T ContextInput] []T

ContextInputs is a slice of ContextInput.

func (ContextInputs[T]) Clone

func (in ContextInputs[T]) Clone() ContextInputs[T]

func (ContextInputs[T]) Size

func (in ContextInputs[T]) Size() int

func (ContextInputs[T]) Sort

func (in ContextInputs[T]) Sort()

Sort sorts the Context Inputs in lexical order.

func (ContextInputs[T]) WorkScore

func (in ContextInputs[T]) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type DelegationID

type DelegationID [DelegationIDLength]byte

DelegationID is the identifier for a Delegation Output. It is computed as the Blake2b-256 hash of the OutputID of the output which created the Delegation Output.

func DelegationIDFromOutputID

func DelegationIDFromOutputID(outputID OutputID) DelegationID

DelegationIDFromOutputID returns the DelegationID computed from a given OutputID.

func EmptyDelegationID

func EmptyDelegationID() DelegationID

func (DelegationID) Addressable

func (delegationID DelegationID) Addressable() bool

func (DelegationID) Empty

func (delegationID DelegationID) Empty() bool

func (DelegationID) FromOutputID

func (delegationID DelegationID) FromOutputID(outid OutputID) ChainID

func (DelegationID) Matches

func (delegationID DelegationID) Matches(other ChainID) bool

func (DelegationID) String

func (delegationID DelegationID) String() string

func (DelegationID) ToAddress

func (delegationID DelegationID) ToAddress() ChainAddress

func (DelegationID) ToHex

func (delegationID DelegationID) ToHex() string

type DelegationIDs

type DelegationIDs []DelegationID

DelegationIDs are DelegationID(s).

type DelegationOutput

type DelegationOutput struct {
	// The amount of IOTA tokens held by the output.
	Amount BaseToken `serix:""`
	// The amount of IOTA tokens that were delegated when the output was created.
	DelegatedAmount BaseToken `serix:""`
	// The identifier for this output.
	DelegationID DelegationID `serix:""`
	// The Account ID of the validator to which this output is delegating.
	ValidatorAddress *AccountAddress `serix:""`
	// The index of the first epoch for which this output delegates.
	StartEpoch EpochIndex `serix:""`
	// The index of the last epoch for which this output delegates.
	EndEpoch EpochIndex `serix:""`
	// The unlock conditions on this output.
	UnlockConditions DelegationOutputUnlockConditions `serix:",omitempty"`
}

DelegationOutput is an output type used to implement delegation.

func (*DelegationOutput) BaseTokenAmount

func (d *DelegationOutput) BaseTokenAmount() BaseToken

func (*DelegationOutput) ChainID

func (d *DelegationOutput) ChainID() ChainID

func (*DelegationOutput) Clone

func (d *DelegationOutput) Clone() Output

func (*DelegationOutput) Equal

func (d *DelegationOutput) Equal(other Output) bool

func (*DelegationOutput) FeatureSet

func (d *DelegationOutput) FeatureSet() FeatureSet

func (*DelegationOutput) Owner

func (d *DelegationOutput) Owner() Address

func (*DelegationOutput) Size

func (d *DelegationOutput) Size() int

func (*DelegationOutput) StorageScore

func (d *DelegationOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*DelegationOutput) StoredMana

func (d *DelegationOutput) StoredMana() Mana

func (*DelegationOutput) Type

func (d *DelegationOutput) Type() OutputType

func (*DelegationOutput) UnlockConditionSet

func (d *DelegationOutput) UnlockConditionSet() UnlockConditionSet

func (*DelegationOutput) UnlockableBy

func (d *DelegationOutput) UnlockableBy(addr Address, pastBoundedSlot SlotIndex, futureBoundedSlot SlotIndex) bool

func (*DelegationOutput) WorkScore

func (d *DelegationOutput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type DelegationOutputUnlockCondition

type DelegationOutputUnlockCondition interface{ UnlockCondition }

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

func Ed25519AddressFromReader(reader io.Reader) (*Ed25519Address, error)

Ed25519AddressFromReader parses the Ed25519Address from the given reader.

func (*Ed25519Address) Bech32

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

func (*Ed25519Address) Clone

func (addr *Ed25519Address) Clone() Address

func (*Ed25519Address) Equal

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

func (*Ed25519Address) ID

func (addr *Ed25519Address) ID() []byte

func (*Ed25519Address) Key

func (addr *Ed25519Address) Key() string

func (*Ed25519Address) Size

func (addr *Ed25519Address) Size() int

func (*Ed25519Address) StorageScore

func (*Ed25519Address) String

func (addr *Ed25519Address) String() string

func (*Ed25519Address) Type

func (addr *Ed25519Address) Type() AddressType

func (*Ed25519Address) Unlock

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

type Ed25519PublicKeyHashBlockIssuerKey

type Ed25519PublicKeyHashBlockIssuerKey struct {
	PublicKeyHash [Ed25519PublicKeyHashBytesLength]byte `serix:"pubKeyHash"`
}

An Ed25519 Address Block Issuer Key.

func Ed25519PublicKeyHashBlockIssuerKeyFromBytes

func Ed25519PublicKeyHashBlockIssuerKeyFromBytes(bytes []byte) (*Ed25519PublicKeyHashBlockIssuerKey, int, error)

func Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress

func Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress(address *ImplicitAccountCreationAddress) *Ed25519PublicKeyHashBlockIssuerKey

Ed25519PublicKeyHashBlockIssuerKeyFromImplicitAccountCreationAddress creates an Ed25519PublicKeyHashBlockIssuerKey from an Ed25519 public key hash.

func Ed25519PublicKeyHashBlockIssuerKeyFromPublicKey

func Ed25519PublicKeyHashBlockIssuerKeyFromPublicKey(pubKey hiveEd25519.PublicKey) *Ed25519PublicKeyHashBlockIssuerKey

Ed25519PublicKeyHashBlockIssuerKeyFromPublicKey creates an Ed25519PublicKeyHashBlockIssuerKey from an Ed25519 public key.

func (*Ed25519PublicKeyHashBlockIssuerKey) Bytes

func (key *Ed25519PublicKeyHashBlockIssuerKey) Bytes() ([]byte, error)

Bytes returns a byte slice consisting of the type prefix and the raw address.

func (*Ed25519PublicKeyHashBlockIssuerKey) Clone

func (*Ed25519PublicKeyHashBlockIssuerKey) Compare

func (*Ed25519PublicKeyHashBlockIssuerKey) Equal

func (*Ed25519PublicKeyHashBlockIssuerKey) Size

Size returns the size of the block issuer key when serialized.

func (*Ed25519PublicKeyHashBlockIssuerKey) StorageScore

func (key *Ed25519PublicKeyHashBlockIssuerKey) StorageScore(storageScoreStructure *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*Ed25519PublicKeyHashBlockIssuerKey) Type

Type returns the BlockIssuerKeyType.

type Ed25519Signature

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

Ed25519Signature defines an Ed25519 signature.

func (*Ed25519Signature) Clone

func (e *Ed25519Signature) Clone() Signature

func (*Ed25519Signature) Decode

func (e *Ed25519Signature) Decode(b []byte) (int, error)

func (*Ed25519Signature) Encode

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

func (*Ed25519Signature) MatchesAddress

func (e *Ed25519Signature) MatchesAddress(addr Address) bool

MatchesAddress checks whether the given address matches the public key of the signature.

func (*Ed25519Signature) SignerUID

func (e *Ed25519Signature) SignerUID() Identifier

SignerUID returns the unique identifier of the signature's signer. This can be used to identify the uniqueness of the signer in the unlocks (e.g. unique public key).

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

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

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

func (*Ed25519Signature) WorkScore

func (e *Ed25519Signature) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type ElementValidationFunc

type ElementValidationFunc[T any] func(index int, next T) error

ElementValidationFunc is a func that, given the index of a slice element and the element itself runs syntactical validations and returns an error if it fails.

func ContextInputsCommitmentInputRequirement

func ContextInputsCommitmentInputRequirement() ElementValidationFunc[ContextInput]

ContextInputsCommitmentInputRequirement returns an ElementValidationFunc which checks that a Commitment Input is present if a BIC or Reward Input is present.

func ContextInputsRewardInputMaxIndex

func ContextInputsRewardInputMaxIndex(inputsCount uint16) ElementValidationFunc[ContextInput]

ContextInputsRewardInputMaxIndex returns a ElementValidationFunc which checks that every Reward Input references an index <= max inputs count.

func InputsSyntacticalIndicesWithinBounds

func InputsSyntacticalIndicesWithinBounds() ElementValidationFunc[Input]

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

func InputsSyntacticalUnique

func InputsSyntacticalUnique() ElementValidationFunc[Input]

InputsSyntacticalUnique returns an ElementValidationFunc which checks that every input has a unique reference UTXO index.

func LexicalOrderAndUniquenessValidator

func LexicalOrderAndUniquenessValidator[T constraints.Comparable[T]]() ElementValidationFunc[T]

An ElementValidationFunc that checks lexical order and uniqueness based on the Compare implementation.

func OutputsSyntacticalAccount

func OutputsSyntacticalAccount() ElementValidationFunc[Output]

OutputsSyntacticalAccount returns an ElementValidationFunc[Output] which checks that AccountOutput(s)':

  • FoundryCounter is zero if the AccountID is zeroed
  • Address must be different from AccountAddress derived from AccountID
  • Amount must be greater than or equal to StakedAmount of staking feature if it is present

func OutputsSyntacticalAddressRestrictions

func OutputsSyntacticalAddressRestrictions() ElementValidationFunc[Output]

OutputsSyntacticalAddressRestrictions returns a func that checks the capability flag restrictions on addresses.

Does not validate the Return Address in StorageDepositReturnUnlockCondition because such a Return Address already is as restricted as the most restricted address.

func OutputsSyntacticalAnchor

func OutputsSyntacticalAnchor() ElementValidationFunc[Output]

OutputsSyntacticalAnchor returns an ElementValidationFunc[Output] which checks that AnchorOutput(s)':

  • StateIndex is zero if the AnchorID is zeroed
  • StateController and GovernanceController must be different from AnchorAddress derived from AnchorID

func OutputsSyntacticalChainConstrainedOutputUniqueness

func OutputsSyntacticalChainConstrainedOutputUniqueness() ElementValidationFunc[Output]

Checks that a chain-constrained output with a certain ChainID is unique on the output side.

func OutputsSyntacticalCommitmentInput

func OutputsSyntacticalCommitmentInput(hasCommitmentInput bool) ElementValidationFunc[Output]

Checks that a Commitment Input is present for

  • Accounts with a Staking Feature.
  • Accounts with a Block Issuer Feature.
  • Delegation Outputs.

func OutputsSyntacticalDelegation

func OutputsSyntacticalDelegation() ElementValidationFunc[Output]

OutputsSyntacticalDelegation returns an ElementValidationFunc[Output] which checks that DelegationOutput(s)':

  • Validator ID is not zeroed out.

func OutputsSyntacticalDepositAmount

func OutputsSyntacticalDepositAmount(protoParams ProtocolParameters, storageScoreStructure *StorageScoreStructure) ElementValidationFunc[Output]

OutputsSyntacticalDepositAmount returns an ElementValidationFunc[Output] which checks that:

  • every output has base token amount more than zero
  • the sum of base token amounts does not exceed the total supply
  • the base token amount fulfills the minimum storage deposit as calculated from the storage score 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() ElementValidationFunc[Output]

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

func OutputsSyntacticalFeaturesLexicalOrderAndUniqueness

func OutputsSyntacticalFeaturesLexicalOrderAndUniqueness() ElementValidationFunc[Output]

Checks lexical order and uniqueness of the output's features and immutable features.

func OutputsSyntacticalFoundry

func OutputsSyntacticalFoundry() ElementValidationFunc[Output]

OutputsSyntacticalFoundry returns an ElementValidationFunc[Output] which checks that FoundryOutput(s)':

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

func OutputsSyntacticalImplicitAccountCreationAddress

func OutputsSyntacticalImplicitAccountCreationAddress() ElementValidationFunc[Output]

func OutputsSyntacticalMetadataFeatureMaxSize

func OutputsSyntacticalMetadataFeatureMaxSize() ElementValidationFunc[Output]

Checks that the (state) metadata feature in outputs do not exceed the max allowed size.

func OutputsSyntacticalNFT

func OutputsSyntacticalNFT() ElementValidationFunc[Output]

OutputsSyntacticalNFT returns an ElementValidationFunc[Output] which checks that NFTOutput(s)':

  • Address must be different from NFTAddress derived from NFTID

func OutputsSyntacticalNativeTokens

func OutputsSyntacticalNativeTokens() ElementValidationFunc[Output]

OutputsSyntacticalNativeTokens returns an ElementValidationFunc[Output] which checks that:

  • each native token holds an amount bigger than zero

func OutputsSyntacticalStoredMana

func OutputsSyntacticalStoredMana(maxManaValue Mana) ElementValidationFunc[Output]

OutputsSyntacticalStoredMana returns an ElementValidationFunc[Output] which checks that:

  • the sum of all stored mana fields does not exceed 2^(Mana Bits Count) - 1.

func OutputsSyntacticalUnlockConditionLexicalOrderAndUniqueness

func OutputsSyntacticalUnlockConditionLexicalOrderAndUniqueness() ElementValidationFunc[Output]

Checks lexical order and uniqueness of the output's unlock conditions.

type EmptyUnlock

type EmptyUnlock struct{}

EmptyUnlock are simply skipped. They are used to maintain correct index relationship between addresses and signatures if the signer doesn't know the signature of another signer.

func (*EmptyUnlock) Clone

func (u *EmptyUnlock) Clone() Unlock

func (*EmptyUnlock) Size

func (u *EmptyUnlock) Size() int

func (*EmptyUnlock) Type

func (u *EmptyUnlock) Type() UnlockType

func (*EmptyUnlock) WorkScore

func (u *EmptyUnlock) WorkScore(_ *WorkScoreParameters) (WorkScore, error)

type EpochBasedProvider

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

func NewEpochBasedProvider

func NewEpochBasedProvider(opts ...options.Option[EpochBasedProvider]) *EpochBasedProvider

func (*EpochBasedProvider) APIForEpoch

func (e *EpochBasedProvider) APIForEpoch(epoch EpochIndex) API

func (*EpochBasedProvider) APIForSlot

func (e *EpochBasedProvider) APIForSlot(slot SlotIndex) API

func (*EpochBasedProvider) APIForTime

func (e *EpochBasedProvider) APIForTime(t time.Time) API

func (*EpochBasedProvider) APIForVersion

func (e *EpochBasedProvider) APIForVersion(version Version) (API, error)

func (*EpochBasedProvider) AddFutureVersion

func (e *EpochBasedProvider) AddFutureVersion(version Version, protocolParamsHash Identifier, epoch EpochIndex)

func (*EpochBasedProvider) AddProtocolParameters

func (e *EpochBasedProvider) AddProtocolParameters(protocolParameters ProtocolParameters)

func (*EpochBasedProvider) AddProtocolParametersAtEpoch

func (e *EpochBasedProvider) AddProtocolParametersAtEpoch(protocolParameters ProtocolParameters, epoch EpochIndex)

func (*EpochBasedProvider) AddVersion

func (e *EpochBasedProvider) AddVersion(version Version, epoch EpochIndex)

func (*EpochBasedProvider) CommittedAPI

func (e *EpochBasedProvider) CommittedAPI() API

func (*EpochBasedProvider) EpochForVersion

func (e *EpochBasedProvider) EpochForVersion(version Version) (EpochIndex, bool)

func (*EpochBasedProvider) LatestAPI

func (e *EpochBasedProvider) LatestAPI() API

func (*EpochBasedProvider) ProtocolEpochVersions

func (e *EpochBasedProvider) ProtocolEpochVersions() []ProtocolEpochVersion

func (*EpochBasedProvider) ProtocolParameters

func (e *EpochBasedProvider) ProtocolParameters(version Version) ProtocolParameters

func (*EpochBasedProvider) ProtocolParametersHash

func (e *EpochBasedProvider) ProtocolParametersHash(version Version) Identifier

func (*EpochBasedProvider) SetCommittedSlot

func (e *EpochBasedProvider) SetCommittedSlot(slot SlotIndex)

func (*EpochBasedProvider) VersionForSlot

func (e *EpochBasedProvider) VersionForSlot(slot SlotIndex) Version

func (*EpochBasedProvider) VersionsAndProtocolParametersHash

func (e *EpochBasedProvider) VersionsAndProtocolParametersHash() (Identifier, error)

type EpochIndex

type EpochIndex uint32

EpochIndex is the index of an epoch.

func EpochIndexFromBytes

func EpochIndexFromBytes(b []byte) (EpochIndex, int, error)

func (EpochIndex) Bytes

func (i EpochIndex) Bytes() ([]byte, error)

func (EpochIndex) MustBytes

func (i EpochIndex) MustBytes() []byte

func (EpochIndex) String

func (i EpochIndex) String() string

type ExpirationUnlockCondition

type ExpirationUnlockCondition struct {
	// The address who is allowed to use the output after the expiration has happened.
	ReturnAddress Address `serix:""`
	// The slot index at which the expiration happens.
	Slot SlotIndex `serix:""`
}

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

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

func (*ExpirationUnlockCondition) Clone

func (*ExpirationUnlockCondition) Compare

func (s *ExpirationUnlockCondition) Compare(other UnlockCondition) int

func (*ExpirationUnlockCondition) Equal

func (*ExpirationUnlockCondition) Size

func (s *ExpirationUnlockCondition) Size() int

func (*ExpirationUnlockCondition) StorageScore

func (s *ExpirationUnlockCondition) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*ExpirationUnlockCondition) Type

func (*ExpirationUnlockCondition) WorkScore

type Feature

type Feature interface {
	Sizer
	NonEphemeralObject
	ProcessableObject
	constraints.Cloneable[Feature]
	constraints.Equalable[Feature]
	constraints.Comparable[Feature]

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

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

type FeatureSet

type FeatureSet map[FeatureType]Feature

FeatureSet is a set of Feature(s).

func (FeatureSet) BlockIssuer

func (f FeatureSet) BlockIssuer() *BlockIssuerFeature

BlockIssuer returns the BlockIssuerFeature in the set or nil.

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

func (f FeatureSet) HasNativeTokenFeature() bool

HasNativeTokenFeature tells whether this set has a FeatureNativeToken.

func (FeatureSet) Issuer

func (f FeatureSet) Issuer() *IssuerFeature

Issuer returns the IssuerFeature in the set or nil.

func (FeatureSet) Metadata

func (f FeatureSet) Metadata() *MetadataFeature

Metadata returns the MetadataFeature in the set or nil.

func (FeatureSet) NativeToken

func (f FeatureSet) NativeToken() *NativeTokenFeature

NativeToken returns the NativeTokenFeature in the set or nil.

func (FeatureSet) SenderFeature

func (f FeatureSet) SenderFeature() *SenderFeature

SenderFeature returns the SenderFeature in the set or nil.

func (FeatureSet) Staking

func (f FeatureSet) Staking() *StakingFeature

Staking returns the StakingFeature in the set or nil.

func (FeatureSet) StateMetadata

func (f FeatureSet) StateMetadata() *StateMetadataFeature

StateMetadata returns the StateMetadataFeature in the set or nil.

func (FeatureSet) Tag

func (f FeatureSet) Tag() *TagFeature

Tag returns the TagFeature in the set or nil.

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
	// FeatureStateMetadata denotes a StateMetadataFeature.
	FeatureStateMetadata
	// FeatureTag denotes a TagFeature.
	FeatureTag
	// NativeTokenFeature denotes a NativeTokenFeature.
	FeatureNativeToken
	// FeatureBlockIssuer denotes a BlockIssuerFeature.
	FeatureBlockIssuer
	// FeatureStaking denotes a StakingFeature.
	FeatureStaking
)

func (FeatureType) String

func (featType FeatureType) String() string

type Features

type Features[T Feature] []T

Features is a slice of Feature(s).

func (Features[T]) Clone

func (f Features[T]) Clone() Features[T]

Clone clones the Features.

func (Features[T]) Equal

func (f Features[T]) Equal(other Features[T]) bool

Equal checks whether this slice is equal to other.

func (Features[T]) MustSet

func (f Features[T]) 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[T]) Remove

func (f *Features[T]) Remove(featureType FeatureType) bool

Remove removes the feature with the given type.

func (Features[T]) Set

func (f Features[T]) Set() (FeatureSet, error)

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

func (Features[T]) Size

func (f Features[T]) Size() int

func (Features[T]) Sort

func (f Features[T]) Sort()

Sort sorts the Features in place by type.

func (Features[T]) StorageScore

func (f Features[T]) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*Features[T]) Upsert

func (f *Features[T]) Upsert(feature T)

Upsert adds the given feature or updates the previous one if existing.

func (Features[T]) WorkScore

func (f Features[T]) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type FoundryID

type FoundryID [FoundryIDLength]byte

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

func (FoundryID) AccountAddress

func (fID FoundryID) AccountAddress() (*AccountAddress, error)

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

func (fID FoundryID) Matches(other ChainID) bool

func (FoundryID) String

func (fID FoundryID) String() string

func (FoundryID) ToAddress

func (fID FoundryID) ToAddress() ChainAddress

func (FoundryID) ToHex

func (fID FoundryID) ToHex() string

type FoundryOutput

type FoundryOutput struct {
	// The amount of IOTA tokens held by the output.
	Amount BaseToken `serix:""`
	// The serial number of the foundry.
	SerialNumber uint32 `serix:""`
	// The token scheme this foundry uses.
	TokenScheme TokenScheme `serix:""`
	// The unlock conditions on this output.
	UnlockConditions FoundryOutputUnlockConditions `serix:",omitempty"`
	// The feature on the output.
	Features FoundryOutputFeatures `serix:",omitempty"`
	// The immutable feature on the output.
	ImmutableFeatures FoundryOutputImmFeatures `serix:",omitempty"`
}

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

func (*FoundryOutput) BaseTokenAmount

func (f *FoundryOutput) BaseTokenAmount() BaseToken

func (*FoundryOutput) ChainID

func (f *FoundryOutput) ChainID() ChainID

func (*FoundryOutput) Clone

func (f *FoundryOutput) Clone() Output

func (*FoundryOutput) Equal

func (f *FoundryOutput) Equal(other Output) bool

func (*FoundryOutput) FeatureSet

func (f *FoundryOutput) FeatureSet() FeatureSet

func (*FoundryOutput) FoundryID

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

FoundryID returns the FoundryID of this FoundryOutput.

func (*FoundryOutput) ImmutableFeatureSet

func (f *FoundryOutput) ImmutableFeatureSet() FeatureSet

func (*FoundryOutput) MustFoundryID

func (f *FoundryOutput) MustFoundryID() FoundryID

MustFoundryID works like FoundryID 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) Owner

func (f *FoundryOutput) Owner() Address

func (*FoundryOutput) Size

func (f *FoundryOutput) Size() int

func (*FoundryOutput) StorageScore

func (f *FoundryOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*FoundryOutput) StoredMana

func (f *FoundryOutput) StoredMana() Mana

func (*FoundryOutput) Type

func (f *FoundryOutput) Type() OutputType

func (*FoundryOutput) UnlockConditionSet

func (f *FoundryOutput) UnlockConditionSet() UnlockConditionSet

func (*FoundryOutput) UnlockableBy

func (f *FoundryOutput) UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool

func (*FoundryOutput) WorkScore

func (f *FoundryOutput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type FoundryOutputFeature

type FoundryOutputFeature interface{ Feature }

type FoundryOutputFeatures

type FoundryOutputFeatures = Features[FoundryOutputFeature]

type FoundryOutputImmFeature

type FoundryOutputImmFeature interface{ Feature }

type FoundryOutputImmFeatures

type FoundryOutputImmFeatures = Features[FoundryOutputImmFeature]

type FoundryOutputUnlockCondition

type FoundryOutputUnlockCondition interface{ UnlockCondition }

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 `serix:""`
}

GovernorAddressUnlockCondition is an UnlockCondition defining the governor address for an AccountOutput.

func (*GovernorAddressUnlockCondition) Clone

func (*GovernorAddressUnlockCondition) Compare

func (*GovernorAddressUnlockCondition) Equal

func (*GovernorAddressUnlockCondition) Size

func (*GovernorAddressUnlockCondition) StorageScore

func (*GovernorAddressUnlockCondition) Type

func (*GovernorAddressUnlockCondition) WorkScore

type HexOutputID

type HexOutputID string

type HexOutputIDs

type HexOutputIDs []HexOutputID

HexOutputIDs is a slice of hex encoded OutputID strings.

func HexOutputIDsFromOutputIDs

func HexOutputIDsFromOutputIDs(outputIDs ...OutputID) HexOutputIDs

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 Identifier

type Identifier [IdentifierLength]byte

Identifier is a 32 byte hash value.

func BlockIdentifierFromBlockBytes

func BlockIdentifierFromBlockBytes(blockBytes []byte) (Identifier, error)

func IdentifierFromBytes

func IdentifierFromBytes(bytes []byte) (Identifier, int, error)

func IdentifierFromData

func IdentifierFromData(data []byte) Identifier

IdentifierFromData returns a new Identifier for the given data by hashing it with blake2b.

func IdentifierFromHexString

func IdentifierFromHexString(hex string) (Identifier, error)

IdentifierFromHexString converts the hex to an Identifier representation.

func MustIdentifierFromHexString

func MustIdentifierFromHexString(hex string) Identifier

MustIdentifierFromHexString converts the hex to an Identifier representation.

func (Identifier) Alias

func (i Identifier) Alias() (alias string)

Alias returns the human-readable alias of the Identifier (or the hex encoded bytes if no alias was set).

func (Identifier) Bytes

func (i Identifier) Bytes() ([]byte, error)

func (Identifier) Empty

func (i Identifier) Empty() bool

Empty tells whether the Identifier is empty.

func (Identifier) MarshalText

func (i Identifier) MarshalText() (text []byte, err error)

func (Identifier) RegisterAlias

func (i Identifier) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the Identifier which will be used as a replacement for the String method.

func (Identifier) String

func (i Identifier) String() string

func (Identifier) ToHex

func (i Identifier) ToHex() string

ToHex converts the Identifier to its hex representation.

func (*Identifier) UnmarshalText

func (i *Identifier) UnmarshalText(text []byte) error

func (Identifier) UnregisterAlias

func (i Identifier) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

type Identifiers

type Identifiers []Identifier

type ImmutableAccountUnlockCondition

type ImmutableAccountUnlockCondition struct {
	Address *AccountAddress `serix:""`
}

ImmutableAccountUnlockCondition is an UnlockCondition defining an account 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 ChainOutput(s).

func (*ImmutableAccountUnlockCondition) Clone

func (*ImmutableAccountUnlockCondition) Compare

func (*ImmutableAccountUnlockCondition) Equal

func (*ImmutableAccountUnlockCondition) Size

func (*ImmutableAccountUnlockCondition) StorageScore

func (*ImmutableAccountUnlockCondition) Type

func (*ImmutableAccountUnlockCondition) WorkScore

type ImplicitAccountCreationAddress

type ImplicitAccountCreationAddress [ImplicitAccountCreationAddressBytesLength]byte

ImplicitAccountCreationAddress defines an ImplicitAccountCreationAddress. An ImplicitAccountCreationAddress is an address that is used to create implicit accounts by sending basic outputs to it.

func ImplicitAccountCreationAddressFromPubKey

func ImplicitAccountCreationAddressFromPubKey(pubKey ed25519.PublicKey) *ImplicitAccountCreationAddress

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

func ImplicitAccountCreationAddressFromReader

func ImplicitAccountCreationAddressFromReader(reader io.Reader) (*ImplicitAccountCreationAddress, error)

ImplicitAccountCreationAddressFromReader parses the ImplicitAccountCreationAddress from the given reader.

func MustParseImplicitAccountCreationAddressFromHexString

func MustParseImplicitAccountCreationAddressFromHexString(hexAddr string) *ImplicitAccountCreationAddress

MustParseImplicitAccountCreationAddressFromHexString parses the given hex string into an ImplicitAccountCreationAddress. It panics if the hex address is invalid.

func ParseImplicitAccountCreationAddressFromHexString

func ParseImplicitAccountCreationAddressFromHexString(hexAddr string) (*ImplicitAccountCreationAddress, error)

ParseImplicitAccountCreationAddressFromHexString parses the given hex string into an ImplicitAccountCreationAddress.

func (*ImplicitAccountCreationAddress) Bech32

func (*ImplicitAccountCreationAddress) CannotReceiveAccountOutputs

func (addr *ImplicitAccountCreationAddress) CannotReceiveAccountOutputs() bool

func (*ImplicitAccountCreationAddress) CannotReceiveAnchorOutputs

func (addr *ImplicitAccountCreationAddress) CannotReceiveAnchorOutputs() bool

func (*ImplicitAccountCreationAddress) CannotReceiveDelegationOutputs

func (addr *ImplicitAccountCreationAddress) CannotReceiveDelegationOutputs() bool

func (*ImplicitAccountCreationAddress) CannotReceiveMana

func (addr *ImplicitAccountCreationAddress) CannotReceiveMana() bool

func (*ImplicitAccountCreationAddress) CannotReceiveNFTOutputs

func (addr *ImplicitAccountCreationAddress) CannotReceiveNFTOutputs() bool

func (*ImplicitAccountCreationAddress) CannotReceiveNativeTokens

func (addr *ImplicitAccountCreationAddress) CannotReceiveNativeTokens() bool

func (*ImplicitAccountCreationAddress) CannotReceiveOutputsWithExpirationUnlockCondition

func (addr *ImplicitAccountCreationAddress) CannotReceiveOutputsWithExpirationUnlockCondition() bool

func (*ImplicitAccountCreationAddress) CannotReceiveOutputsWithStorageDepositReturnUnlockCondition

func (addr *ImplicitAccountCreationAddress) CannotReceiveOutputsWithStorageDepositReturnUnlockCondition() bool

func (*ImplicitAccountCreationAddress) CannotReceiveOutputsWithTimelockUnlockCondition

func (addr *ImplicitAccountCreationAddress) CannotReceiveOutputsWithTimelockUnlockCondition() bool

func (*ImplicitAccountCreationAddress) Clone

func (*ImplicitAccountCreationAddress) Equal

func (addr *ImplicitAccountCreationAddress) Equal(other Address) bool

func (*ImplicitAccountCreationAddress) ID

func (addr *ImplicitAccountCreationAddress) ID() []byte

func (*ImplicitAccountCreationAddress) Key

func (*ImplicitAccountCreationAddress) Size

func (addr *ImplicitAccountCreationAddress) Size() int

func (*ImplicitAccountCreationAddress) StorageScore

func (addr *ImplicitAccountCreationAddress) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*ImplicitAccountCreationAddress) String

func (addr *ImplicitAccountCreationAddress) String() string

func (*ImplicitAccountCreationAddress) Type

func (*ImplicitAccountCreationAddress) Unlock

func (addr *ImplicitAccountCreationAddress) Unlock(msg []byte, sig Signature) error

type InMemoryAddressSigner

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

InMemoryAddressSigner implements AddressSigner by holding keys simply in-memory.

func (*InMemoryAddressSigner) EmptySignatureForAddress

func (s *InMemoryAddressSigner) EmptySignatureForAddress(addr Address) (signature Signature, err error)

EmptySignatureForAddress returns an empty signature for the given address. This can be used to calculate the WorkScore of transactions without actually signing the transaction.

func (*InMemoryAddressSigner) Sign

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

func (*InMemoryAddressSigner) SignerUIDForAddress

func (s *InMemoryAddressSigner) SignerUIDForAddress(addr Address) (Identifier, error)

SignerUIDForAddress returns the signer unique identifier for a given address. This can be used to identify the uniqueness of the signer in the unlocks.

type Input

type Input interface {
	Sizer
	constraints.Cloneable[Input]
	ProcessableObject

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

Input references a generic input.

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
)

func (InputType) String

func (inputType InputType) String() string

type Inputs

type Inputs[T Input] []T

Inputs is a slice of Input.

func (Inputs[T]) Clone

func (in Inputs[T]) Clone() Inputs[T]

func (Inputs[T]) Size

func (in Inputs[T]) Size() int

func (Inputs[T]) WorkScore

func (in Inputs[T]) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type IssuerFeature

type IssuerFeature struct {
	Address Address `serix:""`
}

IssuerFeature is a feature which associates an output with an issuer address. Unlike the SenderFeature, the issuer address only has to be unlocked when the ChainOutput is first created, afterwards, the issuer feature must not change, meaning that subsequent outputs must always define the same issuer address (the address does not need to be unlocked anymore though).

func (*IssuerFeature) Clone

func (s *IssuerFeature) Clone() Feature

func (*IssuerFeature) Compare

func (s *IssuerFeature) Compare(other Feature) int

func (*IssuerFeature) Equal

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

func (*IssuerFeature) Size

func (s *IssuerFeature) Size() int

func (*IssuerFeature) StorageScore

func (s *IssuerFeature) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*IssuerFeature) Type

func (s *IssuerFeature) Type() FeatureType

func (*IssuerFeature) WorkScore

func (s *IssuerFeature) WorkScore(_ *WorkScoreParameters) (WorkScore, error)

type Mana

type Mana uint64

Mana defines the type of the consumable resource e.g. used in congestion control.

func ManaCost

func ManaCost(rmc Mana, workScore WorkScore) (Mana, error)

func PotentialMana

func PotentialMana(manaDecayProvider *ManaDecayProvider, storageScoreStructure *StorageScoreStructure, output Output, creationSlot, targetSlot SlotIndex) (Mana, error)

Computes the Potential Mana that the output generates between creationSlot and targetSlot, while deducting the minimum deposit of the output which does not generate Mana.

Returns 0 if the output does not have the minimum storage deposit covered.

type ManaDecayProvider

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

ManaDecayProvider calculates the mana decay and mana generation using fixed point arithmetic and a precomputed lookup table.

func NewManaDecayProvider

func NewManaDecayProvider(
	timeProvider *TimeProvider,
	slotsPerEpochExponent uint8,
	manaParameters *ManaParameters,
) *ManaDecayProvider

func (*ManaDecayProvider) DecayManaByEpochs

func (p *ManaDecayProvider) DecayManaByEpochs(mana Mana, creationEpoch EpochIndex, targetEpoch EpochIndex) (Mana, error)

DecayManaByEpochs applies the decay between the creation and target epochs to the given mana.

func (*ManaDecayProvider) DecayManaBySlots

func (p *ManaDecayProvider) DecayManaBySlots(mana Mana, creationSlot SlotIndex, targetSlot SlotIndex) (Mana, error)

DecayManaBySlots applies the decay between the epochs corresponding to the creation and target slots to the given mana.

func (*ManaDecayProvider) GenerateManaAndDecayBySlots

func (p *ManaDecayProvider) GenerateManaAndDecayBySlots(amount BaseToken, creationSlot SlotIndex, targetSlot SlotIndex) (Mana, error)

GenerateManaAndDecayBySlots generates mana from the given base token amount and returns the decayed result.

type ManaParameters

type ManaParameters struct {
	// BitsCount is the number of bits used to represent Mana.
	BitsCount uint8 `serix:""`
	// GenerationRate is the amount of potential Mana generated by 1 microIOTA in 1 slot multiplied by 2^GenerationRateExponent.
	GenerationRate uint8 `serix:""`
	// GenerationRateExponent is the scaling of GenerationRate expressed as an exponent of 2.
	// The actual generation rate of Mana is given by GenerationRate * 2^(-GenerationRateExponent).
	GenerationRateExponent uint8 `serix:""`
	// DecayFactors is a lookup table of epoch diff to mana decay factor (slice index 0 = 1 epoch).
	// The actual decay factor is given by DecayFactors[epochDiff] * 2^(-DecayFactorsExponent).
	DecayFactors []uint32 `serix:",lenPrefix=uint16"`
	// DecayFactorsExponent is the scaling of DecayFactors expressed as an exponent of 2.
	DecayFactorsExponent uint8 `serix:""`
	// DecayFactorEpochsSum is an integer approximation of the sum of decay over epochs.
	DecayFactorEpochsSum uint32 `serix:""`
	// DecayFactorEpochsSumExponent is the scaling of DecayFactorEpochsSum expressed as an exponent of 2.
	DecayFactorEpochsSumExponent uint8 `serix:""`
	// AnnualDecayFactorPercentage is the decay factor for 1 year.
	AnnualDecayFactorPercentage uint8 `serix:""`
}

Mana Structure defines the parameters used in mana calculations.

func (ManaParameters) Equals

func (m ManaParameters) Equals(other ManaParameters) bool

type MetadataFeature

type MetadataFeature struct {
	Entries MetadataFeatureEntries `serix:""`
}

MetadataFeature is a feature which holds a map of key-value pairs. The keys must consist of ASCII characters only. The values are arbitrary byte slices.

func (MetadataFeature) Clone

func (m MetadataFeature) Clone() Feature

func (MetadataFeature) Compare

func (m MetadataFeature) Compare(other Feature) int

func (MetadataFeature) Equal

func (m MetadataFeature) Equal(other Feature) bool

func (MetadataFeature) Size

func (m MetadataFeature) Size() int

func (MetadataFeature) StorageScore

func (MetadataFeature) Type

func (m MetadataFeature) Type() FeatureType

func (MetadataFeature) WorkScore

type MetadataFeatureEntriesKey

type MetadataFeatureEntriesKey string

type MetadataFeatureEntriesValue

type MetadataFeatureEntriesValue []byte

type MultiAddress

type MultiAddress struct {
	Addresses AddressesWithWeight `serix:""`
	Threshold uint16              `serix:""`
}

MultiAddress defines a multi address that consists of addresses with weights and a threshold value that needs to be reached to unlock the multi address.

func NewMultiAddress

func NewMultiAddress(addresses AddressesWithWeight, threshold uint16) *MultiAddress

func (*MultiAddress) Bech32

func (addr *MultiAddress) Bech32(hrp NetworkPrefix) string

func (*MultiAddress) Clone

func (addr *MultiAddress) Clone() Address

func (*MultiAddress) Equal

func (addr *MultiAddress) Equal(other Address) bool

func (*MultiAddress) ID

func (addr *MultiAddress) ID() []byte

func (*MultiAddress) Key

func (addr *MultiAddress) Key() string

func (*MultiAddress) Size

func (addr *MultiAddress) Size() int

func (*MultiAddress) StorageScore

func (*MultiAddress) String

func (addr *MultiAddress) String() string

func (*MultiAddress) Type

func (addr *MultiAddress) Type() AddressType

type MultiAddressReference

type MultiAddressReference struct {
	MultiAddressID []byte
}

MultiAddressReference is a reference to a MultiAddress. HINT: This is not an actual AddressType that is used in the protocol, so it should not be registered in serix. It should only be used internally or in APIs.

func MultiAddressReferenceFromBytes

func MultiAddressReferenceFromBytes(bytes []byte) (*MultiAddressReference, int, error)

func NewMultiAddressReferenceFromMultiAddress

func NewMultiAddressReferenceFromMultiAddress(address *MultiAddress) *MultiAddressReference

func (*MultiAddressReference) Bech32

func (addr *MultiAddressReference) Bech32(hrp NetworkPrefix) string

func (*MultiAddressReference) Clone

func (addr *MultiAddressReference) Clone() Address

func (*MultiAddressReference) Equal

func (addr *MultiAddressReference) Equal(other Address) bool

func (*MultiAddressReference) ID

func (addr *MultiAddressReference) ID() []byte

func (*MultiAddressReference) Key

func (addr *MultiAddressReference) Key() string

func (*MultiAddressReference) Size

func (addr *MultiAddressReference) Size() int

func (*MultiAddressReference) StorageScore

func (*MultiAddressReference) String

func (addr *MultiAddressReference) String() string

func (*MultiAddressReference) Type

func (addr *MultiAddressReference) Type() AddressType

type MultiUnlock

type MultiUnlock struct {
	// The unlocks for this MultiUnlock.
	Unlocks []Unlock `serix:",lenPrefix=uint8,minLen=2,maxLen=10"`
}

MultiUnlock is an Unlock which holds a list of unlocks for a multi address.

func (*MultiUnlock) Clone

func (u *MultiUnlock) Clone() Unlock

func (*MultiUnlock) Size

func (u *MultiUnlock) Size() int

func (*MultiUnlock) Type

func (u *MultiUnlock) Type() UnlockType

func (*MultiUnlock) WorkScore

func (u *MultiUnlock) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type NFTAddress

type NFTAddress [NFTAddressBytesLength]byte

NFTAddress defines an NFTAddress. An NFTAddress is the Blake2b-256 hash of the OutputID which created it.

func NFTAddressFromOutputID

func NFTAddressFromOutputID(outputID OutputID) *NFTAddress

NFTAddressFromOutputID returns the NFTAddress computed from a given OutputID.

func NFTAddressFromReader

func NFTAddressFromReader(reader io.Reader) (*NFTAddress, error)

NFTAddressFromReader parses the NFTAddress from the given reader.

func (*NFTAddress) Bech32

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

func (*NFTAddress) ChainID

func (addr *NFTAddress) ChainID() ChainID

func (*NFTAddress) Clone

func (addr *NFTAddress) Clone() Address

func (*NFTAddress) Equal

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

func (*NFTAddress) ID

func (addr *NFTAddress) ID() []byte

func (*NFTAddress) Key

func (addr *NFTAddress) Key() string

func (*NFTAddress) NFTID

func (addr *NFTAddress) NFTID() NFTID

func (*NFTAddress) Size

func (addr *NFTAddress) Size() int

func (*NFTAddress) StorageScore

func (*NFTAddress) String

func (addr *NFTAddress) String() string

func (*NFTAddress) Type

func (addr *NFTAddress) Type() AddressType

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 EmptyNFTID

func EmptyNFTID() NFTID

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

func (nftID NFTID) Matches(other ChainID) bool

func (NFTID) String

func (nftID NFTID) String() string

func (NFTID) ToAddress

func (nftID NFTID) ToAddress() ChainAddress

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 BaseToken `serix:""`
	// The stored mana held by the output.
	Mana Mana `serix:""`
	// The identifier of this NFT.
	NFTID NFTID `serix:""`
	// The unlock conditions on this output.
	UnlockConditions NFTOutputUnlockConditions `serix:",omitempty"`
	// The feature on the output.
	Features NFTOutputFeatures `serix:",omitempty"`
	// The immutable feature on the output.
	ImmutableFeatures NFTOutputImmFeatures `serix:",omitempty"`
}

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

func (*NFTOutput) BaseTokenAmount

func (n *NFTOutput) BaseTokenAmount() BaseToken

func (*NFTOutput) ChainID

func (n *NFTOutput) ChainID() ChainID

func (*NFTOutput) Clone

func (n *NFTOutput) Clone() Output

func (*NFTOutput) Equal

func (n *NFTOutput) Equal(other Output) bool

func (*NFTOutput) FeatureSet

func (n *NFTOutput) FeatureSet() FeatureSet

func (*NFTOutput) ImmutableFeatureSet

func (n *NFTOutput) ImmutableFeatureSet() FeatureSet

func (*NFTOutput) Owner

func (n *NFTOutput) Owner() Address

func (*NFTOutput) Size

func (n *NFTOutput) Size() int

func (*NFTOutput) StorageScore

func (n *NFTOutput) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*NFTOutput) StoredMana

func (n *NFTOutput) StoredMana() Mana

func (*NFTOutput) Type

func (n *NFTOutput) Type() OutputType

func (*NFTOutput) UnlockConditionSet

func (n *NFTOutput) UnlockConditionSet() UnlockConditionSet

func (*NFTOutput) UnlockableBy

func (n *NFTOutput) UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool

func (*NFTOutput) WorkScore

func (n *NFTOutput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type NFTOutputFeature

type NFTOutputFeature interface{ Feature }

type NFTOutputFeatures

type NFTOutputFeatures = Features[NFTOutputFeature]

type NFTOutputImmFeature

type NFTOutputImmFeature interface{ Feature }

type NFTOutputImmFeatures

type NFTOutputImmFeatures = Features[NFTOutputImmFeature]

type NFTOutputUnlockCondition

type NFTOutputUnlockCondition interface{ UnlockCondition }

type NFTUnlock

type NFTUnlock struct {
	// The other input/unlock this NFTUnlock references to.
	Reference uint16 `serix:""`
}

NFTUnlock is an Unlock which references a previous input/unlock.

func (*NFTUnlock) Chainable

func (r *NFTUnlock) Chainable() bool

func (*NFTUnlock) Clone

func (r *NFTUnlock) Clone() Unlock

func (*NFTUnlock) ReferencedInputIndex

func (r *NFTUnlock) ReferencedInputIndex() uint16

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

func (r *NFTUnlock) WorkScore(_ *WorkScoreParameters) (WorkScore, error)

type NativeTokenFeature

type NativeTokenFeature struct {
	ID     NativeTokenID `serix:""`
	Amount *big.Int      `serix:""`
}

NativeTokenFeature is a feature that holds a native token which represents a token that resides natively on the ledger.

func (*NativeTokenFeature) Clone

func (n *NativeTokenFeature) Clone() Feature

Clone clones the NativeTokenFeature.

func (*NativeTokenFeature) Compare

func (n *NativeTokenFeature) Compare(other Feature) int

func (*NativeTokenFeature) Equal

func (n *NativeTokenFeature) Equal(other Feature) bool

Equal checks whether other is equal to this NativeToken.

func (*NativeTokenFeature) Size

func (n *NativeTokenFeature) Size() int

func (*NativeTokenFeature) StorageScore

func (*NativeTokenFeature) Type

func (n *NativeTokenFeature) Type() FeatureType

func (*NativeTokenFeature) WorkScore

func (n *NativeTokenFeature) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type NativeTokenID

type NativeTokenID = FoundryID

NativeTokenID is an identifier which uniquely identifies a NativeToken.

func FoundryIDFromAddressAndSerialNumberAndTokenScheme

func FoundryIDFromAddressAndSerialNumberAndTokenScheme(addr Address, serialNumber uint32, tokenScheme TokenSchemeType) (NativeTokenID, error)

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

Network prefixes.

type NonEphemeralObject

type NonEphemeralObject interface {
	// StorageScore returns the cost this object has in terms of taking up
	// virtual and physical space within the data set needed to implement the 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.
	StorageScore(storageScoreStruct *StorageScoreStructure, override StorageScoreFunc) StorageScore
}

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 {
	Sizer
	NonEphemeralObject
	ProcessableObject
	constraints.Cloneable[Output]
	constraints.Equalable[Output]

	// BaseTokenAmount returns the amount of base tokens held by this Output.
	BaseTokenAmount() BaseToken

	// StoredMana returns the stored mana held by this output.
	StoredMana() Mana

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

Output defines a unit of output of a transaction.

type OutputID

type OutputID [OutputIDLength]byte

OutputID is a 32 byte hash value together with an 4 byte slot index and a 2 byte output index.

func EmptyOutputIDWithCreationSlot

func EmptyOutputIDWithCreationSlot(slot SlotIndex) OutputID

func MustOutputIDFromHexString

func MustOutputIDFromHexString(hex string) OutputID

MustOutputIDFromHexString converts the hex to a OutputID representation.

func OutputIDFromBytes

func OutputIDFromBytes(b []byte) (OutputID, int, error)

OutputIDFromBytes returns a new OutputID represented by the passed bytes.

func OutputIDFromHexString

func OutputIDFromHexString(hex string) (OutputID, error)

OutputIDFromHexString converts the hex to a OutputID representation.

func OutputIDFromTransactionIDAndIndex

func OutputIDFromTransactionIDAndIndex(txID TransactionID, index uint16) OutputID

OutputIDFromTransactionIDAndIndex creates a OutputID from the given TransactionID and output index.

func (OutputID) Alias

func (o OutputID) Alias() (alias string)

Alias returns the human-readable alias of the Identifier (or the base58 encoded bytes of no alias was set).

func (OutputID) Bytes

func (o OutputID) Bytes() ([]byte, error)

func (OutputID) Compare

func (o OutputID) Compare(other OutputID) int

Compare compares two OutputIDs.

func (OutputID) CreationSlot

func (o OutputID) CreationSlot() SlotIndex

CreationSlot returns the slot the Output was created in.

func (OutputID) Empty

func (o OutputID) Empty() bool

Empty tells whether the OutputID is empty.

func (OutputID) Identifier

func (o OutputID) Identifier() Identifier

func (OutputID) Index

func (outputID OutputID) Index() uint16

Index returns the index of the Output this OutputID references.

func (OutputID) MarshalText

func (o OutputID) MarshalText() (text []byte, err error)

func (OutputID) RegisterAlias

func (o OutputID) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the Identifier which will be used as a replacement for the String method.

func (OutputID) Slot

func (o OutputID) Slot() SlotIndex

func (OutputID) String

func (o OutputID) String() string

func (OutputID) ToHex

func (o OutputID) ToHex() string

ToHex converts the Identifier to its hex representation.

func (OutputID) TransactionID

func (o OutputID) TransactionID() TransactionID

TransactionID returns the TransactionID of the Output this OutputID references.

func (OutputID) UTXOInput

func (o OutputID) UTXOInput() *UTXOInput

UTXOInput creates a UTXOInput from this OutputID.

func (*OutputID) UnmarshalText

func (o *OutputID) UnmarshalText(text []byte) error

func (OutputID) UnregisterAlias

func (o OutputID) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

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 OutputIDProof

type OutputIDProof struct {
	API                   API
	Slot                  SlotIndex                                       `serix:""`
	OutputIndex           uint16                                          `serix:""`
	TransactionCommitment Identifier                                      `serix:""`
	OutputCommitmentProof *merklehasher.Proof[*APIByter[TxEssenceOutput]] `serix:""`
}

func NewOutputIDProof

func NewOutputIDProof(api API, txCommitment Identifier, txCreationSlot SlotIndex, outputs TxEssenceOutputs, outputIndex uint16) (*OutputIDProof, error)

func OutputIDProofFromTransaction

func OutputIDProofFromTransaction(tx *Transaction, outputIndex uint16) (*OutputIDProof, error)

func (*OutputIDProof) Bytes

func (p *OutputIDProof) Bytes() ([]byte, error)

func (*OutputIDProof) OutputID

func (p *OutputIDProof) OutputID(output Output) (OutputID, error)

func (*OutputIDProof) SetDeserializationContext

func (p *OutputIDProof) SetDeserializationContext(ctx context.Context)

type OutputIDs

type OutputIDs []OutputID

func OutputIDsFromHexString

func OutputIDsFromHexString(OutputIDsHex []string) (OutputIDs, error)

OutputIDsFromHexString converts the given block IDs from their hex to OutputID representation.

func (OutputIDs) OrderedSet

func (ids OutputIDs) OrderedSet(set OutputSet) Outputs[Output]

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

func (OutputIDs) RemoveDupsAndSort

func (ids OutputIDs) RemoveDupsAndSort() OutputIDs

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

func (OutputIDs) Sort

func (ids OutputIDs) Sort()

Sort sorts the OutputIDs lexically and in-place.

func (OutputIDs) ToHex

func (ids OutputIDs) ToHex() []string

ToHex converts the OutputIDs to their hex representation.

func (OutputIDs) UTXOInputs

func (ids OutputIDs) UTXOInputs() TxEssenceInputs

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

func (outputSet OutputSet) Clone() OutputSet

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

type OutputType

type OutputType byte

OutputType defines the type of outputs.

const (
	// OutputBasic denotes an BasicOutput.
	OutputBasic OutputType = iota
	// OutputAccount denotes an AccountOutput.
	OutputAccount
	// OutputAnchor denotes an AnchorOuptut.
	OutputAnchor
	// OutputFoundry denotes a FoundryOutput.
	OutputFoundry
	// OutputNFT denotes an NFTOutput.
	OutputNFT
	// OutputDelegation denotes a DelegationOutput.
	OutputDelegation
)

func (OutputType) String

func (outputType OutputType) String() string

type Outputs

type Outputs[T Output] []T

Outputs is a slice of Output.

func (Outputs[T]) ChainOutputSet

func (outputs Outputs[T]) ChainOutputSet(txID TransactionID) ChainOutputSet

ChainOutputSet returns a ChainOutputSet for all ChainOutputs in Outputs.

func (Outputs[T]) Clone

func (outputs Outputs[T]) Clone() Outputs[T]

func (Outputs[T]) Filter

func (outputs Outputs[T]) Filter(f OutputsFilterFunc) Outputs[T]

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

func (Outputs[T]) NativeTokenSum

func (outputs Outputs[T]) NativeTokenSum() (NativeTokenSum, error)

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

func (Outputs[T]) Size

func (outputs Outputs[T]) Size() int

func (Outputs[T]) WorkScore

func (outputs Outputs[T]) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

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 OwnerTransitionDependentOutput

type OwnerTransitionDependentOutput interface {
	ChainOutput
	// Owner computes the address to which this output is locked to by examining
	// the transition to the next output state. If next is nil, then this OwnerTransitionDependentOutput
	// treats the owner computation as being for ChainTransitionTypeDestroy.
	Owner(next OwnerTransitionDependentOutput) (Address, error)
	// UnlockableBy tells whether the given address can unlock this Output
	// while also taking into consideration constraints enforced by UnlockConditions(s) within this Output
	// and the next state of this OwnerTransitionDependentOutput. To indicate that this OwnerTransitionDependentOutput
	// is to be destroyed, pass nil as next.
	UnlockableBy(addr Address, next OwnerTransitionDependentOutput, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) (bool, error)
}

OwnerTransitionDependentOutput is a type of Output where the address to unlock is dependent on the transition the output does (without considering UnlockConditions(s)).

type OwnerTransitionIndependentOutput

type OwnerTransitionIndependentOutput interface {
	Output
	// Owner returns the default address to which this output is locked to.
	Owner() Address
	// UnlockableBy tells whether the given address can unlock this Output
	// while also taking into consideration constraints enforced by UnlockConditions(s) within this Output (if any).
	UnlockableBy(addr Address, pastBoundedSlotIndex SlotIndex, futureBoundedSlotIndex SlotIndex) bool
}

OwnerTransitionIndependentOutput is a type of Output where the address to unlock is independent of any transition the output does (without considering Feature(s)).

type Parent

type Parent struct {
	ID   BlockID
	Type ParentsType
}

Parent is a parent that can be either strong or weak.

type ParentsType

type ParentsType uint8

ParentsType is a type that defines the type of the parent.

const (
	// UndefinedParentType is the undefined parent.
	UndefinedParentType ParentsType = iota
	// StrongParentType is the ParentsType for a strong parent.
	StrongParentType
	// WeakParentType is the ParentsType for a weak parent.
	WeakParentType
	// ShallowLikeParentType is the ParentsType for the shallow like parent.
	ShallowLikeParentType
)

func (ParentsType) String

func (p ParentsType) String() string

String returns string representation of ParentsType.

type Payload

type Payload interface {
	Sizer
	ProcessableObject
	constraints.Cloneable[Payload]

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

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

type PayloadType

type PayloadType uint8

PayloadType denotes the type of a payload.

const (
	// PayloadTaggedData denotes a TaggedData payload.
	PayloadTaggedData PayloadType = iota
	// PayloadSignedTransaction denotes a SignedTransaction.
	PayloadSignedTransaction PayloadType = 1
	// PayloadCandidacyAnnouncement denotes a CandidacyAnnouncement.
	PayloadCandidacyAnnouncement PayloadType = 2
)

func (PayloadType) String

func (payloadType PayloadType) String() string

type PrefixedStringUint16

type PrefixedStringUint16 string

type PrefixedStringUint32

type PrefixedStringUint32 string

type PrefixedStringUint64

type PrefixedStringUint64 string

type PrefixedStringUint8

type PrefixedStringUint8 string

type ProcessableObject

type ProcessableObject interface {
	// WorkScore returns the cost this object has in terms of computation
	// requirements for a node to process it. These costs attempt to encapsulate all processing steps
	// carried out on this object throughout its life in the node.
	WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)
}

type ProtocolEpochVersion

type ProtocolEpochVersion struct {
	Version    Version
	StartEpoch EpochIndex
}

func (*ProtocolEpochVersion) Bytes

func (p *ProtocolEpochVersion) Bytes() []byte

func (*ProtocolEpochVersion) String

func (p *ProtocolEpochVersion) String() string

type ProtocolEpochVersions

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

func NewProtocolEpochVersions

func NewProtocolEpochVersions() *ProtocolEpochVersions

func (*ProtocolEpochVersions) Add

func (p *ProtocolEpochVersions) Add(version Version, epoch EpochIndex)

func (*ProtocolEpochVersions) Bytes

func (p *ProtocolEpochVersions) Bytes() []byte

func (*ProtocolEpochVersions) EpochForVersion

func (p *ProtocolEpochVersions) EpochForVersion(version Version) (EpochIndex, bool)

func (*ProtocolEpochVersions) Slice

func (*ProtocolEpochVersions) String

func (p *ProtocolEpochVersions) String() string

func (*ProtocolEpochVersions) VersionForEpoch

func (p *ProtocolEpochVersions) VersionForEpoch(epoch EpochIndex) Version

type ProtocolParameters

type ProtocolParameters interface {
	// Version defines the version of the protocol running.
	Version() Version
	// NetworkName defines the human friendly name of the network.
	NetworkName() string
	// NetworkID defines the ID of the network which is derived from the network name.
	NetworkID() NetworkID
	// Bech32HRP defines the HRP prefix used for Bech32 addresses in the network.
	Bech32HRP() NetworkPrefix
	// StorageScoreParameters defines the storage score structure used by the given network.
	StorageScoreParameters() *StorageScoreParameters
	// WorkScoreParameters defines the work score parameters used by the given network.
	WorkScoreParameters() *WorkScoreParameters
	// ManaParameters defines the mana parameters used by the given network.
	ManaParameters() *ManaParameters
	// TokenSupply defines the current token supply on the network.
	TokenSupply() BaseToken

	// GenesisBlockID defines the block ID of the genesis block.
	GenesisBlockID() BlockID
	// GenesisSlot defines the slot of the genesis.
	GenesisSlot() SlotIndex
	// GenesisUnixTimestamp defines the genesis timestamp at which the slots start to count.
	GenesisUnixTimestamp() int64
	// SlotDurationInSeconds defines the duration of each slot in seconds.
	SlotDurationInSeconds() uint8
	// SlotsPerEpochExponent is the number of slots in an epoch expressed as an exponent of 2.
	SlotsPerEpochExponent() uint8

	StakingUnbondingPeriod() EpochIndex

	ValidationBlocksPerSlot() uint8

	PunishmentEpochs() EpochIndex

	LivenessThresholdLowerBound() time.Duration

	LivenessThresholdUpperBound() time.Duration

	MinCommittableAge() SlotIndex

	MaxCommittableAge() SlotIndex

	// EpochNearingThreshold is used by the epoch orchestrator to detect the slot that should trigger a new committee
	// selection for the next and upcoming epoch.
	EpochNearingThreshold() SlotIndex

	// CongestionControlParameters returns the parameters used to calculate reference Mana cost.
	CongestionControlParameters() *CongestionControlParameters

	VersionSignalingParameters() *VersionSignalingParameters

	RewardsParameters() *RewardsParameters

	TargetCommitteeSize() uint8

	ChainSwitchingThreshold() uint8

	Bytes() ([]byte, error)

	Hash() (Identifier, error)

	Equals(other ProtocolParameters) bool
}

ProtocolParameters defines the parameters of the protocol.

func ProtocolParametersFromBytes

func ProtocolParametersFromBytes(bytes []byte) (params ProtocolParameters, bytesRead int, err error)

type ProtocolParametersType

type ProtocolParametersType byte

ProtocolParametersType defines the type of protocol parameters.

const (
	// ProtocolParametersV3 denotes a V3ProtocolParameters.
	ProtocolParametersV3 ProtocolParametersType = iota
)

type ReferenceUnlock

type ReferenceUnlock struct {
	// The other input/unlock this ReferenceUnlock references to.
	Reference uint16 `serix:""`
}

ReferenceUnlock is an Unlock which references a previous input/unlock.

func (*ReferenceUnlock) Chainable

func (r *ReferenceUnlock) Chainable() bool

func (*ReferenceUnlock) Clone

func (r *ReferenceUnlock) Clone() Unlock

func (*ReferenceUnlock) ReferencedInputIndex

func (r *ReferenceUnlock) ReferencedInputIndex() uint16

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

func (r *ReferenceUnlock) WorkScore(_ *WorkScoreParameters) (WorkScore, error)

type ReferentialUnlock

type ReferentialUnlock interface {
	Unlock

	// ReferencedInputIndex returns the index of the Input/Unlock this ReferentialUnlock references.
	ReferencedInputIndex() 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 RestrictedAddress

type RestrictedAddress struct {
	Address             Address                    `serix:""`
	AllowedCapabilities AddressCapabilitiesBitMask `serix:",omitempty"`
}

func RestrictedAddressWithCapabilities

func RestrictedAddressWithCapabilities(address Address, opts ...options.Option[AddressCapabilitiesOptions]) *RestrictedAddress

RestrictedAddressWithCapabilities returns a restricted address for the given underlying address.

func (*RestrictedAddress) AllowedCapabilitiesBitMask

func (addr *RestrictedAddress) AllowedCapabilitiesBitMask() AddressCapabilitiesBitMask

func (*RestrictedAddress) Bech32

func (addr *RestrictedAddress) Bech32(hrp NetworkPrefix) string

func (*RestrictedAddress) CannotReceiveAccountOutputs

func (addr *RestrictedAddress) CannotReceiveAccountOutputs() bool

func (*RestrictedAddress) CannotReceiveAnchorOutputs

func (addr *RestrictedAddress) CannotReceiveAnchorOutputs() bool

func (*RestrictedAddress) CannotReceiveDelegationOutputs

func (addr *RestrictedAddress) CannotReceiveDelegationOutputs() bool

func (*RestrictedAddress) CannotReceiveMana

func (addr *RestrictedAddress) CannotReceiveMana() bool

func (*RestrictedAddress) CannotReceiveNFTOutputs

func (addr *RestrictedAddress) CannotReceiveNFTOutputs() bool

func (*RestrictedAddress) CannotReceiveNativeTokens

func (addr *RestrictedAddress) CannotReceiveNativeTokens() bool

func (*RestrictedAddress) CannotReceiveOutputsWithExpirationUnlockCondition

func (addr *RestrictedAddress) CannotReceiveOutputsWithExpirationUnlockCondition() bool

func (*RestrictedAddress) CannotReceiveOutputsWithStorageDepositReturnUnlockCondition

func (addr *RestrictedAddress) CannotReceiveOutputsWithStorageDepositReturnUnlockCondition() bool

func (*RestrictedAddress) CannotReceiveOutputsWithTimelockUnlockCondition

func (addr *RestrictedAddress) CannotReceiveOutputsWithTimelockUnlockCondition() bool

func (*RestrictedAddress) Clone

func (addr *RestrictedAddress) Clone() Address

func (*RestrictedAddress) Equal

func (addr *RestrictedAddress) Equal(other Address) bool

func (*RestrictedAddress) ID

func (addr *RestrictedAddress) ID() []byte

func (*RestrictedAddress) Key

func (addr *RestrictedAddress) Key() string

func (*RestrictedAddress) Size

func (addr *RestrictedAddress) Size() int

func (*RestrictedAddress) StorageScore

func (*RestrictedAddress) String

func (addr *RestrictedAddress) String() string

func (*RestrictedAddress) Type

func (addr *RestrictedAddress) Type() AddressType

type RewardInput

type RewardInput struct {
	// The index of the transaction input for which to claim rewards.
	Index uint16 `serix:""`
}

func (*RewardInput) Clone

func (r *RewardInput) Clone() ContextInput

func (*RewardInput) Compare

func (r *RewardInput) Compare(other ContextInput) int

func (*RewardInput) IsReadOnly

func (r *RewardInput) IsReadOnly() bool

func (*RewardInput) Size

func (r *RewardInput) Size() int

func (*RewardInput) Type

func (r *RewardInput) Type() ContextInputType

func (*RewardInput) WorkScore

func (r *RewardInput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type RewardsParameters

type RewardsParameters struct {
	// ProfitMarginExponent is used for shift operation for calculation of profit margin.
	ProfitMarginExponent uint8 `serix:""`
	// BootstrappingDuration is the length, in epochs, of the bootstrapping phase, (approx 3 years).
	BootstrappingDuration EpochIndex `serix:""`
	// RewardToGenerationRatio is the ratio of the final rewards rate to the generation rate of Mana.
	RewardToGenerationRatio uint8 `serix:""`
	// InitialTargetRewardsRate is the rate of Mana rewards at the start of the bootstrapping phase.
	InitialTargetRewardsRate Mana `serix:""`
	// FinalTargetRewardsRate is the rate of Mana rewards after the bootstrapping phase.
	FinalTargetRewardsRate Mana `serix:""`
	// PoolCoefficientExponent is the exponent used for shifting operation in the pool rewards calculations.
	PoolCoefficientExponent uint8 `serix:""`
	// The number of epochs for which rewards are retained.
	RetentionPeriod uint16 `serix:""`
}

func (RewardsParameters) Equals

func (r RewardsParameters) Equals(other RewardsParameters) bool

func (RewardsParameters) TargetReward

func (r RewardsParameters) TargetReward(epoch EpochIndex, api API) (Mana, error)

type Roots

type Roots struct {
	TangleRoot             Identifier `serix:""`
	StateMutationRoot      Identifier `serix:""`
	StateRoot              Identifier `serix:""`
	AccountRoot            Identifier `serix:""`
	AttestationsRoot       Identifier `serix:""`
	CommitteeRoot          Identifier `serix:""`
	RewardsRoot            Identifier `serix:""`
	ProtocolParametersHash Identifier `serix:""`
}

func NewRoots

func NewRoots(tangleRoot, stateMutationRoot, attestationsRoot, stateRoot, accountRoot, committeeRoot, rewardsRoot, protocolParametersHash Identifier) *Roots

func (*Roots) AttestationsProof

func (r *Roots) AttestationsProof() *merklehasher.Proof[Identifier]

func (*Roots) ID

func (r *Roots) ID() (id Identifier)

func (*Roots) MutationProof

func (r *Roots) MutationProof() *merklehasher.Proof[Identifier]

func (*Roots) String

func (r *Roots) String() string

func (*Roots) TangleProof

func (r *Roots) TangleProof() *merklehasher.Proof[Identifier]

type SenderFeature

type SenderFeature struct {
	Address Address `serix:""`
}

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

func (*SenderFeature) Clone

func (s *SenderFeature) Clone() Feature

func (*SenderFeature) Compare

func (s *SenderFeature) Compare(other Feature) int

func (*SenderFeature) Equal

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

func (*SenderFeature) Size

func (s *SenderFeature) Size() int

func (*SenderFeature) StorageScore

func (s *SenderFeature) StorageScore(storageScoreStruct *StorageScoreStructure, f StorageScoreFunc) StorageScore

func (*SenderFeature) Type

func (s *SenderFeature) Type() FeatureType

func (*SenderFeature) WorkScore

func (s *SenderFeature) WorkScore(_ *WorkScoreParameters) (WorkScore, error)

type Signature

type Signature interface {
	serix.Serializable
	serix.Deserializable
	Sizer
	ProcessableObject
	constraints.Cloneable[Signature]

	// MatchesAddress returns true if the Signature matches the given Address.
	MatchesAddress(addr Address) bool

	// SignerUID returns the unique identifier of the signature's signer.
	// This can be used to identify the uniqueness of the signer in the unlocks (e.g. unique public key).
	SignerUID() Identifier

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

Signature is a signature.

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 `serix:""`
}

SignatureUnlock holds a signature which unlocks inputs.

func (*SignatureUnlock) Clone

func (s *SignatureUnlock) Clone() Unlock

func (*SignatureUnlock) Size

func (s *SignatureUnlock) Size() int

func (*SignatureUnlock) Type

func (s *SignatureUnlock) Type() UnlockType

func (*SignatureUnlock) WorkScore

func (s *SignatureUnlock) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type SignedTransaction

type SignedTransaction struct {
	API API
	// The transaction essence, respectively the transfer part of a SignedTransaction.
	Transaction *Transaction `serix:""`
	// The unlocks defining the unlocking data for the inputs within the Transaction.
	Unlocks Unlocks `serix:""`
}

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

func (*SignedTransaction) Clone

func (t *SignedTransaction) Clone() Payload

func (*SignedTransaction) ID

ID computes the ID of the SignedTransaction.

func (*SignedTransaction) MustID

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

func (*SignedTransaction) PayloadType

func (t *SignedTransaction) PayloadType() PayloadType

func (*SignedTransaction) SetDeserializationContext

func (t *SignedTransaction) SetDeserializationContext(ctx context.Context)

func (*SignedTransaction) Size

func (t *SignedTransaction) Size() int

func (*SignedTransaction) String

func (t *SignedTransaction) String() string

String returns a human readable version of the SignedTransaction.

func (*SignedTransaction) WorkScore

func (t *SignedTransaction) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type SignedTransactionID

type SignedTransactionID [SignedTransactionIDLength]byte

SignedTransactionID is a 32 byte hash value together with an 4 byte slot index.

func MustSignedTransactionIDFromHexString

func MustSignedTransactionIDFromHexString(hex string) SignedTransactionID

MustSignedTransactionIDFromHexString converts the hex to a SignedTransactionID representation.

func NewSignedTransactionID

func NewSignedTransactionID(slot SlotIndex, idBytes Identifier) SignedTransactionID

func SignedTransactionIDFromBytes

func SignedTransactionIDFromBytes(b []byte) (SignedTransactionID, int, error)

SignedTransactionIDFromBytes returns a new SignedTransactionID represented by the passed bytes.

func SignedTransactionIDFromHexString

func SignedTransactionIDFromHexString(hex string) (SignedTransactionID, error)

SignedTransactionIDFromHexString converts the hex to a SignedTransactionID representation.

func SignedTransactionIDRepresentingData

func SignedTransactionIDRepresentingData(slot SlotIndex, data []byte) SignedTransactionID

SignedTransactionIDRepresentingData returns a new SignedTransactionID for the given data by hashing it with blake2b and associating it with the given slot index.

func (SignedTransactionID) Alias

func (t SignedTransactionID) Alias() (alias string)

Alias returns the human-readable alias of the Identifier (or the base58 encoded bytes of no alias was set).

func (SignedTransactionID) Bytes

func (t SignedTransactionID) Bytes() ([]byte, error)

func (SignedTransactionID) Compare

func (t SignedTransactionID) Compare(other SignedTransactionID) int

Compare compares two SignedTransactionIDs.

func (SignedTransactionID) Empty

func (t SignedTransactionID) Empty() bool

Empty tells whether the SignedTransactionID is empty.

func (SignedTransactionID) Identifier

func (t SignedTransactionID) Identifier() Identifier

func (SignedTransactionID) Index

func (t SignedTransactionID) Index() SlotIndex

Index returns a slot index to conform with hive's IndexedID interface.

func (SignedTransactionID) MarshalText

func (t SignedTransactionID) MarshalText() (text []byte, err error)

func (SignedTransactionID) RegisterAlias

func (t SignedTransactionID) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the Identifier which will be used as a replacement for the String method.

func (SignedTransactionID) Slot

func (t SignedTransactionID) Slot() SlotIndex

func (SignedTransactionID) String

func (t SignedTransactionID) String() string

func (SignedTransactionID) ToHex

func (t SignedTransactionID) ToHex() string

ToHex converts the Identifier to its hex representation.

func (*SignedTransactionID) UnmarshalText

func (t *SignedTransactionID) UnmarshalText(text []byte) error

func (SignedTransactionID) UnregisterAlias

func (t SignedTransactionID) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

type SignedTransactionIDs

type SignedTransactionIDs []SignedTransactionID

func SignedTransactionIDsFromHexString

func SignedTransactionIDsFromHexString(SignedTransactionIDsHex []string) (SignedTransactionIDs, error)

SignedTransactionIDsFromHexString converts the given block IDs from their hex to SignedTransactionID representation.

func (SignedTransactionIDs) RemoveDupsAndSort

func (ids SignedTransactionIDs) RemoveDupsAndSort() SignedTransactionIDs

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

func (SignedTransactionIDs) Sort

func (ids SignedTransactionIDs) Sort()

Sort sorts the SignedTransactionIDs lexically and in-place.

func (SignedTransactionIDs) ToHex

func (ids SignedTransactionIDs) ToHex() []string

ToHex converts the SignedTransactionIDs to their hex representation.

type SimpleTokenScheme

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

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

func (*SimpleTokenScheme) Clone

func (s *SimpleTokenScheme) Clone() TokenScheme

func (*SimpleTokenScheme) Equal

func (s *SimpleTokenScheme) Equal(other TokenScheme) bool

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

func (*SimpleTokenScheme) SyntacticalValidation

func (s *SimpleTokenScheme) SyntacticalValidation() error

func (*SimpleTokenScheme) Type

func (*SimpleTokenScheme) WorkScore

func (s *SimpleTokenScheme) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type Sizer

type Sizer interface {
	// Size returns the size of the object in terms of bytes.
	Size() int
}

Sizer is an object knowing its own byte size.

type SlotIndex

type SlotIndex uint32

SlotIndex is the index of a slot.

func SlotIndexFromBytes

func SlotIndexFromBytes(b []byte) (SlotIndex, int, error)

func (SlotIndex) Bytes

func (i SlotIndex) Bytes() ([]byte, error)

func (SlotIndex) MustBytes

func (i SlotIndex) MustBytes() []byte

func (SlotIndex) String

func (i SlotIndex) String() string

type StakingFeature

type StakingFeature struct {
	StakedAmount BaseToken  `serix:""`
	FixedCost    Mana       `serix:""`
	StartEpoch   EpochIndex `serix:""`
	EndEpoch     EpochIndex `serix:""`
}

StakingFeature is a feature which indicates that this account wants to register as a validator. The feature includes a fixed cost that the staker can set and will receive as part of its rewards, as well as a range of epoch indices in which the feature is considered active and can claim rewards. Removing the feature can only be done by going through an unbonding period.

func (*StakingFeature) Clone

func (s *StakingFeature) Clone() Feature

func (*StakingFeature) Compare

func (s *StakingFeature) Compare(other Feature) int

func (*StakingFeature) Equal

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

func (*StakingFeature) Size

func (s *StakingFeature) Size() int

func (*StakingFeature) StorageScore

func (s *StakingFeature) StorageScore(storageScoreStruct *StorageScoreStructure, f StorageScoreFunc) StorageScore

func (*StakingFeature) Type

func (s *StakingFeature) Type() FeatureType

func (*StakingFeature) WorkScore

func (s *StakingFeature) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type StateControllerAddressUnlockCondition

type StateControllerAddressUnlockCondition struct {
	Address Address `serix:""`
}

StateControllerAddressUnlockCondition is an UnlockCondition defining the state controller address for an AccountOutput.

func (*StateControllerAddressUnlockCondition) Clone

func (*StateControllerAddressUnlockCondition) Compare

func (*StateControllerAddressUnlockCondition) Equal

func (*StateControllerAddressUnlockCondition) Size

func (*StateControllerAddressUnlockCondition) StorageScore

func (*StateControllerAddressUnlockCondition) Type

func (*StateControllerAddressUnlockCondition) WorkScore

type StateMetadataFeature

type StateMetadataFeature struct {
	Entries StateMetadataFeatureEntries `serix:""`
}

StateMetadataFeature is a feature which holds a map of key-value pairs. The keys must consist of ASCII characters only. The values are arbitrary byte slices.

func (StateMetadataFeature) Clone

func (m StateMetadataFeature) Clone() Feature

func (StateMetadataFeature) Compare

func (m StateMetadataFeature) Compare(other Feature) int

func (StateMetadataFeature) Equal

func (m StateMetadataFeature) Equal(other Feature) bool

func (StateMetadataFeature) Size

func (m StateMetadataFeature) Size() int

func (StateMetadataFeature) StorageScore

func (StateMetadataFeature) Type

func (StateMetadataFeature) WorkScore

type StateMetadataFeatureEntriesKey

type StateMetadataFeatureEntriesKey string

type StateMetadataFeatureEntriesValue

type StateMetadataFeatureEntriesValue []byte

type StorageDepositReturnUnlockCondition

type StorageDepositReturnUnlockCondition struct {
	ReturnAddress Address   `serix:""`
	Amount        BaseToken `serix:""`
}

StorageDepositReturnUnlockCondition is an unlock condition which defines the amount of tokens which must be sent back to the return address, 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 address.

func (*StorageDepositReturnUnlockCondition) Clone

func (*StorageDepositReturnUnlockCondition) Compare

func (*StorageDepositReturnUnlockCondition) Equal

func (*StorageDepositReturnUnlockCondition) Size

func (*StorageDepositReturnUnlockCondition) StorageScore

func (*StorageDepositReturnUnlockCondition) Type

func (*StorageDepositReturnUnlockCondition) WorkScore

type StorageScore

type StorageScore uint64

StorageScore defines the type of storage score.

type StorageScoreFactor

type StorageScoreFactor byte

StorageScoreFactor defines the type of the storage score factor.

func (StorageScoreFactor) Multiply

func (factor StorageScoreFactor) Multiply(in StorageScore) StorageScore

Multiply multiplies in with this factor.

func (StorageScoreFactor) With

With joins two factors with each other.

type StorageScoreFunc

type StorageScoreFunc func(storageScoreStruct *StorageScoreStructure) StorageScore

StorageScoreFunc is a function which computes the storage score of a NonEphemeralObject.

type StorageScoreParameters

type StorageScoreParameters struct {
	// Defines the number of IOTA tokens required per unit of storage score.
	StorageCost BaseToken `serix:""`
	// Defines the factor to be used for data only fields.
	FactorData StorageScoreFactor `serix:""`
	// Defines the offset to be applied to all outputs for the overhead of handling them in storage.
	OffsetOutputOverhead StorageScore `serix:""`
	// Defines the offset to be used for block issuer feature public keys.
	OffsetEd25519BlockIssuerKey StorageScore `serix:""`
	// Defines the offset to be used for staking feature.
	OffsetStakingFeature StorageScore `serix:""`
	// Defines the offset to be used for delegation output.
	OffsetDelegation StorageScore `serix:""`
}

StorageScoreParameters defines the parameters of storage cost calculations on objects which take node resources. This structure defines the minimum base token deposit required on an object. This deposit does not generate Mana, which serves as a rent payment in Mana for storing the object.

func (StorageScoreParameters) Equals

type StorageScoreStructure

type StorageScoreStructure struct {
	StorageScoreParameters *StorageScoreParameters
	// The storage score that a minimal block issuer account needs to have minus the wrapping Basic Output.
	// Since this value is used for implicit account creation addresses, this value plus the wrapping
	// Basic Output (the Implicit Account Creation Address is contained in) results in the
	// minimum storage score of a block issuer account.
	OffsetImplicitAccountCreationAddress StorageScore
	OffsetOutput                         StorageScore
}

StorageScoreStructure includes the storage score parameters and the additional factors/offsets computed from these parameters.

func NewStorageScoreStructure

func NewStorageScoreStructure(storageScoreParameters *StorageScoreParameters) *StorageScoreStructure

NewStorageScoreStructure creates a new StorageScoreStructure.

func (*StorageScoreStructure) CoversMinDeposit

func (r *StorageScoreStructure) CoversMinDeposit(object NonEphemeralObject, amount BaseToken) (BaseToken, error)

CoversMinDeposit tells whether given this NonEphemeralObject, the base token amount fulfills the deposit requirements by examining the storage score of the object. Returns the minimum deposit computed and an error if it is not covered by the base token amount of the object.

func (*StorageScoreStructure) FactorData

func (r *StorageScoreStructure) FactorData() StorageScoreFactor

FactorData returns the factor to be used for data only fields.

func (*StorageScoreStructure) MinDeposit

func (r *StorageScoreStructure) MinDeposit(object NonEphemeralObject) (BaseToken, error)

MinDeposit returns the minimum deposit to cover a given object.

func (*StorageScoreStructure) MinStorageDepositForReturnOutput

func (r *StorageScoreStructure) MinStorageDepositForReturnOutput(sender Address) (BaseToken, error)

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

func (*StorageScoreStructure) OffsetDelegation

func (r *StorageScoreStructure) OffsetDelegation() StorageScore

OffsetDelegation returns the offset to be used for delegation output.

func (*StorageScoreStructure) OffsetEd25519BlockIssuerKey

func (r *StorageScoreStructure) OffsetEd25519BlockIssuerKey() StorageScore

OffsetEd25519BlockIssuerKey returns the offset to be used for block issuer feature public keys.

func (*StorageScoreStructure) OffsetStakingFeature

func (r *StorageScoreStructure) OffsetStakingFeature() StorageScore

OffsetStakingFeature returns the offset to be used for staking feature.

func (*StorageScoreStructure) StorageCost

func (r *StorageScoreStructure) StorageCost() BaseToken

StorageCost returns the cost of a single unit of storage score denoted in base tokens.

type TagFeature

type TagFeature struct {
	Tag []byte `serix:",lenPrefix=uint8,minLen=1,maxLen=64"`
}

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

func (s *TagFeature) Compare(other Feature) int

func (*TagFeature) Equal

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

func (*TagFeature) Size

func (s *TagFeature) Size() int

func (*TagFeature) StorageScore

func (s *TagFeature) StorageScore(storageScoreStruct *StorageScoreStructure, f StorageScoreFunc) StorageScore

func (*TagFeature) Type

func (s *TagFeature) Type() FeatureType

func (*TagFeature) WorkScore

func (s *TagFeature) WorkScore(_ *WorkScoreParameters) (WorkScore, error)

type TaggedData

type TaggedData struct {
	// The tag to use to categorize the data.
	Tag []byte `serix:",omitempty,lenPrefix=uint8,maxLen=64"`
	// The data within the payload.
	Data []byte `serix:",omitempty,lenPrefix=uint32,maxLen=8192"`
}

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

func (*TaggedData) Clone

func (u *TaggedData) Clone() Payload

func (*TaggedData) PayloadType

func (u *TaggedData) PayloadType() PayloadType

func (*TaggedData) Size

func (u *TaggedData) Size() int

func (*TaggedData) WorkScore

func (u *TaggedData) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type TimeProvider

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

TimeProvider defines the perception of time, slots and epochs. It allows to convert slots to and from time, and epochs to and from slots. Slots are counted starting from 1 with 0 being reserved for times before the genesis, which has to be addressable as its own slot. Epochs are counted starting from 0.

Example: with slotDurationSeconds = 10 and slotsPerEpochExponent = 3 [] inclusive range boundary, () exclusive range boundary slot 0: [-inf; genesis) slot 1: [genesis; genesis+10) slot 2: [genesis+10; genesis+20) ... epoch 0: [slot 0; slot 8) epoch 1: [slot 8; slot 16) epoch 2: [slot 16; slot 24) ...

func NewTimeProvider

func NewTimeProvider(genesisSlot SlotIndex, genesisUnixTime int64, slotDurationSeconds int64, slotsPerEpochExponent uint8) *TimeProvider

NewTimeProvider creates a new time provider.

func (*TimeProvider) CurrentEpoch

func (t *TimeProvider) CurrentEpoch() EpochIndex

CurrentEpoch calculates the current epoch based on the current time.

func (*TimeProvider) CurrentSlot

func (t *TimeProvider) CurrentSlot() SlotIndex

CurrentSlot calculates the current slot based on the current time.

func (*TimeProvider) EpochDurationSeconds

func (t *TimeProvider) EpochDurationSeconds() int64

func (*TimeProvider) EpochDurationSlots

func (t *TimeProvider) EpochDurationSlots() SlotIndex

func (*TimeProvider) EpochEnd

func (t *TimeProvider) EpochEnd(epoch EpochIndex) SlotIndex

EpochEnd calculates the end included slot of the given epoch.

func (*TimeProvider) EpochFromSlot

func (t *TimeProvider) EpochFromSlot(slot SlotIndex) EpochIndex

EpochFromSlot calculates the EpochIndex from the given slot.

func (*TimeProvider) EpochStart

func (t *TimeProvider) EpochStart(epoch EpochIndex) SlotIndex

EpochStart calculates the start slot of the given epoch.

func (*TimeProvider) GenesisSlot

func (t *TimeProvider) GenesisSlot() SlotIndex

GenesisSlot is the slot of the genesis.

func (*TimeProvider) GenesisTime

func (t *TimeProvider) GenesisTime() time.Time

GenesisTime is the time of the genesis.

func (*TimeProvider) GenesisUnixTime

func (t *TimeProvider) GenesisUnixTime() int64

GenesisUnixTime is the time (Unix in seconds) of the genesis.

func (*TimeProvider) SlotDurationSeconds

func (t *TimeProvider) SlotDurationSeconds() int64

SlotDurationSeconds is the slot duration in seconds.

func (*TimeProvider) SlotEndTime

func (t *TimeProvider) SlotEndTime(slot SlotIndex) time.Time

SlotEndTime returns the latest possible timestamp for a slot. Anything with higher timestamp will belong to the next slot.

func (*TimeProvider) SlotFromTime

func (t *TimeProvider) SlotFromTime(targetTime time.Time) SlotIndex

SlotFromTime calculates the SlotIndex from the given time.

Note: The + 1 is required because slots are counted starting from 1 with 0 being reserved for times before the genesis, which has to be addressable as its own slot.

func (*TimeProvider) SlotStartTime

func (t *TimeProvider) SlotStartTime(slot SlotIndex) time.Time

SlotStartTime calculates the start time of the given slot.

func (*TimeProvider) SlotsBeforeNextEpoch

func (t *TimeProvider) SlotsBeforeNextEpoch(slot SlotIndex) SlotIndex

SlotsBeforeNextEpoch calculates the slots before the start of the next epoch.

func (*TimeProvider) SlotsPerEpochExponent

func (t *TimeProvider) SlotsPerEpochExponent() uint8

func (*TimeProvider) SlotsSinceEpochStart

func (t *TimeProvider) SlotsSinceEpochStart(slot SlotIndex) SlotIndex

SlotsSinceEpochStart calculates the slots since the start of the epoch.

type TimelockUnlockCondition

type TimelockUnlockCondition struct {
	// The slot index until which the timelock applies (inclusive).
	Slot SlotIndex `serix:""`
}

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

func (s *TimelockUnlockCondition) Compare(other UnlockCondition) int

func (*TimelockUnlockCondition) Equal

func (*TimelockUnlockCondition) Size

func (s *TimelockUnlockCondition) Size() int

func (*TimelockUnlockCondition) StorageScore

func (*TimelockUnlockCondition) Type

func (*TimelockUnlockCondition) WorkScore

type TokenScheme

type TokenScheme interface {
	Sizer
	NonEphemeralObject
	ProcessableObject
	constraints.Cloneable[TokenScheme]
	constraints.Equalable[TokenScheme]

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

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

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 Transaction

type Transaction struct {
	API                 API
	*TransactionEssence `serix:",inlined"`
	// The outputs of this transaction.
	Outputs TxEssenceOutputs `serix:""`
}

Transaction is the part of a SignedTransaction that contains inputs and outputs.

func (*Transaction) BICInputs

func (t *Transaction) BICInputs() []*BlockIssuanceCreditInput

func (*Transaction) Clone

func (t *Transaction) Clone() *Transaction

func (*Transaction) CommitmentInput

func (t *Transaction) CommitmentInput() *CommitmentInput

Returns the first commitment input in the transaction if it exists or nil.

func (*Transaction) ContextInputs

func (t *Transaction) ContextInputs() TransactionContextInputs

func (*Transaction) ID

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

ID returns the TransactionID created without the signatures.

func (*Transaction) Inputs

func (t *Transaction) Inputs() []*UTXOInput

func (*Transaction) MustID

func (t *Transaction) MustID() TransactionID

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

func (*Transaction) OutputCommitment

func (t *Transaction) OutputCommitment() (Identifier, error)

OutputCommitment returns the output commitment which is the root of the merkle tree of the outputs.

func (*Transaction) OutputsSet

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

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

func (*Transaction) RewardInputs

func (t *Transaction) RewardInputs() []*RewardInput

func (*Transaction) SetDeserializationContext

func (t *Transaction) SetDeserializationContext(ctx context.Context)

func (*Transaction) Sign

func (t *Transaction) Sign(addrKeys ...AddressKeys) ([]Signature, error)

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

func (*Transaction) SigningMessage

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

SigningMessage returns the to be signed message.

func (*Transaction) Size

func (t *Transaction) Size() int

func (*Transaction) String

func (t *Transaction) String() string

String returns a human readable version of the Transaction.

func (*Transaction) SyntacticallyValidate

func (t *Transaction) SyntacticallyValidate(api API) error

syntacticallyValidate checks whether the transaction essence is syntactically valid. The function does not syntactically validate the input or outputs themselves.

func (*Transaction) TransactionCommitment

func (t *Transaction) TransactionCommitment() (Identifier, error)

TransactionCommitment returns the transaction commitment hashing the transaction essence.

func (*Transaction) WorkScore

func (t *Transaction) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

WorkScore calculates the Work Score of the Transaction.

type TransactionCapabilitiesBitMask

type TransactionCapabilitiesBitMask []byte

func TransactionCapabilitiesBitMaskFromBytes

func TransactionCapabilitiesBitMaskFromBytes(bytes []byte) (TransactionCapabilitiesBitMask, int, error)

func (TransactionCapabilitiesBitMask) CannotBurnMana

func (bm TransactionCapabilitiesBitMask) CannotBurnMana() bool

func (TransactionCapabilitiesBitMask) CannotBurnNativeTokens

func (bm TransactionCapabilitiesBitMask) CannotBurnNativeTokens() bool

func (TransactionCapabilitiesBitMask) CannotDestroyAccountOutputs

func (bm TransactionCapabilitiesBitMask) CannotDestroyAccountOutputs() bool

func (TransactionCapabilitiesBitMask) CannotDestroyAnchorOutputs

func (bm TransactionCapabilitiesBitMask) CannotDestroyAnchorOutputs() bool

func (TransactionCapabilitiesBitMask) CannotDestroyFoundryOutputs

func (bm TransactionCapabilitiesBitMask) CannotDestroyFoundryOutputs() bool

func (TransactionCapabilitiesBitMask) CannotDestroyNFTOutputs

func (bm TransactionCapabilitiesBitMask) CannotDestroyNFTOutputs() bool

func (TransactionCapabilitiesBitMask) Clone

func (TransactionCapabilitiesBitMask) Size

type TransactionCapabilitiesOptions

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

TransactionCapabilitiesOptions defines the possible capabilities of a TransactionCapabilitiesBitMask.

type TransactionContextInputs

type TransactionContextInputs ContextInputs[ContextInput]

type TransactionEssence

type TransactionEssence struct {
	// The network ID for which this essence is valid for.
	NetworkID NetworkID `serix:""`
	// The slot index in which the transaction was created by the client.
	CreationSlot SlotIndex `serix:""`
	// The commitment references of this transaction.
	ContextInputs TxEssenceContextInputs `serix:",omitempty"`
	// The inputs of this transaction.
	Inputs TxEssenceInputs `serix:""`
	// The optional accounts map with corresponding allotment values.
	Allotments TxEssenceAllotments `serix:",omitempty"`
	// The capabilities of the transaction.
	Capabilities TransactionCapabilitiesBitMask `serix:",omitempty"`
	// The optional embedded payload.
	Payload TxEssencePayload `serix:",optional"`
}

TransactionEssence is the essence part if a Transaction.

func (*TransactionEssence) Clone

func (*TransactionEssence) Size

func (u *TransactionEssence) Size() int

func (*TransactionEssence) WorkScore

func (u *TransactionEssence) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

WorkScore calculates the Work Score of the TransactionEssence.

Does not specifically include the work score of the optional payload because that is already included in the Work Score of the SignedTransaction.

type TransactionID

type TransactionID [TransactionIDLength]byte

TransactionID is a 32 byte hash value together with an 4 byte slot index.

func MustTransactionIDFromHexString

func MustTransactionIDFromHexString(hex string) TransactionID

MustTransactionIDFromHexString converts the hex to a TransactionID representation.

func NewTransactionID

func NewTransactionID(slot SlotIndex, idBytes Identifier) TransactionID

func TransactionIDFromBytes

func TransactionIDFromBytes(b []byte) (TransactionID, int, error)

TransactionIDFromBytes returns a new TransactionID represented by the passed bytes.

func TransactionIDFromHexString

func TransactionIDFromHexString(hex string) (TransactionID, error)

TransactionIDFromHexString converts the hex to a TransactionID representation.

func TransactionIDFromTransactionCommitmentAndOutputCommitment

func TransactionIDFromTransactionCommitmentAndOutputCommitment(slot SlotIndex, transactionCommitment Identifier, outputCommitment Identifier) TransactionID

func TransactionIDRepresentingData

func TransactionIDRepresentingData(slot SlotIndex, data []byte) TransactionID

TransactionIDRepresentingData returns a new TransactionID for the given data by hashing it with blake2b and associating it with the given slot index.

func (TransactionID) Alias

func (t TransactionID) Alias() (alias string)

Alias returns the human-readable alias of the Identifier (or the base58 encoded bytes of no alias was set).

func (TransactionID) Bytes

func (t TransactionID) Bytes() ([]byte, error)

func (TransactionID) Compare

func (t TransactionID) Compare(other TransactionID) int

Compare compares two TransactionIDs.

func (TransactionID) Empty

func (t TransactionID) Empty() bool

Empty tells whether the TransactionID is empty.

func (TransactionID) Identifier

func (t TransactionID) Identifier() Identifier

func (TransactionID) Index

func (t TransactionID) Index() SlotIndex

Index returns a slot index to conform with hive's IndexedID interface.

func (TransactionID) MarshalText

func (t TransactionID) MarshalText() (text []byte, err error)

func (TransactionID) RegisterAlias

func (t TransactionID) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the Identifier which will be used as a replacement for the String method.

func (TransactionID) Slot

func (t TransactionID) Slot() SlotIndex

func (TransactionID) String

func (t TransactionID) String() string

func (TransactionID) ToHex

func (t TransactionID) ToHex() string

ToHex converts the Identifier to its hex representation.

func (*TransactionID) UnmarshalText

func (t *TransactionID) UnmarshalText(text []byte) error

func (TransactionID) UnregisterAlias

func (t TransactionID) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

type TransactionIDs

type TransactionIDs []TransactionID

func TransactionIDsFromHexString

func TransactionIDsFromHexString(TransactionIDsHex []string) (TransactionIDs, error)

TransactionIDsFromHexString converts the given block IDs from their hex to TransactionID representation.

func (TransactionIDs) RemoveDupsAndSort

func (ids TransactionIDs) RemoveDupsAndSort() TransactionIDs

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

func (TransactionIDs) Sort

func (ids TransactionIDs) Sort()

Sort sorts the TransactionIDs lexically and in-place.

func (TransactionIDs) ToHex

func (ids TransactionIDs) ToHex() []string

ToHex converts the TransactionIDs to their hex representation.

type TxEssenceAllotments

type TxEssenceAllotments = Allotments

type TxEssenceContextInputs

type TxEssenceContextInputs = ContextInputs[txEssenceContextInput]

type TxEssenceInputs

type TxEssenceInputs = Inputs[txEssenceInput]

type TxEssenceOutput

type TxEssenceOutput interface{ Output }

type TxEssenceOutputs

type TxEssenceOutputs = Outputs[TxEssenceOutput]

type TxEssencePayload

type TxEssencePayload interface{ Payload }

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 `serix:""`
	// The output index of the output on the referenced transaction.
	TransactionOutputIndex uint16 `serix:""`
}

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

func (*UTXOInput) Clone

func (u *UTXOInput) Clone() Input

func (*UTXOInput) CreationSlot

func (u *UTXOInput) CreationSlot() SlotIndex

CreationSlot returns the slot the Output was created in.

func (*UTXOInput) Equals

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

func (*UTXOInput) Index

func (u *UTXOInput) Index() uint16

func (*UTXOInput) IsReadOnly

func (u *UTXOInput) IsReadOnly() bool

func (*UTXOInput) OutputID

func (u *UTXOInput) OutputID() OutputID

func (*UTXOInput) Size

func (u *UTXOInput) Size() int

func (*UTXOInput) Type

func (u *UTXOInput) Type() InputType

func (*UTXOInput) WorkScore

func (u *UTXOInput) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type Unlock

type Unlock interface {
	Sizer
	ProcessableObject
	constraints.Cloneable[Unlock]

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

Unlock unlocks inputs of a SignedTransaction.

type UnlockCondition

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

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

func (f UnlockConditionSet) CheckExpirationCondition(futureBoundedSlotIndex, pastBoundedSlotIndex SlotIndex) (Address, error)

CheckExpirationCondition returns the expiration return address in case an expiration condition was set and the future bound slot is greater than the expiration slot. In case the past bound slot is smaller than the expiration slot, "nil" is returned to indicate that the original owner can unlock the output. The range in between is not unlockable by anyone and an "ErrExpirationConditionUnlockFailed" error will be returned.

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

func (f UnlockConditionSet) HasManalockCondition(accountID AccountID, slot SlotIndex) bool

HasManalockCondition tells whether the set has both an account address unlock and a timelock that is still locked at slot index.

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

func (f UnlockConditionSet) HasTimelockUntil(slot SlotIndex) bool

HasTimelockUntil tells us whether the set has a timelock that is still locked at slot.

func (UnlockConditionSet) ImmutableAccount

ImmutableAccount returns the ImmutableAccountUnlockCondition in the set or nil.

func (UnlockConditionSet) OwnerAddressCanUnlock

func (f UnlockConditionSet) OwnerAddressCanUnlock(pastBoundedSlot SlotIndex) bool

OwnerAddressCanUnlock tells whether the target address defined in an expiration unlock condition within this set is allowed to unlock an Output containing this UnlockConditionSet given the past bounded slot index of the tx defined as the slot index of the commitment input plus the max committable age.

func (UnlockConditionSet) ReturnAddressCanUnlock

func (f UnlockConditionSet) ReturnAddressCanUnlock(futureBoundedSlotIndex SlotIndex) (bool, Address)

ReturnAddressCanUnlock tells whether a sender defined in an expiration unlock condition within this set is the actual address which could unlock an Output containing this UnlockConditionSet given the future bounded slot index of the tx defined as the slot index of the commitment input plus the min committable age.

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(futureBoundedSlot SlotIndex) error

TimelocksExpired tells whether UnlockCondition(s) in this set which impose a timelock are expired in relation to the given future bounded slot index. The provided slot index is the slot index of the commitment input which is being spent by the transaction plus the min committable age.

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
	// UnlockConditionImmutableAccount denotes an ImmutableAccountUnlockCondition.
	UnlockConditionImmutableAccount
)

func (UnlockConditionType) String

func (unlockCondType UnlockConditionType) String() string

type UnlockConditions

type UnlockConditions[T UnlockCondition] []T

UnlockConditions is a slice of UnlockCondition(s).

func (UnlockConditions[T]) Clone

func (f UnlockConditions[T]) Clone() UnlockConditions[T]

Clone clones the UnlockConditions.

func (UnlockConditions[T]) Equal

func (f UnlockConditions[T]) Equal(other UnlockConditions[T]) bool

func (UnlockConditions[T]) MustSet

func (f UnlockConditions[T]) MustSet() UnlockConditionSet

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[T]) Remove

func (f *UnlockConditions[T]) Remove(unlockConditionType UnlockConditionType) bool

Remove removes the given unlock condition if it exists.

func (UnlockConditions[T]) Set

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

func (UnlockConditions[T]) Size

func (f UnlockConditions[T]) Size() int

func (UnlockConditions[T]) Sort

func (f UnlockConditions[T]) Sort()

Sort sorts the UnlockConditions in place by type.

func (UnlockConditions[T]) StorageScore

func (f UnlockConditions[T]) StorageScore(storageScoreStruct *StorageScoreStructure, _ StorageScoreFunc) StorageScore

func (*UnlockConditions[T]) Upsert

func (f *UnlockConditions[T]) Upsert(unlockCondition T)

Upsert adds the given unlock condition or updates the previous one if existing.

func (UnlockConditions[T]) WorkScore

func (f UnlockConditions[T]) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type UnlockType

type UnlockType byte

UnlockType defines a type of unlock.

const (
	// UnlockSignature denotes a SignatureUnlock.
	UnlockSignature UnlockType = iota
	// UnlockReference denotes a ReferenceUnlock.
	UnlockReference
	// UnlockAccount denotes an AccountUnlock.
	UnlockAccount
	// UnlockAnchor denotes an AnchorUnlock.
	UnlockAnchor
	// UnlockNFT denotes a NFTUnlock.
	UnlockNFT
	// UnlockMulti denotes a MultiUnlock.
	UnlockMulti
	// UnlockEmpty denotes an EmptyUnlock.
	UnlockEmpty
)

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 SignaturesUniqueAndReferenceUnlocksValidator

func SignaturesUniqueAndReferenceUnlocksValidator(api API) UnlockValidatorFunc

SignaturesUniqueAndReferenceUnlocksValidator returns a validator which checks that:

  1. SignatureUnlock(s) are unique (compared by signer UID) - SignatureUnlock(s) inside different MultiUnlock(s) don't need to be unique, as long as there is no equal SignatureUnlock(s) outside of a MultiUnlock(s).
  2. ReferenceUnlock(s) reference a previous SignatureUnlock or MultiUnlock
  3. Following through AccountUnlock(s), AnchorUnlock(s), NFTUnlock(s) refs results to a SignatureUnlock
  4. EmptyUnlock(s) are only used inside of MultiUnlock(s)
  5. MultiUnlock(s) are not nested
  6. MultiUnlock(s) are unique
  7. ReferenceUnlock(s) to MultiUnlock(s) are not nested in MultiUnlock(s)

type Unlocks

type Unlocks []Unlock

func (Unlocks) Clone

func (o Unlocks) Clone() Unlocks

func (Unlocks) Size

func (o Unlocks) Size() int

func (Unlocks) WorkScore

func (o Unlocks) WorkScore(workScoreParameters *WorkScoreParameters) (WorkScore, error)

type V3ProtocolParameters

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

V3ProtocolParameters defines the parameters of the protocol.

func NewV3SnapshotProtocolParameters

func NewV3SnapshotProtocolParameters(opts ...options.Option[V3ProtocolParameters]) *V3ProtocolParameters

NewV3SnapshotProtocolParameters creates a new V3ProtocolParameters instance with the given options. IMPORTANT: this function should only be used to derive new protocol params for genesis snapshots or tests because it uses floating point arithmetic to derive mana decay factors and decay factor epochs sum. This might result in different parameters on different machines.

func (*V3ProtocolParameters) Bech32HRP

func (p *V3ProtocolParameters) Bech32HRP() NetworkPrefix

func (*V3ProtocolParameters) Bytes

func (p *V3ProtocolParameters) Bytes() ([]byte, error)

func (*V3ProtocolParameters) ChainSwitchingThreshold

func (p *V3ProtocolParameters) ChainSwitchingThreshold() uint8

func (*V3ProtocolParameters) CongestionControlParameters

func (p *V3ProtocolParameters) CongestionControlParameters() *CongestionControlParameters

func (*V3ProtocolParameters) EpochNearingThreshold

func (p *V3ProtocolParameters) EpochNearingThreshold() SlotIndex

func (*V3ProtocolParameters) Equals

func (p *V3ProtocolParameters) Equals(other ProtocolParameters) bool

func (*V3ProtocolParameters) GenesisBlockID

func (p *V3ProtocolParameters) GenesisBlockID() BlockID

GenesisBlockID defines the block ID of the genesis block.

func (*V3ProtocolParameters) GenesisSlot

func (p *V3ProtocolParameters) GenesisSlot() SlotIndex

GenesisSlot defines the genesis slot.

func (*V3ProtocolParameters) GenesisUnixTimestamp

func (p *V3ProtocolParameters) GenesisUnixTimestamp() int64

GenesisUnixTimestamp defines the genesis timestamp at which the slots start to count.

func (*V3ProtocolParameters) Hash

func (p *V3ProtocolParameters) Hash() (Identifier, error)

func (*V3ProtocolParameters) LivenessThresholdLowerBound

func (p *V3ProtocolParameters) LivenessThresholdLowerBound() time.Duration

func (*V3ProtocolParameters) LivenessThresholdUpperBound

func (p *V3ProtocolParameters) LivenessThresholdUpperBound() time.Duration

func (*V3ProtocolParameters) ManaParameters

func (p *V3ProtocolParameters) ManaParameters() *ManaParameters

func (*V3ProtocolParameters) MaxCommittableAge

func (p *V3ProtocolParameters) MaxCommittableAge() SlotIndex

func (*V3ProtocolParameters) MinCommittableAge

func (p *V3ProtocolParameters) MinCommittableAge() SlotIndex

func (*V3ProtocolParameters) NetworkID

func (p *V3ProtocolParameters) NetworkID() NetworkID

func (*V3ProtocolParameters) NetworkName

func (p *V3ProtocolParameters) NetworkName() string

func (*V3ProtocolParameters) ParamEpochDurationInSlots

func (p *V3ProtocolParameters) ParamEpochDurationInSlots() SlotIndex

ParamEpochDurationInSlots defines the amount of slots in an epoch.

func (*V3ProtocolParameters) PunishmentEpochs

func (p *V3ProtocolParameters) PunishmentEpochs() EpochIndex

func (*V3ProtocolParameters) RewardsParameters

func (p *V3ProtocolParameters) RewardsParameters() *RewardsParameters

func (*V3ProtocolParameters) SlotDurationInSeconds

func (p *V3ProtocolParameters) SlotDurationInSeconds() uint8

SlotDurationInSeconds defines the duration of each slot in seconds.

func (*V3ProtocolParameters) SlotsPerEpochExponent

func (p *V3ProtocolParameters) SlotsPerEpochExponent() uint8

SlotsPerEpochExponent is the number of slots in an epoch expressed as an exponent of 2.

func (*V3ProtocolParameters) StakingUnbondingPeriod

func (p *V3ProtocolParameters) StakingUnbondingPeriod() EpochIndex

func (*V3ProtocolParameters) StorageScoreParameters

func (p *V3ProtocolParameters) StorageScoreParameters() *StorageScoreParameters

func (*V3ProtocolParameters) String

func (p *V3ProtocolParameters) String() string

func (*V3ProtocolParameters) TargetCommitteeSize

func (p *V3ProtocolParameters) TargetCommitteeSize() uint8

func (*V3ProtocolParameters) TokenSupply

func (p *V3ProtocolParameters) TokenSupply() BaseToken

func (*V3ProtocolParameters) ValidationBlocksPerSlot

func (p *V3ProtocolParameters) ValidationBlocksPerSlot() uint8

func (*V3ProtocolParameters) Version

func (p *V3ProtocolParameters) Version() Version

func (*V3ProtocolParameters) VersionSignalingParameters

func (p *V3ProtocolParameters) VersionSignalingParameters() *VersionSignalingParameters

func (*V3ProtocolParameters) WorkScoreParameters

func (p *V3ProtocolParameters) WorkScoreParameters() *WorkScoreParameters

type ValidationBlockBody

type ValidationBlockBody struct {
	API API
	// The parents the block references.
	StrongParents      BlockIDs `serix:",lenPrefix=uint8,minLen=1,maxLen=50"`
	WeakParents        BlockIDs `serix:",lenPrefix=uint8,minLen=0,maxLen=50,omitempty"`
	ShallowLikeParents BlockIDs `serix:",lenPrefix=uint8,minLen=0,maxLen=50,omitempty"`

	HighestSupportedVersion Version `serix:""`
	// ProtocolParametersHash is the hash of the protocol parameters for the HighestSupportedVersion.
	ProtocolParametersHash Identifier `serix:""`
}

ValidationBlockBody represents a validation vertex in the Tangle/BlockDAG.

func (*ValidationBlockBody) Hash

func (b *ValidationBlockBody) Hash() (Identifier, error)

func (*ValidationBlockBody) SetDeserializationContext

func (b *ValidationBlockBody) SetDeserializationContext(ctx context.Context)

func (*ValidationBlockBody) ShallowLikeParentIDs

func (b *ValidationBlockBody) ShallowLikeParentIDs() BlockIDs

func (*ValidationBlockBody) Size

func (b *ValidationBlockBody) Size() int

func (*ValidationBlockBody) StrongParentIDs

func (b *ValidationBlockBody) StrongParentIDs() BlockIDs

func (*ValidationBlockBody) Type

func (*ValidationBlockBody) WeakParentIDs

func (b *ValidationBlockBody) WeakParentIDs() BlockIDs

func (*ValidationBlockBody) WorkScore

type Version

type Version byte

func LatestProtocolVersion

func LatestProtocolVersion() Version

func VersionFromBytes

func VersionFromBytes(b []byte) (Version, int, error)

func (Version) Bytes

func (v Version) Bytes() ([]byte, error)

type VersionSignalingParameters

type VersionSignalingParameters struct {
	// WindowSize is the size of the window in epochs to find which version of protocol parameters was most signaled, from currentEpoch - windowSize to currentEpoch.
	WindowSize uint8 `serix:""`
	// WindowTargetRatio is the target number of supporters for a version to win in a windowSize.
	WindowTargetRatio uint8 `serix:""`
	// ActivationOffset is the offset in epochs to activate the new version of protocol parameters.
	ActivationOffset uint8 `serix:""`
}

VersionSignalingParameters defines the parameters used by signaling protocol parameters upgrade.

func (VersionSignalingParameters) Equals

type WorkScore

type WorkScore uint32

WorkScore defines the type of work score used to denote the computation costs of processing an object.

func (WorkScore) Add

func (w WorkScore) Add(in ...WorkScore) (WorkScore, error)

Add adds in to this workscore.

func (WorkScore) Multiply

func (w WorkScore) Multiply(in int) (WorkScore, error)

Multiply multiplies in with this workscore.

type WorkScoreParameters

type WorkScoreParameters struct {
	// DataByte accounts for the network traffic per byte.
	DataByte WorkScore `serix:""`
	// Block accounts for work done to process a block in the node software (includes signature check for the block).
	Block WorkScore `serix:""`
	// Input accounts for loading the UTXO from the database and performing the mana calculations.
	Input WorkScore `serix:""`
	// ContextInput accounts for loading and checking the context input.
	ContextInput WorkScore `serix:""`
	// Output accounts for storing the UTXO in the database.
	Output WorkScore `serix:""`
	// NativeToken accounts for calculations done with native tokens.
	NativeToken WorkScore `serix:""`
	// Staking accounts for the existence of a staking feature in the output.
	// The node might need to update the staking vector.
	Staking WorkScore `serix:""`
	// BlockIssuer accounts for the existence of a block issuer feature in the output.
	// The node might need to update the available public keys that are allowed to issue blocks.
	BlockIssuer WorkScore `serix:""`
	// Allotment accounts for accessing the account based ledger to transform the mana to block issuance credits.
	Allotment WorkScore `serix:""`
	// SignatureEd25519 accounts for an Ed25519 signature check.
	SignatureEd25519 WorkScore `serix:""`
}

func (WorkScoreParameters) Equals

func (WorkScoreParameters) MaxBlockWork

func (w WorkScoreParameters) MaxBlockWork() (WorkScore, error)

MaxBlockWork is the maximum work score a block can have. This provides an overestimation of the maximum workscore as some constraints prevent a block from reaching this WorkScore, e.g., native tokens can't present on an account output, and the a block with this many signatures would exceed the maximum payload size. It is ok to have an overestimation as we only need this to ensure no block with larger WorkScore can exist.

Source Files

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.
blockissuer
pow
vm

Jump to

Keyboard shortcuts

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