public static class ServiceHub.DefaultImpls
A service hub is the starting point for most operations you can do inside the node. You are provided with one
when a class annotated with annotationclass CordaService
is constructed, and you have access to one inside flows. Most RPCs
simply forward to the services found here after some access checking.
The APIs are organised roughly by category, with a few very important top level APIs available on the ServiceHub itself. Inside a flow, it's safe to keep a reference to services found here on the stack: checkpointing will do the right thing (it won't try to serialise the internals of the service).
In unit test environments, some of those services may be missing or mocked out.
annotationclass CordaService
public static void recordTransactions(ServiceHub $this, boolean notifyVault, @NotNull java.lang.Iterable<net.corda.core.transactions.SignedTransaction> txs)
Stores the given class SignedTransaction
s in the local transaction storage and then sends them to the vault for
further processing if notifyVault
is true. This is expected to be run within a database transaction.
$this
- indicate if the vault should be notified for the update.notifyVault
- The transactions to record.txs
- The transactions to record.class SignedTransaction
,
notifyVault
public static void recordTransactions(ServiceHub $this, boolean notifyVault, @NotNull SignedTransaction first, @NotNull net.corda.core.transactions.SignedTransaction... remaining)
Stores the given class SignedTransaction
s in the local transaction storage and then sends them to the vault for
further processing if notifyVault
is true. This is expected to be run within a database transaction.
class SignedTransaction
,
notifyVault
public static void recordTransactions(ServiceHub $this, @NotNull SignedTransaction first, @NotNull net.corda.core.transactions.SignedTransaction... remaining)
Stores the given class SignedTransaction
s in the local transaction storage and then sends them to the vault for
further processing. This is expected to be run within a database transaction.
class SignedTransaction
public static void recordTransactions(ServiceHub $this, @NotNull java.lang.Iterable<net.corda.core.transactions.SignedTransaction> txs)
Stores the given class SignedTransaction
s in the local transaction storage and then sends them to the vault for
further processing. This is expected to be run within a database transaction.
class SignedTransaction
@NotNull public static <T extends ContractState> StateAndRef<T> toStateAndRef(ServiceHub $this, @NotNull StateRef stateRef)
Converts the given class StateRef
into a class StateAndRef
object.
TransactionResolutionException
- if stateRef
points to a non-existent transaction.class StateRef
,
class StateAndRef
@NotNull public static SignedTransaction signInitialTransaction(ServiceHub $this, @NotNull TransactionBuilder builder, @NotNull java.security.PublicKey publicKey)
Helper method to construct an initial partially signed transaction from a class TransactionBuilder
using keys stored inside the node. Signature metadata is added automatically.
$this
- The class TransactionBuilder
to seal with the node's signature.Any existing signatures on the builder will be preserved.builder
- The PublicKey matched to the internal java.security.PrivateKey to use in signing this transaction.If the passed in key is actually a CompositeKey the code searches for the first child key hosted within this nodeto sign with.publicKey
- The PublicKey matched to the internal java.security.PrivateKey to use in signing this transaction.
If the passed in key is actually a CompositeKey the code searches for the first child key hosted within this node
to sign with.class TransactionBuilder
@NotNull public static SignedTransaction signInitialTransaction(ServiceHub $this, @NotNull TransactionBuilder builder)
Helper method to construct an initial partially signed transaction from a TransactionBuilder using the default identity key contained in the node. The legal identity key is used to sign.
$this
- The TransactionBuilder to seal with the node's signature.Any existing signatures on the builder will be preserved.builder
- The TransactionBuilder to seal with the node's signature.
Any existing signatures on the builder will be preserved.@NotNull public static SignedTransaction signInitialTransaction(ServiceHub $this, @NotNull TransactionBuilder builder, @NotNull java.lang.Iterable<? extends java.security.PublicKey> signingPubKeys)
Helper method to construct an initial partially signed transaction from a class TransactionBuilder
using a set of keys all held in this node.
$this
- The class TransactionBuilder
to seal with the node's signature.Any existing signatures on the builder will be preserved.builder
- A list of PublicKeys used to lookup the matching java.security.PrivateKey and sign.signingPubKeys
- A list of PublicKeys used to lookup the matching java.security.PrivateKey and sign.class SignedTransaction
with the new node signature attached.IllegalArgumentException
- is thrown if any keys are unavailable locally.class TransactionBuilder
@NotNull public static TransactionSignature createSignature(ServiceHub $this, @NotNull SignedTransaction signedTransaction, @NotNull java.security.PublicKey publicKey)
Helper method to create an additional signature for an existing (partially) class SignedTransaction
. Additional
class SignatureMetadata
, including the
platform version used during signing and the cryptographic signature scheme use, is added to the signature.
$this
- The class SignedTransaction
to which the signature will apply.signedTransaction
- The PublicKey matching to a signing java.security.PrivateKey hosted in the node.If the PublicKey is actually a class CompositeKey
the first leaf key found locally will be usedfor signing.publicKey
- The PublicKey matching to a signing java.security.PrivateKey hosted in the node.
If the PublicKey is actually a class CompositeKey
the first leaf key found locally will be used
for signing.class TransactionSignature
generated by signing with the internally held java.security.PrivateKey.class SignedTransaction
,
class SignatureMetadata
@NotNull public static TransactionSignature createSignature(ServiceHub $this, @NotNull SignedTransaction signedTransaction)
Helper method to create a signature for an existing (partially) class SignedTransaction
using the default identity signing key of the node. The legal identity key is used to sign. Additional
class SignatureMetadata
, including the
platform version used during signing and the cryptographic signature scheme use, is added to the signature.
$this
- The SignedTransaction to which the signature will apply.signedTransaction
- The SignedTransaction to which the signature will apply.class SignedTransaction
,
class SignatureMetadata
@NotNull public static SignedTransaction addSignature(ServiceHub $this, @NotNull SignedTransaction signedTransaction, @NotNull java.security.PublicKey publicKey)
Helper method to append an additional signature to an existing (partially) class SignedTransaction
.
$this
- The class SignedTransaction
to which the signature will be added.signedTransaction
- The PublicKey matching to a signing java.security.PrivateKey hosted in the node.If the PublicKey is actually a class CompositeKey
the first leaf key found locally will be usedfor signing.publicKey
- The PublicKey matching to a signing java.security.PrivateKey hosted in the node.
If the PublicKey is actually a class CompositeKey
the first leaf key found locally will be used
for signing.class SignedTransaction
with the addition of the new signature.class SignedTransaction
@NotNull public static SignedTransaction addSignature(ServiceHub $this, @NotNull SignedTransaction signedTransaction)
Helper method to append an additional signature for an existing (partially) class SignedTransaction
using the default identity signing key of the node.
$this
- The class SignedTransaction
to which the signature will be added.signedTransaction
- The class SignedTransaction
to which the signature will be added.class SignedTransaction
with the addition of the new signature.class SignedTransaction
@NotNull public static TransactionSignature createSignature(ServiceHub $this, @NotNull FilteredTransaction filteredTransaction, @NotNull java.security.PublicKey publicKey)
Helper method to create a signature for a FilteredTransaction. Additional class SignatureMetadata
, including the
platform version used during signing and the cryptographic signature scheme use, is added to the signature.
$this
- the class FilteredTransaction
to which the signature will apply.filteredTransaction
- The PublicKey matching to a signing java.security.PrivateKey hosted in the node.If the PublicKey is actually a class CompositeKey
the first leaf key found locally will be usedfor signing.publicKey
- The PublicKey matching to a signing java.security.PrivateKey hosted in the node.
If the PublicKey is actually a class CompositeKey
the first leaf key found locally will be used
for signing.class TransactionSignature
generated by signing with the internally held java.security.PrivateKey.class SignatureMetadata
@NotNull public static TransactionSignature createSignature(ServiceHub $this, @NotNull FilteredTransaction filteredTransaction)
Helper method to create a signature for a FilteredTransaction
using the default identity signing key of the node. The legal identity key is used to sign. Additional
class SignatureMetadata
, including the platform version used during signing and the cryptographic signature scheme use,
is added to the signature.
$this
- the FilteredTransaction to which the signature will apply.filteredTransaction
- the FilteredTransaction to which the signature will apply.class TransactionSignature
generated by signing with the internally held identity java.security.PrivateKey.class SignatureMetadata
@NotNull public static CordappContext getAppContext(ServiceHub $this)
CordappProvider.getAppContext