public 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.
Modifier and Type | Field and Description |
---|---|
static net.corda.core.transactions.TransactionBuilder.Companion |
Companion
Deprecated.
|
Constructor and Description |
---|
TransactionBuilder(Party notary,
java.util.UUID lockId,
java.util.List<net.corda.core.contracts.StateRef> inputs,
java.util.List<net.corda.core.crypto.SecureHash> attachments,
java.util.List<net.corda.core.contracts.TransactionState> outputs,
java.util.List<net.corda.core.contracts.Command> commands,
TimeWindow window,
PrivacySalt privacySalt,
java.util.List<net.corda.core.contracts.StateRef> references,
ServiceHub 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.
|
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.
|
TransactionBuilder(Party notary,
java.util.UUID lockId,
java.util.List<net.corda.core.contracts.StateRef> inputs,
java.util.List<net.corda.core.crypto.SecureHash> attachments,
java.util.List<net.corda.core.contracts.TransactionState> outputs,
java.util.List<net.corda.core.contracts.Command> commands,
TimeWindow window,
PrivacySalt privacySalt) |
TransactionBuilder(Party notary) |
Modifier and Type | Method and Description |
---|---|
NonExistentClass |
addAttachment(SecureHash attachmentId)
Adds an attachment with the specified hash to the TransactionBuilder.
|
NonExistentClass |
addCommand(Command<?> arg)
Adds a
class Command to the transaction. |
NonExistentClass |
addCommand(CommandData data,
java.security.PublicKey keys)
Adds a
class Command to the transaction, specified by the encapsulated interface CommandData object and required list of
signing PublicKeys. |
NonExistentClass |
addCommand(CommandData data,
java.util.List<? extends java.security.PublicKey> keys) |
NonExistentClass |
addInputState(StateAndRef<?> stateAndRef)
Adds an input
class StateRef to the transaction. |
NonExistentClass |
addOutputState(TransactionState<?> state)
Adds an output state to the transaction.
|
TransactionBuilder |
addOutputState(ContractState state,
java.lang.String contract,
Party notary,
java.lang.Integer encumbrance,
AttachmentConstraint constraint)
Adds an output state, with associated contract code (and constraints), and notary, to the transaction.
|
TransactionBuilder |
addOutputState(ContractState state,
java.lang.String contract,
AttachmentConstraint constraint)
Adds an output state. A default notary must be specified during builder construction to use this method
|
TransactionBuilder |
addOutputState(ContractState state,
AttachmentConstraint constraint)
Adds an output state with the specified constraint.
|
NonExistentClass |
addReferenceState(ReferencedStateAndRef<?> referencedStateAndRef)
Adds a reference input
class StateRef to the transaction. |
java.util.List<net.corda.core.crypto.SecureHash> |
attachments()
Returns an immutable list of attachment hashes.
|
java.util.List<net.corda.core.contracts.Command> |
commands()
Returns an immutable list of
class Command s. |
TransactionBuilder |
copy()
Creates a copy of the builder.
|
java.util.List<net.corda.core.crypto.SecureHash> |
getAttachments() |
java.util.List<net.corda.core.contracts.Command> |
getCommands() |
java.util.List<net.corda.core.contracts.StateRef> |
getInputs() |
java.util.UUID |
getLockId() |
Party |
getNotary()
Notary used for the transaction.
|
java.util.List<net.corda.core.contracts.TransactionState> |
getOutputs() |
PrivacySalt |
getPrivacySalt() |
java.util.List<net.corda.core.contracts.StateRef> |
getReferences() |
ServiceHub |
getServiceHub() |
TimeWindow |
getWindow() |
java.util.List<net.corda.core.contracts.StateRef> |
inputStates()
Returns an immutable list of input
class StateRef s. |
java.util.List<net.corda.core.contracts.TransactionState> |
outputStates()
Returns an immutable list of output
class TransactionState s. |
java.util.List<net.corda.core.contracts.StateRef> |
referenceStates()
Returns an immutable list of reference input
class StateRef s. |
void |
setLockId(java.util.UUID p) |
void |
setNotary(Party p)
Notary used for the transaction.
|
NonExistentClass |
setPrivacySalt(PrivacySalt privacySalt) |
void |
setPrivacySalt(PrivacySalt p) |
NonExistentClass |
setTimeWindow(TimeWindow timeWindow)
Sets the
class TimeWindow for this transaction, replacing the existing class 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. |
NonExistentClass |
setTimeWindow(java.time.Instant time,
java.time.Duration timeTolerance)
The
class 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. |
void |
setWindow(TimeWindow p) |
LedgerTransaction |
toLedgerTransaction(ServiceHub services) |
SignedTransaction |
toSignedTransaction(KeyManagementService keyManagementService,
java.security.PublicKey publicKey,
SignatureMetadata signatureMetadata,
ServicesForResolution services)
Sign the built transaction and return it. This is an internal function for use by the service hub, please use
ServiceHub.signInitialTransaction instead.
|
WireTransaction |
toWireTransaction(ServicesForResolution services)
Generates a
class WireTransaction from this builder, resolves any class AutomaticPlaceholderConstraint , and selects the attachments to use for this transaction. |
WireTransaction |
toWireTransaction(ServicesForResolution services,
int schemeId)
Generates a
class WireTransaction from this builder, resolves any class AutomaticPlaceholderConstraint , and selects the attachments to use for this transaction. |
WireTransaction |
toWireTransaction(ServicesForResolution services,
int schemeId,
java.util.Map<java.lang.Object,? extends java.lang.Object> properties)
Generates a
class WireTransaction from this builder, resolves any class AutomaticPlaceholderConstraint , and selects the attachments to use for this transaction. |
void |
verify(ServiceHub services) |
NonExistentClass |
withItems(java.lang.Object items)
A more convenient way to add items to this transaction that calls the add* methods for you based on type
|
public static net.corda.core.transactions.TransactionBuilder.Companion Companion
public TransactionBuilder(Party notary, java.util.UUID lockId, java.util.List<net.corda.core.contracts.StateRef> inputs, java.util.List<net.corda.core.crypto.SecureHash> attachments, java.util.List<net.corda.core.contracts.TransactionState> outputs, java.util.List<net.corda.core.contracts.Command> commands, TimeWindow window, PrivacySalt privacySalt, java.util.List<net.corda.core.contracts.StateRef> references, ServiceHub 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.
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 interface ContractState
– aclass TransactionState
with this notary specified will be generated automatically.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 interface ContractState
– a
class TransactionState
with this notary specified will be generated automatically.public 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.
public TransactionBuilder(Party notary, java.util.UUID lockId, java.util.List<net.corda.core.contracts.StateRef> inputs, java.util.List<net.corda.core.crypto.SecureHash> attachments, java.util.List<net.corda.core.contracts.TransactionState> outputs, java.util.List<net.corda.core.contracts.Command> commands, TimeWindow window, PrivacySalt privacySalt)
public TransactionBuilder(Party notary)
public TransactionBuilder copy()
Creates a copy of the builder.
public NonExistentClass withItems(java.lang.Object items)
A more convenient way to add items to this transaction that calls the add* methods for you based on type
public WireTransaction toWireTransaction(ServicesForResolution services)
Generates a class WireTransaction
from this builder, resolves any class AutomaticPlaceholderConstraint
, and selects the attachments to use for this transaction.
class WireTransaction
,
class AutomaticPlaceholderConstraint
public WireTransaction toWireTransaction(ServicesForResolution services, int schemeId)
Generates a class WireTransaction
from this builder, resolves any class AutomaticPlaceholderConstraint
, and selects the attachments to use for this transaction.
schemeId
- is used to specify the interface CustomSerializationScheme
used to serialize each component of the componentGroups of the class WireTransaction
.
This is an experimental feature.class WireTransaction
,
class AutomaticPlaceholderConstraint
public WireTransaction toWireTransaction(ServicesForResolution services, int schemeId, java.util.Map<java.lang.Object,? extends java.lang.Object> properties)
Generates a class WireTransaction
from this builder, resolves any class AutomaticPlaceholderConstraint
, and selects the attachments to use for this transaction.
schemeId
- is used to specify the interface CustomSerializationScheme
used to serialize each component of the componentGroups of the class WireTransaction
.
This is an experimental feature.properties
- a list of properties to add to the interface SerializationSchemeContext
these properties can be accessed in CustomSerializationScheme.serialize
when serializing the componentGroups of the wire transaction but might not be available when deserializing.class WireTransaction
,
class AutomaticPlaceholderConstraint
public LedgerTransaction toLedgerTransaction(ServiceHub services)
public void verify(ServiceHub services)
public NonExistentClass addReferenceState(ReferencedStateAndRef<?> referencedStateAndRef)
Adds a reference input class StateRef
to the transaction.
Note: Reference states are only supported on Corda networks running a minimum platform version of 4.
TransactionBuilder.toWireTransaction
will throw an IllegalStateException if called in such an environment.
public NonExistentClass addInputState(StateAndRef<?> stateAndRef)
Adds an input class StateRef
to the transaction.
class StateRef
public NonExistentClass addAttachment(SecureHash attachmentId)
Adds an attachment with the specified hash to the TransactionBuilder.
public NonExistentClass addOutputState(TransactionState<?> state)
Adds an output state to the transaction.
public TransactionBuilder addOutputState(ContractState state, java.lang.String contract, Party notary, java.lang.Integer encumbrance, AttachmentConstraint constraint)
Adds an output state, with associated contract code (and constraints), and notary, to the transaction.
public TransactionBuilder addOutputState(ContractState state, java.lang.String contract, AttachmentConstraint constraint)
Adds an output state. A default notary must be specified during builder construction to use this method
public TransactionBuilder addOutputState(ContractState state, AttachmentConstraint constraint)
Adds an output state with the specified constraint.
public NonExistentClass addCommand(Command<?> arg)
Adds a class Command
to the transaction.
class Command
public NonExistentClass addCommand(CommandData data, java.security.PublicKey keys)
Adds a class Command
to the transaction, specified by the encapsulated interface CommandData
object and required list of
signing PublicKeys.
class Command
,
interface CommandData
,
PublicKeypublic NonExistentClass addCommand(CommandData data, java.util.List<? extends java.security.PublicKey> keys)
public NonExistentClass setTimeWindow(TimeWindow timeWindow)
Sets the class TimeWindow
for this transaction, replacing the existing class 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.
class TimeWindow
,
class TimeWindow
public NonExistentClass setTimeWindow(java.time.Instant time, java.time.Duration timeTolerance)
The class 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.
class TimeWindow
public NonExistentClass setPrivacySalt(PrivacySalt privacySalt)
public java.util.List<net.corda.core.contracts.StateRef> inputStates()
Returns an immutable list of input class StateRef
s.
class StateRef
public java.util.List<net.corda.core.contracts.StateRef> referenceStates()
Returns an immutable list of reference input class StateRef
s.
class StateRef
public java.util.List<net.corda.core.crypto.SecureHash> attachments()
Returns an immutable list of attachment hashes.
public java.util.List<net.corda.core.contracts.TransactionState> outputStates()
Returns an immutable list of output class TransactionState
s.
class TransactionState
public java.util.List<net.corda.core.contracts.Command> commands()
Returns an immutable list of class Command
s.
class Command
public SignedTransaction toSignedTransaction(KeyManagementService keyManagementService, java.security.PublicKey publicKey, SignatureMetadata signatureMetadata, ServicesForResolution services)
Sign the built transaction and return it. This is an internal function for use by the service hub, please use ServiceHub.signInitialTransaction instead.
public Party getNotary()
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 interface ContractState
– aclass TransactionState
with this notary specified will be generated automatically.
interface ContractState
,
class TransactionState
public void setNotary(Party p)
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 interface ContractState
– aclass TransactionState
with this notary specified will be generated automatically.
p
- 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 interface ContractState
– aclass TransactionState
with this notary specified will be generated automatically.interface ContractState
,
class TransactionState
public java.util.UUID getLockId()
public void setLockId(java.util.UUID p)
public java.util.List<net.corda.core.contracts.StateRef> getInputs()
public java.util.List<net.corda.core.crypto.SecureHash> getAttachments()
public java.util.List<net.corda.core.contracts.TransactionState> getOutputs()
public java.util.List<net.corda.core.contracts.Command> getCommands()
public TimeWindow getWindow()
public void setWindow(TimeWindow p)
public PrivacySalt getPrivacySalt()
public void setPrivacySalt(PrivacySalt p)
public java.util.List<net.corda.core.contracts.StateRef> getReferences()
public ServiceHub getServiceHub()