WireTransaction

class WireTransaction(val componentGroups: List<ComponentGroup>, val privacySalt: PrivacySalt, val digestService: DigestService) : TraversableTransaction

A transaction ready for serialisation, without any signatures attached. A WireTransaction is usually wrapped by a SignedTransaction that carries the signatures over this payload. The identity of the transaction is the Merkle tree root of its components (see MerkleTree).

For privacy purposes, each part of a transaction should be accompanied by a nonce. To avoid storing a random number (nonce) per component, an initial privacySalt is the sole value utilised, so that all component nonces are deterministically computed.

A few notes about backwards compatibility: A wire transaction can be backwards compatible, in the sense that if an old client receives a componentGroups with more elements than expected, it will normally deserialise the required objects and omit any checks in the optional new fields. Moreover, because the Merkle tree is constructed from the received list of ComponentGroup, which internally deals with bytes, any client can compute the Merkle tree and on the same time relay a WireTransaction object even if she is unable to read some of the "optional" component types. We stress that practically, a new type of WireTransaction should only be considered compatible if and only if the following rules apply:

  • Component-type ordering is fixed (eg. inputs, then outputs, then commands etc, see [ComponentGroupEnum] for the actual ordering).
  • Removing a component-type that existed in older wire transaction types is not allowed, because it will affect the Merkle tree structure.
  • Changing the order of existing component types is also not allowed, for the same reason.
  • New component types must be added at the end of the list of [ComponentGroup] and update the [ComponentGroupEnum] with the new type. After a component is added, its ordinal must never change.
  • A new component type should always be an "optional value", in the sense that lack of its visibility does not change the transaction and contract logic and details. An example of "optional" components could be a transaction summary or some statistics.

Constructors

Link copied to clipboard
constructor(componentGroups: List<ComponentGroup>)
constructor(componentGroups: List<ComponentGroup>, privacySalt: PrivacySalt = PrivacySalt())

Old version of WireTransaction constructor for ABI compatibility.

constructor(inputs: List<StateRef>, attachments: List<SecureHash>, outputs: List<TransactionState<ContractState>>, commands: List<Command<*>>, notary: Party?, timeWindow: TimeWindow?, privacySalt: PrivacySalt = PrivacySalt())
constructor(componentGroups: List<ComponentGroup>, privacySalt: PrivacySalt, digestService: DigestService)

Properties

Link copied to clipboard

Hashes of the ZIP/JAR files that are needed to interpret the contents of this wire transaction.

Link copied to clipboard

Returns a list of all the component groups that are present in the transaction, excluding the privacySalt, in the following order (which is the same with the order in ComponentGroupEnum:

Link copied to clipboard

Ordered list of (CommandData, PublicKey) pairs that instruct the contracts what to do.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val id: SecureHash

The transaction id is represented by the root hash of Merkle tree over the transaction components.

Link copied to clipboard
open override val inputs: List<StateRef>

Pointers to the input states on the ledger, identified by (tx identity hash, output index).

Link copied to clipboard

Returns the attachments compatible with 4.11 and earlier. This may be empty, which means this transaction cannot be verified by a 4.11 node. On 4.12 and later these attachments are ignored.

Link copied to clipboard

Builds whole Merkle tree for a transaction. Briefly, each component group has its own sub Merkle tree and all of the roots of these trees are used as leaves in a top level Merkle tree. Note that ordering of elements inside a ComponentGroup matters when computing the Merkle root. On the other hand, insertion group ordering does not affect the top level Merkle tree construction, as it is actually an ordered Merkle tree, where its leaves are ordered based on the group ordinal in ComponentGroupEnum. If any of the groups is an empty list or a null object, then SecureHash.allOnesHash is used as its hash. Also, privacySalt is not a Merkle tree leaf, because it is already "inherently" included via the component nonces.

Link copied to clipboard
open override val networkParametersHash: SecureHash?

Hash of the network parameters that were in force when the transaction was notarised. Null means, that the transaction was created on older version of Corda (before 4), resolution will default to initial parameters.

Link copied to clipboard
open override 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.

Link copied to clipboard

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

Link copied to clipboard

Helper property to return a list of ContractState objects, rather than the often less convenient TransactionState

Link copied to clipboard
Link copied to clipboard
open override val references: List<StateRef>

Pointers to reference states, identified by (tx identity hash, output index).

Link copied to clipboard

Public keys that need to be fulfilled by signatures in order for the transaction to be valid.

Link copied to clipboard

Functions

Link copied to clipboard

Build filtered transaction using provided filtering functions.

Link copied to clipboard

Checks that the given signature matches one of the commands and that it is a correct signature over the tx.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
inline fun <T : ContractState> filterOutputs(crossinline predicate: (T) -> Boolean): List<T>

fun <T : ContractState> filterOutputs(clazz: Class<T>, predicate: Predicate<T>): List<T>

Helper to simplify filtering outputs according to a Predicate.

Link copied to clipboard
inline fun <T : ContractState> filterOutRefs(crossinline predicate: (T) -> Boolean): List<StateAndRef<T>>

fun <T : ContractState> filterOutRefs(clazz: Class<T>, predicate: Predicate<T>): List<StateAndRef<T>>

Helper to simplify filtering output StateAndRef items according to a Predicate.

Link copied to clipboard
inline fun <T : ContractState> findOutput(crossinline predicate: (T) -> Boolean): T

fun <T : ContractState> findOutput(clazz: Class<T>, predicate: Predicate<T>): T

Helper to simplify finding a single output matching a Predicate.

Link copied to clipboard
inline fun <T : ContractState> findOutRef(crossinline predicate: (T) -> Boolean): StateAndRef<T>

fun <T : ContractState> findOutRef(clazz: Class<T>, predicate: Predicate<T>): StateAndRef<T>

Helper to simplify finding a single output StateAndRef matching a Predicate.

Link copied to clipboard

Helper to simplify getting an indexed output.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
inline fun <T : ContractState> outputsOfType(): List<T>

Helper to simplify getting all output states of a particular class, interface, or base class.

Link copied to clipboard

Returns a StateAndRef for the given output index.

Returns a StateAndRef for the requested output state, or throws IllegalArgumentException if not found.

Link copied to clipboard

Helper to simplify getting all output StateAndRef items of a particular state class, interface, or base class.

Link copied to clipboard

Looks up identities and attachments from storage to generate a LedgerTransaction. A transaction is expected to have been fully resolved using the resolution flow by this point.

fun toLedgerTransaction(resolveIdentity: (PublicKey) -> Party?, resolveAttachment: (SecureHash) -> Attachment?, resolveStateRef: (StateRef) -> TransactionState<*>?, resolveContractAttachment: (TransactionState<ContractState>) -> AttachmentId?): LedgerTransaction

Looks up identities, attachments and dependent input states using the provided lookup functions in order to construct a LedgerTransaction. Note that identity lookup failure does not cause an exception to be thrown. This invocation doesn't check various rules like no-downgrade or package namespace ownership.

Link copied to clipboard
Link copied to clipboard
open override fun toString(): String