mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-17 09:34:16 -05:00
* mvp * only redial if DisconnectedAndNotDialing * progress * progress * progress * some progress * progress * extract common logic into behaviour_util::ConnectionTracker * extract common logic into BackoffTracker helper struct * add comment in quote::background behaviour * BackoffTracker rename get_backoff to get(...) * cleanup, fix some things that got lost during rebase * properly propagate quote::background ToSwarm events * actually persist event loop, add quotes and rendezvous::discovery to cli behaviour * some progress, cleanup, comments * progress * redial all peers that we dont know dont support quote, use quotes_cached behaviour in example, add remove_peer(...) to redial behaviour, don't redial discovered rendezvous peers * remove old todo * quotes_cached.rs: cache last connected endpoint * rename: add_peer_address -> queue_peer_address * extract p2p defaults into swap-p2p/defaults.rs * split rendezvous.rs into two sub-modules * remove unused bob::BackgroundQuoteReceived * replace usage of list_sellers with event loop * prune: remove list_sellers command * use backoff helper in swap-p2p/src/protocols/quotes.rs * refactor rendezvous::register behaviour, getting some unit tests working again * add all peer addresses to the swarm on init * less agressive redials * extract magic backoff numbers * proof of concept: drill tracing span into event loop through channels * add BackoffTracker::increment, re-schedule register when we lose connection to rendezvous point * fetch identify version and propagate into UI * forbid private/local/loopback ip addresses to be shared/accepted through Identify * remove legacy list_sellers code * ensure uuids are unique for alice during swap_setup * formatting and nitpicks * fix: allow multiple swap setup requests over the same connection handler * small cleanups * fix: protocols/quotes.rs unit tests * revert: listen on 0.0.0.0 for asb p2p * propagate handle_pending_inbound_connection and handle_pending_outbound_connection to identify patch source * replace loop with repeated return Poll::Ready in discovery.rs * format * MultiAddrVecExt trait, emit rendezvous addresses to rendezvous-node swarm * fix: strictly disallow concurrent swap setup requests for the same swap on the same connection * fix tests etc * remove slop from futures_util.rs * address some comments * behaviour_util.rs: track inflight dials, add tests, return Some(peer_id) if internal state was changed * replace boring-avatars with jidenticon * feat: add peer discovery status dialog * remove buy-xmr cli command, remove "sellers" arg for BuyXmrArgs, add changelog * disable body overscroll * add changelog for jidenticon * increase quote fetch interval to 45s * fix rendezvous::register_and_discover_together test
103 lines
3.2 KiB
Rust
103 lines
3.2 KiB
Rust
use jsonrpsee::proc_macros::rpc;
|
|
use jsonrpsee::types::ErrorObjectOwned;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct BitcoinBalanceResponse {
|
|
#[serde(with = "bitcoin::amount::serde::as_sat")]
|
|
pub balance: bitcoin::Amount,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct BitcoinSeedResponse {
|
|
pub descriptor: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct MoneroBalanceResponse {
|
|
pub balance: u64,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct MoneroAddressResponse {
|
|
pub address: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct MultiaddressesResponse {
|
|
pub multiaddresses: Vec<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct PeerIdResponse {
|
|
pub peer_id: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct ActiveConnectionsResponse {
|
|
pub connections: usize,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub enum RendezvousConnectionStatus {
|
|
Connected,
|
|
Disconnected,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub enum RendezvousRegistrationStatus {
|
|
Registered,
|
|
WillRegisterAfterDelay,
|
|
RegisterOnceConnected,
|
|
RequestInflight,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct RegistrationStatusItem {
|
|
pub address: Option<String>,
|
|
pub connection: RendezvousConnectionStatus,
|
|
pub registration: RendezvousRegistrationStatus,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct RegistrationStatusResponse {
|
|
pub registrations: Vec<RegistrationStatusItem>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct Swap {
|
|
pub id: String,
|
|
pub state: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct MoneroSeedResponse {
|
|
pub seed: String,
|
|
pub restore_height: u64,
|
|
}
|
|
|
|
#[rpc(client, server)]
|
|
pub trait AsbApi {
|
|
#[method(name = "check_connection")]
|
|
async fn check_connection(&self) -> Result<(), ErrorObjectOwned>;
|
|
#[method(name = "bitcoin_balance")]
|
|
async fn bitcoin_balance(&self) -> Result<BitcoinBalanceResponse, ErrorObjectOwned>;
|
|
#[method(name = "bitcoin_seed")]
|
|
async fn bitcoin_seed(&self) -> Result<BitcoinSeedResponse, ErrorObjectOwned>;
|
|
#[method(name = "monero_balance")]
|
|
async fn monero_balance(&self) -> Result<MoneroBalanceResponse, ErrorObjectOwned>;
|
|
#[method(name = "monero_address")]
|
|
async fn monero_address(&self) -> Result<MoneroAddressResponse, ErrorObjectOwned>;
|
|
#[method(name = "monero_seed")]
|
|
async fn monero_seed(&self) -> Result<MoneroSeedResponse, ErrorObjectOwned>;
|
|
#[method(name = "multiaddresses")]
|
|
async fn multiaddresses(&self) -> Result<MultiaddressesResponse, ErrorObjectOwned>;
|
|
#[method(name = "peer_id")]
|
|
async fn peer_id(&self) -> Result<PeerIdResponse, ErrorObjectOwned>;
|
|
#[method(name = "active_connections")]
|
|
async fn active_connections(&self) -> Result<ActiveConnectionsResponse, ErrorObjectOwned>;
|
|
#[method(name = "get_swaps")]
|
|
async fn get_swaps(&self) -> Result<Vec<Swap>, ErrorObjectOwned>;
|
|
#[method(name = "registration_status")]
|
|
async fn registration_status(&self) -> Result<RegistrationStatusResponse, ErrorObjectOwned>;
|
|
}
|