diff --git a/swap/src/asb/fixed_rate.rs b/swap/src/asb/fixed_rate.rs index 31ce83bf..53d42308 100644 --- a/swap/src/asb/fixed_rate.rs +++ b/swap/src/asb/fixed_rate.rs @@ -1,4 +1,5 @@ use crate::asb::{LatestRate, Rate}; +use anyhow::Result; pub const RATE: f64 = 0.01; @@ -8,7 +9,7 @@ pub struct RateService(Rate); impl LatestRate for RateService { type Error = anyhow::Error; - fn latest_rate(&mut self) -> anyhow::Result { + fn latest_rate(&mut self) -> Result { Ok(self.0) } } diff --git a/swap/src/asb/kraken.rs b/swap/src/asb/kraken.rs index 6113fabb..f1f38732 100644 --- a/swap/src/asb/kraken.rs +++ b/swap/src/asb/kraken.rs @@ -1,4 +1,5 @@ use crate::asb::{LatestRate, Rate}; +use anyhow::Result; use bitcoin::util::amount::ParseAmountError; use futures::{SinkExt, StreamExt}; use reqwest::Url; @@ -64,7 +65,7 @@ impl From for Error { } impl RateService { - pub async fn new() -> anyhow::Result { + pub async fn new() -> Result { let (tx, rx) = watch::channel(Err(Error::NotYetRetrieved)); let (ws, _response) = diff --git a/swap/src/bitcoin.rs b/swap/src/bitcoin.rs index f308574a..9d12d8b6 100644 --- a/swap/src/bitcoin.rs +++ b/swap/src/bitcoin.rs @@ -283,7 +283,7 @@ pub async fn current_epoch( cancel_timelock: CancelTimelock, punish_timelock: PunishTimelock, lock_tx_id: ::bitcoin::Txid, -) -> anyhow::Result +) -> Result where W: WatchForRawTransaction + TransactionBlockHeight + GetBlockHeight, { diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs index 1b4c8f45..88348f21 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -1,4 +1,5 @@ use crate::bitcoin; +use anyhow::Result; use libp2p::{core::Multiaddr, PeerId}; use std::path::PathBuf; use uuid::Uuid; @@ -85,7 +86,7 @@ pub enum Refund { }, } -fn parse_btc(str: &str) -> anyhow::Result { +fn parse_btc(str: &str) -> Result { let amount = bitcoin::Amount::from_str_in(str, ::bitcoin::Denomination::Bitcoin)?; Ok(amount) } diff --git a/swap/src/database.rs b/swap/src/database.rs index 33c02b0c..8d963918 100644 --- a/swap/src/database.rs +++ b/swap/src/database.rs @@ -65,7 +65,7 @@ impl Database { .context("Could not flush db") } - pub fn get_state(&self, swap_id: Uuid) -> anyhow::Result { + pub fn get_state(&self, swap_id: Uuid) -> Result { let key = serialize(&swap_id)?; let encoded = self @@ -97,14 +97,14 @@ impl Database { } } -pub fn serialize(t: &T) -> anyhow::Result> +pub fn serialize(t: &T) -> Result> where T: Serialize, { Ok(serde_cbor::to_vec(t)?) } -pub fn deserialize(v: &[u8]) -> anyhow::Result +pub fn deserialize(v: &[u8]) -> Result where T: DeserializeOwned, { diff --git a/swap/src/fs.rs b/swap/src/fs.rs index fc4dedbe..38be1bca 100644 --- a/swap/src/fs.rs +++ b/swap/src/fs.rs @@ -1,4 +1,4 @@ -use anyhow::Context; +use anyhow::{Context, Result}; use directories_next::ProjectDirs; use std::path::{Path, PathBuf}; @@ -9,7 +9,7 @@ fn default_config_dir() -> Option { ProjectDirs::from("", "", "xmr-btc-swap").map(|proj_dirs| proj_dirs.config_dir().to_path_buf()) } -pub fn default_config_path() -> anyhow::Result { +pub fn default_config_path() -> Result { default_config_dir() .map(|dir| Path::join(&dir, "config.toml")) .context("Could not generate default configuration path") diff --git a/swap/src/monero.rs b/swap/src/monero.rs index da2c6994..a01c68c3 100644 --- a/swap/src/monero.rs +++ b/swap/src/monero.rs @@ -186,7 +186,7 @@ pub trait Transfer { public_spend_key: PublicKey, public_view_key: PublicViewKey, amount: Amount, - ) -> anyhow::Result<(TransferProof, Amount)>; + ) -> Result<(TransferProof, Amount)>; } #[async_trait] @@ -215,17 +215,17 @@ pub trait CreateWalletForOutput { private_spend_key: PrivateKey, private_view_key: PrivateViewKey, restore_height: Option, - ) -> anyhow::Result<()>; + ) -> Result<()>; } #[async_trait] pub trait OpenWallet { - async fn open_wallet(&self, file_name: &str) -> anyhow::Result<()>; + async fn open_wallet(&self, file_name: &str) -> Result<()>; } #[async_trait] pub trait CreateWallet { - async fn create_wallet(&self, file_name: &str) -> anyhow::Result<()>; + async fn create_wallet(&self, file_name: &str) -> Result<()>; } #[derive(thiserror::Error, Debug, Clone, PartialEq)] diff --git a/swap/src/protocol/alice/behaviour.rs b/swap/src/protocol/alice/behaviour.rs index eef2350c..8aa59904 100644 --- a/swap/src/protocol/alice/behaviour.rs +++ b/swap/src/protocol/alice/behaviour.rs @@ -119,7 +119,7 @@ impl Behaviour { &mut self, channel: ResponseChannel, quote_response: QuoteResponse, - ) -> anyhow::Result<()> { + ) -> Result<()> { self.quote_response.send(channel, quote_response)?; info!("Sent quote response"); Ok(()) diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index 5f33db16..ee30275f 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -140,7 +140,7 @@ impl State0 { } } - pub async fn receive(self, wallet: &W, msg: Message1) -> anyhow::Result + pub async fn receive(self, wallet: &W, msg: Message1) -> Result where W: BuildTxLockPsbt + GetNetwork, { diff --git a/swap/src/trace.rs b/swap/src/trace.rs index 252d57fc..d711c148 100644 --- a/swap/src/trace.rs +++ b/swap/src/trace.rs @@ -1,10 +1,11 @@ +use anyhow::Result; use atty::{self}; use log::LevelFilter; use tracing::{info, subscriber}; use tracing_log::LogTracer; use tracing_subscriber::FmtSubscriber; -pub fn init_tracing(level: LevelFilter) -> anyhow::Result<()> { +pub fn init_tracing(level: LevelFilter) -> Result<()> { if level == LevelFilter::Off { return Ok(()); } diff --git a/swap/tests/testutils/mod.rs b/swap/tests/testutils/mod.rs index ad2a3550..02464e39 100644 --- a/swap/tests/testutils/mod.rs +++ b/swap/tests/testutils/mod.rs @@ -84,7 +84,7 @@ pub struct TestContext { alice_starting_balances: StartingBalances, alice_bitcoin_wallet: Arc, alice_monero_wallet: Arc, - alice_swap_handle: mpsc::Receiver>>, + alice_swap_handle: mpsc::Receiver>>, bob_params: BobParams, bob_starting_balances: StartingBalances,