Documentation
¶
Index ¶
- Constants
- Variables
- func EssenceBytesFromTransactionDataTree(txTree *lazybytes.Tree) []byte
- func IDAndTimestampFromTransactionBytes(txBytes []byte) (ledger.TransactionID, ledger.Time, error)
- func IDFromTransactionBytes(txBytes []byte) (ledger.TransactionID, error)
- func OutputWithIDFromTransactionBytes(txBytes []byte, idx byte) (*ledger.OutputWithID, error)
- func OutputsWithIDFromTransactionBytes(txBytes []byte) ([]*ledger.OutputWithID, error)
- func ParseBytesToString(txBytes []byte, fetchOutput func(oid *ledger.OutputID) ([]byte, bool)) string
- func PathToString(path []byte) string
- func PickOutputFromListFunc(lst []*ledger.OutputWithID) func(oid *ledger.OutputID) ([]byte, bool)
- func SaveTransactionAsFile(txBytes []byte, fname ...string) error
- func StringFromTxBytes(txBytes []byte, inputLoaderByIndex func(byte) (*ledger.Output, error)) string
- func UnlockDataToString(data []byte) string
- type SequencerTransactionData
- type Transaction
- func (tx *Transaction) Bytes() []byte
- func (tx *Transaction) ConsumedOutputAt(idx byte, fetchOutput func(id *ledger.OutputID) ([]byte, bool)) (*ledger.OutputDataWithID, error)
- func (tx *Transaction) EndorsementAt(idx byte) ledger.TransactionID
- func (tx *Transaction) EndorsementsVeryShort() string
- func (tx *Transaction) EssenceBytes() []byte
- func (tx *Transaction) FindChainOutput(chainID ledger.ChainID) *ledger.OutputWithID
- func (tx *Transaction) FindStemProducedOutput() *ledger.OutputWithID
- func (tx *Transaction) ForEachEndorsement(fun func(idx byte, txid *ledger.TransactionID) bool)
- func (tx *Transaction) ForEachInput(fun func(i byte, oid *ledger.OutputID) bool)
- func (tx *Transaction) ForEachOutputData(fun func(idx byte, oData []byte) bool)
- func (tx *Transaction) ForEachProducedOutput(fun func(idx byte, o *ledger.Output, oid *ledger.OutputID) bool)
- func (tx *Transaction) Hash() ledger.TransactionIDShort
- func (tx *Transaction) HashInputsAndEndorsements() [32]byte
- func (tx *Transaction) ID() ledger.TransactionID
- func (tx *Transaction) IDRef() *ledger.TransactionID
- func (tx *Transaction) IDShortString() string
- func (tx *Transaction) IDString() string
- func (tx *Transaction) IDStringHex() string
- func (tx *Transaction) IDVeryShortString() string
- func (tx *Transaction) InflationAmount() uint64
- func (tx *Transaction) InputAt(idx byte) (ret ledger.OutputID, err error)
- func (tx *Transaction) InputAtShort(idx byte) string
- func (tx *Transaction) InputAtString(idx byte) string
- func (tx *Transaction) InputLoaderByIndex(fetchOutput func(oid *ledger.OutputID) ([]byte, bool)) func(byte) (*ledger.Output, error)
- func (tx *Transaction) InputLoaderFromState(rdr multistate.StateReader) func(idx byte) (*ledger.Output, error)
- func (tx *Transaction) Inputs() []ledger.OutputID
- func (tx *Transaction) IsBranchTransaction() bool
- func (tx *Transaction) IsSequencerMilestone() bool
- func (tx *Transaction) Lines(inputLoaderByIndex func(i byte) (*ledger.Output, error), prefix ...string) *lines.Lines
- func (tx *Transaction) LinesShort(prefix ...string) *lines.Lines
- func (tx *Transaction) MustInputAt(idx byte) ledger.OutputID
- func (tx *Transaction) MustOutputDataAt(idx byte) []byte
- func (tx *Transaction) MustOutputIndexOfTheInput(inputIdx byte) byte
- func (tx *Transaction) MustProducedOutputAt(idx byte) *ledger.Output
- func (tx *Transaction) MustProducedOutputWithIDAt(idx byte) *ledger.OutputWithID
- func (tx *Transaction) MustUnlockDataAt(idx byte) []byte
- func (tx *Transaction) NumEndorsements() int
- func (tx *Transaction) NumInputs() int
- func (tx *Transaction) NumProducedOutputs() int
- func (tx *Transaction) OutputID(idx byte) ledger.OutputID
- func (tx *Transaction) PredecessorTransactionIDs() set.Set[ledger.TransactionID]
- func (tx *Transaction) ProducedOutputAt(idx byte) (*ledger.Output, error)
- func (tx *Transaction) ProducedOutputWithIDAt(idx byte) (*ledger.OutputWithID, error)
- func (tx *Transaction) ProducedOutputs() []*ledger.OutputWithID
- func (tx *Transaction) ProducedOutputsToString() string
- func (tx *Transaction) ProducedOutputsWithTargetLock(lock ledger.Lock) []*ledger.OutputWithID
- func (tx *Transaction) SenderAddress() ledger.AddressED25519
- func (tx *Transaction) SequencerAndStemInputData() (seqInputIdx *byte, stemInputIdx *byte, seqID *ledger.ChainID)
- func (tx *Transaction) SequencerAndStemOutputIndices() (byte, byte)
- func (tx *Transaction) SequencerChainPredecessor() (*ledger.OutputID, byte)
- func (tx *Transaction) SequencerOutput() *ledger.OutputWithID
- func (tx *Transaction) SequencerTransactionData() *SequencerTransactionData
- func (tx *Transaction) SignatureBytes() []byte
- func (tx *Transaction) Slot() ledger.Slot
- func (tx *Transaction) StateMutations() *multistate.Mutations
- func (tx *Transaction) StemOutput() *ledger.OutputWithID
- func (tx *Transaction) StemOutputData() *ledger.StemLock
- func (tx *Transaction) String() string
- func (tx *Transaction) Timestamp() ledger.Time
- func (tx *Transaction) TimestampTime() time.Time
- func (tx *Transaction) ToString(fetchOutput func(oid *ledger.OutputID) ([]byte, bool)) string
- func (tx *Transaction) ToStringWithInputLoaderByIndex(fetchOutput func(i byte) (*ledger.Output, error)) string
- func (tx *Transaction) TotalAmount() uint64
- func (tx *Transaction) Validate(opt ...TxValidationOption) error
- type TxContext
- func TxContextFromState(tx *Transaction, rdr multistate.SugaredStateReader) (*TxContext, error)
- func TxContextFromTransaction(tx *Transaction, inputLoaderByIndex func(i byte) (*ledger.Output, error), ...) (*TxContext, error)
- func TxContextFromTransferableBytes(txBytes []byte, fetchInput func(oid *ledger.OutputID) ([]byte, bool), ...) (*TxContext, error)
- func (ctx *TxContext) ConsumedOutput(idx byte) (*ledger.Output, error)
- func (ctx *TxContext) ConsumedOutputData(idx byte) []byte
- func (ctx *TxContext) ConsumedOutputHash() [32]byte
- func (ctx *TxContext) ForEachConsumedOutput(fun func(idx byte, oid *ledger.OutputID, out *ledger.Output) bool)
- func (ctx *TxContext) ForEachEndorsement(fun func(idx byte, txid *ledger.TransactionID) bool)
- func (ctx *TxContext) ForEachInputID(fun func(idx byte, oid *ledger.OutputID) bool)
- func (ctx *TxContext) ForEachProducedOutput(fun func(idx byte, out *ledger.Output, oid *ledger.OutputID) bool)
- func (ctx *TxContext) ForEachProducedOutputData(fun func(idx byte, oData []byte) bool)
- func (ctx *TxContext) InputCommitment() []byte
- func (ctx *TxContext) InputID(idx byte) ledger.OutputID
- func (ctx *TxContext) Lines(prefix ...string) *lines.Lines
- func (ctx *TxContext) MustTimestampData() ([]byte, ledger.Time)
- func (ctx *TxContext) NumEndorsements() int
- func (ctx *TxContext) NumInputs() int
- func (ctx *TxContext) NumProducedOutputs() int
- func (ctx *TxContext) OutputID(idx byte) ledger.OutputID
- func (ctx *TxContext) ProducedOutput(idx byte) (*ledger.OutputWithID, error)
- func (ctx *TxContext) ProducedOutputData(idx byte) []byte
- func (ctx *TxContext) SequencerAndStemOutputIndices() (byte, byte)
- func (ctx *TxContext) Signature() []byte
- func (ctx *TxContext) String() string
- func (ctx *TxContext) TotalAmountStored() uint64
- func (ctx *TxContext) TotalInflation() uint64
- func (ctx *TxContext) TransactionBytes() []byte
- func (ctx *TxContext) TransactionID() *ledger.TransactionID
- func (ctx *TxContext) UnlockDataAt(idx byte) []byte
- func (ctx *TxContext) UnlockParams(consumedOutputIdx, constraintIdx byte) []byte
- func (ctx *TxContext) Validate() error
- func (ctx *TxContext) ValidateWithReportOnConsumedOutputs() ([]byte, error)
- type TxValidationOption
- func BaseValidation() TxValidationOption
- func CheckEndorsements() TxValidationOption
- func CheckNumElements() TxValidationOption
- func CheckSender() TxValidationOption
- func CheckSizeOfOutputCommitment() TxValidationOption
- func CheckTimePace() TxValidationOption
- func CheckTimestampLowerBound(lowerBound time.Time) TxValidationOption
- func CheckTimestampUpperBound(upperBound time.Time) TxValidationOption
- func CheckUniqueness() TxValidationOption
- func ScanOutputs() TxValidationOption
- func ScanSequencerData() TxValidationOption
- func ValidateOptionWithFullContext(inputLoaderByIndex func(i byte) (*ledger.Output, error)) TxValidationOption
Constants ¶
const ( TraceOptionNone = iota TraceOptionAll TraceOptionFailedConstraints )
Variables ¶
var MainTxValidationOptions = []TxValidationOption{ ScanSequencerData(), CheckSender(), CheckNumElements(), CheckTimePace(), CheckEndorsements(), CheckUniqueness(), ScanOutputs(), CheckSizeOfOutputCommitment(), }
MainTxValidationOptions is all except Base, time bounds and input context validation
var Path = lazybytes.Path
Functions ¶
func IDFromTransactionBytes ¶
func IDFromTransactionBytes(txBytes []byte) (ledger.TransactionID, error)
func OutputWithIDFromTransactionBytes ¶
func OutputWithIDFromTransactionBytes(txBytes []byte, idx byte) (*ledger.OutputWithID, error)
func OutputsWithIDFromTransactionBytes ¶
func OutputsWithIDFromTransactionBytes(txBytes []byte) ([]*ledger.OutputWithID, error)
func ParseBytesToString ¶
func PathToString ¶
func PickOutputFromListFunc ¶
func SaveTransactionAsFile ¶
func StringFromTxBytes ¶
func UnlockDataToString ¶
Types ¶
type SequencerTransactionData ¶
type SequencerTransactionData struct { SequencerOutputData *ledger.SequencerOutputData StemOutputData *ledger.StemLock // nil if does not contain stem output SequencerID ledger.ChainID // adjusted for chain origin SequencerOutputIndex byte StemOutputIndex byte // 0xff if not a branch transaction }
SequencerTransactionData represents sequencer and stem data on the transaction
func (*SequencerTransactionData) Short ¶
func (m *SequencerTransactionData) Short() string
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction provides access to the tree of transferable transaction
func FromBytes ¶
func FromBytes(txBytes []byte, opt ...TxValidationOption) (*Transaction, error)
func FromBytesMainChecksWithOpt ¶
func FromBytesMainChecksWithOpt(txBytes []byte, additional ...TxValidationOption) (*Transaction, error)
func (*Transaction) Bytes ¶
func (tx *Transaction) Bytes() []byte
func (*Transaction) ConsumedOutputAt ¶
func (tx *Transaction) ConsumedOutputAt(idx byte, fetchOutput func(id *ledger.OutputID) ([]byte, bool)) (*ledger.OutputDataWithID, error)
func (*Transaction) EndorsementAt ¶
func (tx *Transaction) EndorsementAt(idx byte) ledger.TransactionID
func (*Transaction) EndorsementsVeryShort ¶
func (tx *Transaction) EndorsementsVeryShort() string
func (*Transaction) EssenceBytes ¶
func (tx *Transaction) EssenceBytes() []byte
func (*Transaction) FindChainOutput ¶
func (tx *Transaction) FindChainOutput(chainID ledger.ChainID) *ledger.OutputWithID
func (*Transaction) FindStemProducedOutput ¶
func (tx *Transaction) FindStemProducedOutput() *ledger.OutputWithID
func (*Transaction) ForEachEndorsement ¶
func (tx *Transaction) ForEachEndorsement(fun func(idx byte, txid *ledger.TransactionID) bool)
func (*Transaction) ForEachInput ¶
func (tx *Transaction) ForEachInput(fun func(i byte, oid *ledger.OutputID) bool)
func (*Transaction) ForEachOutputData ¶
func (tx *Transaction) ForEachOutputData(fun func(idx byte, oData []byte) bool)
func (*Transaction) ForEachProducedOutput ¶
func (tx *Transaction) ForEachProducedOutput(fun func(idx byte, o *ledger.Output, oid *ledger.OutputID) bool)
ForEachProducedOutput traverses all produced outputs Inside callback function the correct outputID must be obtained with OutputID(idx byte) ledger.OutputID because stem output ID has special form
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() ledger.TransactionIDShort
func (*Transaction) HashInputsAndEndorsements ¶
func (tx *Transaction) HashInputsAndEndorsements() [32]byte
HashInputsAndEndorsements blake2b of concatenated input IDs and endorsements independent on any other tz data but inputs
func (*Transaction) ID ¶
func (tx *Transaction) ID() ledger.TransactionID
func (*Transaction) IDRef ¶
func (tx *Transaction) IDRef() *ledger.TransactionID
func (*Transaction) IDShortString ¶
func (tx *Transaction) IDShortString() string
func (*Transaction) IDString ¶
func (tx *Transaction) IDString() string
func (*Transaction) IDStringHex ¶
func (tx *Transaction) IDStringHex() string
func (*Transaction) IDVeryShortString ¶
func (tx *Transaction) IDVeryShortString() string
func (*Transaction) InflationAmount ¶
func (tx *Transaction) InflationAmount() uint64
func (*Transaction) InputAt ¶
func (tx *Transaction) InputAt(idx byte) (ret ledger.OutputID, err error)
func (*Transaction) InputAtShort ¶
func (tx *Transaction) InputAtShort(idx byte) string
func (*Transaction) InputAtString ¶
func (tx *Transaction) InputAtString(idx byte) string
func (*Transaction) InputLoaderByIndex ¶
func (*Transaction) InputLoaderFromState ¶
func (tx *Transaction) InputLoaderFromState(rdr multistate.StateReader) func(idx byte) (*ledger.Output, error)
func (*Transaction) Inputs ¶
func (tx *Transaction) Inputs() []ledger.OutputID
func (*Transaction) IsBranchTransaction ¶
func (tx *Transaction) IsBranchTransaction() bool
func (*Transaction) IsSequencerMilestone ¶
func (tx *Transaction) IsSequencerMilestone() bool
func (*Transaction) LinesShort ¶
func (tx *Transaction) LinesShort(prefix ...string) *lines.Lines
func (*Transaction) MustInputAt ¶
func (tx *Transaction) MustInputAt(idx byte) ledger.OutputID
func (*Transaction) MustOutputDataAt ¶
func (tx *Transaction) MustOutputDataAt(idx byte) []byte
func (*Transaction) MustOutputIndexOfTheInput ¶
func (tx *Transaction) MustOutputIndexOfTheInput(inputIdx byte) byte
func (*Transaction) MustProducedOutputAt ¶
func (tx *Transaction) MustProducedOutputAt(idx byte) *ledger.Output
func (*Transaction) MustProducedOutputWithIDAt ¶
func (tx *Transaction) MustProducedOutputWithIDAt(idx byte) *ledger.OutputWithID
func (*Transaction) MustUnlockDataAt ¶
func (tx *Transaction) MustUnlockDataAt(idx byte) []byte
func (*Transaction) NumEndorsements ¶
func (tx *Transaction) NumEndorsements() int
func (*Transaction) NumInputs ¶
func (tx *Transaction) NumInputs() int
func (*Transaction) NumProducedOutputs ¶
func (tx *Transaction) NumProducedOutputs() int
func (*Transaction) PredecessorTransactionIDs ¶
func (tx *Transaction) PredecessorTransactionIDs() set.Set[ledger.TransactionID]
func (*Transaction) ProducedOutputAt ¶
func (tx *Transaction) ProducedOutputAt(idx byte) (*ledger.Output, error)
func (*Transaction) ProducedOutputWithIDAt ¶
func (tx *Transaction) ProducedOutputWithIDAt(idx byte) (*ledger.OutputWithID, error)
func (*Transaction) ProducedOutputs ¶
func (tx *Transaction) ProducedOutputs() []*ledger.OutputWithID
func (*Transaction) ProducedOutputsToString ¶
func (tx *Transaction) ProducedOutputsToString() string
func (*Transaction) ProducedOutputsWithTargetLock ¶
func (tx *Transaction) ProducedOutputsWithTargetLock(lock ledger.Lock) []*ledger.OutputWithID
func (*Transaction) SenderAddress ¶
func (tx *Transaction) SenderAddress() ledger.AddressED25519
func (*Transaction) SequencerAndStemInputData ¶
func (tx *Transaction) SequencerAndStemInputData() (seqInputIdx *byte, stemInputIdx *byte, seqID *ledger.ChainID)
func (*Transaction) SequencerAndStemOutputIndices ¶
func (tx *Transaction) SequencerAndStemOutputIndices() (byte, byte)
SequencerAndStemOutputIndices return seq output index and stem output index
func (*Transaction) SequencerChainPredecessor ¶
func (tx *Transaction) SequencerChainPredecessor() (*ledger.OutputID, byte)
SequencerChainPredecessor returns chain predecessor output ID If it is chain origin, it returns nil. Otherwise, it may or may not be a sequencer ID It also returns index of the inout
func (*Transaction) SequencerOutput ¶
func (tx *Transaction) SequencerOutput() *ledger.OutputWithID
func (*Transaction) SequencerTransactionData ¶
func (tx *Transaction) SequencerTransactionData() *SequencerTransactionData
SequencerTransactionData returns nil it is not a sequencer milestone
func (*Transaction) SignatureBytes ¶
func (tx *Transaction) SignatureBytes() []byte
func (*Transaction) Slot ¶
func (tx *Transaction) Slot() ledger.Slot
func (*Transaction) StateMutations ¶
func (tx *Transaction) StateMutations() *multistate.Mutations
func (*Transaction) StemOutput ¶
func (tx *Transaction) StemOutput() *ledger.OutputWithID
func (*Transaction) StemOutputData ¶
func (tx *Transaction) StemOutputData() *ledger.StemLock
func (*Transaction) String ¶
func (tx *Transaction) String() string
func (*Transaction) Timestamp ¶
func (tx *Transaction) Timestamp() ledger.Time
func (*Transaction) TimestampTime ¶
func (tx *Transaction) TimestampTime() time.Time
func (*Transaction) ToStringWithInputLoaderByIndex ¶
func (*Transaction) TotalAmount ¶
func (tx *Transaction) TotalAmount() uint64
func (*Transaction) Validate ¶
func (tx *Transaction) Validate(opt ...TxValidationOption) error
type TxContext ¶
type TxContext struct {
// contains filtered or unexported fields
}
TxContext is a data structure, which contains transferable transaction, consumed outputs and constraint library
func TxContextFromState ¶
func TxContextFromState(tx *Transaction, rdr multistate.SugaredStateReader) (*TxContext, error)
func TxContextFromTransferableBytes ¶
func TxContextFromTransferableBytes(txBytes []byte, fetchInput func(oid *ledger.OutputID) ([]byte, bool), traceOption ...int) (*TxContext, error)
TxContextFromTransferableBytes constructs lazybytes.Tree from transaction bytes and consumed outputs
func (*TxContext) ConsumedOutput ¶
func (*TxContext) ConsumedOutputData ¶
func (*TxContext) ConsumedOutputHash ¶
func (*TxContext) ForEachConsumedOutput ¶
func (*TxContext) ForEachEndorsement ¶
func (ctx *TxContext) ForEachEndorsement(fun func(idx byte, txid *ledger.TransactionID) bool)
func (*TxContext) ForEachInputID ¶
func (*TxContext) ForEachProducedOutput ¶
func (*TxContext) ForEachProducedOutputData ¶
func (*TxContext) InputCommitment ¶
func (*TxContext) MustTimestampData ¶
func (*TxContext) NumEndorsements ¶
func (*TxContext) NumProducedOutputs ¶
func (*TxContext) ProducedOutput ¶
func (ctx *TxContext) ProducedOutput(idx byte) (*ledger.OutputWithID, error)
func (*TxContext) ProducedOutputData ¶
func (*TxContext) SequencerAndStemOutputIndices ¶
func (*TxContext) TotalAmountStored ¶
func (*TxContext) TotalInflation ¶
func (*TxContext) TransactionBytes ¶
func (*TxContext) TransactionID ¶
func (ctx *TxContext) TransactionID() *ledger.TransactionID
func (*TxContext) UnlockDataAt ¶
func (*TxContext) UnlockParams ¶
func (*TxContext) ValidateWithReportOnConsumedOutputs ¶
ValidateWithReportOnConsumedOutputs validates the transaction and returns indices of failing consumed outputs, if any This for the convenience of automated VMs and sequencers
type TxValidationOption ¶
type TxValidationOption func(tx *Transaction) error
Transaction provides access to the tree of transferable transaction
func BaseValidation ¶
func BaseValidation() TxValidationOption
BaseValidation is a checking of being able to extract ID. If not, bytes are not identifiable as a transaction
func CheckEndorsements ¶
func CheckEndorsements() TxValidationOption
CheckEndorsements endorsed transactions must be sequencer transaction from the current slot
func CheckNumElements ¶
func CheckNumElements() TxValidationOption
func CheckSender ¶
func CheckSender() TxValidationOption
CheckSender returns a signature validator. It also sets the sender field
func CheckSizeOfOutputCommitment ¶
func CheckSizeOfOutputCommitment() TxValidationOption
func CheckTimePace ¶
func CheckTimePace() TxValidationOption
CheckTimePace consumed outputs must satisfy time pace constraint
func CheckTimestampLowerBound ¶
func CheckTimestampLowerBound(lowerBound time.Time) TxValidationOption
func CheckTimestampUpperBound ¶
func CheckTimestampUpperBound(upperBound time.Time) TxValidationOption
func CheckUniqueness ¶
func CheckUniqueness() TxValidationOption
func ScanOutputs ¶
func ScanOutputs() TxValidationOption
ScanOutputs validation option scans all inputs, enforces existence of mandatory constrains, computes total of outputs and total inflation
func ScanSequencerData ¶
func ScanSequencerData() TxValidationOption
func ValidateOptionWithFullContext ¶
func ValidateOptionWithFullContext(inputLoaderByIndex func(i byte) (*ledger.Output, error)) TxValidationOption