You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
Rust
56 lines
1.2 KiB
Rust
#![allow(non_snake_case)]
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use std::fmt::{self, Display};
|
|
|
|
pub mod alice;
|
|
pub mod bitcoin;
|
|
pub mod bob;
|
|
pub mod cli;
|
|
pub mod monero;
|
|
pub mod network;
|
|
pub mod recover;
|
|
pub mod state;
|
|
pub mod storage;
|
|
pub mod tor;
|
|
pub mod trace;
|
|
|
|
pub type Never = std::convert::Infallible;
|
|
|
|
/// Commands sent from Bob to the main task.
|
|
#[derive(Clone, Copy, Debug)]
|
|
pub enum Cmd {
|
|
VerifyAmounts(SwapAmounts),
|
|
}
|
|
|
|
/// Responses sent from the main task back to Bob.
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
pub enum Rsp {
|
|
VerifiedAmounts,
|
|
Abort,
|
|
}
|
|
|
|
/// XMR/BTC swap amounts.
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
|
// TODO(Franck): review necessity of this struct
|
|
pub struct SwapAmounts {
|
|
/// Amount of BTC to swap.
|
|
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
|
|
pub btc: bitcoin::Amount,
|
|
/// Amount of XMR to swap.
|
|
#[serde(with = "xmr_btc::serde::monero_amount")]
|
|
pub xmr: monero::Amount,
|
|
}
|
|
|
|
// TODO: Display in XMR and BTC (not picos and sats).
|
|
impl Display for SwapAmounts {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
write!(
|
|
f,
|
|
"{} sats for {} piconeros",
|
|
self.btc.as_sat(),
|
|
self.xmr.as_piconero()
|
|
)
|
|
}
|
|
}
|