open class TransactionBuilder
A TransactionBuilder is a transaction class thats 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
- The default notary that will be used for outputs that dont have a notary specified. When this is set,
an output state can be added by just passing in a ContractState – a TransactionState with the
default notary will be generated automatically.<init> |
TransactionBuilder(type: TransactionType = TransactionType.General(), notary: Party? = null, inputs: MutableList<StateRef> = arrayListOf(), attachments: MutableList<SecureHash> = arrayListOf(), outputs: MutableList<TransactionState<ContractState>> = arrayListOf(), commands: MutableList<Command> = arrayListOf(), signers: MutableSet<PublicKey> = mutableSetOf()) A TransactionBuilder is a transaction class thats 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. |
attachments |
val attachments: MutableList<SecureHash> |
commands |
val commands: MutableList<Command> |
currentSigs |
val currentSigs: <ERROR CLASS> The signatures that have been collected so far - might be incomplete |
inputs |
val inputs: MutableList<StateRef> |
notary |
val notary: Party? |
outputs |
val outputs: MutableList<TransactionState<ContractState>> |
signers |
val signers: MutableSet<PublicKey> |
time |
val time: TimestampCommand? |
type |
val type: TransactionType |
addAttachment |
fun addAttachment(attachmentId: SecureHash): Unit |
addCommand |
fun addCommand(arg: Command): Unit fun addCommand(data: CommandData, vararg keys: PublicKey): <ERROR CLASS> fun addCommand(data: CommandData, keys: List<PublicKey>): Unit |
addInputState |
open fun addInputState(stateAndRef: StateAndRef<*>): Unit fun addInputState(stateRef: StateRef, notary: Party): Unit |
addOutputState |
fun addOutputState(state: TransactionState<*>): Int fun addOutputState(state: ContractState, notary: Party): Int fun addOutputState(state: ContractState): Int A default notary must be specified during builder construction to use this method |
addSignatureUnchecked |
fun addSignatureUnchecked(sig: WithKey): Unit Adds the signature directly to the transaction, without checking it for validity. |
attachments |
fun attachments(): List<SecureHash> |
checkAndAddSignature |
fun checkAndAddSignature(sig: WithKey): Unit Checks that the given signature matches one of the commands and that it is a correct signature over the tx, then adds it. |
checkSignature |
fun checkSignature(sig: WithKey): Unit Checks that the given signature matches one of the commands and that it is a correct signature over the tx. |
commands |
fun commands(): List<Command> |
copy |
fun copy(): TransactionBuilder Creates a copy of the builder. |
inputStates |
fun inputStates(): List<StateRef> |
outputStates |
fun outputStates(): List<TransactionState<*>> |
setTime |
fun setTime(time: Instant, authority: Party, timeTolerance: Duration): Unit Places a TimestampCommand in this transaction, removing any existing command if there is one. The command requires a signature from the Notary service, which acts as a Timestamp Authority. The signature can be obtained using NotaryProtocol. |
signWith |
fun signWith(key: KeyPair): Unit |
toSignedTransaction |
fun toSignedTransaction(checkSufficientSignatures: Boolean = true): SignedTransaction |
toWireTransaction |
fun toWireTransaction(): WireTransaction |
withItems |
fun withItems(vararg items: Any): TransactionBuilder A more convenient way to add items to this transaction that calls the add* methods for you based on type |
Builder |
class Builder : TransactionBuilder Just uses the default TransactionBuilder with no special logic |
Builder |
class Builder : TransactionBuilder A transaction builder that automatically sets the transaction type to NotaryChange and adds the list of participants to the signers set for every input state. |