Add support for swapping through Tor.

This PR does a few things.
* It adds a TorTransport which either dials through Tor's socks5 proxy or via clearnet.
* It enables ASB to register hidden services for each network it is listening on. We assume that we only care about different ports and re-use the same onion-address for all of them. The ASB requires to have access to Tor's control port.
* It adds support to dial through a local Tor socks5 proxy. We assume that Tor is always available on localhost.  Swap cli only requires Tor to be running so that it can send messages via Tor's socks5 proxy.
* It adds a new e2e test which swaps through Tor. For this we assume that Tor is currently running on localhost. All other tests are running via clear net.
This commit is contained in:
Philipp Hoenisch 2021-04-22 11:33:36 +10:00
parent e262345b4f
commit 632293cf91
No known key found for this signature in database
GPG key ID: E5F8E74C672BC666
14 changed files with 856 additions and 116 deletions

View file

@ -13,6 +13,8 @@ pub const DEFAULT_STAGENET_MONERO_DAEMON_HOST: &str = "monero-stagenet.exan.tech
pub const DEFAULT_ELECTRUM_HTTP_URL: &str = "https://blockstream.info/testnet/api/";
const DEFAULT_ELECTRUM_RPC_URL: &str = "ssl://electrum.blockstream.info:60002";
const DEFAULT_TOR_SOCKS5_PORT: &str = "9050";
#[derive(structopt::StructOpt, Debug)]
#[structopt(name = "swap", about = "CLI for swapping BTC for XMR", author)]
pub struct Arguments {
@ -48,6 +50,9 @@ pub enum Command {
#[structopt(flatten)]
monero_params: MoneroParams,
#[structopt(long = "tor-socks5-port", help = "Your local Tor socks5 proxy port", default_value = DEFAULT_TOR_SOCKS5_PORT)]
tor_socks5_port: u16,
},
/// Show a list of past ongoing and completed swaps
History,
@ -70,6 +75,9 @@ pub enum Command {
#[structopt(flatten)]
monero_params: MoneroParams,
#[structopt(long = "tor-socks5-port", help = "Your local Tor socks5 proxy port", default_value = DEFAULT_TOR_SOCKS5_PORT)]
tor_socks5_port: u16,
},
/// Try to cancel an ongoing swap (expert users only)
Cancel {