FilteredTransaction
Keywords: net.corda.core.transactions.FilteredTransaction class
Date: 2023-09-18

net.corda.core.transactions

## Class FilteredTransaction

- net.corda.core.transactions.BaseTransaction
- - net.corda.core.transactions.CoreTransaction
  - - TraversableTransaction
    - - net.corda.core.transactions.FilteredTransaction

- All Implemented Interfaces:
    NamedByHash

      public class FilteredTransaction
      extends TraversableTransaction

  Class representing merkleized filtered transaction.

- - ### Field Detail

    - #### Companion

          public static net.corda.core.transactions.FilteredTransaction.Companion Companion

  - ### Method Detail

    - #### verify

          public void verify()

      Runs verification of partial Merkle branch against id. Note that empty filtered transactions (with no component groups) are accepted as well, e.g. for Timestamp Authorities to blindly sign or any other similar case in the future that requires a blind signature over a transaction's id.

      Throws:
        `FilteredTransactionVerificationException` - if verification fails.

    - #### checkWithFun

          public boolean checkWithFun(@NotNull
                                      kotlin.jvm.functions.Function1<java.lang.Object,java.lang.Boolean> checkingFun)

      Function that checks the whole filtered structure. Force type checking on a structure that we obtained, so we don't sign more than expected. Example: Oracle is implemented to check only for commands, if it gets an attachment and doesn't expect it - it can sign over a transaction with the attachment that wasn't verified. Of course it depends on how you implement it, but else -> false should solve a problem with possible later extensions to WireTransaction.

      Parameters:
        `checkingFun` - function that performs type checking on the structure fields and provides verification logic accordingly.
      Returns:
        false if no elements were matched on a structure or checkingFun returned false.

    - #### checkAllComponentsVisible

          public void checkAllComponentsVisible(@NotNull
                                                ComponentGroupEnum componentGroupEnum)

      Function that checks if all of the components in a particular group are visible. This functionality is required on non-Validating Notaries to check that all inputs are visible. It might also be applied in Oracles or any other entity requiring `class Command` visibility, but because this method cannot distinguish between related and unrelated to the signer `class Command`s, one should use the `checkCommandVisibility` method, which is specifically designed for `class Command` visibility purposes. The logic behind this algorithm is that we check that the root of the provided group partialMerkleTree matches with the root of a fullMerkleTree if computed using all visible components. Note that this method is usually called after or before `verify`, to also ensure that the provided partial Merkle tree corresponds to the correct leaf in the top Merkle tree.

      Parameters:
        `componentGroupEnum` - the `enum ComponentGroupEnum` that corresponds to the componentGroup for which we require full component visibility.
      Throws:
        `ComponentVisibilityException` - if not all of the components are visible or if the component group is not present in the `class FilteredTransaction`.
      See Also:
        `class Command`, `class Command`, `checkCommandVisibility`, `class Command`, `verify`

    - #### checkCommandVisibility

          public void checkCommandVisibility(@NotNull
                                             java.security.PublicKey publicKey)

      Function that checks if all of the commands that should be signed by the input public key are visible. This functionality is required from Oracles to check that all of the commands they should sign are visible. This algorithm uses the ComponentGroupEnum.SIGNERS_GROUP to count how many commands should be signed by the input PublicKey and it then matches it with the size of received `commands`. Note that this method does not throw if there are no commands for this key to sign in the original `class WireTransaction`.

      Parameters:
        `publicKey` - signer's PublicKey
      Throws:
        `ComponentVisibilityException` - if not all of the related commands are visible.
      See Also:
        PublicKey, `commands`, `class WireTransaction`

    - #### getId

          @NotNull
          public SecureHash getId()

      Merkle tree root hash.

    - #### getFilteredComponentGroups

          @NotNull
          public java.util.List<net.corda.core.transactions.FilteredComponentGroup> getFilteredComponentGroups()

      list of transaction components groups remained after filters are applied to

      `class WireTransaction`.

      See Also:
        `class WireTransaction`

    - #### getGroupHashes

          @NotNull
          public java.util.List<net.corda.core.crypto.SecureHash> getGroupHashes()

      the roots of the transaction component groups.

    - #### buildFilteredTransaction

          @JvmStatic
           @NotNull
          public static FilteredTransaction buildFilteredTransaction(@NotNull
                                                                                          WireTransaction wtx,
                                                                                          @NotNull
                                                                                          java.util.function.Predicate<java.lang.Object> filtering)

      Construction of filtered transaction with partial Merkle tree.

      Parameters:
        `wtx` - WireTransaction to be filtered.
        `filtering` - filtering over the whole WireTransaction.