mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-09-19 20:34:38 -04:00
Trigger refund if the publication of Monero TxLock takes too long
This commit is contained in:
parent
08be87747f
commit
ba3011a9c9
3 changed files with 61 additions and 13 deletions
|
@ -1,12 +1,16 @@
|
|||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use backoff::{future::FutureOperation as _, ExponentialBackoff};
|
||||
use bitcoin::{util::psbt::PartiallySignedTransaction, Address, Amount, Transaction, Txid};
|
||||
use bitcoin_harness::{bitcoind_rpc::PsbtBase64, Bitcoind};
|
||||
use reqwest::Url;
|
||||
use std::time::Duration;
|
||||
use tokio::time;
|
||||
use xmr_btc::bitcoin::{
|
||||
BroadcastSignedTransaction, BuildTxLockPsbt, SignTxLock, TxLock, WatchForRawTransaction,
|
||||
use xmr_btc::{
|
||||
bitcoin::{
|
||||
BroadcastSignedTransaction, BuildTxLockPsbt, SignTxLock, TxLock, WatchForRawTransaction,
|
||||
},
|
||||
MedianTime,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -117,3 +121,16 @@ impl WatchForRawTransaction for Wallet {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl MedianTime for Wallet {
|
||||
async fn median_time(&self) -> u32 {
|
||||
(|| async { Ok(self.0.median_time().await?) })
|
||||
.retry(ExponentialBackoff {
|
||||
max_elapsed_time: None,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.expect("transient errors to be retried")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue