From d21bd556ecf7a67a973d045ac17a127bcb6f4bd6 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 9 Jul 2021 09:44:37 +1000 Subject: [PATCH 1/3] Remove rendezvous point default This also fixes a bug where an empty string wasn't actually allowed as a rendezvous point in the ASB's initial setup wizard. --- swap/src/asb/config.rs | 23 ++++++++++------------- swap/src/cli/command.rs | 5 ++--- swap/src/network/rendezvous.rs | 3 --- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/swap/src/asb/config.rs b/swap/src/asb/config.rs index 1cd3ab2f..a8c7f37f 100644 --- a/swap/src/asb/config.rs +++ b/swap/src/asb/config.rs @@ -1,6 +1,5 @@ use crate::env::{Mainnet, Testnet}; use crate::fs::{ensure_directory_exists, system_config_dir, system_data_dir}; -use crate::network::rendezvous::DEFAULT_RENDEZVOUS_ADDRESS; use crate::tor::{DEFAULT_CONTROL_PORT, DEFAULT_SOCKS5_PORT}; use anyhow::{bail, Context, Result}; use config::ConfigError; @@ -249,7 +248,7 @@ pub fn query_user_for_initial_config(testnet: bool) -> Result { .map(|str| str.parse()) .collect::, _>>()?; - let electrum_rpc_url: Url = Input::with_theme(&ColorfulTheme::default()) + let electrum_rpc_url = Input::with_theme(&ColorfulTheme::default()) .with_prompt("Enter Electrum RPC URL or hit return to use default") .default(defaults.electrum_rpc_url) .interact_text()?; @@ -290,24 +289,22 @@ pub fn query_user_for_initial_config(testnet: bool) -> Result { } let ask_spread = Decimal::from_f64(ask_spread).context("Unable to parse spread")?; - let rendezvous_address = Input::with_theme(&ColorfulTheme::default()) + let rendezvous_point = Input::::with_theme(&ColorfulTheme::default()) .with_prompt("Do you want to advertise your ASB instance with a rendezvous node? Enter an empty string if not.") - .default(DEFAULT_RENDEZVOUS_ADDRESS.to_string()) + .allow_empty(true) .interact_text()?; - let rendezvous_point = if rendezvous_address.is_empty() { - None - } else { - Some(Multiaddr::from_str(&rendezvous_address)?) - }; - println!(); Ok(Config { data: Data { dir: data_dir }, network: Network { listen: listen_addresses, - rendezvous_point, + rendezvous_point: if rendezvous_point.is_empty() { + None + } else { + Some(rendezvous_point) + }, external_addresses: vec![], }, bitcoin: Bitcoin { @@ -358,7 +355,7 @@ mod tests { }, network: Network { listen: vec![defaults.listen_address_tcp, defaults.listen_address_ws], - rendezvous_point: Some(DEFAULT_RENDEZVOUS_ADDRESS.parse().unwrap()), + rendezvous_point: None, external_addresses: vec![], }, @@ -401,7 +398,7 @@ mod tests { }, network: Network { listen: vec![defaults.listen_address_tcp, defaults.listen_address_ws], - rendezvous_point: Some(DEFAULT_RENDEZVOUS_ADDRESS.parse().unwrap()), + rendezvous_point: None, external_addresses: vec![], }, diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs index 630cd6b2..48e03963 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -1,6 +1,6 @@ use crate::env::GetConfig; use crate::fs::system_data_dir; -use crate::network::rendezvous::{XmrBtcNamespace, DEFAULT_RENDEZVOUS_ADDRESS}; +use crate::network::rendezvous::XmrBtcNamespace; use crate::{env, monero}; use anyhow::{Context, Result}; use bitcoin::AddressType; @@ -336,8 +336,7 @@ enum RawCommand { ListSellers { #[structopt( long, - help = "Address of the rendezvous point you want to use to discover ASBs", - default_value = DEFAULT_RENDEZVOUS_ADDRESS + help = "Address of the rendezvous point you want to use to discover ASBs" )] rendezvous_point: Multiaddr, diff --git a/swap/src/network/rendezvous.rs b/swap/src/network/rendezvous.rs index 9060f000..5f8727c5 100644 --- a/swap/src/network/rendezvous.rs +++ b/swap/src/network/rendezvous.rs @@ -1,9 +1,6 @@ use libp2p::rendezvous::Namespace; use std::fmt; -pub const DEFAULT_RENDEZVOUS_ADDRESS: &str = - "/dnsaddr/rendezvous.coblox.tech/p2p/12D3KooWQUt9DkNZxEn2R5ymJzWj15MpG6mTW84kyd8vDaRZi46o"; - #[derive(Debug, PartialEq, Clone, Copy)] pub enum XmrBtcNamespace { Mainnet, From e72922923af6a931d0c415bc6e69e091f3b1722e Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Fri, 9 Jul 2021 10:18:34 +1000 Subject: [PATCH 2/3] Update discover-and-take script with rendezvous-point param --- docs/cli/discover_and_take.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/cli/discover_and_take.sh b/docs/cli/discover_and_take.sh index 43adca9b..af250951 100755 --- a/docs/cli/discover_and_take.sh +++ b/docs/cli/discover_and_take.sh @@ -1,10 +1,21 @@ #!/bin/bash -CLI_PATH=$1 -YOUR_MONERO_ADDR=$2 -YOUR_BITCOIN_ADDR=$3 +# This is a utility script to showcase how the swap CLI can discover sellers and then trigger a swap using the discovered sellers +# +# 1st param: Path to the "swap" binary (aka the swap CLI) +# 2nd param: Multiaddress of the rendezvous node to be used for discovery +# 3rd param: Your Monero stagenet address where the XMR will be received +# 4th param: Your bech32 Bitcoin testnet address that will be used for any change output (e.g. refund scenario or when swapping an amount smaller than the transferred BTC) +# +# Example usage: +# discover_and_take.sh "PATH/TO/swap" "/dnsaddr/rendezvous.coblox.tech/p2p/12D3KooWQUt9DkNZxEn2R5ymJzWj15MpG6mTW84kyd8vDaRZi46o" "YOUR_XMR_STAGENET_ADDRESS" "YOUR_BECH32_BITCOIN_TESTNET_ADDRESS" -CLI_LIST_SELLERS="$CLI_PATH --testnet --json --debug list-sellers" +CLI_PATH=$1 +RENDEZVOUS_POINT=$2 +YOUR_MONERO_ADDR=$3 +YOUR_BITCOIN_ADDR=$4 + +CLI_LIST_SELLERS="$CLI_PATH --testnet --json --debug list-sellers --rendezvous-point $RENDEZVOUS_POINT" echo "Requesting sellers with command: $CLI_LIST_SELLERS" echo From 5e2e0f7dc065af5f3d3ded6eba76e41dde22771d Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Fri, 9 Jul 2021 10:32:58 +1000 Subject: [PATCH 3/3] No default for rendezvous-point in CLI README --- docs/cli/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/cli/README.md b/docs/cli/README.md index c2f4d320..a4cbfc9d 100644 --- a/docs/cli/README.md +++ b/docs/cli/README.md @@ -94,13 +94,11 @@ FLAGS: -V, --version Prints version information OPTIONS: - --rendezvous-point Address of the rendezvous point you want to use to discover ASBs [default: /dnsaddr/rendezvous.coblox.tech/p2p/12D3KooWQUt9DkNZxEn2R5ymJzWj15MpG6mTW84kyd8vDaRZi46o] + --rendezvous-point Address of the rendezvous point you want to use to discover ASBs --tor-socks5-port Your local Tor socks5 proxy port [default: 9050] ``` -This command only takes optional parameters and can be run as-is: - -Running `swap --testnet list-sellers` will give you something like: +Running `swap --testnet list-sellers --rendezvous-point /dnsaddr/rendezvous.coblox.tech/p2p/12D3KooWQUt9DkNZxEn2R5ymJzWj15MpG6mTW84kyd8vDaRZi46o` will give you something like: ``` Connected to rendezvous point, discovering nodes in 'xmr-btc-swap-testnet' namespace ...