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

Receive Chain Swap: claim fails if the user RBF-ed the BTC tx #518

Open
ok300 opened this issue Oct 2, 2024 · 1 comment
Open

Receive Chain Swap: claim fails if the user RBF-ed the BTC tx #518

ok300 opened this issue Oct 2, 2024 · 1 comment

Comments

@ok300
Copy link
Contributor

ok300 commented Oct 2, 2024

In the following scenario:

  • SDK creates a Receive Chain Swap (receive-payment --method bitcoin --payer-amount-sat 50000)
  • user sends the correct amount to the BTC swap address
  • user RBFs that tx to bump the fee
  • the BTC tx gets confirmed
  • SDK fails to claim
    • "Failed to handle Chain Swap ... update: Could not verify user lockup transaction: Transaction was not found in script history"

The reason is that we are looking for the initial tx ID in the swap script history, instead of the new (RBF) tx ID:

script_history
.iter()
.find(|h| h.txid.to_hex() == user_lockup_tx_id)
.ok_or(anyhow!("Transaction was not found in script history"))?;

We store the initial tx ID as user_lockup_tx_id as soon as we see it in the mempool, but we don't update it in case it's RBF-ed.

One solution is to update it in our DB on RBF.

Another idea is to skip checking the tx ID here and instead get the 1st tx in the swap script history, since the 1st tx is by definition the lockup tx.

@roeierez
Copy link
Member

roeierez commented Oct 5, 2024

We should take the first transaction. If there are more transactions they will be refunded.

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