open class TransactionBuilder
A TransactionBuilder is a transaction class that's mutable (unlike the others which are all immutable). It is intended to be passed around contracts that may edit it by adding new states/commands. Then once the states and commands are right, this class can be used as a holding bucket to gather signatures from multiple parties.
The builder can be customised for specific transaction types, e.g. where additional processing is needed before adding a state/command.
notary
- Notary used for the transaction. If null, this indicates the transaction DOES NOT have a notary.
When this is set to a non-null value, an output state can be added by just passing in a ContractState – a
TransactionState with this notary specified will be generated automatically.
TransactionBuilder(notary: Party? = null, lockId: UUID = defaultLockId(), inputs: MutableList<StateRef> = arrayListOf(), attachments: MutableList<AttachmentId> = arrayListOf(), outputs: MutableList<TransactionState<ContractState>> = arrayListOf(), commands: MutableList<Command<*>> = arrayListOf(), window: TimeWindow? = null, privacySalt: PrivacySalt = PrivacySalt()) TransactionBuilder(notary: Party) TransactionBuilder(notary: Party? = null, lockId: UUID = defaultLockId(), inputs: MutableList<StateRef> = arrayListOf(), attachments: MutableList<AttachmentId> = arrayListOf(), outputs: MutableList<TransactionState<ContractState>> = arrayListOf(), commands: MutableList<Command<*>> = arrayListOf(), window: TimeWindow? = null, privacySalt: PrivacySalt = PrivacySalt(), references: MutableList<StateRef> = arrayListOf(), serviceHub: ServiceHub? = (Strand.currentStrand() as? FlowStateMachine<*>)?.serviceHub)
A TransactionBuilder is a transaction class that's mutable (unlike the others which are all immutable). It is intended to be passed around contracts that may edit it by adding new states/commands. Then once the states and commands are right, this class can be used as a holding bucket to gather signatures from multiple parties. |
val attachments: MutableList<AttachmentId> |
|
val commands: MutableList<Command<*>> |
|
val inputs: MutableList<StateRef> |
|
var lockId: UUID |
|
var notary: Party?
Notary used for the transaction. If null, this indicates the transaction DOES NOT have a notary. When this is set to a non-null value, an output state can be added by just passing in a ContractState – a TransactionState with this notary specified will be generated automatically. |
|
val outputs: MutableList<TransactionState<ContractState>> |
|
var privacySalt: PrivacySalt |
|
val references: MutableList<StateRef> |
|
val serviceHub: ServiceHub? |
|
var window: TimeWindow? |
fun addAttachment(attachmentId: AttachmentId): <ERROR CLASS>
Adds an attachment with the specified hash to the TransactionBuilder. |
|
fun addCommand(arg: Command<*>): <ERROR CLASS>
Adds a Command to the transaction. fun addCommand(data: CommandData, vararg keys: PublicKey): <ERROR CLASS>
Adds a Command to the transaction, specified by the encapsulated CommandData object and required list of signing PublicKeys. fun addCommand(data: CommandData, keys: List<PublicKey>): <ERROR CLASS> |
|
open fun addInputState(stateAndRef: StateAndRef<*>): <ERROR CLASS>
Adds an input StateRef to the transaction. |
|
fun addOutputState(state: TransactionState<*>): <ERROR CLASS>
Adds an output state to the transaction. fun addOutputState(state: ContractState, contract: ContractClassName = requireNotNullContractClassName(state), notary: Party, encumbrance: Int? = null, constraint: AttachmentConstraint = AutomaticPlaceholderConstraint): TransactionBuilder
Adds an output state, with associated contract code (and constraints), and notary, to the transaction. fun addOutputState(state: ContractState, contract: ContractClassName = requireNotNullContractClassName(state), constraint: AttachmentConstraint = AutomaticPlaceholderConstraint): TransactionBuilder
Adds an output state. A default notary must be specified during builder construction to use this method fun addOutputState(state: ContractState, constraint: AttachmentConstraint): TransactionBuilder
Adds an output state with the specified constraint. |
|
open fun addReferenceState(referencedStateAndRef: ReferencedStateAndRef<*>): <ERROR CLASS>
Adds a reference input StateRef to the transaction. |
|
fun attachments(): List<AttachmentId>
Returns an immutable list of attachment hashes. |
|
fun commands(): List<Command<*>>
Returns an immutable list of Commands. |
|
fun copy(): TransactionBuilder
Creates a copy of the builder. |
|
fun inputStates(): List<StateRef>
Returns an immutable list of input StateRefs. |
|
fun outputStates(): List<TransactionState<*>>
Returns an immutable list of output TransactionStates. |
|
fun referenceStates(): List<StateRef>
Returns an immutable list of reference input StateRefs. |
|
fun setPrivacySalt(privacySalt: PrivacySalt): <ERROR CLASS> |
|
fun setTimeWindow(timeWindow: TimeWindow): <ERROR CLASS>
Sets the TimeWindow for this transaction, replacing the existing TimeWindow if there is one. To be valid, the transaction must then be signed by the notary service within this window of time. In this way, the notary acts as the Timestamp Authority. fun setTimeWindow(time: Instant, timeTolerance: Duration): <ERROR CLASS>
The TimeWindow for the transaction can also be defined as time +/- timeTolerance. The tolerance should be chosen such that your code can finish building the transaction and sending it to the Timestamp Authority within that window of time, taking into account factors such as network latency. Transactions being built by a group of collaborating parties may therefore require a higher time tolerance than a transaction being built by a single node. |
|
fun toLedgerTransaction(services: ServiceHub): LedgerTransaction |
|
fun toSignedTransaction(keyManagementService: KeyManagementService, publicKey: PublicKey, signatureMetadata: SignatureMetadata, services: ServicesForResolution): SignedTransaction
Sign the built transaction and return it. This is an internal function for use by the service hub, please use ServiceHub.signInitialTransaction instead. |
|
fun toWireTransaction(services: ServicesForResolution): WireTransaction fun toWireTransaction(services: ServicesForResolution, schemeId: Int): WireTransaction fun toWireTransaction(services: ServicesForResolution, schemeId: Int, properties: Map<Any, Any>): WireTransaction
Generates a WireTransaction from this builder, resolves any AutomaticPlaceholderConstraint, and selects the attachments to use for this transaction. |
|
fun verify(services: ServiceHub): Unit |
|
fun withItems(vararg items: Any): <ERROR CLASS>
A more convenient way to add items to this transaction that calls the add* methods for you based on type |
fun Any.contextLogger(): <ERROR CLASS>
When called from a companion object, returns the logger for the enclosing class. |