Documentation ¶
Index ¶
- Constants
- Variables
- func FromStorageKey(key []byte, optionalTargetObject ...*Transaction) (result objectstorage.StorableObject, consumedBytes int, err error)
- type CachedTransaction
- type ID
- type Inputs
- func (inputs *Inputs) Add(input OutputID) *Inputs
- func (inputs *Inputs) Bytes() (bytes []byte)
- func (inputs *Inputs) ForEach(consumer func(outputID OutputID) bool) bool
- func (inputs *Inputs) ForEachAddress(consumer func(currentAddress address.Address) bool) bool
- func (inputs *Inputs) ForEachTransaction(consumer func(transactionId ID) bool) bool
- func (inputs *Inputs) String() string
- type OutputID
- func NewOutputID(outputAddress address.Address, transactionID ID) (outputID OutputID)
- func OutputIDFromBase58(base58String string) (outputid OutputID, err error)
- func OutputIDFromBytes(bytes []byte) (result OutputID, consumedBytes int, err error)
- func ParseOutputID(marshalUtil *marshalutil.MarshalUtil) (OutputID, error)
- type Outputs
- type Signatures
- func (signatures *Signatures) Add(address address.Address, signature signaturescheme.Signature)
- func (signatures *Signatures) Bytes() []byte
- func (signatures *Signatures) ForEach(...)
- func (signatures *Signatures) Get(address address.Address) (signaturescheme.Signature, bool)
- func (signatures *Signatures) Size() int
- func (signatures *Signatures) String() string
- type Transaction
- func (transaction *Transaction) Bytes() []byte
- func (transaction *Transaction) DataPayloadSize() uint32
- func (transaction *Transaction) EssenceBytes() []byte
- func (transaction *Transaction) GetDataPayload() []byte
- func (transaction *Transaction) ID() ID
- func (transaction *Transaction) Inputs() *Inputs
- func (transaction *Transaction) InputsCountValid() bool
- func (transaction *Transaction) ObjectStorageKey() []byte
- func (transaction *Transaction) ObjectStorageValue() []byte
- func (transaction *Transaction) Outputs() *Outputs
- func (transaction *Transaction) PutSignature(signature signaturescheme.Signature) error
- func (transaction *Transaction) SetDataPayload(data []byte) error
- func (transaction *Transaction) Sign(signature signaturescheme.SignatureScheme) *Transaction
- func (transaction *Transaction) SignatureBytes() []byte
- func (transaction *Transaction) Signatures() (signatures []signaturescheme.Signature)
- func (transaction *Transaction) SignaturesValid() bool
- func (transaction *Transaction) String() string
- func (transaction *Transaction) UnmarshalObjectStorageValue(bytes []byte) (consumedBytes int, err error)
- func (transaction *Transaction) Update(other objectstorage.StorableObject)
Constants ¶
const IDLength = 32
IDLength contains the amount of bytes that a marshaled version of the ID contains.
const (
// MaxTransactionInputCount is the maximum number of inputs a transaction can have
MaxTransactionInputCount = 100
)
const OutputIDLength = address.Length + IDLength
OutputIDLength contains the amount of bytes that a marshaled version of the OutputID contains.
Variables ¶
var ( // ErrMaxDataPayloadSizeExceeded is returned if the data payload size is exceeded. ErrMaxDataPayloadSizeExceeded = errors.New("maximum data payload size exceeded") )
Functions ¶
func FromStorageKey ¶
func FromStorageKey(key []byte, optionalTargetObject ...*Transaction) (result objectstorage.StorableObject, consumedBytes int, err error)
FromStorageKey is a factory method that creates a new Transaction instance from a storage key of the objectstorage. It is used by the objectstorage, to create new instances of this entity.
Types ¶
type CachedTransaction ¶
type CachedTransaction struct {
objectstorage.CachedObject
}
CachedTransaction is a wrapper for the object storage, that takes care of type casting the Transaction objects. Since go does not have generics (yet), the object storage works based on the generic "interface{}" type, which means that we have to regularly type cast the returned objects, to match the expected type. To reduce the burden of manually managing these type, we create a wrapper that does this for us. This way, we can consistently handle the specialized types of Transaction, without having to manually type cast over and over again.
func (*CachedTransaction) Consume ¶
func (cachedTransaction *CachedTransaction) Consume(consumer func(tx *Transaction)) bool
Consume overrides the underlying method to use a CachedTransaction object instead of a generic CachedObject in the consumer).
func (*CachedTransaction) Retain ¶
func (cachedTransaction *CachedTransaction) Retain() *CachedTransaction
Retain overrides the underlying method to return a new CachedTransaction instead of a generic CachedObject.
func (*CachedTransaction) Unwrap ¶
func (cachedTransaction *CachedTransaction) Unwrap() *Transaction
Unwrap provides a way to retrieve a type casted version of the underlying object.
type ID ¶
ID is the data type that represents the identifier for a Transaction.
var GenesisID ID
GenesisID represents the genesis ID.
func IDFromBase58 ¶
IDFromBase58 creates an id from a base58 encoded string.
func IDFromBytes ¶
IDFromBytes unmarshals an ID from a sequence of bytes.
func ParseID ¶
func ParseID(marshalUtil *marshalutil.MarshalUtil) (ID, error)
ParseID is a wrapper for simplified unmarshaling of Ids from a byte stream using the marshalUtil package.
type Inputs ¶
type Inputs struct {
*orderedmap.OrderedMap
}
Inputs represents a list of referenced Outputs that are used as Inputs in a transaction.
func InputsFromBytes ¶
InputsFromBytes unmarshals the Inputs from a sequence of bytes.
func NewInputs ¶
NewInputs is the constructor of the Inputs object and creates a new list with the given OutputIds.
func (*Inputs) ForEach ¶
ForEach iterates through the referenced Outputs and calls the consumer function for every Output. The iteration can be aborted by returning false in the consumer.
func (*Inputs) ForEachAddress ¶
ForEachAddress iterates through the input addresses and calls the consumer function for every Address. The iteration can be aborted by returning false in the consumer.
func (*Inputs) ForEachTransaction ¶
ForEachTransaction iterates through the transactions that had their Outputs consumed and calls the consumer function for every founds transaction. The iteration can be aborted by returning false in the consumer.
type OutputID ¶
type OutputID [OutputIDLength]byte
OutputID is the data type that represents the identifier for a Output.
func NewOutputID ¶
NewOutputID is the constructor for the OutputID type.
func OutputIDFromBase58 ¶
OutputIDFromBase58 creates an output id from a base58 encoded string.
func OutputIDFromBytes ¶
OutputIDFromBytes unmarshals an OutputID from a sequence of bytes.
func ParseOutputID ¶
func ParseOutputID(marshalUtil *marshalutil.MarshalUtil) (OutputID, error)
ParseOutputID is a wrapper for simplified unmarshaling of Ids from a byte stream using the marshalUtil package.
func (OutputID) String ¶
String creates a human readable version of the OutputID (for debug purposes).
func (OutputID) TransactionID ¶
TransactionID returns the transaction id part of an OutputID.
type Outputs ¶
type Outputs struct {
*orderedmap.OrderedMap
}
Outputs represents a list of Outputs that are part of a transaction.
func NewOutputs ¶
NewOutputs is the constructor of the Outputs struct and creates the list of Outputs from the given details.
func OutputsFromBytes ¶
func OutputsFromBytes(bytes []byte, optionalTargetObject ...*Outputs) (result *Outputs, consumedBytes int, err error)
OutputsFromBytes reads the bytes and unmarshals the given information into an *Outputs object. It either creates a new object, or uses the optional object provided in the arguments.
type Signatures ¶
type Signatures struct {
// contains filtered or unexported fields
}
Signatures represents a container for the address signatures of a value transfer. It internally manages the list of signatures as an ordered map, so that the serialization order is deterministic and produces the same sequence of bytes during marshaling and unmarshaling.
func NewSignatures ¶
func NewSignatures() *Signatures
NewSignatures creates an empty container for the address signatures of a value transfer.
func SignaturesFromBytes ¶
func SignaturesFromBytes(bytes []byte, optionalTargetObject ...*Signatures) (result *Signatures, consumedBytes int, err error)
SignaturesFromBytes unmarshals a container with signatures from a sequence of bytes. It either creates a new container or fills the optionally provided container with the parsed information.
func (*Signatures) Add ¶
func (signatures *Signatures) Add(address address.Address, signature signaturescheme.Signature)
Add adds a new Signature to this container.
func (*Signatures) Bytes ¶
func (signatures *Signatures) Bytes() []byte
Bytes marshals the signatures into a sequence of bytes.
func (*Signatures) ForEach ¶
func (signatures *Signatures) ForEach(consumer func(address address.Address, signature signaturescheme.Signature) bool)
ForEach iterates through all signatures, calling the consumer for every found entry. The iteration can be aborted by the consumer returning false
func (*Signatures) Get ¶
func (signatures *Signatures) Get(address address.Address) (signaturescheme.Signature, bool)
Get returns the Signature, that belongs to an Address.
func (*Signatures) Size ¶
func (signatures *Signatures) Size() int
Size returns the amount of signatures in this container.
func (*Signatures) String ¶
func (signatures *Signatures) String() string
type Transaction ¶
type Transaction struct { objectstorage.StorableObjectFlags // contains filtered or unexported fields }
Transaction represents a value transfer for IOTA. It consists out of a number of inputs, a number of outputs and their corresponding signature. Additionally, there is an optional data field, that can be used to include payment details or processing information.
func FromBytes ¶
func FromBytes(bytes []byte, optionalTargetObject ...*Transaction) (result *Transaction, consumedBytes int, err error)
FromBytes unmarshals a Transaction from a sequence of bytes.
func New ¶
func New(inputs *Inputs, outputs *Outputs) *Transaction
New creates a new Transaction from the given details. The signatures are omitted as signing requires us to marshal the transaction into a sequence of bytes and these bytes are unknown at the time of the creation of the Transaction.
func Parse ¶
func Parse(marshalUtil *marshalutil.MarshalUtil, optionalTargetObject ...*Transaction) (result *Transaction, err error)
Parse unmarshals a Transaction using the given marshalUtil (for easier marshaling/unmarshaling).
func (*Transaction) Bytes ¶
func (transaction *Transaction) Bytes() []byte
Bytes returns a marshaled version of this Transaction (essence + signatures).
func (*Transaction) DataPayloadSize ¶
func (transaction *Transaction) DataPayloadSize() uint32
DataPayloadSize returns the size of the dataPayload as uint32. nil payload as size 0
func (*Transaction) EssenceBytes ¶
func (transaction *Transaction) EssenceBytes() []byte
EssenceBytes return the bytes of the transaction excluding the Signatures. These bytes are later signed and used to generate the Signatures.
func (*Transaction) GetDataPayload ¶
func (transaction *Transaction) GetDataPayload() []byte
GetDataPayload gets the dataPayload and its type
func (*Transaction) ID ¶
func (transaction *Transaction) ID() ID
ID returns the identifier of this Transaction.
func (*Transaction) Inputs ¶
func (transaction *Transaction) Inputs() *Inputs
Inputs returns the list of Inputs that were consumed by this Transaction.
func (*Transaction) InputsCountValid ¶ added in v0.2.2
func (transaction *Transaction) InputsCountValid() bool
InputsCountValid returns true if the number of inputs in this transaction is not greater than MaxTransactionInputCount.
func (*Transaction) ObjectStorageKey ¶
func (transaction *Transaction) ObjectStorageKey() []byte
ObjectStorageKey returns the bytes that are used as a key when storing the Transaction in an objectstorage.
func (*Transaction) ObjectStorageValue ¶
func (transaction *Transaction) ObjectStorageValue() []byte
ObjectStorageValue returns a bytes representation of the Transaction by implementing the encoding.BinaryMarshaler interface.
func (*Transaction) Outputs ¶
func (transaction *Transaction) Outputs() *Outputs
Outputs returns the list of Outputs where this Transaction moves its consumed funds.
func (*Transaction) PutSignature ¶
func (transaction *Transaction) PutSignature(signature signaturescheme.Signature) error
PutSignature validates and adds signature to the transaction
func (*Transaction) SetDataPayload ¶
func (transaction *Transaction) SetDataPayload(data []byte) error
SetDataPayload sets yhe dataPayload and its type
func (*Transaction) Sign ¶
func (transaction *Transaction) Sign(signature signaturescheme.SignatureScheme) *Transaction
Sign adds a new signature to the Transaction.
func (*Transaction) SignatureBytes ¶
func (transaction *Transaction) SignatureBytes() []byte
SignatureBytes returns the bytes of all of the signatures in the Transaction.
func (*Transaction) Signatures ¶ added in v0.2.2
func (transaction *Transaction) Signatures() (signatures []signaturescheme.Signature)
Signatures returns all the signatures in this transaction.
func (*Transaction) SignaturesValid ¶
func (transaction *Transaction) SignaturesValid() bool
SignaturesValid returns true if the Signatures in this transaction
func (*Transaction) String ¶
func (transaction *Transaction) String() string
String returns a human readable version of this Transaction (for debug purposes).
func (*Transaction) UnmarshalObjectStorageValue ¶
func (transaction *Transaction) UnmarshalObjectStorageValue(bytes []byte) (consumedBytes int, err error)
UnmarshalObjectStorageValue unmarshals the bytes that are stored in the value of the objectstorage.
func (*Transaction) Update ¶
func (transaction *Transaction) Update(other objectstorage.StorableObject)
Update is disabled but needs to be implemented to be compatible with the objectstorage.