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

Use a relative timelock #34

Merged
merged 3 commits into from
Feb 3, 2025
Merged

Use a relative timelock #34

merged 3 commits into from
Feb 3, 2025

Conversation

JssDWt
Copy link
Collaborator

@JssDWt JssDWt commented Jan 24, 2025

The absolute timelock used poses challenges. Namely the user has to get his locking transaction confirmed in a reasonable period, otherwise the swap will timeout before it has even started. In this PR, the timelock is changed to a relative timelock.

  • Changed the code to use a relative timelock
  • Changed the payout function to look at all outputs, not just utxos. The first confirmed output for a swap address defines the entire swap's timeout height.
  • Added integration tests for unilateral refund to ensure outputs cannot be unilaterally refunded before the relative timelock expires. (I could NOT figure out which parity to use in the taproot control block. Hance that code in the test now contains a hack of trying both parities)

@JssDWt JssDWt force-pushed the jssdwt-relative-timelock branch from ac27efb to d3154b0 Compare January 27, 2025 19:50
@JssDWt JssDWt marked this pull request as ready for review January 27, 2025 20:00
@JssDWt
Copy link
Collaborator Author

JssDWt commented Jan 27, 2025

Fixed the RBF test. There was an issue calculating the blocks left.

Also caught an issue where the claims were not inserted, thankfully caught that in the process.

Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! One small comment.

swapd/src/chain/types.rs Show resolved Hide resolved
@JssDWt JssDWt merged commit d3154b0 into main Feb 3, 2025
16 checks passed
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

Successfully merging this pull request may close these issues.

3 participants