com.r3corda.core.contracts / TransactionBuilder

TransactionBuilder

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 or modifying the existing set. Then once the states and commands are right, this class can be used as a holding bucket to gather signatures from multiple parties.



Constructors

<init> TransactionBuilder(inputs: MutableList<StateRef> = arrayListOf(), attachments: MutableList<SecureHash> = arrayListOf(), outputs: MutableList<ContractState> = arrayListOf(), commands: MutableList<Command> = arrayListOf())

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 or modifying the existing set. Then once the states and commands are right, this class can be used as a holding bucket to gather signatures from multiple parties.

Properties

time val time: TimestampCommand?

Functions

addAttachment fun addAttachment(attachment: Attachment): 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 fun addInputState(ref: StateRef): Unit
addOutputState fun addOutputState(state: ContractState): Unit
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>
inputStates fun inputStates(): List<StateRef>
outputStates fun outputStates(): List<ContractState>
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