Fix reverse swap claim tx fee estimation #1055
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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-usescreate_claim_tx
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 addingbuild_fake_claim_tx
on top.Fixes #1054