class LedgerTransaction : FullTransaction
A LedgerTransaction is derived from a WireTransaction. It is the result of doing the following operations:
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
data class InOutGroup<out T : ContractState, out K : Any>
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. |
LedgerTransaction(inputs: List<StateAndRef<ContractState>>, outputs: List<TransactionState<ContractState>>, commands: List<CommandWithParties<CommandData>>, attachments: List<Attachment>, id: SecureHash, notary: Party?, timeWindow: TimeWindow?, privacySalt: PrivacySalt) LedgerTransaction(inputs: List<StateAndRef<ContractState>>, outputs: List<TransactionState<ContractState>>, commands: List<CommandWithParties<CommandData>>, attachments: List<Attachment>, id: SecureHash, notary: Party?, timeWindow: TimeWindow?, privacySalt: PrivacySalt, networkParameters: NetworkParameters) |
val attachments: List<Attachment>
A list of Attachment objects identified by the transaction that are needed for this transaction to verify. |
|
val commands: List<CommandWithParties<CommandData>>
Arbitrary data passed to the program of each input state. |
|
val digestService: DigestService |
|
val id: SecureHash
The hash of the original serialised WireTransaction. |
|
val inputStates: List<ContractState> |
|
val inputs: List<StateAndRef<ContractState>>
The resolved input states which will be consumed/invalidated by the execution of this transaction. |
|
val networkParameters: NetworkParameters?
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. |
|
val notary: Party?
The notary that the tx uses, this must be the same as the notary of all the inputs, or null if there are no inputs. |
|
val outputs: List<TransactionState<ContractState>>
The outputs created by the transaction. |
|
val privacySalt: PrivacySalt
Random data used to make the transaction hash unpredictable even if the contents can be predicted; needed to avoid some obscure attacks. |
|
val referenceStates: List<ContractState> |
|
val references: List<StateAndRef<ContractState>>
Referenced states, which are like inputs but won't be consumed. |
|
val timeWindow: TimeWindow?
The time window within which the tx is valid, will be checked against notary pool member clocks. |
fun <T : CommandData> commandsOfType(clazz: Class<T>): List<Command<T>>
Helper to simplify getting all Command items with a CommandData of a particular class, interface, or base class. fun <T : CommandData> commandsOfType(): List<Command<T>> |
|
operator fun component1(): List<StateAndRef<ContractState>> |
|
operator fun component10(): List<StateAndRef<ContractState>> |
|
operator fun component2(): List<TransactionState<ContractState>> |
|
operator fun component3(): List<CommandWithParties<CommandData>> |
|
operator fun component4(): List<Attachment> |
|
operator fun component5(): SecureHash |
|
operator fun component6(): Party? |
|
operator fun component7(): TimeWindow? |
|
operator fun component8(): PrivacySalt |
|
operator fun component9(): NetworkParameters? |
|
fun fun |
|
fun equals(other: Any?): Boolean |
|
fun <T : CommandData> filterCommands(clazz: Class<T>, predicate: Predicate<T>): List<Command<T>>
Helper to simplify filtering Command items according to a Predicate. fun <T : CommandData> filterCommands(predicate: (T) -> Boolean): List<Command<T>> |
|
fun <T : ContractState> filterInRefs(clazz: Class<T>, predicate: Predicate<T>): List<StateAndRef<T>>
Helper to simplify filtering inputs according to a Predicate. fun <T : ContractState> filterInRefs(predicate: (T) -> Boolean): List<StateAndRef<T>> |
|
fun <T : ContractState> filterInputs(clazz: Class<T>, predicate: Predicate<T>): List<T>
Helper to simplify filtering inputs according to a Predicate. fun <T : ContractState> filterInputs(predicate: (T) -> Boolean): List<T> |
|
fun <T : ContractState> filterReferenceInputRefs(clazz: Class<T>, predicate: Predicate<T>): List<StateAndRef<T>>
Helper to simplify filtering reference inputs according to a Predicate. fun <T : ContractState> filterReferenceInputRefs(predicate: (T) -> Boolean): List<StateAndRef<T>> |
|
fun <T : ContractState> filterReferenceInputs(clazz: Class<T>, predicate: Predicate<T>): List<T>
Helper to simplify filtering reference inputs according to a Predicate. fun <T : ContractState> filterReferenceInputs(predicate: (T) -> Boolean): List<T> |
|
fun <T : CommandData> findCommand(clazz: Class<T>, predicate: Predicate<T>): Command<T>
Helper to simplify finding a single Command items according to a Predicate. fun <T : CommandData> findCommand(predicate: (T) -> Boolean): Command<T> |
|
fun <T : ContractState> findInRef(clazz: Class<T>, predicate: Predicate<T>): StateAndRef<T>
Helper to simplify finding a single input matching a Predicate. fun <T : ContractState> findInRef(predicate: (T) -> Boolean): StateAndRef<T> |
|
fun <T : ContractState> findInput(clazz: Class<T>, predicate: Predicate<T>): T
Helper to simplify finding a single input ContractState matching a Predicate. fun <T : ContractState> findInput(predicate: (T) -> Boolean): T |
|
fun <T : ContractState> findReference(clazz: Class<T>, predicate: Predicate<T>): T
Helper to simplify finding a single reference inputs ContractState matching a Predicate. fun <T : ContractState> findReference(predicate: (T) -> Boolean): T |
|
fun <T : ContractState> findReferenceInputRef(clazz: Class<T>, predicate: Predicate<T>): StateAndRef<T>
Helper to simplify finding a single reference input matching a Predicate. fun <T : ContractState> findReferenceInputRef(predicate: (T) -> Boolean): StateAndRef<T> |
|
fun getAttachment(index: Int): Attachment fun getAttachment(id: SecureHash): Attachment
Helper to simplify getting an indexed attachment. |
|
fun <T : CommandData> getCommand(index: Int): Command<T>
Helper to simplify getting an indexed command. |
|
fun getInput(index: Int): ContractState
Helper to simplify getting an indexed input ContractState. |
|
fun getReferenceInput(index: Int): ContractState
Helper to simplify getting an indexed reference input ContractState. |
|
fun <T : ContractState, K : Any> groupStates(ofType: Class<T>, selector: (T) -> K): List<InOutGroup<T, K>>
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). fun <T : ContractState, K : Any> groupStates(selector: (T) -> K): List<InOutGroup<T, K>>
See the documentation for the reflection-based version of groupStates |
|
fun hashCode(): Int |
|
fun <T : ContractState> inRef(index: Int): StateAndRef<T>
Returns the typed input StateAndRef at the specified index |
|
fun <T : ContractState> inRefsOfType(clazz: Class<T>): List<StateAndRef<T>>
Helper to simplify getting all inputs states of a particular class, interface, or base class. fun <T : ContractState> inRefsOfType(): List<StateAndRef<T>> |
|
fun <T : ContractState> inputsOfType(clazz: Class<T>): List<T>
Helper to simplify getting all inputs states of a particular class, interface, or base class. fun <T : ContractState> inputsOfType(): List<T> |
|
fun <T : ContractState> referenceInputRefsOfType(clazz: Class<T>): List<StateAndRef<T>>
Helper to simplify getting all reference input states of a particular class, interface, or base class. fun <T : ContractState> referenceInputRefsOfType(): List<StateAndRef<T>> |
|
fun <T : ContractState> referenceInputsOfType(clazz: Class<T>): List<T>
Helper to simplify getting all reference input states of a particular class, interface, or base class. fun <T : ContractState> referenceInputsOfType(): List<T> |
|
fun specialise(alternateVerifier: (LedgerTransaction, ClassLoader) -> Verifier): LedgerTransaction
We need a way to customise transaction verification inside the Node without changing either the wire format or any public APIs. |
|
fun toString(): String |
|
fun <T> transform(transformer: (List<ComponentGroup>, List<SerializedStateAndRef>, List<SerializedStateAndRef>) -> T): T
Pass all of this LedgerTransaction object's serialized state to a transformer function. |
|
fun verify(): Unit
Verifies this transaction and runs contract code. At this stage it is assumed that signatures have already been verified. |
open fun checkBaseInvariants(): Unit |
|
fun checkNotaryWhitelisted(): Unit
Make sure the assigned notary is part of the network parameter whitelist. |
fun createForSandbox(inputs: List<StateAndRef<ContractState>>, outputs: List<TransactionState<ContractState>>, commands: List<CommandWithParties<CommandData>>, attachments: List<Attachment>, id: SecureHash, notary: Party?, timeWindow: TimeWindow?, privacySalt: PrivacySalt, networkParameters: NetworkParameters, references: List<StateAndRef<ContractState>>, digestService: DigestService): LedgerTransaction
This factory function will create an instance of LedgerTransaction that will be used inside the DJVM sandbox. |
fun Any.contextLogger(): <ERROR CLASS>
When called from a companion object, returns the logger for the enclosing class. |