A buyer finalizes the atomic swap by adding one or more inputs to the swap offer transaction, carrying enough value to pay for the payment output, and by adding a payload and reference output to the transaction, to transfer the tokens to the buyer. A change output can optionally be added. Once the transaction is signed, it can be broadcasted, which "executes" the swap, transfering bitcoins to the seller, and tokens to the buyer.
This use-case describes the process of accepting an atomic swap offer and finalizing the trade.
- Swap client
- User-goal
- Buyer
- None
- The buyer configured the system's settings to connect to a running Omni Core RPC server
- The buyer received an unfinalized swap offer transaction from the seller (UC-Client-6)
- The buyer requests to accept and finalize an atomic swap
- The buyer provides the transaction stub from the seller (UC-Client-6), it's transaction inputs (i.e. the hash of the signed funding transaction, the index of the funding output to the script lock destination, the corresponding scriptPubKey and the redeemScript for the locked destination), a destination to send the tokens to, and a source address to pay for the swap
- The system determines the identifier and amount of locked tokens
- The system adds a payload to the transaction stub, sending the previously determined amount of tokens (either as "simple send" or "send all")
- The system determines the total output value including transaction fees of the transaction
- The system adds sufficient inputs to the transaction, spending from the specified source to pay from
- The system adds a reference output to the transaction stub, with the buyer's specified destination, whereby the reference amount also serves to carry change
- The system signs the transaction with the signature hash flag
"ALL"
- The system broadcasts the signed transaction
- The system returns the hash of the broadcasted transaction
3a. The system determines the locked destination has a zero balance
- The system indicates the failure
- The use-case ends
6a. The system determines the buyer has not enough coins to pay for the transaction
- The system indicates the failure
- The use-case ends
8a. The system fails to sign the transaction
- The system indicates the failure
- The use-case ends
9a. The system fails to broadcast the funding transaction
- The system indicates the failure
- The use-case ends
- The tokens are transferred to the buyer
- The coins are transferred to the seller as payment
- Alternatively the buyer may provide a set of unspent outputs, instead of a source address to pay from
- Alternatively the buyer may provide the payload to add to the transaction, to reduce the need for a fully synchronized chain