ObligationUtils
Keywords: net.corda.finance.workflows.asset.ObligationUtils class
Date: 2023-09-18

net.corda.finance.workflows.asset

## Class ObligationUtils

- net.corda.finance.workflows.asset.ObligationUtils

-     public class ObligationUtils

- - ### Field Detail

    - #### INSTANCE

          public static ObligationUtils INSTANCE

  - ### Method Detail

    - #### generateCashIssue

          @JvmStatic
          public static void generateCashIssue(@NotNull
                                                          TransactionBuilder tx,
                                                          @NotNull
                                                          AbstractParty obligor,
                                                          @NotNull
                                                          SecureHash acceptableContract,
                                                          @NotNull
                                                          Amount<net.corda.core.contracts.Issued> amount,
                                                          @NotNull
                                                          java.time.Instant dueBefore,
                                                          @NotNull
                                                          AbstractParty beneficiary,
                                                          @NotNull
                                                          Party notary)

      Puts together an issuance transaction for the specified currency obligation amount that starts out being owned by the given pubkey.

      Parameters:
        `tx` - transaction builder to add states and commands to.
        `obligor` - the party who is expected to pay some currency amount to fulfil the obligation (also the owner ofthe obligation).
        `amount` - currency amount the obligor is expected to pay.
        `dueBefore` - the date on which the obligation is due. The default time tolerance is used (currently this is30 seconds).
        `beneficiary` - the party the obligor is expected to pay.
        `notary` - the notary for this transaction's outputs.

    - #### generateIssue

          @NotNull
          public <P> java.util.Set<java.security.PublicKey> generateIssue(@NotNull
                                                                                   TransactionBuilder tx,
                                                                                   @NotNull
                                                                                   AbstractParty obligor,
                                                                                   @NotNull
                                                                                   net.corda.finance.contracts.asset.Obligation.Terms<P> issuanceDef,
                                                                                   long pennies,
                                                                                   @NotNull
                                                                                   AbstractParty beneficiary,
                                                                                   @NotNull
                                                                                   Party notary)

      Puts together an issuance transaction for the specified amount that starts out being owned by the given pubkey.

      Parameters:
        `tx` - transaction builder to add states and commands to.
        `obligor` - the party who is expected to pay some amount to fulfil the obligation.
        `issuanceDef` - the terms of the obligation, including which contracts and underlying assets are acceptableforms of payment.
        `pennies` - the quantity of the asset (in the smallest normal unit of measurement) owed.
        `beneficiary` - the party the obligor is expected to pay.
        `notary` - the notary for this transaction's outputs.

    - #### generateCloseOutNetting

          @JvmStatic
          public static <P> void generateCloseOutNetting(@NotNull
                                                                    TransactionBuilder tx,
                                                                    @NotNull
                                                                    AbstractParty signer,
                                                                    @NotNull
                                                                    net.corda.core.contracts.StateAndRef... inputs)

      Generate a transaction performing close-out netting of two or more states.

      Parameters:
        `signer` - the party which will sign the transaction. Must be one of the obligor or beneficiary.
        `inputs` - two or more states, which must be compatible for bilateral netting (same issuance definitions,and same parties involved).

    - #### generatePaymentNetting

          @JvmStatic
          public static <P> void generatePaymentNetting(@NotNull
                                                                   TransactionBuilder tx,
                                                                   @NotNull
                                                                   Issued<net.corda.finance.contracts.asset.Obligation.Terms> issued,
                                                                   @NotNull
                                                                   Party notary,
                                                                   @NotNull
                                                                   net.corda.core.contracts.StateAndRef... inputs)

    - #### generateSetLifecycle

          @JvmStatic
          public static <P> void generateSetLifecycle(@NotNull
                                                                 TransactionBuilder tx,
                                                                 @NotNull
                                                                 java.util.List<net.corda.core.contracts.StateAndRef> statesAndRefs,
                                                                 @NotNull
                                                                 net.corda.finance.contracts.asset.Obligation.Lifecycle lifecycle,
                                                                 @NotNull
                                                                 Party notary)

      Generate a transaction changing the lifecycle of one or more state objects.

      Parameters:
        `statesAndRefs` - a list of state objects, which MUST all have the same issuance definition. This avoidspotential complications arising from different deadlines applying to different states.

    - #### generateSettle

          @JvmStatic
          public static <P> void generateSettle(@NotNull
                                                           TransactionBuilder tx,
                                                           @NotNull
                                                           java.lang.Iterable<net.corda.core.contracts.StateAndRef> statesAndRefs,
                                                           @NotNull
                                                           java.lang.Iterable<? extends net.corda.core.contracts.StateAndRef<? extends net.corda.core.contracts.FungibleAsset<P>>> assetStatesAndRefs,
                                                           @NotNull
                                                           MoveCommand moveCommand,
                                                           @NotNull
                                                           Party notary)

      Parameters:
        `statesAndRefs` - a list of state objects, which MUST all have the same aggregate state. This is done asonly a single settlement command can be present in a transaction, to avoid potential problems with allocatingassets to different obligation issuances.
        `assetStatesAndRefs` - a list of fungible asset state objects, which MUST all be of the same issued product.It is strongly encouraged that these all have the same beneficiary.
        `moveCommand` - the command used to move the asset state objects to their new owner.

    - #### generateExit

          @JvmStatic
           @NotNull
          public static <P> java.util.Set<java.security.PublicKey> generateExit(@NotNull
                                                                                                     TransactionBuilder tx,
                                                                                                     @NotNull
                                                                                                     Amount<net.corda.core.contracts.Issued> amountIssued,
                                                                                                     @NotNull
                                                                                                     java.util.List<net.corda.core.contracts.StateAndRef> assetStates)

      Generate an transaction exiting an obligation from the ledger.

      Parameters:
        `tx` - transaction builder to add states and commands to.
        `amountIssued` - the amount to be exited, represented as a quantity of issued currency.
        `assetStates` - the asset states to take funds from. No checks are done about ownership of these states, it isthe responsibility of the caller to check that they do not exit funds held by others.
      Returns:
        the public keys which must sign the transaction for it to be valid.