pub struct Transaction {
    pub kind: TxKind,
    pub inputs: Vec<CoinID>,
    pub outputs: Vec<CoinData>,
    pub fee: CoinValue,
    pub covenants: Vec<Bytes>,
    pub data: Bytes,
    pub sigs: Vec<Bytes>,
}
Expand description

Transaction represents an individual, serializable Themelio transaction.

Fields

kind: TxKind

The “kind” of the transaction. Most transactions are of kind TxKind::Normal.

inputs: Vec<CoinID>

The coins that this transaction spends, identified by CoinID (transaction hash and index)

outputs: Vec<CoinData>

The outputs that this transaction creates.

fee: CoinValue

The fee paid by this transaction, in MEL.

covenants: Vec<Bytes>

The contents of the covenants locking the coins spent by this transaction. Themelio is uniformly “pay to script hash”, so coins (CoinDatas) themselves only contain the hash of the covenant locking the coin. The spending transaction must provide the actual covenants (in MelVM bytecode).

The ordering of this field does not matter. As long as there is some element in covenants corresponding to each unique covhash of the coins being spent, we’re good.

data: Bytes

Arbitrary additional data of the transaction. Used mostly for unlocking covenants, as well as playing a special role in Melswap and Melmint transactions.

sigs: Vec<Bytes>

A place to place cryptographically malleable data, usually signatures. The reason why we use this rather than data is because sigs is ignored when computing the unique hash of a transaction (see Transaction::hash_nosigs), which is important for checking whether a particular transaction went through while scanning the blockchain by transaction hash. (This is similar to the reason SegWit was included in Bitcoin)

Implementations

Creates a new transaction with the given kind, no inputs, no outputs, no nothing.

Checks whether or not the transaction is well formed, respecting coin size bounds and such. Does not fully validate the transaction.

hash_nosigs returns the hash of the transaction with a zeroed-out signature field. This is what signatures are computed against.

sign_ed25519 consumes the transaction, appends an ed25519 signature, and returns it.

total_outputs returns a HashMap mapping each type of coin to its total value. Fees will be included in the Mel cointype.

scripts_as_map returns a HashMap mapping the hash of each script in the transaction to the script itself.

Returns the minimum fee of the transaction at a given fee multiplier, with a given “ballast”.

Returns the weight of the transaction, given a function that maps a covenant to its weight.

Convenience function that constructs a CoinID that points to a certain output of this transaction. Panics if the index is out of bounds.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function. Read more
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more
Should always be Self
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.