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

Check HTLC output status before funding HTLC tx #2944

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Nov 22, 2024

When a channel force-closes, we publish our commit tx and HTLC txs. HTLC transactions conflict with our peer's transactions that also spend the HTLC outputs. If our peer is able to get their transaction confirmed before ours, we should stop retrying to publish our HTLC transaction as that will never succeed.

Since we didn't check the output status, we kept retrying until the channel was closed (which requires waiting for the to_self_delay). The retries always fail at funding time: bitcoind returns an error saying that the UTXO cannot be found (which is expected because it has already been spent by our peer). This creates a lot of unnecessary retries and a lot of noise in the logs.

This scenario usually happens when our peer didn't send the preimage before force-closing the channel, but reveals it on-chain before the HTLC timeout: when that happens we kept retrying to publish our HTLC timeout transaction, which cannot succeed.

We now check the output status in our publishing preconditions, and immediately abort if the output has already been spent by a confirmed transaction.

@t-bast t-bast requested a review from pm47 November 22, 2024 10:31
When a channel force-closes, we publish our commit tx and HTLC txs.
HTLC transactions conflict with our peer's transactions that also spend
the HTLC outputs. If our peer is able to get their transaction confirmed
before ours, we should stop retrying to publish our HTLC transaction as
that will never succeed.

Since we didn't check the output status, we kept retrying until the
channel was closed (which requires waiting for the `to_self_delay`).
The retries always fail at funding time: `bitcoind` returns an error
saying that the UTXO cannot be found (which is expected because it has
already been spent by our peer). This creates a lot of unnecessary
retries and a lot of noise in the logs.

This scenario usually happens when our peer didn't send the preimage
before force-closing the channel, but reveals it on-chain before the
HTLC timeout: when that happens we kept retrying to publish our HTLC
timeout transaction, which cannot succeed.

We now check the output status in our publishing preconditions, and
immediately abort if the output has already been spent by a confirmed
transaction.
@t-bast t-bast force-pushed the replaceable-tx-preconditions branch from 3d4d1fb to 52bef09 Compare November 25, 2024 14:10
@t-bast t-bast merged commit f47acd0 into master Dec 3, 2024
1 check passed
@t-bast t-bast deleted the replaceable-tx-preconditions branch December 3, 2024 14:49
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.

2 participants