net.corda.core.transactions

## Class SignedTransaction

- net.corda.core.transactions.SignedTransaction

- All Implemented Interfaces:
    NamedByHash

      public class SignedTransaction
      implements NamedByHash

  SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key 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 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`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SignedTransaction(SerializedBytes<net.corda.core.transactions.WireTransaction> txBits, java.util.List<? extends net.corda.core.crypto.DigitalSignature.WithKey> sigs)` SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key 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 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.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkSignaturesAreValid()` Mathematically validates the signatures that are present on this transaction. This does not imply that the signatures are by the right keys, or that there are sufficient signatures, just that they aren't corrupt. If you use this function directly you'll need to do the other checks yourself. Probably you want verifySignatures instead.
    `SerializedBytes<net.corda.core.transactions.WireTransaction>` | `component1()`
    `java.util.List<net.corda.core.crypto.DigitalSignature.WithKey>` | `component2()`
    `SignedTransaction` | `copy(SerializedBytes<net.corda.core.transactions.WireTransaction> txBits, java.util.List<? extends net.corda.core.crypto.DigitalSignature.WithKey> sigs)` SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key 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 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.
    `boolean` | `equals(java.lang.Object p)`
    `SecureHash` | `getId()` The Merkle root of the inner `class WireTransaction`. Note that this is not the same as the simple hash of txBits, which would not use the Merkle tree structure. If the difference isn't clear, please consult the user guide section "Transaction tear-offs" to learn more about Merkle trees.
    `java.util.List<net.corda.core.crypto.DigitalSignature.WithKey>` | `getSigs()`
    `WireTransaction` | `getTx()` Lazily calculated access to the deserialised/hashed transaction data.
    `SerializedBytes<net.corda.core.transactions.WireTransaction>` | `getTxBits()`
    `int` | `hashCode()`
    `SignedTransaction` | `plus(DigitalSignature.WithKey sig)` Alias for `SignedTransaction.withAdditionalSignature` to let you use Kotlin operator overloading.
    `SignedTransaction` | `plus(java.util.Collection<? extends net.corda.core.crypto.DigitalSignature.WithKey> sigList)` Alias for withAdditionalSignatures to let you use Kotlin operator overloading.
    `DigitalSignature.WithKey` | `signWithECDSA(java.security.KeyPair keyPair)` Utility to simplify the act of signing the transaction.
    `LedgerTransaction` | `toLedgerTransaction(ServiceHub services)` Calls verifySignatures 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.
    `java.lang.String` | `toString()`
    `WireTransaction` | `verifySignatures(net.corda.core.crypto.CompositeKey allowedToBeMissing)` Verifies the signatures on this transaction and throws if any are missing which aren't passed as parameters. In this context, "verifying" means checking they are valid signatures and that their public keys are in the contained transactions BaseTransaction.mustSign property.
    `SignedTransaction` | `withAdditionalSignature(DigitalSignature.WithKey sig)` Returns the same transaction but with an additional (unchecked) signature.
    `SignedTransaction` | `withAdditionalSignatures(java.lang.Iterable<? extends net.corda.core.crypto.DigitalSignature.WithKey> sigList)` Returns the same transaction but with an additional (unchecked) signatures.

    - ### Methods inherited from interface net.corda.core.contracts.NamedByHash

      `getId`

- - ### Constructor Detail

    - #### SignedTransaction

          public SignedTransaction(SerializedBytes<net.corda.core.transactions.WireTransaction> txBits,
                                   java.util.List<? extends net.corda.core.crypto.DigitalSignature.WithKey> sigs)

      SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key 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 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`

  - ### Method Detail

    - #### getTx

          public WireTransaction getTx()

      Lazily calculated access to the deserialised/hashed transaction data.

    - #### getId

          public SecureHash getId()

      The Merkle root of the inner `class WireTransaction`. Note that this is not the same as the simple hash of txBits, which would not use the Merkle tree structure. If the difference isn't clear, please consult the user guide section "Transaction tear-offs" to learn more about Merkle trees.

      See Also:
        `class WireTransaction`

    - #### verifySignatures

          public WireTransaction verifySignatures(net.corda.core.crypto.CompositeKey allowedToBeMissing)

      Verifies the signatures on this transaction and throws if any are missing which aren't passed as parameters. In this context, "verifying" means checking they are valid signatures and that their public keys are in the contained transactions BaseTransaction.mustSign property.

      Normally you would not provide any keys to this function, but if you're in the process of building a partial transaction and you want to access the contents before you've signed it, you can specify your own keys here to bypass that check.

      Throws:
        - if any signatures are invalid or unrecognised.
        - if any signatures should have been present but were not.

    - #### checkSignaturesAreValid

          public void checkSignaturesAreValid()

      Mathematically validates the signatures that are present on this transaction. This does not imply that the signatures are by the right keys, or that there are sufficient signatures, just that they aren't corrupt. If you use this function directly you'll need to do the other checks yourself. Probably you want verifySignatures instead.

      Throws:
        - if a signature fails to verify.

    - #### withAdditionalSignature

          public SignedTransaction withAdditionalSignature(DigitalSignature.WithKey sig)

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

    - #### withAdditionalSignatures

          public SignedTransaction withAdditionalSignatures(java.lang.Iterable<? extends net.corda.core.crypto.DigitalSignature.WithKey> sigList)

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

    - #### plus

          public SignedTransaction plus(DigitalSignature.WithKey sig)

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

      See Also:
        `SignedTransaction.withAdditionalSignature`

    - #### plus

          public SignedTransaction plus(java.util.Collection<? extends net.corda.core.crypto.DigitalSignature.WithKey> sigList)

      Alias for withAdditionalSignatures to let you use Kotlin operator overloading.

    - #### toLedgerTransaction

          public LedgerTransaction toLedgerTransaction(ServiceHub services)

      Calls verifySignatures 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.

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

    - #### signWithECDSA

          public DigitalSignature.WithKey signWithECDSA(java.security.KeyPair keyPair)

      Utility to simplify the act of signing the transaction.

      Parameters:
        `keyPair` - the signer's public/private key pair.
      Returns:
        a digital signature of the transaction.

    - #### toString

          public java.lang.String toString()

    - #### getTxBits

          public SerializedBytes<net.corda.core.transactions.WireTransaction> getTxBits()

    - #### getSigs

          public java.util.List<net.corda.core.crypto.DigitalSignature.WithKey> getSigs()

    - #### component1

          public SerializedBytes<net.corda.core.transactions.WireTransaction> component1()

    - #### component2

          public java.util.List<net.corda.core.crypto.DigitalSignature.WithKey> component2()

    - #### copy

          public SignedTransaction copy(SerializedBytes<net.corda.core.transactions.WireTransaction> txBits,
                                        java.util.List<? extends net.corda.core.crypto.DigitalSignature.WithKey> sigs)

      SignedTransaction wraps a serialized WireTransaction. It contains one or more signatures, each one for a public key 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 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`

    - #### hashCode

          public int hashCode()

    - #### equals

          public boolean equals(java.lang.Object p)