mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-18 10:02:45 -05:00
feat(asb): add peer-id command to asb-controller (#754)
* add peer-id command to controller * add peer-id command to changelog * nitpick: add some more context to peer id command --------- Co-authored-by: Binarybaron <binarybaron@protonmail.com>
This commit is contained in:
parent
ea94437315
commit
8fe2c2ad7e
5 changed files with 32 additions and 2 deletions
|
|
@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- ASB + CONTROLLER: Add the `peer-id` command to the controller shell which can be used to obtain the Peer ID of your ASB instance.
|
||||||
|
|
||||||
## [3.3.7] - 2025-11-19
|
## [3.3.7] - 2025-11-19
|
||||||
|
|
||||||
- ORCHESTRATOR + ASB: Support for tunneling both the Bitcoin and Monero node over Tor has been added (thanks to @nabijaczleweli)
|
- ORCHESTRATOR + ASB: Support for tunneling both the Bitcoin and Monero node over Tor has been added (thanks to @nabijaczleweli)
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@ pub struct MultiaddressesResponse {
|
||||||
pub multiaddresses: Vec<String>,
|
pub multiaddresses: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct PeerIdResponse {
|
||||||
|
pub peer_id: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct ActiveConnectionsResponse {
|
pub struct ActiveConnectionsResponse {
|
||||||
pub connections: usize,
|
pub connections: usize,
|
||||||
|
|
@ -87,6 +92,8 @@ pub trait AsbApi {
|
||||||
async fn monero_seed(&self) -> Result<MoneroSeedResponse, ErrorObjectOwned>;
|
async fn monero_seed(&self) -> Result<MoneroSeedResponse, ErrorObjectOwned>;
|
||||||
#[method(name = "multiaddresses")]
|
#[method(name = "multiaddresses")]
|
||||||
async fn multiaddresses(&self) -> Result<MultiaddressesResponse, ErrorObjectOwned>;
|
async fn multiaddresses(&self) -> Result<MultiaddressesResponse, ErrorObjectOwned>;
|
||||||
|
#[method(name = "peer_id")]
|
||||||
|
async fn peer_id(&self) -> Result<PeerIdResponse, ErrorObjectOwned>;
|
||||||
#[method(name = "active_connections")]
|
#[method(name = "active_connections")]
|
||||||
async fn active_connections(&self) -> Result<ActiveConnectionsResponse, ErrorObjectOwned>;
|
async fn active_connections(&self) -> Result<ActiveConnectionsResponse, ErrorObjectOwned>;
|
||||||
#[method(name = "get_swaps")]
|
#[method(name = "get_swaps")]
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ pub enum Cmd {
|
||||||
MoneroSeed,
|
MoneroSeed,
|
||||||
/// Get external multiaddresses
|
/// Get external multiaddresses
|
||||||
Multiaddresses,
|
Multiaddresses,
|
||||||
|
/// Get peer ID
|
||||||
|
PeerId,
|
||||||
/// Get active connection count
|
/// Get active connection count
|
||||||
ActiveConnections,
|
ActiveConnections,
|
||||||
/// Get list of swaps
|
/// Get list of swaps
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,13 @@ async fn dispatch(cmd: Cmd, client: impl AsbApiClient) -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Cmd::PeerId => {
|
||||||
|
let response = client.peer_id().await?;
|
||||||
|
println!("Peer IDs are used to identify peers within the P2P network.");
|
||||||
|
println!("They are effectively the hash of your public key and are used for end-to-end encryption of network traffic.");
|
||||||
|
println!();
|
||||||
|
println!("Your Peer ID is: {}", response.peer_id);
|
||||||
|
}
|
||||||
Cmd::ActiveConnections => {
|
Cmd::ActiveConnections => {
|
||||||
let response = client.active_connections().await?;
|
let response = client.active_connections().await?;
|
||||||
println!("Connected to {} peers", response.connections);
|
println!("Connected to {} peers", response.connections);
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ use std::sync::Arc;
|
||||||
use swap_controller_api::{
|
use swap_controller_api::{
|
||||||
ActiveConnectionsResponse, AsbApiServer, BitcoinBalanceResponse, BitcoinSeedResponse,
|
ActiveConnectionsResponse, AsbApiServer, BitcoinBalanceResponse, BitcoinSeedResponse,
|
||||||
MoneroAddressResponse, MoneroBalanceResponse, MoneroSeedResponse, MultiaddressesResponse,
|
MoneroAddressResponse, MoneroBalanceResponse, MoneroSeedResponse, MultiaddressesResponse,
|
||||||
RegistrationStatusItem, RegistrationStatusResponse, RendezvousConnectionStatus,
|
PeerIdResponse, RegistrationStatusItem, RegistrationStatusResponse,
|
||||||
RendezvousRegistrationStatus, Swap,
|
RendezvousConnectionStatus, RendezvousRegistrationStatus, Swap,
|
||||||
};
|
};
|
||||||
use tokio_util::task::AbortOnDropHandle;
|
use tokio_util::task::AbortOnDropHandle;
|
||||||
|
|
||||||
|
|
@ -131,6 +131,18 @@ impl AsbApiServer for RpcImpl {
|
||||||
Ok(MultiaddressesResponse { multiaddresses })
|
Ok(MultiaddressesResponse { multiaddresses })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn peer_id(&self) -> Result<PeerIdResponse, ErrorObjectOwned> {
|
||||||
|
let (peer_id, _) = self
|
||||||
|
.event_loop_service
|
||||||
|
.get_multiaddresses()
|
||||||
|
.await
|
||||||
|
.into_json_rpc_result()?;
|
||||||
|
|
||||||
|
Ok(PeerIdResponse {
|
||||||
|
peer_id: peer_id.to_string(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async fn active_connections(&self) -> Result<ActiveConnectionsResponse, ErrorObjectOwned> {
|
async fn active_connections(&self) -> Result<ActiveConnectionsResponse, ErrorObjectOwned> {
|
||||||
let connections = self
|
let connections = self
|
||||||
.event_loop_service
|
.event_loop_service
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue