mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-05-20 15:40:48 -04:00
Fix Alice redeem scenario
- Properly check the timelocks before trying to redeem - Distinguish different failure scenarios and reactions to it. - if we fail to construct the redeem transaction: wait for cancel. - if we fail to publish the redeem transaction: wait for cancel but let the user know that restarting the application will result in retrying to publish the tx. - if we succeed to publish the tx but then fail when waiting for finality, print error to the user (secreat already leaked, the user has to check manually if the tx was included)
This commit is contained in:
parent
9fa900dce8
commit
6a75c840b5
3 changed files with 89 additions and 51 deletions
|
@ -191,19 +191,16 @@ pub fn build_bitcoin_redeem_transaction(
|
|||
pub async fn publish_bitcoin_redeem_transaction<W>(
|
||||
redeem_tx: bitcoin::Transaction,
|
||||
bitcoin_wallet: Arc<W>,
|
||||
config: Config,
|
||||
) -> Result<()>
|
||||
) -> Result<::bitcoin::Txid>
|
||||
where
|
||||
W: BroadcastSignedTransaction + WaitForTransactionFinality,
|
||||
{
|
||||
info!("Attempting to publish bitcoin redeem txn");
|
||||
let tx_id = bitcoin_wallet
|
||||
let txid = bitcoin_wallet
|
||||
.broadcast_signed_transaction(redeem_tx)
|
||||
.await?;
|
||||
|
||||
bitcoin_wallet
|
||||
.wait_for_transaction_finality(tx_id, config)
|
||||
.await
|
||||
Ok(txid)
|
||||
}
|
||||
|
||||
pub async fn publish_cancel_transaction<W>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue