corda / net.corda.core.transactions / LedgerTransaction

LedgerTransaction

data 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.

Types

InOutGroup

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.

Constructors

<init>

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? = null)

A LedgerTransaction is derived from a WireTransaction. It is the result of doing the following operations:

Properties

attachments

val attachments: List<Attachment>

A list of Attachment objects identified by the transaction that are needed for this transaction to verify.

commands

val commands: List<CommandWithParties<CommandData>>

Arbitrary data passed to the program of each input state.

id

val id: SecureHash

The hash of the original serialised WireTransaction.

inputStates

val inputStates: List<ContractState>

inputs

val inputs: List<StateAndRef<ContractState>>

The resolved input states which will be consumed/invalidated by the execution of this transaction.

notary

val notary: Party?

If present, the notary for this transaction. If absent then the transaction is not notarised at all. This is intended for issuance/genesis transactions that don't consume any other states and thus can't double spend anything.

outputs

val outputs: List<TransactionState<ContractState>>

Ordered list of states defined by this transaction, along with the associated notaries.

privacySalt

val privacySalt: PrivacySalt

timeWindow

val timeWindow: TimeWindow?

Functions

commandsOfType

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>>

copy

fun copy(inputs: List<StateAndRef<ContractState>>, outputs: List<TransactionState<ContractState>>, commands: List<CommandWithParties<CommandData>>, attachments: List<Attachment>, id: SecureHash, notary: Party?, timeWindow: TimeWindow?, privacySalt: PrivacySalt): LedgerTransaction

filterCommands

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>>

filterInRefs

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>>

filterInputs

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>

findCommand

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>

findInRef

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>

findInput

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

getAttachment

fun getAttachment(index: Int): Attachment
fun getAttachment(id: SecureHash): Attachment

Helper to simplify getting an indexed attachment.

getCommand

fun <T : CommandData> getCommand(index: Int): Command<T>

Helper to simplify getting an indexed command.

getInput

fun getInput(index: Int): ContractState

Helper to simplify getting an indexed input ContractState.

groupStates

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

inRef

fun <T : ContractState> inRef(index: Int): StateAndRef<T>

Returns the typed input StateAndRef at the specified index

inRefsOfType

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>>

inputsOfType

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>

verify

fun verify(): Unit

Verifies this transaction and runs contract code. At this stage it is assumed that signatures have already been verified.

Inherited Functions

checkBaseInvariants

open fun checkBaseInvariants(): Unit

Extension Functions

contextLogger

fun Any.contextLogger(): Logger

When called from a companion object, returns the logger for the enclosing class.