mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Fix clippy warnings and formatting
This commit is contained in:
parent
b06321a40f
commit
1c401aad31
@ -7,8 +7,8 @@ description = "XMR/BTC trustless atomic swaps."
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
async-trait = "0.1"
|
||||
async-recursion = "0.3.1"
|
||||
async-trait = "0.1"
|
||||
atty = "0.2"
|
||||
backoff = { version = "0.2", features = ["tokio"] }
|
||||
base64 = "0.12"
|
||||
|
@ -213,10 +213,10 @@ pub fn build_bitcoin_redeem_transaction(
|
||||
.context("Invalid encrypted signature received")?;
|
||||
|
||||
let sig_a = a.sign(tx_redeem.digest());
|
||||
let sig_b = adaptor.decrypt_signature(&s_a.into_secp256k1(), encrypted_signature.clone());
|
||||
let sig_b = adaptor.decrypt_signature(&s_a.into_secp256k1(), encrypted_signature);
|
||||
|
||||
let tx = tx_redeem
|
||||
.add_signatures(&tx_lock, (a.public(), sig_a), (B.clone(), sig_b))
|
||||
.add_signatures(&tx_lock, (a.public(), sig_a), (B, sig_b))
|
||||
.context("sig_{a,b} are invalid for tx_redeem")?;
|
||||
|
||||
Ok(tx)
|
||||
@ -229,7 +229,7 @@ pub async fn publish_bitcoin_redeem_transaction<W>(
|
||||
where
|
||||
W: BroadcastSignedTransaction + WaitForTransactionFinality,
|
||||
{
|
||||
let tx_id = bitcoin_wallet
|
||||
let _tx_id = bitcoin_wallet
|
||||
.broadcast_signed_transaction(redeem_tx)
|
||||
.await?;
|
||||
|
||||
@ -258,7 +258,11 @@ where
|
||||
let tx_cancel = bitcoin::TxCancel::new(&tx_lock, refund_timelock, a.public(), B.clone());
|
||||
|
||||
// If Bob hasn't yet broadcasted the tx cancel, we do it
|
||||
if let Err(_) = bitcoin_wallet.get_raw_transaction(tx_cancel.txid()).await {
|
||||
if bitcoin_wallet
|
||||
.get_raw_transaction(tx_cancel.txid())
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
// TODO(Franck): Maybe the cancel transaction is already mined, in this case,
|
||||
// the broadcast will error out.
|
||||
|
||||
@ -348,10 +352,10 @@ pub fn build_bitcoin_punish_transaction(
|
||||
let tx_punish = bitcoin::TxPunish::new(&tx_cancel, &punish_address, punish_timelock);
|
||||
|
||||
let sig_a = a.sign(tx_punish.digest());
|
||||
let sig_b = tx_punish_sig_bob.clone();
|
||||
let sig_b = tx_punish_sig_bob;
|
||||
|
||||
let signed_tx_punish = tx_punish
|
||||
.add_signatures(&tx_cancel, (a.public(), sig_a), (B.clone(), sig_b))
|
||||
.add_signatures(&tx_cancel, (a.public(), sig_a), (B, sig_b))
|
||||
.expect("sig_{a,b} to be valid signatures for tx_cancel");
|
||||
|
||||
Ok(signed_tx_punish)
|
||||
|
@ -38,6 +38,7 @@ impl<T> Rng for T where T: RngCore + CryptoRng + Send {}
|
||||
|
||||
// The same data structure is used for swap execution and recovery.
|
||||
// This allows for a seamless transition from a failed swap to recovery.
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum AliceState {
|
||||
Started {
|
||||
amounts: SwapAmounts,
|
||||
|
@ -165,7 +165,7 @@ where
|
||||
_ = t1_timeout => {
|
||||
// Check whether TxCancel has been published.
|
||||
// We should not fail if the transaction is already on the blockchain
|
||||
if let Err(_) = state.check_for_tx_cancel(bitcoin_wallet.as_ref()).await {
|
||||
if state.check_for_tx_cancel(bitcoin_wallet.as_ref()).await.is_err() {
|
||||
state.submit_tx_cancel(bitcoin_wallet.as_ref()).await?;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ use testcontainers::clients::Cli;
|
||||
use uuid::Uuid;
|
||||
use xmr_btc::{bitcoin, cross_curve_dleq};
|
||||
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn swap() {
|
||||
use tracing_subscriber::util::SubscriberInitExt as _;
|
||||
@ -124,7 +125,7 @@ async fn swap() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn simple_swap_happy_path() {
|
||||
async fn happy_path_recursive_executor() {
|
||||
use tracing_subscriber::util::SubscriberInitExt as _;
|
||||
let _guard = tracing_subscriber::fmt()
|
||||
.with_env_filter("swap=info,xmr_btc=info")
|
||||
|
@ -449,6 +449,7 @@ pub struct State0 {
|
||||
}
|
||||
|
||||
impl State0 {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
a: bitcoin::SecretKey,
|
||||
s_a: cross_curve_dleq::Scalar,
|
||||
|
Loading…
Reference in New Issue
Block a user