Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine BTX-lock and BTX-refund conditions #4

Closed
Norfolks opened this issue Mar 25, 2020 · 1 comment
Closed

Combine BTX-lock and BTX-refund conditions #4

Norfolks opened this issue Mar 25, 2020 · 1 comment

Comments

@Norfolks
Copy link

Norfolks commented Mar 25, 2020

Great work.
Why is not possible to make one transaction script for three possible withdrawals?

  1. Swap as expected
  2. Bob refund by timelock
  3. Alice takes bitcoins after time lock

Smth like?

OP_IF  
   OP_SHA256 <h_a> OP_VERIFY
   OP_SHA256 <h_s> OP_VERIFY
   <B_a> OP_CHECKSIG
OP_ELSE
   <t_0> OP_CHECK
   OP_SHA256 <h_b> OP_VERIFY
   <B_b> OP_CHECKSIG
OP_ElSE
   <t_1> OP_CHECK
   <B_a> OP_CHECKSIG
OP_ENDIF
@h4sh3d
Copy link
Owner

h4sh3d commented Mar 26, 2020

Because you introduce an race condition.

In that case Alice can wait on Bob to start a refund with path 2, when she sees <h_b> value she can try to complete the swap on the BTC side (path 1) with higher fees AND get the Monero back with <h_a> and <h_b>.

If she managed to do it, she gets BTC and XMR. (At that point Bob can also race, all values are revealed.)

To be safe Bob needs to:

  1. Broadcast the Refund transaction,
  2. Wait enough confirmations invalidating path 1, and
  3. Complete the refund, reveling <h_b>

No race is possible in that scenario.

@h4sh3d h4sh3d closed this as completed Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants