mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-01-24 22:26:48 -05:00
Upgrade bitcoin-harness
This commit is contained in:
parent
5a1fff5ee3
commit
78674818c2
27
Cargo.lock
generated
27
Cargo.lock
generated
@ -254,14 +254,15 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "bitcoin-harness"
|
name = "bitcoin-harness"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/coblox/bitcoin-harness-rs?rev=864b55fcba2e770105f135781dd2e3002c503d12#864b55fcba2e770105f135781dd2e3002c503d12"
|
||||||
checksum = "8f4cd49a4bc53eaeab332d66022a158515f0b5bb4b381a1583a07a0c667ac280"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
"base64 0.12.3",
|
"base64 0.12.3",
|
||||||
"bitcoin",
|
"bitcoin",
|
||||||
"bitcoincore-rpc-json",
|
"bitcoincore-rpc-json",
|
||||||
"futures",
|
"futures",
|
||||||
"hex 0.4.2",
|
"hex 0.4.2",
|
||||||
|
"jsonrpc_client",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -1551,6 +1552,28 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jsonrpc_client"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "git+https://github.com/thomaseizinger/rust-jsonrpc-client?rev=c7010817e0f86ab24b3dc10d6bb0463faa0aace4#c7010817e0f86ab24b3dc10d6bb0463faa0aace4"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"jsonrpc_client_macro",
|
||||||
|
"reqwest",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"url",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jsonrpc_client_macro"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/thomaseizinger/rust-jsonrpc-client?rev=c7010817e0f86ab24b3dc10d6bb0463faa0aace4#c7010817e0f86ab24b3dc10d6bb0463faa0aace4"
|
||||||
|
dependencies = [
|
||||||
|
"quote 1.0.7",
|
||||||
|
"syn 1.0.48",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "keccak"
|
name = "keccak"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -13,7 +13,7 @@ atty = "0.2"
|
|||||||
backoff = { version = "0.2", features = ["tokio"] }
|
backoff = { version = "0.2", features = ["tokio"] }
|
||||||
base64 = "0.12"
|
base64 = "0.12"
|
||||||
bitcoin = { version = "0.25", features = ["rand", "use-serde"] }
|
bitcoin = { version = "0.25", features = ["rand", "use-serde"] }
|
||||||
bitcoin-harness = "0.2"
|
bitcoin-harness = { git = "https://github.com/coblox/bitcoin-harness-rs", rev = "864b55fcba2e770105f135781dd2e3002c503d12" }
|
||||||
conquer-once = "0.3"
|
conquer-once = "0.3"
|
||||||
derivative = "2"
|
derivative = "2"
|
||||||
ecdsa_fun = { git = "https://github.com/LLFourn/secp256kfun", rev = "cdfbc766045ea678a41780919d6228dd5acee3be", features = ["libsecp_compat", "serde"] }
|
ecdsa_fun = { git = "https://github.com/LLFourn/secp256kfun", rev = "cdfbc766045ea678a41780919d6228dd5acee3be", features = ["libsecp_compat", "serde"] }
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
use std::time::Duration;
|
use anyhow::{Context, Result};
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use backoff::{backoff::Constant as ConstantBackoff, future::FutureOperation as _};
|
use backoff::{backoff::Constant as ConstantBackoff, future::FutureOperation as _};
|
||||||
use bitcoin::util::psbt::PartiallySignedTransaction;
|
use bitcoin::util::psbt::PartiallySignedTransaction;
|
||||||
use bitcoin_harness::bitcoind_rpc::PsbtBase64;
|
use bitcoin_harness::{bitcoind_rpc::PsbtBase64, BitcoindRpcApi};
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
|
use std::time::Duration;
|
||||||
use tokio::time::interval;
|
use tokio::time::interval;
|
||||||
use xmr_btc::{
|
use xmr_btc::{
|
||||||
bitcoin::{
|
bitcoin::{
|
||||||
@ -44,7 +43,15 @@ impl Wallet {
|
|||||||
.0
|
.0
|
||||||
.get_wallet_transaction(txid)
|
.get_wallet_transaction(txid)
|
||||||
.await
|
.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)
|
Ok(fee)
|
||||||
}
|
}
|
||||||
@ -116,7 +123,7 @@ impl GetRawTransaction for Wallet {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl BlockHeight for Wallet {
|
impl BlockHeight for Wallet {
|
||||||
async fn block_height(&self) -> u32 {
|
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)))
|
.retry(ConstantBackoff::new(Duration::from_secs(1)))
|
||||||
.await
|
.await
|
||||||
.expect("transient errors to be retried")
|
.expect("transient errors to be retried")
|
||||||
|
@ -16,6 +16,7 @@ use crate::{
|
|||||||
state::{Alice, Bob, Swap},
|
state::{Alice, Bob, Swap},
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use bitcoin_harness::BitcoindRpcApi;
|
||||||
use ecdsa_fun::{adaptor::Adaptor, nonce::Deterministic};
|
use ecdsa_fun::{adaptor::Adaptor, nonce::Deterministic};
|
||||||
use futures::{
|
use futures::{
|
||||||
future::{select, Either},
|
future::{select, Either},
|
||||||
@ -163,7 +164,7 @@ pub async fn alice_recover(
|
|||||||
.transaction_block_height(state.tx_lock.txid())
|
.transaction_block_height(state.tx_lock.txid())
|
||||||
.await;
|
.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;
|
let refund_absolute_expiry = tx_lock_height + state.refund_timelock;
|
||||||
|
|
||||||
info!("Checking refund timelock");
|
info!("Checking refund timelock");
|
||||||
|
@ -29,7 +29,7 @@ tracing = "0.1"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
backoff = { version = "0.2", features = ["tokio"] }
|
backoff = { version = "0.2", features = ["tokio"] }
|
||||||
base64 = "0.12"
|
base64 = "0.12"
|
||||||
bitcoin-harness = "0.2"
|
bitcoin-harness = { git = "https://github.com/coblox/bitcoin-harness-rs", rev = "864b55fcba2e770105f135781dd2e3002c503d12" }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
monero-harness = { path = "../monero-harness" }
|
monero-harness = { path = "../monero-harness" }
|
||||||
reqwest = { version = "0.10", default-features = false }
|
reqwest = { version = "0.10", default-features = false }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use anyhow::Result;
|
use anyhow::{Context, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use backoff::{backoff::Constant as ConstantBackoff, future::FutureOperation as _};
|
use backoff::{backoff::Constant as ConstantBackoff, future::FutureOperation as _};
|
||||||
use bitcoin::{util::psbt::PartiallySignedTransaction, Address, Amount, Transaction, Txid};
|
use bitcoin::{util::psbt::PartiallySignedTransaction, Address, Amount, Transaction, Txid};
|
||||||
use bitcoin_harness::{bitcoind_rpc::PsbtBase64, Bitcoind};
|
use bitcoin_harness::{bitcoind_rpc::PsbtBase64, Bitcoind, BitcoindRpcApi};
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::time;
|
use tokio::time;
|
||||||
@ -35,7 +35,15 @@ impl Wallet {
|
|||||||
.0
|
.0
|
||||||
.get_wallet_transaction(txid)
|
.get_wallet_transaction(txid)
|
||||||
.await
|
.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)
|
Ok(fee)
|
||||||
}
|
}
|
||||||
@ -121,7 +129,7 @@ impl WatchForRawTransaction for Wallet {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl BlockHeight for Wallet {
|
impl BlockHeight for Wallet {
|
||||||
async fn block_height(&self) -> u32 {
|
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)))
|
.retry(ConstantBackoff::new(Duration::from_secs(1)))
|
||||||
.await
|
.await
|
||||||
.expect("transient errors to be retried")
|
.expect("transient errors to be retried")
|
||||||
|
Loading…
Reference in New Issue
Block a user