SignedTransaction
Keywords: net.corda.core.transactions.SignedTransaction class
Date: 2023-09-18

net.corda.core.transactions

## Class SignedTransaction

- net.corda.core.transactions.SignedTransaction

- All Implemented Interfaces:
    NamedByHash, TransactionWithSignatures

      public class SignedTransaction
      implements TransactionWithSignatures

  SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key (including composite keys) that is mentioned inside a transaction command. SignedTransaction is the top level transaction type and the type most frequently passed around the network and stored. The identity of a transaction is the hash of Merkle root of a WireTransaction, therefore if you are storing data keyed by WT hash be aware that multiple different STs may map to the same key (and they could be different in important ways, like validity!). The signatures on a SignedTransaction might be invalid or missing: the type does not imply validity. A transaction ID should be the hash of the `class WireTransaction` Merkle tree root. Thus adding or removing a signature does not change it.

  See Also:
    `class WireTransaction`

- - ### Field Detail

    - #### Companion

          public static net.corda.core.transactions.SignedTransaction.Companion Companion

      Deprecated.

  - ### Constructor Detail

    - #### SignedTransaction

          public SignedTransaction(@NotNull
                                   SerializedBytes<net.corda.core.transactions.CoreTransaction> txBits,
                                   @NotNull
                                   java.util.List<net.corda.core.crypto.TransactionSignature> sigs)

      SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key (including composite keys) that is mentioned inside a transaction command. SignedTransaction is the top level transaction type and the type most frequently passed around the network and stored. The identity of a transaction is the hash of Merkle root of a WireTransaction, therefore if you are storing data keyed by WT hash be aware that multiple different STs may map to the same key (and they could be different in important ways, like validity!). The signatures on a SignedTransaction might be invalid or missing: the type does not imply validity. A transaction ID should be the hash of the `class WireTransaction` Merkle tree root. Thus adding or removing a signature does not change it.

      Parameters:
        `sigs` - a list of signatures from individual (non-composite) public keys. This is passed as a list of signatureswhen verifying composite key signatures, but may be used as individual signatures where a single key is expected tosign.
      See Also:
        `class WireTransaction`

    - #### SignedTransaction

          public SignedTransaction(@NotNull
                                   CoreTransaction ctx,
                                   @NotNull
                                   java.util.List<net.corda.core.crypto.TransactionSignature> sigs)

  - ### Method Detail

    - #### getId

          @NotNull
          public SecureHash getId()

      The id of the contained `class WireTransaction`.

      See Also:
        `class WireTransaction`

    - #### getCoreTransaction

          @NotNull
          public CoreTransaction getCoreTransaction()

      Lazily calculated access to the deserialised/hashed transaction data.

    - #### getTx

          @NotNull
          public WireTransaction getTx()

      Returns the contained `class WireTransaction`, or throws if this is a notary change or contract upgrade transaction.

      See Also:
        `class WireTransaction`

    - #### buildFilteredTransaction

          @NotNull
          public FilteredTransaction buildFilteredTransaction(@NotNull
                                                                       java.util.function.Predicate<java.lang.Object> filtering)

      Helper function to directly build a `class FilteredTransaction` using provided filtering functions, without first accessing the `tx`.

      See Also:
        `class FilteredTransaction`, `tx`

    - #### getInputs

          @NotNull
          public java.util.List<net.corda.core.contracts.StateRef> getInputs()

      Helper to access the inputs of the contained transaction.

    - #### getReferences

          @NotNull
          public java.util.List<net.corda.core.contracts.StateRef> getReferences()

      Helper to access the unspendable inputs of the contained transaction.

    - #### getNotary

          @Nullable
          public Party getNotary()

      Helper to access the notary of the contained transaction.

    - #### getNetworkParametersHash

          @Nullable
          public SecureHash getNetworkParametersHash()

      Helper to access the network parameters hash for the contained transaction.

    - #### getRequiredSigningKeys

          @NotNull
          public java.util.Set<java.security.PublicKey> getRequiredSigningKeys()

      Specifies all the public keys that require signatures for the transaction to be valid.

    - #### getKeyDescriptions

          @NotNull
          public java.util.ArrayList<java.lang.String> getKeyDescriptions(@NotNull
                                                                                   java.util.Set<? extends java.security.PublicKey> keys)

      Get a human readable description of where signatures are required from, and are missing, to assist in debugging the underlying cause.

      Note that the results should not be serialised, parsed or expected to remain stable between Corda versions.

    - #### withAdditionalSignature

          @VisibleForTesting
           @NotNull
          public SignedTransaction withAdditionalSignature(@NotNull
                                                                                        java.security.KeyPair keyPair,
                                                                                        @NotNull
                                                                                        SignatureMetadata signatureMetadata)

    - #### withAdditionalSignature

          @NotNull
          public SignedTransaction withAdditionalSignature(@NotNull
                                                                    TransactionSignature sig)

      Returns the same transaction but with an additional (unchecked) signature.

    - #### withAdditionalSignatures

          @NotNull
          public SignedTransaction withAdditionalSignatures(@NotNull
                                                                     java.lang.Iterable<net.corda.core.crypto.TransactionSignature> sigList)

      Returns the same transaction but with an additional (unchecked) signatures.

    - #### plus

          @NotNull
          public SignedTransaction plus(@NotNull
                                                 TransactionSignature sig)

      Alias for `withAdditionalSignature` to let you use Kotlin operator overloading.

      See Also:
        `withAdditionalSignature`

    - #### plus

          @NotNull
          public SignedTransaction plus(@NotNull
                                                 java.util.Collection<net.corda.core.crypto.TransactionSignature> sigList)

      Alias for `withAdditionalSignatures` to let you use Kotlin operator overloading.

      See Also:
        `withAdditionalSignatures`

    - #### toLedgerTransaction

          @JvmOverloads
           @NotNull
          public LedgerTransaction toLedgerTransaction(@NotNull
                                                                               ServiceHub services,
                                                                               boolean checkSufficientSignatures)

      Checks the transaction's signatures are valid, optionally calls `verifyRequiredSignatures` to check all required signatures are present, and then calls `WireTransaction.toLedgerTransaction` with the passed in `interface ServiceHub` to resolve the dependencies, returning an unverified LedgerTransaction.

      This allows us to perform validation over the entirety of the transaction's contents. WireTransaction only contains StateRef for the inputs and hashes for the attachments, rather than ContractState instances for the inputs and Attachment instances for the attachments.

      Throws:
        `AttachmentResolutionException` - if a required attachment was not found in storage.
        `TransactionResolutionException` - if an input points to a transaction not found in storage.
        `SignatureException` - if any signatures were invalid or unrecognised
        `SignaturesMissingException` - if any signatures that should have been present are missing.
      See Also:
        `verifyRequiredSignatures`, `WireTransaction.toLedgerTransaction`, `interface ServiceHub`

    - #### toLedgerTransaction

          @JvmOverloads
           @NotNull
          public LedgerTransaction toLedgerTransaction(@NotNull
                                                                               ServiceHub services)

      Checks the transaction's signatures are valid, optionally calls `verifyRequiredSignatures` to check all required signatures are present, and then calls `WireTransaction.toLedgerTransaction` with the passed in `interface ServiceHub` to resolve the dependencies, returning an unverified LedgerTransaction.

      This allows us to perform validation over the entirety of the transaction's contents. WireTransaction only contains StateRef for the inputs and hashes for the attachments, rather than ContractState instances for the inputs and Attachment instances for the attachments.

      Throws:
        `AttachmentResolutionException` - if a required attachment was not found in storage.
        `TransactionResolutionException` - if an input points to a transaction not found in storage.
        `SignatureException` - if any signatures were invalid or unrecognised
        `SignaturesMissingException` - if any signatures that should have been present are missing.
      See Also:
        `verifyRequiredSignatures`, `WireTransaction.toLedgerTransaction`, `interface ServiceHub`

    - #### verify

          @JvmOverloads
          public void verify(@NotNull
                                           ServiceHub services,
                                           boolean checkSufficientSignatures)

      Checks the transaction's signatures are valid, optionally calls `verifyRequiredSignatures` to check all required signatures are present. Resolves inputs and attachments from the local storage and performs full transaction verification, including running the contracts.

      Throws:
        `AttachmentResolutionException` - if a required attachment was not found in storage.
        `TransactionResolutionException` - if an input points to a transaction not found in storage.
        `SignatureException` - if any signatures were invalid or unrecognised
        `SignaturesMissingException` - if any signatures that should have been present are missing.
      See Also:
        `verifyRequiredSignatures`

    - #### verify

          @JvmOverloads
          public void verify(@NotNull
                                           ServiceHub services)

      Checks the transaction's signatures are valid, optionally calls `verifyRequiredSignatures` to check all required signatures are present. Resolves inputs and attachments from the local storage and performs full transaction verification, including running the contracts.

      Throws:
        `AttachmentResolutionException` - if a required attachment was not found in storage.
        `TransactionResolutionException` - if an input points to a transaction not found in storage.
        `SignatureException` - if any signatures were invalid or unrecognised
        `SignaturesMissingException` - if any signatures that should have been present are missing.
      See Also:
        `verifyRequiredSignatures`

    - #### resolveBaseTransaction

          @NotNull
          public BaseTransaction resolveBaseTransaction(@NotNull
                                                                 ServicesForResolution servicesForResolution)

      Resolves the underlying base transaction and then returns it, handling any special case transactions such as `class NotaryChangeWireTransaction`.

      See Also:
        `class NotaryChangeWireTransaction`

    - #### resolveTransactionWithSignatures

          @NotNull
          public TransactionWithSignatures resolveTransactionWithSignatures(@NotNull
                                                                                     ServicesForResolution services)

      Resolves the underlying transaction with signatures and then returns it, handling any special case transactions such as `class NotaryChangeWireTransaction`.

      See Also:
        `class NotaryChangeWireTransaction`

    - #### resolveNotaryChangeTransaction

          @NotNull
          public NotaryChangeLedgerTransaction resolveNotaryChangeTransaction(@NotNull
                                                                                       ServicesForResolution services)

      If transaction is a `class NotaryChangeWireTransaction`, loads the input states and resolves it to a `class NotaryChangeLedgerTransaction` so the signatures can be verified.

      See Also:
        transaction, `class NotaryChangeWireTransaction`, `class NotaryChangeLedgerTransaction`

    - #### resolveNotaryChangeTransaction

          @NotNull
          public NotaryChangeLedgerTransaction resolveNotaryChangeTransaction(@NotNull
                                                                                       ServiceHub services)

      If transaction is a `class NotaryChangeWireTransaction`, loads the input states and resolves it to a `class NotaryChangeLedgerTransaction` so the signatures can be verified.

      See Also:
        transaction, `class NotaryChangeWireTransaction`, `class NotaryChangeLedgerTransaction`

    - #### resolveContractUpgradeTransaction

          @NotNull
          public ContractUpgradeLedgerTransaction resolveContractUpgradeTransaction(@NotNull
                                                                                             ServicesForResolution services)

      If `coreTransaction` is a `class ContractUpgradeWireTransaction`, loads the input states and resolves it to a `class ContractUpgradeLedgerTransaction` so the signatures can be verified.

      See Also:
        `coreTransaction`, `class ContractUpgradeWireTransaction`, `class ContractUpgradeLedgerTransaction`

    - #### toString

          @NotNull
          public java.lang.String toString()

    - #### getNotaryChangeTx

          @NotNull
          public NotaryChangeWireTransaction getNotaryChangeTx()

      Deprecated.

      Returns the contained `class NotaryChangeWireTransaction`, or throws if this is a normal transaction.

      See Also:
        `class NotaryChangeWireTransaction`

    - #### isNotaryChangeTransaction

          @Deprecated
          public boolean isNotaryChangeTransaction()

      Deprecated.

    - #### getTxBits

          @NotNull
          public SerializedBytes<net.corda.core.transactions.CoreTransaction> getTxBits()

    - #### getSigs

          @NotNull
          public java.util.List<net.corda.core.crypto.TransactionSignature> getSigs()

      a list of signatures from individual

      (non-composite) public keys. This is passed as a list of signatureswhen verifying composite key signatures, but may be used as individual signatures where a single key is expected tosign.

    - #### component1

          @NotNull
          public SerializedBytes<net.corda.core.transactions.CoreTransaction> component1()

    - #### component2

          @NotNull
          public java.util.List<net.corda.core.crypto.TransactionSignature> component2()

      a list of signatures from individual

      (non-composite) public keys. This is passed as a list of signatureswhen verifying composite key signatures, but may be used as individual signatures where a single key is expected tosign.

    - #### copy

          @NotNull
          public SignedTransaction copy(@NotNull
                                                 SerializedBytes<net.corda.core.transactions.CoreTransaction> txBits,
                                                 @NotNull
                                                 java.util.List<net.corda.core.crypto.TransactionSignature> sigs)

      SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key (including composite keys) that is mentioned inside a transaction command. SignedTransaction is the top level transaction type and the type most frequently passed around the network and stored. The identity of a transaction is the hash of Merkle root of a WireTransaction, therefore if you are storing data keyed by WT hash be aware that multiple different STs may map to the same key (and they could be different in important ways, like validity!). The signatures on a SignedTransaction might be invalid or missing: the type does not imply validity. A transaction ID should be the hash of the `class WireTransaction` Merkle tree root. Thus adding or removing a signature does not change it.

      Parameters:
        `sigs` - a list of signatures from individual (non-composite) public keys. This is passed as a list of signatures when verifying composite key signatures, but may be used as individual signatures where a single key is expected to sign.
      See Also:
        `class WireTransaction`

    - #### hashCode

          public int hashCode()

      SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key (including composite keys) that is mentioned inside a transaction command. SignedTransaction is the top level transaction type and the type most frequently passed around the network and stored. The identity of a transaction is the hash of Merkle root of a WireTransaction, therefore if you are storing data keyed by WT hash be aware that multiple different STs may map to the same key (and they could be different in important ways, like validity!). The signatures on a SignedTransaction might be invalid or missing: the type does not imply validity. A transaction ID should be the hash of the `class WireTransaction` Merkle tree root. Thus adding or removing a signature does not change it.

      See Also:
        `class WireTransaction`

    - #### equals

          public boolean equals(@Nullable
                                java.lang.Object p)

      SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key (including composite keys) that is mentioned inside a transaction command. SignedTransaction is the top level transaction type and the type most frequently passed around the network and stored. The identity of a transaction is the hash of Merkle root of a WireTransaction, therefore if you are storing data keyed by WT hash be aware that multiple different STs may map to the same key (and they could be different in important ways, like validity!). The signatures on a SignedTransaction might be invalid or missing: the type does not imply validity. A transaction ID should be the hash of the `class WireTransaction` Merkle tree root. Thus adding or removing a signature does not change it.

      See Also:
        `class WireTransaction`