mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-06 13:34:38 -04:00
Upgrade bitcoin-harness
This commit is contained in:
parent
5a1fff5ee3
commit
78674818c2
6 changed files with 54 additions and 15 deletions
|
@ -1,11 +1,10 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::{Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use backoff::{backoff::Constant as ConstantBackoff, future::FutureOperation as _};
|
||||
use bitcoin::util::psbt::PartiallySignedTransaction;
|
||||
use bitcoin_harness::bitcoind_rpc::PsbtBase64;
|
||||
use bitcoin_harness::{bitcoind_rpc::PsbtBase64, BitcoindRpcApi};
|
||||
use reqwest::Url;
|
||||
use std::time::Duration;
|
||||
use tokio::time::interval;
|
||||
use xmr_btc::{
|
||||
bitcoin::{
|
||||
|
@ -44,7 +43,15 @@ impl Wallet {
|
|||
.0
|
||||
.get_wallet_transaction(txid)
|
||||
.await
|
||||
.map(|res| bitcoin::Amount::from_btc(-res.fee))??;
|
||||
.map(|res| {
|
||||
res.fee.map(|signed_amount| {
|
||||
signed_amount
|
||||
.abs()
|
||||
.to_unsigned()
|
||||
.expect("Absolute value is always positive")
|
||||
})
|
||||
})?
|
||||
.context("Rpc response did not contain a fee")?;
|
||||
|
||||
Ok(fee)
|
||||
}
|
||||
|
@ -116,7 +123,7 @@ impl GetRawTransaction for Wallet {
|
|||
#[async_trait]
|
||||
impl BlockHeight for Wallet {
|
||||
async fn block_height(&self) -> u32 {
|
||||
(|| async { Ok(self.0.block_height().await?) })
|
||||
(|| async { Ok(self.0.client.getblockcount().await?) })
|
||||
.retry(ConstantBackoff::new(Duration::from_secs(1)))
|
||||
.await
|
||||
.expect("transient errors to be retried")
|
||||
|
|
|
@ -16,6 +16,7 @@ use crate::{
|
|||
state::{Alice, Bob, Swap},
|
||||
};
|
||||
use anyhow::Result;
|
||||
use bitcoin_harness::BitcoindRpcApi;
|
||||
use ecdsa_fun::{adaptor::Adaptor, nonce::Deterministic};
|
||||
use futures::{
|
||||
future::{select, Either},
|
||||
|
@ -163,7 +164,7 @@ pub async fn alice_recover(
|
|||
.transaction_block_height(state.tx_lock.txid())
|
||||
.await;
|
||||
|
||||
let block_height = bitcoin_wallet.0.block_height().await?;
|
||||
let block_height = bitcoin_wallet.0.client.getblockcount().await?;
|
||||
let refund_absolute_expiry = tx_lock_height + state.refund_timelock;
|
||||
|
||||
info!("Checking refund timelock");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue