# Ablockchain Atomic Swap

https://en.bitcoin.it/wiki/Atomic_swap

# Algorithm

- 2 pay txs and 2 claim tx
- claim txs are singed at first, locked with time
- 2 pay txs are encrypted by x, affects only when x is reveal on the network

- Initialization

A: random number x

tx1: A pay B A Pay BTC to B’s public key if x known & singed by B or Signed by A & B

tx2: A claim tx1 pay BTC to A’s public key locked 48 hours signed by A

A -> B tx2 B -> A tx2 signed by A & B

- A -> submit tx1

tx3: B pay A alt-coin B Pay A alt-coin if x known & singed by A or signed by A & B

tx4: B claim tx3 pay B alt-coins locked 48 hours signed by B

B -> A tx4 A -> B tx4 signed by A & B

- B submit tx3
- A spends tx3, reveal x
- B spends tx1 using x