TransactionDSL
Keywords: net.corda.testing.dsl.TransactionDSL class
Date: 2023-09-18

net.corda.testing.dsl

## Class TransactionDSL<T extends TransactionDSLInterpreter>

- net.corda.testing.dsl.TransactionDSL<T>

- All Implemented Interfaces:
    OutputStateLookup, TransactionDSLInterpreter, Verifies

      public class TransactionDSL<T extends TransactionDSLInterpreter>
      implements TransactionDSLInterpreter

  Underlying class for the transaction DSL. Do not instantiate directly, instead use the transaction function.

  See Also:
    transaction

- - ### Constructor Detail

    - #### TransactionDSL

          public TransactionDSL(@NotNull
                                T interpreter,
                                @NotNull
                                Party notary)

      Underlying class for the transaction DSL. Do not instantiate directly, instead use the transaction function.

      See Also:
        transaction

  - ### Method Detail

    - #### reference

          public void reference(@NotNull
                                java.lang.String stateLabel)

      Looks up the output label and adds the found state as an reference input state.

      Parameters:
        `stateLabel` - The label of the output state specified when calling `TransactionDSLInterpreter.output` and friends.

    - #### reference

          public void reference(@NotNull
                                java.lang.String contractClassName,
                                @NotNull
                                ContractState state)

      Creates an `LedgerDSLInterpreter._unverifiedTransaction` with a single reference input state and adds its reference as in input to the current transaction.

      Parameters:
        `state` - The state to be added.
      See Also:
        `LedgerDSLInterpreter._unverifiedTransaction`

    - #### input

          public void input(@NotNull
                            java.lang.String stateLabel)

      Looks up the output label and adds the found state as an input.

      Parameters:
        `stateLabel` - The label of the output state specified when calling `TransactionDSLInterpreter.output` and friends.

    - #### input

          public void input(@NotNull
                            java.lang.String contractClassName,
                            @NotNull
                            java.lang.String stateLabel)

    - #### input

          public void input(@NotNull
                            java.lang.String contractClassName,
                            @NotNull
                            ContractState state)

      Creates an `LedgerDSLInterpreter._unverifiedTransaction` with a single output state and adds its reference as an input to the current transaction.

      Parameters:
        `state` - The state to be added.
      See Also:
        `LedgerDSLInterpreter._unverifiedTransaction`

    - #### output

          public void output(@NotNull
                             java.lang.String contractClassName,
                             @NotNull
                             java.lang.String label,
                             @NotNull
                             Party notary,
                             @NotNull
                             ContractState contractState)

      Adds a labelled output to the transaction.

    - #### output

          public void output(@NotNull
                             java.lang.String contractClassName,
                             @NotNull
                             java.lang.String label,
                             int encumbrance,
                             @NotNull
                             ContractState contractState)

      Adds a labelled output to the transaction.

    - #### output

          public void output(@NotNull
                             java.lang.String contractClassName,
                             @NotNull
                             java.lang.String label,
                             @NotNull
                             ContractState contractState)

      Adds a labelled output to the transaction.

    - #### output

          public void output(@NotNull
                             java.lang.String contractClassName,
                             @NotNull
                             Party notary,
                             @NotNull
                             ContractState contractState)

      Adds an output to the transaction.

    - #### output

          public void output(@NotNull
                             java.lang.String contractClassName,
                             int encumbrance,
                             @NotNull
                             ContractState contractState)

      Adds an output to the transaction.

    - #### output

          public void output(@NotNull
                             java.lang.String contractClassName,
                             @NotNull
                             ContractState contractState)

      Adds an output to the transaction.

    - #### command

          public void command(@NotNull
                              java.security.PublicKey signer,
                              @NotNull
                              CommandData commandData)

      Adds a command to the transaction.

    - #### timeWindow

          @JvmOverloads
          public void timeWindow(@NotNull
                                               java.time.Instant time,
                                               @NotNull
                                               java.time.Duration tolerance)

      Sets the `class TimeWindow` of the transaction.

      Parameters:
        `time` - The Instant of the `class TimeWindow`.
        `tolerance` - The tolerance of the `class TimeWindow`.
      See Also:
        `class TimeWindow`

    - #### timeWindow

          @JvmOverloads
          public void timeWindow(@NotNull
                                               java.time.Instant time)

      Sets the `class TimeWindow` of the transaction.

      Parameters:
        `time` - The Instant of the `class TimeWindow`.
      See Also:
        `class TimeWindow`

    - #### tweak

          @NotNull
          public EnforceVerifyOrFail tweak(@NotNull
                                                    kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSL<? extends net.corda.testing.dsl.TransactionDSLInterpreter>,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)

      Creates a local scoped copy of the transaction.

    - #### attachment

          public void attachment(@NotNull
                                 java.lang.String contractClassName)

      See Also:
        `TransactionDSLInterpreter._attachment`

    - #### attachment

          public void attachment(@NotNull
                                 java.lang.String contractClassName,
                                 @NotNull
                                 SecureHash attachmentId,
                                 @NotNull
                                 java.util.List<? extends java.security.PublicKey> signers,
                                 @NotNull
                                 java.util.Map<java.lang.String,java.lang.String> jarManifestAttributes)

    - #### attachment

          public void attachment(@NotNull
                                 java.lang.String contractClassName,
                                 @NotNull
                                 SecureHash attachmentId)

    - #### attachments

          public void attachments(@NotNull
                                  java.lang.String... contractClassNames)

    - #### getLedgerInterpreter

          @NotNull
          public LedgerDSLInterpreter<net.corda.testing.dsl.TransactionDSLInterpreter> getLedgerInterpreter()

      A reference to the enclosing ledger{..}'s interpreter.

    - #### _attachment

          public void _attachment(@NotNull
                                  java.lang.String contractClassName)

      Attaches an attachment containing the named contract to the transaction

      Parameters:
        `contractClassName` - The contract class to attach

    - #### _attachment

          public void _attachment(@NotNull
                                  java.lang.String contractClassName,
                                  @NotNull
                                  SecureHash attachmentId,
                                  @NotNull
                                  java.util.List<? extends java.security.PublicKey> signers)

      Attaches an attachment containing the named contract to the transaction

      Parameters:
        `contractClassName` - The contract class to attach
        `attachmentId` - The attachment

    - #### _attachment

          public void _attachment(@NotNull
                                  java.lang.String contractClassName,
                                  @NotNull
                                  SecureHash attachmentId,
                                  @NotNull
                                  java.util.List<? extends java.security.PublicKey> signers,
                                  @NotNull
                                  java.util.Map<java.lang.String,java.lang.String> jarManifestAttributes)

      Attaches an attachment containing the named contract to the transaction.

      Parameters:
        `contractClassName` - The contract class to attach.
        `attachmentId` - The attachment.
        `signers` - The signers.
        `jarManifestAttributes` - The JAR manifest file attributes.

    - #### _tweak

          @NotNull
          public EnforceVerifyOrFail _tweak(@NotNull
                                                     kotlin.jvm.functions.Function1<? super net.corda.testing.dsl.TransactionDSLInterpreter,? extends net.corda.testing.dsl.EnforceVerifyOrFail> dsl)

      Creates a local scoped copy of the transaction.

      Parameters:
        `dsl` - The transaction DSL to be interpreted using the copy.

    - #### attachment

          public void attachment(@NotNull
                                 SecureHash attachmentId)

      Adds an `interface Attachment` reference to the transaction.

      Parameters:
        `attachmentId` - The hash of the attachment, possibly returned by `LedgerDSLInterpreter.attachment`.
      See Also:
        `interface Attachment`

    - #### command

          public void command(@NotNull
                              java.util.List<? extends java.security.PublicKey> signers,
                              @NotNull
                              CommandData commandData)

      Adds a command to the transaction.

      Parameters:
        `signers` - The signer public keys.
        `commandData` - The contents of the command.

    - #### fails

          @NotNull
          public EnforceVerifyOrFail fails()

      Asserts that `verifies` throws, with no condition on the exception message.

      See Also:
        `verifies`

    - #### fails with

          @NotNull
          public EnforceVerifyOrFail fails with(@NotNull
                                                         java.lang.String msg)

      See Also:
        `failsWith`

    - #### failsWith

          @NotNull
          public EnforceVerifyOrFail failsWith(@Nullable
                                                        java.lang.String expectedMessage)

      Asserts that verifies() throws.

      Parameters:
        `expectedMessage` - An optional string to be searched for in the raised exception.

    - #### input

          public void input(@NotNull
                            StateRef stateRef)

      Adds an input reference to the transaction. Note that `verifies` will resolve this reference.

      Parameters:
        `stateRef` - The input `class StateRef`.
      See Also:
        `verifies`

    - #### output

          public void output(@NotNull
                             java.lang.String contractClassName,
                             @Nullable
                             java.lang.String label,
                             @NotNull
                             Party notary,
                             @Nullable
                             java.lang.Integer encumbrance,
                             @NotNull
                             AttachmentConstraint attachmentConstraint,
                             @NotNull
                             ContractState contractState)

      Adds an output to the transaction.

      Parameters:
        `contractClassName` - The class name of the contract that verifies this state.
        `label` - An optional label that may be later used to retrieve the output probably in other transactions.
        `notary` - The associated notary.
        `encumbrance` - The position of the encumbrance state.
        `attachmentConstraint` - The attachment constraint
        `contractState` - The state itself.

    - #### reference

          public void reference(@NotNull
                                StateRef stateRef)

      Add a reference input state to the transaction. Note that `verifies` will resolve this reference.

      Parameters:
        `stateRef` - The input `class StateRef`.
      See Also:
        `verifies`

    - #### retrieveOutputStateAndRef

          @NotNull
          public <S extends ContractState> StateAndRef<S> retrieveOutputStateAndRef(@NotNull
                                                                                             java.lang.Class<S> clazz,
                                                                                             @NotNull
                                                                                             java.lang.String label)

      Retrieves an output previously defined by `TransactionDSLInterpreter.output` with a label passed in.

      Parameters:
        `clazz` - The class object holding the type of the output state expected.
        `label` - The label of the to-be-retrieved output state.
      Returns:
        The output `class StateAndRef`.
      See Also:
        `TransactionDSLInterpreter.output`

    - #### timeWindow

          public void timeWindow(@NotNull
                                 TimeWindow data)

      Sets the time-window of the transaction.

      Parameters:
        `data` - the `class TimeWindow` (validation window).

    - #### verifies

          @NotNull
          public EnforceVerifyOrFail verifies()

      Verifies the ledger/transaction, throws if the verification fails.