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

Add CLI command to double-spend Bitcoin lock transaction funds if the transaction has no hopes of being confirmed #1664

Open
binarybaron opened this issue May 31, 2024 · 0 comments
Labels
cli Related to the swap CLI tool enhancement New feature or request

Comments

@binarybaron
Copy link
Collaborator

binarybaron commented May 31, 2024

If the Bitcoin lock transaction is not getting confirmed due to the fee being too low, it can be challenging to refund the swap. If the transaction has not been confirmed within the first hour of the swap being initiated, there's no hope of the swap being successful because Alice has already given up.

AliceState::Started { state3 } => {
let tx_lock_status = bitcoin_wallet.subscribe_to(state3.tx_lock.clone()).await;
match timeout(
env_config.bitcoin_lock_mempool_timeout,
tx_lock_status.wait_until_seen(),
)
.await
{
Err(_) => {
tracing::info!(
minutes = %env_config.bitcoin_lock_mempool_timeout.as_secs_f64() / 60.0,
"TxLock lock was not seen in mempool in time",
);
AliceState::SafelyAborted
}
Ok(res) => {
res?;
AliceState::BtcLockTransactionSeen { state3 }
}
}
}

You have carefully monitor the transaction (sometimes for multiple weeks) and as soon as it is gets confirmed, you need to make sure to publish the refund transaction in time. This is quite annoying and can be mitigated by allowing the user to double-spend the funds using RBF (Replace-By-Fee).

I propose that we add add a flag --double-spend-unconfirmed-outgoing-funds flag to the withdraw-btc command and a --include-unconfirmed-outgoing-funds to the balance command. This'll allow the user to double spend those funds by publishing a RBF bitcoin withdraw transaction.

We can also add a new command rbf-unconfirmed-lock-tx that takes a swap id and double-spends only the inputs of the Bitcoin lock transaction that corresponds to that swap to a receive address of the internal Bitcoin wallet. Ideally, this'd even be integrated into the existing state machine. If we haven't seen the XMR Lock Transaction after a certain time has passed, we check if we can double-spend the Bitcoin lock tx.

Here are two instances of users experiencing this issue: UnstoppableSwap/unstoppableswap-gui#200, UnstoppableSwap/unstoppableswap-gui#202

@binarybaron binarybaron added enhancement New feature or request cli Related to the swap CLI tool Priority 1 This issue is top-priority at the moment labels May 31, 2024
@binarybaron binarybaron removed the Priority 1 This issue is top-priority at the moment label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the swap CLI tool enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant