Implement Identify protocol to make network and version of ASB available to peers

This commit is contained in:
binarybaron 2022-04-17 19:57:34 +02:00
parent a962aa465d
commit 9e96ef64d3
11 changed files with 108 additions and 32 deletions

View file

@ -99,6 +99,7 @@ where
monero_receive_address,
monero_daemon_address,
tor_socks5_port,
namespace: XmrBtcNamespace::from_is_testnet(is_testnet),
},
}
}
@ -179,6 +180,7 @@ where
bitcoin_target_block,
monero_daemon_address,
tor_socks5_port,
namespace: XmrBtcNamespace::from_is_testnet(is_testnet),
},
}
}
@ -230,8 +232,8 @@ where
data_dir: data::data_dir_from(data, is_testnet)?,
cmd: Command::ListSellers {
rendezvous_point,
namespace: rendezvous_namespace_from(is_testnet),
tor_socks5_port,
namespace: XmrBtcNamespace::from_is_testnet(is_testnet),
},
},
RawCommand::ExportBitcoinWallet { bitcoin } => {
@ -273,6 +275,7 @@ pub enum Command {
monero_receive_address: monero::Address,
monero_daemon_address: String,
tor_socks5_port: u16,
namespace: XmrBtcNamespace,
},
History,
Config,
@ -292,6 +295,7 @@ pub enum Command {
bitcoin_target_block: usize,
monero_daemon_address: String,
tor_socks5_port: u16,
namespace: XmrBtcNamespace,
},
Cancel {
swap_id: Uuid,
@ -562,14 +566,6 @@ mod data {
}
}
fn rendezvous_namespace_from(is_testnet: bool) -> XmrBtcNamespace {
if is_testnet {
XmrBtcNamespace::Testnet
} else {
XmrBtcNamespace::Mainnet
}
}
fn env_config_from(testnet: bool) -> env::Config {
if testnet {
env::Testnet::get_config()
@ -1212,6 +1208,7 @@ mod tests {
.unwrap(),
monero_daemon_address: DEFAULT_MONERO_DAEMON_ADDRESS_STAGENET.to_string(),
tor_socks5_port: DEFAULT_SOCKS5_PORT,
namespace: XmrBtcNamespace::Testnet,
},
}
}
@ -1231,6 +1228,7 @@ mod tests {
.unwrap(),
monero_daemon_address: DEFAULT_MONERO_DAEMON_ADDRESS.to_string(),
tor_socks5_port: DEFAULT_SOCKS5_PORT,
namespace: XmrBtcNamespace::Mainnet,
},
}
}
@ -1248,6 +1246,7 @@ mod tests {
bitcoin_target_block: DEFAULT_BITCOIN_CONFIRMATION_TARGET_TESTNET,
monero_daemon_address: DEFAULT_MONERO_DAEMON_ADDRESS_STAGENET.to_string(),
tor_socks5_port: DEFAULT_SOCKS5_PORT,
namespace: XmrBtcNamespace::Testnet,
},
}
}
@ -1264,6 +1263,7 @@ mod tests {
bitcoin_target_block: DEFAULT_BITCOIN_CONFIRMATION_TARGET,
monero_daemon_address: DEFAULT_MONERO_DAEMON_ADDRESS.to_string(),
tor_socks5_port: DEFAULT_SOCKS5_PORT,
namespace: XmrBtcNamespace::Mainnet,
},
}
}