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

Fix reverse swap claim tx fee estimation #1055

Merged
merged 5 commits into from
Jul 30, 2024

Conversation

ok300
Copy link
Contributor

@ok300 ok300 commented Jul 26, 2024

When estimating the claim tx fee for reverse swaps (send onchain), we used a dummy tx with a simple input and a simple output. This was a non-segwit tx with a size of 60 Bytes.

However, this tx structure is simpler than the actual claim tx, which is a segwit tx where the input has a witness with 3 elements: a signature, the preimage and the redeem script. A claim tx has approx. 310 Bytes / 148 vBytes. The actual size varies within a few bytes, depending on the output type and on signature size fluctuations (+/-1 Byte).

This PR extracts the low-level creation of the claim tx in it's own build_claim_tx_inner, which it then re-uses

  • in the actual claim tx: create_claim_tx
  • in constructing a dummy tx for the purposes of fee estimation: build_fake_claim_tx

This way, the claim tx fee estimation is based on a realistic tx.

The PR is split in 2 commits, for easier review: extracting the low-level build_claim_tx_inner and adding build_fake_claim_tx on top.

Fixes #1054

@ok300 ok300 requested a review from roeierez July 26, 2024 11:02
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.

LGTM

@ok300 ok300 merged commit a0a205a into main Jul 30, 2024
9 checks passed
@ok300 ok300 deleted the ok300-fix-rev-swap-claim-tx-fee-estimation branch July 30, 2024 06:45
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.

Reverse Swap: chosen claim tx feerate not applied correctly when paying to P2TR
2 participants