Extract transport creation and remove tor conditional compile

The numerous tor conditional compile flags were removed by
extracting transport creation to the main statement. A tor
transport is created if Alice specifies a tor port using the CLI.
This commit is contained in:
rishflab 2020-10-29 22:18:59 +11:00
parent 0ca511bf8a
commit 796d0b3439
7 changed files with 101 additions and 128 deletions

View file

@ -4,41 +4,32 @@ use url::Url;
#[derive(structopt::StructOpt, Debug)]
pub enum Options {
Alice {
/// Run the swap as Bob and try to swap this many BTC (in satoshi).
#[structopt(long = "sats")]
satoshis: u64,
// /// Run the swap as Bob and try to swap this many XMR (in piconero).
// #[structopt(long = "picos", conflicts_with = "sats"))]
// pub piconeros: u64,
#[structopt(default_value = "http://127.0.0.1:8332", long = "bitcoind")]
bitcoind_url: Url,
#[structopt(default_value = "127.0.0.1", long = "listen_addr")]
listen_addr: String,
#[structopt(default_value = "/ip4/127.0.0.1/tcp/9876", long = "listen-addr")]
listen_addr: Multiaddr,
#[structopt(default_value = 9876, long = "list_port")]
listen_port: u16,
/// Run the swap as Bob and try to swap this many BTC (in satoshi).
// #[cfg(feature = "tor")]
#[structopt(long = "tor-port")]
tor_port: Option<u16>,
},
Bob {
/// Alice's multitaddr (only required for Bob, Alice will autogenerate
/// one)
#[structopt(long = "alice_addr")]
alice_addr: Multiaddr,
/// Run the swap as Bob and try to swap this many BTC (in satoshi).
#[structopt(long = "sats")]
satoshis: u64,
#[structopt(long = "alice-addr")]
alice_addr: Multiaddr,
// /// Run the swap as Bob and try to swap this many XMR (in piconero).
// #[structopt(long = "picos", conflicts_with = "sats"))]
// pub piconeros: u64,
#[structopt(default_value = "http://127.0.0.1:8332", long = "bitcoind")]
bitcoind_url: Url,
// #[structopt(default_value = "/ip4/127.0.0.1/tcp/9876", long = "dial")]
// alice_addr: String,
#[cfg(feature = "tor")]
#[structopt(long = "tor")]
tor_port: u16,
},
}