@ -74,11 +74,11 @@ where
bitcoin_electrum_rpc_url ,
bitcoin_electrum_rpc_url ,
bitcoin_target_block ,
bitcoin_target_block ,
} ,
} ,
monero:
bitcoin_change_address,
Monero {
monero: Monero {
monero_receive _address,
monero_daemon _address,
monero_daemon_address ,
} ,
} ,
monero_receive_address ,
tor : Tor { tor_socks5_port } ,
tor : Tor { tor_socks5_port } ,
} = > Arguments {
} = > Arguments {
env_config : env_config_from ( is_testnet ) ,
env_config : env_config_from ( is_testnet ) ,
@ -92,6 +92,7 @@ where
is_testnet ,
is_testnet ,
) ? ,
) ? ,
bitcoin_target_block : bitcoin_target_block_from ( bitcoin_target_block , is_testnet ) ,
bitcoin_target_block : bitcoin_target_block_from ( bitcoin_target_block , is_testnet ) ,
bitcoin_change_address ,
monero_receive_address : validate_monero_address (
monero_receive_address : validate_monero_address (
monero_receive_address ,
monero_receive_address ,
is_testnet ,
is_testnet ,
@ -117,11 +118,9 @@ where
bitcoin_electrum_rpc_url ,
bitcoin_electrum_rpc_url ,
bitcoin_target_block ,
bitcoin_target_block ,
} ,
} ,
monero :
monero : Monero {
Monero {
monero_daemon_address ,
monero_receive_address ,
} ,
monero_daemon_address ,
} ,
tor : Tor { tor_socks5_port } ,
tor : Tor { tor_socks5_port } ,
} = > Arguments {
} = > Arguments {
env_config : env_config_from ( is_testnet ) ,
env_config : env_config_from ( is_testnet ) ,
@ -135,7 +134,6 @@ where
is_testnet ,
is_testnet ,
) ? ,
) ? ,
bitcoin_target_block : bitcoin_target_block_from ( bitcoin_target_block , is_testnet ) ,
bitcoin_target_block : bitcoin_target_block_from ( bitcoin_target_block , is_testnet ) ,
monero_receive_address ,
monero_daemon_address : monero_daemon_address_from (
monero_daemon_address : monero_daemon_address_from (
monero_daemon_address ,
monero_daemon_address ,
is_testnet ,
is_testnet ,
@ -214,6 +212,7 @@ pub enum Command {
seller : Multiaddr ,
seller : Multiaddr ,
bitcoin_electrum_rpc_url : Url ,
bitcoin_electrum_rpc_url : Url ,
bitcoin_target_block : usize ,
bitcoin_target_block : usize ,
bitcoin_change_address : bitcoin ::Address ,
monero_receive_address : monero ::Address ,
monero_receive_address : monero ::Address ,
monero_daemon_address : String ,
monero_daemon_address : String ,
tor_socks5_port : u16 ,
tor_socks5_port : u16 ,
@ -223,7 +222,6 @@ pub enum Command {
swap_id : Uuid ,
swap_id : Uuid ,
bitcoin_electrum_rpc_url : Url ,
bitcoin_electrum_rpc_url : Url ,
bitcoin_target_block : usize ,
bitcoin_target_block : usize ,
monero_receive_address : monero ::Address ,
monero_daemon_address : String ,
monero_daemon_address : String ,
tor_socks5_port : u16 ,
tor_socks5_port : u16 ,
} ,
} ,
@ -287,9 +285,21 @@ pub enum RawCommand {
#[ structopt(flatten) ]
#[ structopt(flatten) ]
bitcoin : Bitcoin ,
bitcoin : Bitcoin ,
#[ structopt(
long = "change-address" ,
help = "The bitcoin address where any form of change or excess funds should be sent to"
) ]
bitcoin_change_address : bitcoin ::Address ,
#[ structopt(flatten) ]
#[ structopt(flatten) ]
monero : Monero ,
monero : Monero ,
#[ structopt(long = " receive-address " ,
help = "The monero address where you would like to receive monero" ,
parse ( try_from_str = parse_monero_address )
) ]
monero_receive_address : monero ::Address ,
#[ structopt(flatten) ]
#[ structopt(flatten) ]
tor : Tor ,
tor : Tor ,
} ,
} ,
@ -346,12 +356,6 @@ pub enum RawCommand {
#[ derive(structopt::StructOpt, Debug) ]
#[ derive(structopt::StructOpt, Debug) ]
pub struct Monero {
pub struct Monero {
#[ structopt(long = " receive-address " ,
help = "Provide the monero address where you would like to receive monero" ,
parse ( try_from_str = parse_monero_address )
) ]
pub monero_receive_address : monero ::Address ,
#[ structopt(
#[ structopt(
long = "monero-daemon-address" ,
long = "monero-daemon-address" ,
help = "Specify to connect to a monero daemon of your choice: <host>:<port>"
help = "Specify to connect to a monero daemon of your choice: <host>:<port>"
@ -520,7 +524,9 @@ mod tests {
const MAINNET : & str = "mainnet" ;
const MAINNET : & str = "mainnet" ;
const MONERO_STAGENET_ADDRESS : & str = "53gEuGZUhP9JMEBZoGaFNzhwEgiG7hwQdMCqFxiyiTeFPmkbt1mAoNybEUvYBKHcnrSgxnVWgZsTvRBaHBNXPa8tHiCU51a" ;
const MONERO_STAGENET_ADDRESS : & str = "53gEuGZUhP9JMEBZoGaFNzhwEgiG7hwQdMCqFxiyiTeFPmkbt1mAoNybEUvYBKHcnrSgxnVWgZsTvRBaHBNXPa8tHiCU51a" ;
const BITCOIN_TESTNET_ADDRESS : & str = "tb1qr3em6k3gfnyl8r7q0v7t4tlnyxzgxma3lressv" ;
const MONERO_MAINNET_ADDRESS : & str = "44Ato7HveWidJYUAVw5QffEcEtSH1DwzSP3FPPkHxNAS4LX9CqgucphTisH978FLHE34YNEx7FcbBfQLQUU8m3NUC4VqsRa" ;
const MONERO_MAINNET_ADDRESS : & str = "44Ato7HveWidJYUAVw5QffEcEtSH1DwzSP3FPPkHxNAS4LX9CqgucphTisH978FLHE34YNEx7FcbBfQLQUU8m3NUC4VqsRa" ;
const BITCOIN_MAINNET_ADDRESS : & str = "bc1qe4epnfklcaa0mun26yz5g8k24em5u9f92hy325" ;
const MULTI_ADDRESS : & str =
const MULTI_ADDRESS : & str =
"/ip4/127.0.0.1/tcp/9939/p2p/12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi" ;
"/ip4/127.0.0.1/tcp/9939/p2p/12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi" ;
const SWAP_ID : & str = "ea030832-3be9-454f-bb98-5ea9a788406b" ;
const SWAP_ID : & str = "ea030832-3be9-454f-bb98-5ea9a788406b" ;
@ -532,6 +538,8 @@ mod tests {
"buy-xmr" ,
"buy-xmr" ,
"--receive-address" ,
"--receive-address" ,
MONERO_MAINNET_ADDRESS ,
MONERO_MAINNET_ADDRESS ,
"--change-address" ,
BITCOIN_MAINNET_ADDRESS ,
"--seller" ,
"--seller" ,
MULTI_ADDRESS ,
MULTI_ADDRESS ,
] ;
] ;
@ -550,6 +558,8 @@ mod tests {
"buy-xmr" ,
"buy-xmr" ,
"--receive-address" ,
"--receive-address" ,
MONERO_STAGENET_ADDRESS ,
MONERO_STAGENET_ADDRESS ,
"--change-address" ,
BITCOIN_TESTNET_ADDRESS ,
"--seller" ,
"--seller" ,
MULTI_ADDRESS ,
MULTI_ADDRESS ,
] ;
] ;
@ -569,6 +579,8 @@ mod tests {
"buy-xmr" ,
"buy-xmr" ,
"--receive-address" ,
"--receive-address" ,
MONERO_STAGENET_ADDRESS ,
MONERO_STAGENET_ADDRESS ,
"--change-address" ,
BITCOIN_TESTNET_ADDRESS ,
"--seller" ,
"--seller" ,
MULTI_ADDRESS ,
MULTI_ADDRESS ,
] ;
] ;
@ -592,6 +604,8 @@ mod tests {
"buy-xmr" ,
"buy-xmr" ,
"--receive-address" ,
"--receive-address" ,
MONERO_MAINNET_ADDRESS ,
MONERO_MAINNET_ADDRESS ,
"--change-address" ,
BITCOIN_MAINNET_ADDRESS ,
"--seller" ,
"--seller" ,
MULTI_ADDRESS ,
MULTI_ADDRESS ,
] ;
] ;
@ -609,14 +623,7 @@ mod tests {
#[ test ]
#[ test ]
fn given_resume_on_mainnet_then_defaults_to_mainnet ( ) {
fn given_resume_on_mainnet_then_defaults_to_mainnet ( ) {
let raw_ars = vec! [
let raw_ars = vec! [ BINARY_NAME , "resume" , "--swap-id" , SWAP_ID ] ;
BINARY_NAME ,
"resume" ,
"--swap-id" ,
SWAP_ID ,
"--receive-address" ,
MONERO_MAINNET_ADDRESS ,
] ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
@ -628,15 +635,7 @@ mod tests {
#[ test ]
#[ test ]
fn given_resume_on_testnet_then_defaults_to_testnet ( ) {
fn given_resume_on_testnet_then_defaults_to_testnet ( ) {
let raw_ars = vec! [
let raw_ars = vec! [ BINARY_NAME , "--testnet" , "resume" , "--swap-id" , SWAP_ID ] ;
BINARY_NAME ,
"--testnet" ,
"resume" ,
"--swap-id" ,
SWAP_ID ,
"--receive-address" ,
MONERO_STAGENET_ADDRESS ,
] ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
@ -703,6 +702,8 @@ mod tests {
"--data-dir" ,
"--data-dir" ,
data_dir ,
data_dir ,
"buy-xmr" ,
"buy-xmr" ,
"--change-address" ,
BITCOIN_MAINNET_ADDRESS ,
"--receive-address" ,
"--receive-address" ,
MONERO_MAINNET_ADDRESS ,
MONERO_MAINNET_ADDRESS ,
"--seller" ,
"--seller" ,
@ -725,6 +726,8 @@ mod tests {
"--data-dir" ,
"--data-dir" ,
data_dir ,
data_dir ,
"buy-xmr" ,
"buy-xmr" ,
"--change-address" ,
BITCOIN_TESTNET_ADDRESS ,
"--receive-address" ,
"--receive-address" ,
MONERO_STAGENET_ADDRESS ,
MONERO_STAGENET_ADDRESS ,
"--seller" ,
"--seller" ,
@ -748,8 +751,6 @@ mod tests {
"resume" ,
"resume" ,
"--swap-id" ,
"--swap-id" ,
SWAP_ID ,
SWAP_ID ,
"--receive-address" ,
MONERO_MAINNET_ADDRESS ,
] ;
] ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
@ -770,8 +771,6 @@ mod tests {
"resume" ,
"resume" ,
"--swap-id" ,
"--swap-id" ,
SWAP_ID ,
SWAP_ID ,
"--receive-address" ,
MONERO_STAGENET_ADDRESS ,
] ;
] ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
@ -791,6 +790,8 @@ mod tests {
BINARY_NAME ,
BINARY_NAME ,
"--debug" ,
"--debug" ,
"buy-xmr" ,
"buy-xmr" ,
"--change-address" ,
BITCOIN_MAINNET_ADDRESS ,
"--receive-address" ,
"--receive-address" ,
MONERO_MAINNET_ADDRESS ,
MONERO_MAINNET_ADDRESS ,
"--seller" ,
"--seller" ,
@ -808,6 +809,8 @@ mod tests {
"--testnet" ,
"--testnet" ,
"--debug" ,
"--debug" ,
"buy-xmr" ,
"buy-xmr" ,
"--change-address" ,
BITCOIN_TESTNET_ADDRESS ,
"--receive-address" ,
"--receive-address" ,
MONERO_STAGENET_ADDRESS ,
MONERO_STAGENET_ADDRESS ,
"--seller" ,
"--seller" ,
@ -820,15 +823,7 @@ mod tests {
ParseResult ::Arguments ( Arguments ::buy_xmr_testnet_defaults ( ) . with_debug ( ) )
ParseResult ::Arguments ( Arguments ::buy_xmr_testnet_defaults ( ) . with_debug ( ) )
) ;
) ;
let raw_ars = vec! [
let raw_ars = vec! [ BINARY_NAME , "--debug" , "resume" , "--swap-id" , SWAP_ID ] ;
BINARY_NAME ,
"--debug" ,
"resume" ,
"--swap-id" ,
SWAP_ID ,
"--receive-address" ,
MONERO_MAINNET_ADDRESS ,
] ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
assert_eq! (
assert_eq! (
@ -843,8 +838,6 @@ mod tests {
"resume" ,
"resume" ,
"--swap-id" ,
"--swap-id" ,
SWAP_ID ,
SWAP_ID ,
"--receive-address" ,
MONERO_STAGENET_ADDRESS ,
] ;
] ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
@ -860,6 +853,8 @@ mod tests {
BINARY_NAME ,
BINARY_NAME ,
"--json" ,
"--json" ,
"buy-xmr" ,
"buy-xmr" ,
"--change-address" ,
BITCOIN_MAINNET_ADDRESS ,
"--receive-address" ,
"--receive-address" ,
MONERO_MAINNET_ADDRESS ,
MONERO_MAINNET_ADDRESS ,
"--seller" ,
"--seller" ,
@ -877,6 +872,8 @@ mod tests {
"--testnet" ,
"--testnet" ,
"--json" ,
"--json" ,
"buy-xmr" ,
"buy-xmr" ,
"--change-address" ,
BITCOIN_TESTNET_ADDRESS ,
"--receive-address" ,
"--receive-address" ,
MONERO_STAGENET_ADDRESS ,
MONERO_STAGENET_ADDRESS ,
"--seller" ,
"--seller" ,
@ -889,15 +886,7 @@ mod tests {
ParseResult ::Arguments ( Arguments ::buy_xmr_testnet_defaults ( ) . with_json ( ) )
ParseResult ::Arguments ( Arguments ::buy_xmr_testnet_defaults ( ) . with_json ( ) )
) ;
) ;
let raw_ars = vec! [
let raw_ars = vec! [ BINARY_NAME , "--json" , "resume" , "--swap-id" , SWAP_ID ] ;
BINARY_NAME ,
"--json" ,
"resume" ,
"--swap-id" ,
SWAP_ID ,
"--receive-address" ,
MONERO_MAINNET_ADDRESS ,
] ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
assert_eq! (
assert_eq! (
@ -912,8 +901,6 @@ mod tests {
"resume" ,
"resume" ,
"--swap-id" ,
"--swap-id" ,
SWAP_ID ,
SWAP_ID ,
"--receive-address" ,
MONERO_STAGENET_ADDRESS ,
] ;
] ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
let args = parse_args_and_apply_defaults ( raw_ars ) . unwrap ( ) ;
@ -935,6 +922,7 @@ mod tests {
bitcoin_electrum_rpc_url : Url ::from_str ( DEFAULT_ELECTRUM_RPC_URL_TESTNET )
bitcoin_electrum_rpc_url : Url ::from_str ( DEFAULT_ELECTRUM_RPC_URL_TESTNET )
. unwrap ( ) ,
. unwrap ( ) ,
bitcoin_target_block : DEFAULT_BITCOIN_CONFIRMATION_TARGET_TESTNET ,
bitcoin_target_block : DEFAULT_BITCOIN_CONFIRMATION_TARGET_TESTNET ,
bitcoin_change_address : BITCOIN_TESTNET_ADDRESS . parse ( ) . unwrap ( ) ,
monero_receive_address : monero ::Address ::from_str ( MONERO_STAGENET_ADDRESS )
monero_receive_address : monero ::Address ::from_str ( MONERO_STAGENET_ADDRESS )
. unwrap ( ) ,
. unwrap ( ) ,
monero_daemon_address : DEFAULT_MONERO_DAEMON_ADDRESS_STAGENET . to_string ( ) ,
monero_daemon_address : DEFAULT_MONERO_DAEMON_ADDRESS_STAGENET . to_string ( ) ,
@ -953,6 +941,7 @@ mod tests {
seller : Multiaddr ::from_str ( MULTI_ADDRESS ) . unwrap ( ) ,
seller : Multiaddr ::from_str ( MULTI_ADDRESS ) . unwrap ( ) ,
bitcoin_electrum_rpc_url : Url ::from_str ( DEFAULT_ELECTRUM_RPC_URL ) . unwrap ( ) ,
bitcoin_electrum_rpc_url : Url ::from_str ( DEFAULT_ELECTRUM_RPC_URL ) . unwrap ( ) ,
bitcoin_target_block : DEFAULT_BITCOIN_CONFIRMATION_TARGET ,
bitcoin_target_block : DEFAULT_BITCOIN_CONFIRMATION_TARGET ,
bitcoin_change_address : BITCOIN_MAINNET_ADDRESS . parse ( ) . unwrap ( ) ,
monero_receive_address : monero ::Address ::from_str ( MONERO_MAINNET_ADDRESS )
monero_receive_address : monero ::Address ::from_str ( MONERO_MAINNET_ADDRESS )
. unwrap ( ) ,
. unwrap ( ) ,
monero_daemon_address : DEFAULT_MONERO_DAEMON_ADDRESS . to_string ( ) ,
monero_daemon_address : DEFAULT_MONERO_DAEMON_ADDRESS . to_string ( ) ,
@ -972,8 +961,6 @@ mod tests {
bitcoin_electrum_rpc_url : Url ::from_str ( DEFAULT_ELECTRUM_RPC_URL_TESTNET )
bitcoin_electrum_rpc_url : Url ::from_str ( DEFAULT_ELECTRUM_RPC_URL_TESTNET )
. unwrap ( ) ,
. unwrap ( ) ,
bitcoin_target_block : DEFAULT_BITCOIN_CONFIRMATION_TARGET_TESTNET ,
bitcoin_target_block : DEFAULT_BITCOIN_CONFIRMATION_TARGET_TESTNET ,
monero_receive_address : monero ::Address ::from_str ( MONERO_STAGENET_ADDRESS )
. unwrap ( ) ,
monero_daemon_address : DEFAULT_MONERO_DAEMON_ADDRESS_STAGENET . to_string ( ) ,
monero_daemon_address : DEFAULT_MONERO_DAEMON_ADDRESS_STAGENET . to_string ( ) ,
tor_socks5_port : DEFAULT_SOCKS5_PORT ,
tor_socks5_port : DEFAULT_SOCKS5_PORT ,
} ,
} ,
@ -990,8 +977,6 @@ mod tests {
swap_id : Uuid ::from_str ( SWAP_ID ) . unwrap ( ) ,
swap_id : Uuid ::from_str ( SWAP_ID ) . unwrap ( ) ,
bitcoin_electrum_rpc_url : Url ::from_str ( DEFAULT_ELECTRUM_RPC_URL ) . unwrap ( ) ,
bitcoin_electrum_rpc_url : Url ::from_str ( DEFAULT_ELECTRUM_RPC_URL ) . unwrap ( ) ,
bitcoin_target_block : DEFAULT_BITCOIN_CONFIRMATION_TARGET ,
bitcoin_target_block : DEFAULT_BITCOIN_CONFIRMATION_TARGET ,
monero_receive_address : monero ::Address ::from_str ( MONERO_MAINNET_ADDRESS )
. unwrap ( ) ,
monero_daemon_address : DEFAULT_MONERO_DAEMON_ADDRESS . to_string ( ) ,
monero_daemon_address : DEFAULT_MONERO_DAEMON_ADDRESS . to_string ( ) ,
tor_socks5_port : DEFAULT_SOCKS5_PORT ,
tor_socks5_port : DEFAULT_SOCKS5_PORT ,
} ,
} ,