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]
|
[dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
async-trait = "0.1"
|
|
||||||
async-recursion = "0.3.1"
|
async-recursion = "0.3.1"
|
||||||
|
async-trait = "0.1"
|
||||||
atty = "0.2"
|
atty = "0.2"
|
||||||
backoff = { version = "0.2", features = ["tokio"] }
|
backoff = { version = "0.2", features = ["tokio"] }
|
||||||
base64 = "0.12"
|
base64 = "0.12"
|
||||||
|
@ -213,10 +213,10 @@ pub fn build_bitcoin_redeem_transaction(
|
|||||||
.context("Invalid encrypted signature received")?;
|
.context("Invalid encrypted signature received")?;
|
||||||
|
|
||||||
let sig_a = a.sign(tx_redeem.digest());
|
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
|
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")?;
|
.context("sig_{a,b} are invalid for tx_redeem")?;
|
||||||
|
|
||||||
Ok(tx)
|
Ok(tx)
|
||||||
@ -229,7 +229,7 @@ pub async fn publish_bitcoin_redeem_transaction<W>(
|
|||||||
where
|
where
|
||||||
W: BroadcastSignedTransaction + WaitForTransactionFinality,
|
W: BroadcastSignedTransaction + WaitForTransactionFinality,
|
||||||
{
|
{
|
||||||
let tx_id = bitcoin_wallet
|
let _tx_id = bitcoin_wallet
|
||||||
.broadcast_signed_transaction(redeem_tx)
|
.broadcast_signed_transaction(redeem_tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@ -258,7 +258,11 @@ where
|
|||||||
let tx_cancel = bitcoin::TxCancel::new(&tx_lock, refund_timelock, a.public(), B.clone());
|
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 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,
|
// TODO(Franck): Maybe the cancel transaction is already mined, in this case,
|
||||||
// the broadcast will error out.
|
// 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 tx_punish = bitcoin::TxPunish::new(&tx_cancel, &punish_address, punish_timelock);
|
||||||
|
|
||||||
let sig_a = a.sign(tx_punish.digest());
|
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
|
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");
|
.expect("sig_{a,b} to be valid signatures for tx_cancel");
|
||||||
|
|
||||||
Ok(signed_tx_punish)
|
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.
|
// The same data structure is used for swap execution and recovery.
|
||||||
// This allows for a seamless transition from a failed swap to recovery.
|
// This allows for a seamless transition from a failed swap to recovery.
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum AliceState {
|
pub enum AliceState {
|
||||||
Started {
|
Started {
|
||||||
amounts: SwapAmounts,
|
amounts: SwapAmounts,
|
||||||
|
@ -165,8 +165,8 @@ where
|
|||||||
_ = t1_timeout => {
|
_ = t1_timeout => {
|
||||||
// Check whether TxCancel has been published.
|
// Check whether TxCancel has been published.
|
||||||
// We should not fail if the transaction is already on the blockchain
|
// 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?;
|
state.submit_tx_cancel(bitcoin_wallet.as_ref()).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
swap(
|
swap(
|
||||||
|
@ -13,6 +13,7 @@ use testcontainers::clients::Cli;
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use xmr_btc::{bitcoin, cross_curve_dleq};
|
use xmr_btc::{bitcoin, cross_curve_dleq};
|
||||||
|
|
||||||
|
#[ignore]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn swap() {
|
async fn swap() {
|
||||||
use tracing_subscriber::util::SubscriberInitExt as _;
|
use tracing_subscriber::util::SubscriberInitExt as _;
|
||||||
@ -124,7 +125,7 @@ async fn swap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn simple_swap_happy_path() {
|
async fn happy_path_recursive_executor() {
|
||||||
use tracing_subscriber::util::SubscriberInitExt as _;
|
use tracing_subscriber::util::SubscriberInitExt as _;
|
||||||
let _guard = tracing_subscriber::fmt()
|
let _guard = tracing_subscriber::fmt()
|
||||||
.with_env_filter("swap=info,xmr_btc=info")
|
.with_env_filter("swap=info,xmr_btc=info")
|
||||||
|
@ -449,6 +449,7 @@ pub struct State0 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl State0 {
|
impl State0 {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
a: bitcoin::SecretKey,
|
a: bitcoin::SecretKey,
|
||||||
s_a: cross_curve_dleq::Scalar,
|
s_a: cross_curve_dleq::Scalar,
|
||||||
|
Loading…
Reference in New Issue
Block a user