Ledger Transaction
A LedgerTransaction is derived from a WireTransaction. It is the result of doing the following operations:
Downloading and locally storing all the dependencies of the transaction.
Resolving the input states and loading them into memory.
Doing some basic key lookups on the Commands to see if any keys are from a recognised party, thus converting the Command objects into CommandWithParties.
Deserialising the output states.
All the above refer to inputs using a (txhash, output index) pair.
Usage notes:
LedgerTransaction is an abstraction that is meant to be used during the transaction verification stage. It needs full access to input states that might be in transactions that are encrypted and unavailable for code running outside the secure enclave. Also, it might need to deserialize states with code that might not be available on the classpath.
Because of this, trying to create or use a LedgerTransaction for any other purpose then transaction verification can result in unexpected exceptions, which need de be handled.
LedgerTransactions should never be instantiated directly from client code, but rather via WireTransaction.toLedgerTransaction
Constructors
Types
A set of related inputs and outputs that are connected by some common attributes. An InOutGroup is calculated using groupStates and is useful for handling cases where a transaction may contain similar but unrelated state evolutions, for example, a transaction that moves cash in two different currencies. The numbers must add up on both sides of the transaction, but the values must be summed independently per currency. Grouping can be used to simplify this logic.
Properties
A list of Attachment objects identified by the transaction that are needed for this transaction to verify.
Arbitrary data passed to the program of each input state.
The hash of the original serialised WireTransaction.
The resolved input states which will be consumed/invalidated by the execution of this transaction.
Network parameters that were in force when the transaction was constructed. This is nullable only for backwards compatibility for serialized transactions. In reality this field will always be set when on the normal codepaths.
The outputs created by the transaction.
Helper property to return a list of ContractState objects, rather than the often less convenient TransactionState
Random data used to make the transaction hash unpredictable even if the contents can be predicted; needed to avoid some obscure attacks.
Referenced states, which are like inputs but won't be consumed.
The time window within which the tx is valid, will be checked against notary pool member clocks.
Functions
Helper to simplify getting all Command items with a CommandData of a particular class, interface, or base class.
Helper to simplify filtering inputs according to a Predicate.
Helper to simplify filtering inputs according to a Predicate.
Helper to simplify filtering outputs according to a Predicate.
Helper to simplify filtering output StateAndRef items according to a Predicate.
Helper to simplify filtering reference inputs according to a Predicate.
Helper to simplify filtering reference inputs according to a Predicate.
Helper to simplify finding a single input matching a Predicate.
Helper to simplify finding a single output matching a Predicate.
Helper to simplify finding a single output StateAndRef matching a Predicate.
Helper to simplify finding a single reference inputs ContractState matching a Predicate.
Helper to simplify finding a single reference input matching a Predicate.
Helper to simplify getting an indexed attachment.
Helper to simplify getting an indexed command.
Helper to simplify getting an indexed input ContractState.
Helper to simplify getting an indexed output.
Helper to simplify getting an indexed reference input ContractState.
See the documentation for the reflection-based version of groupStates
Given a type and a function that returns a grouping key, associates inputs and outputs together so that they can be processed as one. The grouping key is any arbitrary object that can act as a map key (so must implement equals and hashCode).
Helper to simplify getting all inputs states of a particular class, interface, or base class.
Returns the typed input StateAndRef at the specified index
Helper to simplify getting all inputs states of a particular class, interface, or base class.
Helper to simplify getting all output states of a particular class, interface, or base class.
Returns a StateAndRef for the given output index.
Returns a StateAndRef for the requested output state, or throws IllegalArgumentException if not found.
Helper to simplify getting all output StateAndRef items of a particular state class, interface, or base class.
Helper to simplify getting all reference input states of a particular class, interface, or base class.
Helper to simplify getting all reference input states of a particular class, interface, or base class.
We need a way to customise transaction verification inside the Node without changing either the wire format or any public APIs.
Pass all of this LedgerTransaction object's serialized state to a transformer function.