Skip to content

Instantly share code, notes, and snippets.

@nikicat
Created November 22, 2023 20:16
Show Gist options
  • Save nikicat/8e8b91e11a0800d30ea82ec3e1c67002 to your computer and use it in GitHub Desktop.
Save nikicat/8e8b91e11a0800d30ea82ec3e1c67002 to your computer and use it in GitHub Desktop.
Atomic Swap scenarios WIP

All cases suppose that Maker and Taker already agree on X and Y and their public keys.

Without dealer

Maker locks first

Success case

  1. Maker locks X
  2. Taker locks Y
  3. Maker takes Y
  4. Taker takes X

Taker leaves

  1. Maker locks X
  2. Taker leaves

Results

  • Maker loses time
  • Taker gains optionality

Maker leaves

  1. Maker locks X
  2. Taker locks Y
  3. Maker leaves

Results

  • Maker loses time
  • Taker loses time
  • Maker gains optionality

Taker locks first

Success path

  1. Taker locks X
  2. Maker locks Y
  3. Taker takes Y
  4. Maker takes X

Maker leaves

  1. Taker locks X
  2. Maker leaves

Results

  • Taker loses time
  • Maker gains optionality

Taker leaves

  1. Taker locks X
  2. Maker locks Y
  3. Taker leaves

Results

  • Maker loses time
  • Taker loses time
  • Taker gains optionality

With dealer

All cases suppose that Maker, Taker and Dealer already agree on X and Y, their public keys.

Maker locks first

Success path

  1. Maker locks X, sends preimage to Dealer
  2. Taker locks Y
  3. Dealer spends Y to Maker's wallet
  4. Taker takes X

Taker leaves

  1. Maker locks X, sends preimage and his address to Dealer
  2. Taker leaves

Results

  • Maker loses time
  • Taker gains optionality

Maker leaves

No such case

Dealer leaves

  1. Maker locks X, sends preimage and his address to Dealer
  2. Taker locks Y
  3. Dealer leaves
  4. Maker

Taker locks first

Success

  1. Taker locks X, sends preimage to Dealer
  2. Maker locks Y
  3. Dealer spends X to Maker's wallet
  4. Taker takes Y

Maker leaves

  1. Taker locks X, sends preimage to Dealer
  2. Maker leaves

Results

  • Taker loses time
  • Maker loses reputation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment