net.corda.flows

## Class TwoPartyTradeFlow

- net.corda.flows.TwoPartyTradeFlow

-     public class TwoPartyTradeFlow

  This asset trading flow implements a "delivery vs payment" type swap. It has two parties (B and S for buyer and seller) and the following steps:

  1. S sends the `class StateAndRef` pointing to what they want to sell to B, along with info about the price they require B to pay. For example this has probably been agreed on an exchange.

  2. B sends to S a `class SignedTransaction` that includes the state as input, B's cash as input, the state with the new owner key as output, and any change cash as output. It contains a single signature from B but isn't valid because it lacks a signature from S authorising movement of the asset.

  3. S signs it and commits it to the ledger, notarising it and distributing the final signed transaction back to B.

  Assuming no malicious termination, they both end the flow being in posession of a valid, signed transaction that represents an atomic asset swap.

  Note that it's the seller who initiates contact with the buyer, not vice-versa as you might imagine.

  See Also:
    `class StateAndRef`, `class SignedTransaction`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `TwoPartyTradeFlow.Buyer`
    `static class` | `TwoPartyTradeFlow.Seller`
    `static class` | `TwoPartyTradeFlow.SellerTradeInfo`
    `static class` | `TwoPartyTradeFlow.SignaturesFromSeller`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static TwoPartyTradeFlow` | `INSTANCE` This asset trading flow implements a "delivery vs payment" type swap. It has two parties (B and S for buyer and seller) and the following steps:

- - ### Field Detail

    - #### INSTANCE

          public static TwoPartyTradeFlow INSTANCE

      This asset trading flow implements a "delivery vs payment" type swap. It has two parties (B and S for buyer and seller) and the following steps:

      1. S sends the `class StateAndRef` pointing to what they want to sell to B, along with info about the price they require B to pay. For example this has probably been agreed on an exchange.

      2. B sends to S a `class SignedTransaction` that includes the state as input, B's cash as input, the state with the new owner key as output, and any change cash as output. It contains a single signature from B but isn't valid because it lacks a signature from S authorising movement of the asset.

      3. S signs it and commits it to the ledger, notarising it and distributing the final signed transaction back to B.

      Assuming no malicious termination, they both end the flow being in posession of a valid, signed transaction that represents an atomic asset swap.

      Note that it's the seller who initiates contact with the buyer, not vice-versa as you might imagine.

      See Also:
        `class StateAndRef`, `class SignedTransaction`