AppServiceHub.DefaultImpls
Keywords: net.corda.core.node.AppServiceHub.DefaultImpls class
Date: 2023-09-18

net.corda.core.node

## Class AppServiceHub.DefaultImpls

- net.corda.core.node.AppServiceHub.DefaultImpls

- Enclosing interface:
    AppServiceHub

      public static class AppServiceHub.DefaultImpls

  A `annotationclass CordaService` annotated class requires a constructor taking a single parameter of type `interface AppServiceHub`. With the `interface AppServiceHub` parameter a `annotationclass CordaService` is able to access to privileged operations. In particular such a `annotationclass CordaService` can initiate and track flows marked with `annotationclass StartableByService`.

  See Also:
    `annotationclass CordaService`, `interface AppServiceHub`, `interface AppServiceHub`, `annotationclass CordaService`, `annotationclass CordaService`, `annotationclass StartableByService`

- - ### Constructor Detail

    - #### DefaultImpls

          public DefaultImpls()

  - ### Method Detail

    - #### register

          public static <T> void register(AppServiceHub $this,
                                          int priority,
                                          @NotNull
                                          kotlin.jvm.functions.Function1<? super net.corda.core.node.services.ServiceLifecycleEvent,? extends T> func)

      Convenience method to be able to add an arbitrary function as a `register` callback.

      See Also:
        `register`

    - #### recordTransactions

          public static void recordTransactions(AppServiceHub $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.

      Parameters:
        `$this` - indicate if the vault should be notified for the update.
        `notifyVault` - The transactions to record.
        `txs` - The transactions to record.
      See Also:
        `class SignedTransaction`, `notifyVault`

    - #### recordTransactions

          public static void recordTransactions(AppServiceHub $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.

      See Also:
        `class SignedTransaction`, `notifyVault`

    - #### recordTransactions

          public static void recordTransactions(AppServiceHub $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.

      See Also:
        `class SignedTransaction`

    - #### recordTransactions

          public static void recordTransactions(AppServiceHub $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.

      See Also:
        `class SignedTransaction`

    - #### toStateAndRef

          @NotNull
          public static <T extends ContractState> StateAndRef<T> toStateAndRef(AppServiceHub $this,
                                                                                        @NotNull
                                                                                        StateRef stateRef)

      Converts the given `class StateRef` into a `class StateAndRef` object.

      Throws:
        `TransactionResolutionException` - if `stateRef` points to a non-existent transaction.
      See Also:
        `class StateRef`, `class StateAndRef`

    - #### signInitialTransaction

          @NotNull
          public static SignedTransaction signInitialTransaction(AppServiceHub $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.

      Parameters:
        `$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.
      Returns:
        Returns a SignedTransaction with the new node signature attached.
      See Also:
        `class TransactionBuilder`

    - #### signInitialTransaction

          @NotNull
          public static SignedTransaction signInitialTransaction(AppServiceHub $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.

      Parameters:
        `$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.
      Returns:
        Returns a SignedTransaction with the new node signature attached.

    - #### signInitialTransaction

          @NotNull
          public static SignedTransaction signInitialTransaction(AppServiceHub $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.

      Parameters:
        `$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.
      Returns:
        Returns a `class SignedTransaction` with the new node signature attached.
      Throws:
        `IllegalArgumentException` - is thrown if any keys are unavailable locally.
      See Also:
        `class TransactionBuilder`

    - #### createSignature

          @NotNull
          public static TransactionSignature createSignature(AppServiceHub $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.

      Parameters:
        `$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.
      Returns:
        The `class TransactionSignature` generated by signing with the internally held java.security.PrivateKey.
      See Also:
        `class SignedTransaction`, `class SignatureMetadata`

    - #### createSignature

          @NotNull
          public static TransactionSignature createSignature(AppServiceHub $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.

      Parameters:
        `$this` - The SignedTransaction to which the signature will apply.
        `signedTransaction` - The SignedTransaction to which the signature will apply.
      Returns:
        the TransactionSignature generated by signing with the internally held identity PrivateKey.
      See Also:
        `class SignedTransaction`, `class SignatureMetadata`

    - #### createSignature

          @NotNull
          public static TransactionSignature createSignature(AppServiceHub $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.

      Parameters:
        `$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.
      Returns:
        The `class TransactionSignature` generated by signing with the internally held java.security.PrivateKey.
      See Also:
        `class SignatureMetadata`

    - #### createSignature

          @NotNull
          public static TransactionSignature createSignature(AppServiceHub $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.

      Parameters:
        `$this` - the FilteredTransaction to which the signature will apply.
        `filteredTransaction` - the FilteredTransaction to which the signature will apply.
      Returns:
        the `class TransactionSignature` generated by signing with the internally held identity java.security.PrivateKey.
      See Also:
        `class SignatureMetadata`

    - #### addSignature

          @NotNull
          public static SignedTransaction addSignature(AppServiceHub $this,
                                                                @NotNull
                                                                SignedTransaction signedTransaction,
                                                                @NotNull
                                                                java.security.PublicKey publicKey)

      Helper method to append an additional signature to an existing (partially) `class SignedTransaction`.

      Parameters:
        `$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.
      Returns:
        A new `class SignedTransaction` with the addition of the new signature.
      See Also:
        `class SignedTransaction`

    - #### addSignature

          @NotNull
          public static SignedTransaction addSignature(AppServiceHub $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.

      Parameters:
        `$this` - The `class SignedTransaction` to which the signature will be added.
        `signedTransaction` - The `class SignedTransaction` to which the signature will be added.
      Returns:
        A new `class SignedTransaction` with the addition of the new signature.
      See Also:
        `class SignedTransaction`

    - #### getAppContext

          @NotNull
          public static CordappContext getAppContext(AppServiceHub $this)

      See `CordappProvider.getAppContext`

      See Also:
        `CordappProvider.getAppContext`