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.
class WireTransaction
public static net.corda.core.transactions.SignedTransaction.Companion Companion
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.
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.class WireTransaction
public SignedTransaction(@NotNull CoreTransaction ctx, @NotNull java.util.List<net.corda.core.crypto.TransactionSignature> sigs)
@NotNull public SecureHash getId()
The id of the contained class WireTransaction
.
class WireTransaction
@NotNull public CoreTransaction getCoreTransaction()
Lazily calculated access to the deserialised/hashed transaction data.
@NotNull public WireTransaction getTx()
Returns the contained class WireTransaction
, or throws if this is a notary change or contract upgrade transaction.
class WireTransaction
@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
.
class FilteredTransaction
,
tx
@NotNull public java.util.List<net.corda.core.contracts.StateRef> getInputs()
Helper to access the inputs of the contained transaction.
@NotNull public java.util.List<net.corda.core.contracts.StateRef> getReferences()
Helper to access the unspendable inputs of the contained transaction.
@Nullable public Party getNotary()
Helper to access the notary of the contained transaction.
@Nullable public SecureHash getNetworkParametersHash()
Helper to access the network parameters hash for the contained transaction.
@NotNull public java.util.Set<java.security.PublicKey> getRequiredSigningKeys()
Specifies all the public keys that require signatures for the transaction to be valid.
@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.
@VisibleForTesting @NotNull public SignedTransaction withAdditionalSignature(@NotNull java.security.KeyPair keyPair, @NotNull SignatureMetadata signatureMetadata)
@NotNull public SignedTransaction withAdditionalSignature(@NotNull TransactionSignature sig)
Returns the same transaction but with an additional (unchecked) signature.
@NotNull public SignedTransaction withAdditionalSignatures(@NotNull java.lang.Iterable<net.corda.core.crypto.TransactionSignature> sigList)
Returns the same transaction but with an additional (unchecked) signatures.
@NotNull public SignedTransaction plus(@NotNull TransactionSignature sig)
Alias for withAdditionalSignature
to let you use Kotlin operator overloading.
withAdditionalSignature
@NotNull public SignedTransaction plus(@NotNull java.util.Collection<net.corda.core.crypto.TransactionSignature> sigList)
Alias for withAdditionalSignatures
to let you use Kotlin operator overloading.
withAdditionalSignatures
@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.
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 unrecognisedSignaturesMissingException
- if any signatures that should have been present are missing.verifyRequiredSignatures
,
WireTransaction.toLedgerTransaction
,
interface ServiceHub
@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.
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 unrecognisedSignaturesMissingException
- if any signatures that should have been present are missing.verifyRequiredSignatures
,
WireTransaction.toLedgerTransaction
,
interface ServiceHub
@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.
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 unrecognisedSignaturesMissingException
- if any signatures that should have been present are missing.verifyRequiredSignatures
@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.
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 unrecognisedSignaturesMissingException
- if any signatures that should have been present are missing.verifyRequiredSignatures
@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
.
class NotaryChangeWireTransaction
@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
.
class NotaryChangeWireTransaction
@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.
@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.
@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.
@NotNull public java.lang.String toString()
@NotNull public NotaryChangeWireTransaction getNotaryChangeTx()
Returns the contained class NotaryChangeWireTransaction
, or throws if this is a normal transaction.
class NotaryChangeWireTransaction
@Deprecated public boolean isNotaryChangeTransaction()
@NotNull public SerializedBytes<net.corda.core.transactions.CoreTransaction> getTxBits()
@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.
@NotNull public SerializedBytes<net.corda.core.transactions.CoreTransaction> component1()
@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.
@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.
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.class WireTransaction
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.
class WireTransaction
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.
class WireTransaction