corda / net.corda.core.transactions / SignedTransaction

# SignedTransaction

`data class SignedTransaction : 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 WireTransaction Merkle tree root. Thus adding or removing a signature does not change it.

### Exceptions

SignaturesMissingException | `class SignaturesMissingException : NamedByHash, SignatureException`

### Constructors

<init> | `SignedTransaction(txBits: SerializedBytes<WireTransaction>, sigs: List<WithKey>)` 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 WireTransaction Merkle tree root. Thus adding or removing a signature does not change it.

### Properties

id | `val id: SecureHash` The Merkle root of the inner 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.
sigs | `val sigs: List<WithKey>`
tx | `val tx: WireTransaction` Lazily calculated access to the deserialised/hashed transaction data.
txBits | `val txBits: SerializedBytes<WireTransaction>`

### Functions

checkSignaturesAreValid | `fun checkSignaturesAreValid(): Unit` 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.
plus | `operator fun plus(sig: WithKey): SignedTransaction` Alias for withAdditionalSignature to let you use Kotlin operator overloading. `operator fun plus(sigList: Collection<WithKey>): SignedTransaction` Alias for withAdditionalSignatures to let you use Kotlin operator overloading.
signWithECDSA | `fun signWithECDSA(keyPair: KeyPair): WithKey` Utility to simplify the act of signing the transaction.
toLedgerTransaction | `fun toLedgerTransaction(services: ServiceHub): LedgerTransaction` Calls verifySignatures to check all required signatures are present, and then calls WireTransaction.toLedgerTransaction with the passed in ServiceHub to resolve the dependencies, returning an unverified LedgerTransaction.
toString | `fun toString(): String`
verifySignatures | `fun verifySignatures(vararg allowedToBeMissing: CompositeKey): WireTransaction` 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.
withAdditionalSignature | `fun withAdditionalSignature(sig: WithKey): SignedTransaction` Returns the same transaction but with an additional (unchecked) signature.
withAdditionalSignatures | `fun withAdditionalSignatures(sigList: Iterable<WithKey>): SignedTransaction` Returns the same transaction but with an additional (unchecked) signatures.