pub enum Transaction {
    V1 {
        inputs: Vec<Input>,
        outputs: Vec<Output>,
        lock_time: LockTime,
    },
    V2 {
        inputs: Vec<Input>,
        outputs: Vec<Output>,
        lock_time: LockTime,
        joinsplit_data: Option<JoinSplitData<Bctv14Proof>>,
    },
    V3 {
        inputs: Vec<Input>,
        outputs: Vec<Output>,
        lock_time: LockTime,
        expiry_height: Height,
        joinsplit_data: Option<JoinSplitData<Bctv14Proof>>,
    },
    V4 {
        inputs: Vec<Input>,
        outputs: Vec<Output>,
        lock_time: LockTime,
        expiry_height: Height,
        joinsplit_data: Option<JoinSplitData<Groth16Proof>>,
        sapling_shielded_data: Option<ShieldedData<PerSpendAnchor>>,
    },
    V5 {
        network_upgrade: NetworkUpgrade,
        lock_time: LockTime,
        expiry_height: Height,
        inputs: Vec<Input>,
        outputs: Vec<Output>,
        sapling_shielded_data: Option<ShieldedData<SharedAnchor>>,
        orchard_shielded_data: Option<ShieldedData>,
    },
}
Expand description

A Zcash transaction.

A transaction is an encoded data structure that facilitates the transfer of value between two public key addresses on the Zcash ecosystem. Everything is designed to ensure that transactions can be created, propagated on the network, validated, and finally added to the global ledger of transactions (the blockchain).

Zcash has a number of different transaction formats. They are represented internally by different enum variants. Because we checkpoint on Canopy activation, we do not validate any pre-Sapling transaction types.

Variants

V1

Fields

inputs: Vec<Input>

The transparent inputs to the transaction.

outputs: Vec<Output>

The transparent outputs from the transaction.

lock_time: LockTime

The earliest time or block height that this transaction can be added to the chain.

A fully transparent transaction (version = 1).

V2

Fields

inputs: Vec<Input>

The transparent inputs to the transaction.

outputs: Vec<Output>

The transparent outputs from the transaction.

lock_time: LockTime

The earliest time or block height that this transaction can be added to the chain.

joinsplit_data: Option<JoinSplitData<Bctv14Proof>>

The JoinSplit data for this transaction, if any.

A Sprout transaction (version = 2).

V3

Fields

inputs: Vec<Input>

The transparent inputs to the transaction.

outputs: Vec<Output>

The transparent outputs from the transaction.

lock_time: LockTime

The earliest time or block height that this transaction can be added to the chain.

expiry_height: Height

The latest block height that this transaction can be added to the chain.

joinsplit_data: Option<JoinSplitData<Bctv14Proof>>

The JoinSplit data for this transaction, if any.

An Overwinter transaction (version = 3).

V4

Fields

inputs: Vec<Input>

The transparent inputs to the transaction.

outputs: Vec<Output>

The transparent outputs from the transaction.

lock_time: LockTime

The earliest time or block height that this transaction can be added to the chain.

expiry_height: Height

The latest block height that this transaction can be added to the chain.

joinsplit_data: Option<JoinSplitData<Groth16Proof>>

The JoinSplit data for this transaction, if any.

sapling_shielded_data: Option<ShieldedData<PerSpendAnchor>>

The sapling shielded data for this transaction, if any.

A Sapling transaction (version = 4).

V5

Fields

network_upgrade: NetworkUpgrade

The Network Upgrade for this transaction.

Derived from the ConsensusBranchId field.

lock_time: LockTime

The earliest time or block height that this transaction can be added to the chain.

expiry_height: Height

The latest block height that this transaction can be added to the chain.

inputs: Vec<Input>

The transparent inputs to the transaction.

outputs: Vec<Output>

The transparent outputs from the transaction.

sapling_shielded_data: Option<ShieldedData<SharedAnchor>>

The sapling shielded data for this transaction, if any.

orchard_shielded_data: Option<ShieldedData>

The orchard data for this transaction, if any.

A version = 5 transaction , which supports Orchard, Sapling, and transparent, but not Sprout.

Implementations

Returns a new version 5 coinbase transaction for network and height, which contains the specified outputs.

Generate a proptest strategy for V1 Transactions

Generate a proptest strategy for V2 Transactions

Generate a proptest strategy for V3 Transactions

Generate a proptest strategy for V4 Transactions

Generate a proptest strategy for V5 Transactions

Proptest Strategy for creating a Vector of transactions where the first transaction is always the only coinbase transaction

Apply f to the transparent output, v_sprout_new, and v_sprout_old values in this transaction, regardless of version.

Apply f to the sapling value balance and orchard value balance in this transaction, regardless of version.

Fixup transparent values and shielded value balances, so that transaction and chain value pools won’t overflow MAX_MONEY.

These fixes are applied to coinbase and non-coinbase transactions.

Fixup transparent values and shielded value balances, so that this transaction passes the “non-negative chain value pool” checks. (These checks use the sum of unspent outputs for each transparent and shielded pool.)

These fixes are applied to coinbase and non-coinbase transactions.

chain_value_pools contains the chain value pool balances, as of the previous transaction in this block (or the last transaction in the previous block).

outputs must contain all the transparent::Outputs spent in this transaction.

Currently, these fixes almost always leave some remaining value in each transparent and shielded chain value pool.

Before fixing the chain value balances, this method calls fix_overflow to make sure that transaction and chain value pools don’t overflow MAX_MONEY.

After fixing the chain value balances, this method calls fix_remaining_value to fix the remaining value in the transaction value pool.

Returns the remaining transaction value, and the updated chain value balances.

Panics

If any spent transparent::Output is missing from transparent::OutPoints.

Returns the total input value of this transaction’s value pool.

This is the sum of transparent inputs, sprout input values, and if positive, the sapling and orchard value balances.

outputs must contain all the transparent::Outputs spent in this transaction.

Fixup non-coinbase transparent values and shielded value balances, so that this transaction passes the “non-negative remaining transaction value” check. (This check uses the sum of inputs minus outputs.)

Returns the remaining transaction value.

outputs must contain all the transparent::Outputs spent in this transaction.

Currently, these fixes almost always leave some remaining value in the transaction value pool.

Panics

If any spent transparent::Output is missing from transparent::OutPoints.

Compute the hash (mined transaction ID) of this transaction.

The hash uniquely identifies mined v5 transactions, and all v1-v4 transactions, whether mined or unmined.

Compute the unmined transaction ID of this transaction.

This ID uniquely identifies unmined transactions, regardless of version.

Calculate the sighash for the current transaction

Details

The input argument indicates the transparent Input for which we are producing a sighash. It is comprised of the index identifying the transparent::Input within the transaction and the transparent::Output representing the UTXO being spent by that input.

Panics
  • if passed in any NetworkUpgrade from before NetworkUpgrade::Overwinter
  • if called on a v1 or v2 transaction
  • if the input index points to a transparent::Input::CoinBase
  • if the input index is out of bounds for self.inputs()

Compute the authorizing data commitment of this transaction as specified in ZIP-244.

Returns None for pre-v5 transactions.

Does this transaction have transparent or shielded inputs?

Does this transaction have shielded inputs?

See Self::has_transparent_or_shielded_inputs for details.

Does this transaction have transparent or shielded outputs?

Does this transaction have shielded outputs?

See Self::has_transparent_or_shielded_outputs for details.

Does this transaction has at least one flag when we have at least one orchard action?

Returns the CoinbaseSpendRestriction for this transaction, assuming it is mined at spend_height.

Return if the fOverwintered flag of this transaction is set.

Return the version of this transaction.

Get this transaction’s lock time.

Get this transaction’s expiry height, if any.

Modify the expiry height of this transaction.

Panics
  • if called on a v1 or v2 transaction

Get this transaction’s network upgrade field, if any. This field is serialized as nConsensusBranchId (7.1).

Access the transparent inputs of this transaction, regardless of version.

Modify the transparent inputs of this transaction, regardless of version.

Access the transparent::OutPoints spent by this transaction’s transparent::Inputs.

Access the transparent outputs of this transaction, regardless of version.

Modify the transparent outputs of this transaction, regardless of version.

Returns true if this transaction has valid inputs for a coinbase transaction, that is, has a single input and it is a coinbase input (null prevout).

Returns true if this transaction has valid inputs for a non-coinbase transaction, that is, does not have any coinbase input (non-null prevouts).

Note that it’s possible for a transaction return false in both Transaction::is_coinbase and Transaction::is_valid_non_coinbase, though those transactions will be rejected.

Returns the Sprout JoinSplit<Groth16Proof>s in this transaction, regardless of version.

Returns the number of JoinSplits in this transaction, regardless of version.

Access the sprout::Nullifiers in this transaction, regardless of version.

Access the JoinSplit public validating key in this transaction, regardless of version, if any.

Return if the transaction has any Sprout JoinSplit data.

Returns the Sprout note commitments in this transaction.

Access the deduplicated sapling::tree::Roots in this transaction, regardless of version.

Iterate over the sapling Spends for this transaction, returning Spend<PerSpendAnchor> regardless of the underlying transaction version.

Shared anchors in V5 transactions are copied into each sapling spend. This allows the same code to validate spends from V4 and V5 transactions.

Correctness

Do not use this function for serialization.

Iterate over the sapling Outputs for this transaction

Access the sapling::Nullifiers in this transaction, regardless of version.

Returns the Sapling note commitments in this transaction, regardless of version.

Return if the transaction has any Sapling shielded data.

Access the orchard::ShieldedData in this transaction, regardless of version.

Modify the orchard::ShieldedData in this transaction, regardless of version.

Iterate over the orchard::Actions in this transaction, if there are any, regardless of version.

Access the orchard::Nullifiers in this transaction, if there are any, regardless of version.

Access the note commitments in this transaction, if there are any, regardless of version.

Access the orchard::Flags in this transaction, if there is any, regardless of version.

Return if the transaction has any Orchard shielded data, regardless of version.

Return the transparent value balance, using the outputs spent by this transaction.

See transparent_value_balance for details.

Modify the transparent output values of this transaction, regardless of version.

Returns the vpub_old fields from JoinSplits in this transaction, regardless of version, in the order they appear in the transaction.

These values are added to the sprout chain value pool, and removed from the value pool of this transaction.

Modify the vpub_old fields from JoinSplits in this transaction, regardless of version, in the order they appear in the transaction.

See output_values_to_sprout for details.

Returns the vpub_new fields from JoinSplits in this transaction, regardless of version, in the order they appear in the transaction.

These values are removed from the value pool of this transaction. and added to the sprout chain value pool.

Modify the vpub_new fields from JoinSplits in this transaction, regardless of version, in the order they appear in the transaction.

See input_values_from_sprout for details.

Return a list of sprout value balances, the changes in the transaction value pool due to each sprout JoinSplit.

Each value balance is the sprout vpub_new field, minus the vpub_old field.

See sprout_value_balance for details.

Return the sprout value balance, the change in the transaction value pool due to sprout JoinSplits.

The sum of all sprout vpub_new fields, minus the sum of all vpub_old fields.

Positive values are added to this transaction’s value pool, and removed from the sprout chain value pool. Negative values are removed from this transaction, and added to the sprout pool.

https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions

Return the sapling value balance, the change in the transaction value pool due to sapling Spends and Outputs.

Returns the valueBalanceSapling field in this transaction.

Positive values are added to this transaction’s value pool, and removed from the sapling chain value pool. Negative values are removed from this transaction, and added to sapling pool.

https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions

Modify the value_balance field from the sapling::ShieldedData in this transaction, regardless of version.

See sapling_value_balance for details.

Return the orchard value balance, the change in the transaction value pool due to orchard::Actions.

Returns the valueBalanceOrchard field in this transaction.

Positive values are added to this transaction’s value pool, and removed from the orchard chain value pool. Negative values are removed from this transaction, and added to orchard pool.

https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions

Modify the value_balance field from the orchard::ShieldedData in this transaction, regardless of version.

See orchard_value_balance for details.

Get the value balances for this transaction, using the transparent outputs spent in this transaction.

See value_balance for details.

Get the value balances for this transaction. These are the changes in the transaction value pool, split up into transparent, sprout, sapling, and orchard values.

Calculated as the sum of the inputs and outputs from each pool, or the sum of the value balances from each pool.

Positive values are added to this transaction’s value pool, and removed from the corresponding chain value pool. Negative values are removed from this transaction, and added to the corresponding pool.

https://zebra.zfnd.org/dev/rfcs/0012-value-pools.html#definitions

utxos must contain the utxos of every input in the transaction, including UTXOs created by earlier transactions in this block.

Note: the chain value pool has the opposite sign to the transaction value pool.

Trait Implementations

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default. Read more
Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
The type of Strategy used to generate values of type Self. Read more
Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more

Computes the authorizing data commitment for a transaction.

Panics

If passed a pre-v5 transaction.

Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Computes the witnessed transaction ID for a transaction.

Panics

If passed a pre-v5 transaction.

Computes the authorizing data commitment for a transaction.

Panics

If passed a pre-v5 transaction.

Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Computes the witnessed transaction ID for a transaction.

Panics

If passed a pre-v5 transaction.

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

No valid Zcash message contains more transactions than can fit in a single block

tx messages contain a single transaction, and block messages are limited to the maximum block size.

Provides a loose upper bound on the size of the Vec<T: TrustedPreallocate> which can possibly be received from an honest peer. Read more

Convert a Zebra transaction into a librustzcash one.

Panics

If the transaction is not V5. (Currently there is no need for this conversion for other versions.)

The type returned in the event of a conversion error.
Try to read self from the given reader. Read more
Write self to the given writer using the canonical format. Read more
Helper function to construct a vec to serialize the current struct into
Get the size of self by using a fake writer.

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
Compare self to key and return true if they are equal.
Causes self to use its Binary implementation when Debug-formatted. Read more
Causes self to use its Display implementation when Debug-formatted. Read more
Causes self to use its LowerExp implementation when Debug-formatted. Read more
Causes self to use its LowerHex implementation when Debug-formatted. Read more
Causes self to use its Octal implementation when Debug-formatted. Read more
Causes self to use its Pointer implementation when Debug-formatted. Read more
Causes self to use its UpperExp implementation when Debug-formatted. Read more
Causes self to use its UpperHex implementation when Debug-formatted. Read more
Formats each item in a sequence. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Set the foreground color generically Read more
Set the background color generically. Read more
Change the foreground color to black
Change the background color to black
Change the foreground color to red
Change the background color to red
Change the foreground color to green
Change the background color to green
Change the foreground color to yellow
Change the background color to yellow
Change the foreground color to blue
Change the background color to blue
Change the foreground color to magenta
Change the background color to magenta
Change the foreground color to purple
Change the background color to purple
Change the foreground color to cyan
Change the background color to cyan
Change the foreground color to white
Change the background color to white
Change the foreground color to the terminal default
Change the background color to the terminal default
Change the foreground color to bright black
Change the background color to bright black
Change the foreground color to bright red
Change the background color to bright red
Change the foreground color to bright green
Change the background color to bright green
Change the foreground color to bright yellow
Change the background color to bright yellow
Change the foreground color to bright blue
Change the background color to bright blue
Change the foreground color to bright magenta
Change the background color to bright magenta
Change the foreground color to bright purple
Change the background color to bright purple
Change the foreground color to bright cyan
Change the background color to bright cyan
Change the foreground color to bright white
Change the background color to bright white
Make the text bold
Make the text dim
Make the text italicized
Make the text italicized
Make the text blink
Make the text blink (but fast!)
Swap the foreground and background colors
Hide the text
Cross out the text
Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Set the foreground color to a specific RGB value.
Set the background color to a specific RGB value.
Sets the foreground color to an RGB value.
Sets the background color to an RGB value.
Apply a runtime-determined style
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
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Converts the type into a Result that can be sent as a response.
Should always be Self
Add a header to a Section and indent the body Read more
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
Converts the given value to a String. 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.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more