diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 85609dcc..5cb515da 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -5,6 +5,12 @@ authors = ["CoBloX developers "] edition = "2018" description = "XMR/BTC trustless atomic swaps." +[[bin]] +name = "cli" + +[lib] +name = "swap" + [dependencies] anyhow = "1" async-recursion = "0.3.1" diff --git a/swap/src/main.rs b/swap/src/bin/cli.rs similarity index 95% rename from swap/src/main.rs rename to swap/src/bin/cli.rs index da6fd9fa..03176ae3 100644 --- a/swap/src/main.rs +++ b/swap/src/bin/cli.rs @@ -12,41 +12,34 @@ #![forbid(unsafe_code)] #![allow(non_snake_case)] -use crate::{ +use anyhow::{Context, Result}; +use log::LevelFilter; +use prettytable::{row, Table}; +use std::{path::PathBuf, sync::Arc}; +use structopt::StructOpt; +use swap::{ + bitcoin, cli::{Cancel, Command, Options, Refund, Resume}, + config, config::{ initial_setup, query_user_for_initial_testnet_config, read_config, ConfigNotInitialized, }, + database::Database, + execution_params, execution_params::GetExecutionParams, + fs::{default_config_path, default_data_dir}, + monero, monero::{CreateWallet, OpenWallet}, - protocol::bob::cancel::CancelError, + protocol::{ + bob, + bob::{cancel::CancelError, Builder}, + SwapAmounts, + }, + trace::init_tracing, }; -use anyhow::{Context, Result}; -use database::Database; -use fs::{default_config_path, default_data_dir}; -use log::LevelFilter; -use prettytable::{row, Table}; -use protocol::{bob, bob::Builder, SwapAmounts}; -use std::{path::PathBuf, sync::Arc}; -use structopt::StructOpt; -use trace::init_tracing; use tracing::{error, info, warn}; use uuid::Uuid; -pub mod bitcoin; -pub mod config; -pub mod database; -pub mod execution_params; -pub mod monero; -pub mod network; -pub mod protocol; -pub mod seed; -pub mod trace; - -mod cli; -mod fs; -mod serde_peer_id; - #[macro_use] extern crate prettytable; @@ -70,7 +63,7 @@ async fn main() -> Result<()> { ); let db_path = data_dir.join("database"); - let seed = config::seed::Seed::from_file_or_generate(&data_dir) + let seed = config::Seed::from_file_or_generate(&data_dir) .expect("Could not retrieve/initialize seed") .into(); diff --git a/swap/src/config.rs b/swap/src/config.rs index 11049581..f9f56431 100644 --- a/swap/src/config.rs +++ b/swap/src/config.rs @@ -13,6 +13,8 @@ use url::Url; pub mod seed; +pub use seed::Seed; + const DEFAULT_BITCOIND_TESTNET_URL: &str = "http://127.0.0.1:18332"; const DEFAULT_MONERO_WALLET_RPC_TESTNET_URL: &str = "http://127.0.0.1:38083/json_rpc"; diff --git a/swap/src/lib.rs b/swap/src/lib.rs index 72c81012..f042cddc 100644 --- a/swap/src/lib.rs +++ b/swap/src/lib.rs @@ -17,8 +17,11 @@ )] pub mod bitcoin; +pub mod cli; +pub mod config; pub mod database; pub mod execution_params; +pub mod fs; pub mod monero; pub mod network; pub mod protocol;