mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
fixup! Move files from protocol
to appropriate module
This commit is contained in:
parent
52e2e7e489
commit
a11c9d9c03
@ -1,16 +1,15 @@
|
||||
pub use rate::Rate;
|
||||
|
||||
pub mod behaviour;
|
||||
mod behaviour;
|
||||
pub mod command;
|
||||
pub mod config;
|
||||
pub mod event_loop;
|
||||
mod event_loop;
|
||||
mod rate;
|
||||
pub mod recovery;
|
||||
mod recovery;
|
||||
pub mod tracing;
|
||||
pub mod transport;
|
||||
|
||||
pub use behaviour::{Behaviour, OutEvent};
|
||||
pub use event_loop::{EventLoop, EventLoopHandle};
|
||||
pub use event_loop::{EventLoop, EventLoopHandle, FixedRate, KrakenRate, LatestRate};
|
||||
pub use rate::Rate;
|
||||
pub use recovery::cancel::cancel;
|
||||
pub use recovery::punish::punish;
|
||||
pub use recovery::redeem::{redeem, Finality};
|
||||
|
@ -26,9 +26,7 @@ use swap::asb::command::{parse_args, Arguments, Command};
|
||||
use swap::asb::config::{
|
||||
initial_setup, query_user_for_initial_config, read_config, Config, ConfigNotInitialized,
|
||||
};
|
||||
use swap::asb::event_loop::{EventLoop, KrakenRate};
|
||||
use swap::asb::recovery::redeem;
|
||||
use swap::asb::{cancel, punish, redeem, refund, safely_abort};
|
||||
use swap::asb::{cancel, punish, redeem, refund, safely_abort, EventLoop, Finality, KrakenRate};
|
||||
use swap::database::Database;
|
||||
use swap::monero::Amount;
|
||||
use swap::network::swarm;
|
||||
@ -282,7 +280,7 @@ async fn main() -> Result<()> {
|
||||
Arc::new(bitcoin_wallet),
|
||||
Arc::new(db),
|
||||
force,
|
||||
redeem::Finality::from_bool(do_not_await_finality),
|
||||
Finality::from_bool(do_not_await_finality),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
@ -12,24 +12,19 @@
|
||||
#![forbid(unsafe_code)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use anyhow::{bail, Context, Result};
|
||||
use prettytable::{row, Table};
|
||||
use qrcode::render::unicode;
|
||||
use qrcode::QrCode;
|
||||
use std::cmp::min;
|
||||
use std::env;
|
||||
use std::future::Future;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{bail, Context, Result};
|
||||
use prettytable::{row, Table};
|
||||
use qrcode::render::unicode;
|
||||
use qrcode::QrCode;
|
||||
use tracing::{debug, error, info, warn};
|
||||
use url::Url;
|
||||
use uuid::Uuid;
|
||||
|
||||
use swap::bitcoin::TxLock;
|
||||
use swap::cli::command::{parse_args_and_apply_defaults, Arguments, Command, ParseResult};
|
||||
use swap::cli::event_loop::EventLoop;
|
||||
use swap::cli::EventLoop;
|
||||
use swap::database::Database;
|
||||
use swap::env::Config;
|
||||
use swap::network::quote::BidQuote;
|
||||
@ -38,6 +33,9 @@ use swap::protocol::bob;
|
||||
use swap::protocol::bob::Swap;
|
||||
use swap::seed::Seed;
|
||||
use swap::{bitcoin, cli, monero};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use url::Url;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[macro_use]
|
||||
extern crate prettytable;
|
||||
|
@ -1,7 +1,7 @@
|
||||
pub mod behaviour;
|
||||
mod behaviour;
|
||||
pub mod cancel;
|
||||
pub mod command;
|
||||
pub mod event_loop;
|
||||
mod event_loop;
|
||||
pub mod refund;
|
||||
pub mod tracing;
|
||||
pub mod transport;
|
||||
|
@ -1,17 +1,15 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{anyhow, Error, Result};
|
||||
use libp2p::core::Multiaddr;
|
||||
use libp2p::ping::{Ping, PingEvent};
|
||||
use libp2p::request_response::{RequestId, ResponseChannel};
|
||||
use libp2p::{NetworkBehaviour, PeerId};
|
||||
|
||||
use crate::network::quote::BidQuote;
|
||||
use crate::network::swap_setup::bob;
|
||||
use crate::network::{encrypted_signature, quote, redial, transfer_proof};
|
||||
use crate::protocol::bob::State2;
|
||||
use crate::{bitcoin, env};
|
||||
use anyhow::{anyhow, Error, Result};
|
||||
use libp2p::core::Multiaddr;
|
||||
use libp2p::ping::{Ping, PingEvent};
|
||||
use libp2p::request_response::{RequestId, ResponseChannel};
|
||||
use libp2p::{NetworkBehaviour, PeerId};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum OutEvent {
|
||||
|
@ -1,7 +1,4 @@
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::cli;
|
||||
use backoff::backoff::Backoff;
|
||||
use backoff::ExponentialBackoff;
|
||||
use futures::future::FutureExt;
|
||||
@ -10,11 +7,12 @@ use libp2p::core::Multiaddr;
|
||||
use libp2p::swarm::protocols_handler::DummyProtocolsHandler;
|
||||
use libp2p::swarm::{DialPeerCondition, NetworkBehaviour, NetworkBehaviourAction, PollParameters};
|
||||
use libp2p::PeerId;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::Duration;
|
||||
use tokio::time::{Instant, Sleep};
|
||||
use void::Void;
|
||||
|
||||
use crate::cli;
|
||||
|
||||
pub enum OutEvent {
|
||||
AllAttemptsExhausted { peer: PeerId },
|
||||
}
|
||||
@ -121,11 +119,11 @@ impl NetworkBehaviour for Behaviour {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OutEvent> for cli::behaviour::OutEvent {
|
||||
impl From<OutEvent> for cli::OutEvent {
|
||||
fn from(event: OutEvent) -> Self {
|
||||
match event {
|
||||
OutEvent::AllAttemptsExhausted { peer } => {
|
||||
cli::behaviour::OutEvent::AllRedialAttemptsExhausted { peer }
|
||||
cli::OutEvent::AllRedialAttemptsExhausted { peer }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
use crate::monero;
|
||||
use anyhow::{Context, Result};
|
||||
use libp2p::core::upgrade;
|
||||
use libp2p::swarm::NegotiatedSubstream;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::monero;
|
||||
|
||||
pub mod alice;
|
||||
pub mod bob;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::asb::event_loop::LatestRate;
|
||||
use crate::asb::LatestRate;
|
||||
use crate::network::swap_setup;
|
||||
use crate::network::swap_setup::{
|
||||
protocol, BlockchainNetwork, SpotPriceError, SpotPriceRequest, SpotPriceResponse,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::asb::event_loop::LatestRate;
|
||||
use crate::asb::LatestRate;
|
||||
use crate::seed::Seed;
|
||||
use crate::{asb, bitcoin, cli, env, tor};
|
||||
use anyhow::Result;
|
||||
|
@ -14,7 +14,7 @@ pub mod swap;
|
||||
|
||||
pub struct Swap {
|
||||
pub state: AliceState,
|
||||
pub event_loop_handle: asb::event_loop::EventLoopHandle,
|
||||
pub event_loop_handle: asb::EventLoopHandle,
|
||||
pub bitcoin_wallet: Arc<bitcoin::Wallet>,
|
||||
pub monero_wallet: Arc<monero::Wallet>,
|
||||
pub env_config: Config,
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Run an XMR/BTC swap in the role of Alice.
|
||||
//! Alice holds XMR and wishes receive BTC.
|
||||
use crate::asb::event_loop::{EventLoopHandle, LatestRate};
|
||||
use crate::asb::{EventLoopHandle, LatestRate};
|
||||
use crate::bitcoin::ExpiredTimelocks;
|
||||
use crate::env::Config;
|
||||
use crate::protocol::alice::{AliceState, Swap};
|
||||
|
@ -14,7 +14,7 @@ pub mod swap;
|
||||
|
||||
pub struct Swap {
|
||||
pub state: BobState,
|
||||
pub event_loop_handle: cli::event_loop::EventLoopHandle,
|
||||
pub event_loop_handle: cli::EventLoopHandle,
|
||||
pub db: Database,
|
||||
pub bitcoin_wallet: Arc<bitcoin::Wallet>,
|
||||
pub monero_wallet: Arc<monero::Wallet>,
|
||||
@ -31,7 +31,7 @@ impl Swap {
|
||||
bitcoin_wallet: Arc<bitcoin::Wallet>,
|
||||
monero_wallet: Arc<monero::Wallet>,
|
||||
env_config: env::Config,
|
||||
event_loop_handle: cli::event_loop::EventLoopHandle,
|
||||
event_loop_handle: cli::EventLoopHandle,
|
||||
receive_monero_address: monero::Address,
|
||||
btc_amount: bitcoin::Amount,
|
||||
) -> Self {
|
||||
@ -53,7 +53,7 @@ impl Swap {
|
||||
bitcoin_wallet: Arc<bitcoin::Wallet>,
|
||||
monero_wallet: Arc<monero::Wallet>,
|
||||
env_config: env::Config,
|
||||
event_loop_handle: cli::event_loop::EventLoopHandle,
|
||||
event_loop_handle: cli::EventLoopHandle,
|
||||
receive_monero_address: monero::Address,
|
||||
) -> Result<Self> {
|
||||
let state = db.get_state(id)?.try_into_bob()?.into();
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::bitcoin::{ExpiredTimelocks, TxCancel, TxRefund};
|
||||
use crate::cli::event_loop::EventLoopHandle;
|
||||
use crate::cli::EventLoopHandle;
|
||||
use crate::database::Swap;
|
||||
use crate::network::swap_setup::bob::NewSwap;
|
||||
use crate::protocol::bob;
|
||||
|
@ -3,7 +3,7 @@ pub mod harness;
|
||||
use harness::alice_run_until::is_xmr_lock_transaction_sent;
|
||||
use harness::bob_run_until::is_btc_locked;
|
||||
use harness::FastCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
@ -3,7 +3,7 @@ pub mod harness;
|
||||
use harness::alice_run_until::is_xmr_lock_transaction_sent;
|
||||
use harness::bob_run_until::is_btc_locked;
|
||||
use harness::SlowCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
@ -3,7 +3,7 @@ pub mod harness;
|
||||
use harness::alice_run_until::is_xmr_lock_transaction_sent;
|
||||
use harness::bob_run_until::is_btc_locked;
|
||||
use harness::SlowCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
@ -4,7 +4,7 @@ use harness::alice_run_until::is_xmr_lock_transaction_sent;
|
||||
use harness::bob_run_until::is_btc_locked;
|
||||
use harness::FastPunishConfig;
|
||||
use swap::asb;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
@ -3,8 +3,7 @@ pub mod harness;
|
||||
use harness::alice_run_until::is_encsig_learned;
|
||||
use harness::SlowCancelConfig;
|
||||
use swap::asb;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::Finality;
|
||||
use swap::asb::{Finality, FixedRate};
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
||||
|
@ -3,7 +3,7 @@ pub mod harness;
|
||||
use harness::alice_run_until::is_xmr_lock_transaction_sent;
|
||||
use harness::bob_run_until::is_btc_locked;
|
||||
use harness::FastPunishConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
@ -2,7 +2,7 @@ pub mod harness;
|
||||
|
||||
use harness::alice_run_until::is_xmr_lock_transaction_sent;
|
||||
use harness::FastCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
||||
|
@ -2,7 +2,7 @@ pub mod harness;
|
||||
|
||||
use harness::bob_run_until::is_xmr_locked;
|
||||
use harness::SlowCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
@ -2,7 +2,7 @@ pub mod harness;
|
||||
|
||||
use harness::bob_run_until::is_btc_locked;
|
||||
use harness::SlowCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
@ -1,7 +1,7 @@
|
||||
pub mod harness;
|
||||
|
||||
use harness::SlowCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::{alice, bob};
|
||||
use tokio::join;
|
||||
|
||||
|
@ -2,7 +2,7 @@ pub mod harness;
|
||||
|
||||
use harness::alice_run_until::is_xmr_lock_transaction_sent;
|
||||
use harness::SlowCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::alice::AliceState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
||||
|
@ -2,7 +2,7 @@ pub mod harness;
|
||||
|
||||
use harness::bob_run_until::is_xmr_locked;
|
||||
use harness::SlowCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
||||
|
@ -2,7 +2,7 @@ pub mod harness;
|
||||
|
||||
use harness::bob_run_until::is_xmr_locked;
|
||||
use harness::SlowCancelConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
||||
|
@ -14,7 +14,7 @@ use std::fmt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::bitcoin::{CancelTimelock, PunishTimelock, TxCancel, TxPunish, TxRedeem, TxRefund};
|
||||
use swap::database::Database;
|
||||
use swap::env::{Config, GetConfig};
|
||||
|
@ -2,7 +2,7 @@ pub mod harness;
|
||||
|
||||
use harness::bob_run_until::is_btc_locked;
|
||||
use harness::FastPunishConfig;
|
||||
use swap::asb::event_loop::FixedRate;
|
||||
use swap::asb::FixedRate;
|
||||
use swap::protocol::bob::BobState;
|
||||
use swap::protocol::{alice, bob};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user