diff --git a/Cargo.lock b/Cargo.lock index c74ca7bd..a342fd5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,6 +141,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "arrayvec" version = "0.7.4" @@ -884,8 +890,10 @@ checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-targets 0.52.6", ] @@ -2398,6 +2406,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "hex_fmt" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" + [[package]] name = "hmac" version = "0.11.0" @@ -2931,7 +2945,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" dependencies = [ "anyhow", - "arrayvec", + "arrayvec 0.7.4", "async-lock", "async-trait", "beef", @@ -3122,7 +3136,9 @@ dependencies = [ "lazy_static", "libp2p-core", "libp2p-dns", + "libp2p-gossipsub", "libp2p-identify", + "libp2p-kad", "libp2p-metrics", "libp2p-mplex", "libp2p-noise", @@ -3167,6 +3183,7 @@ dependencies = [ "rand 0.8.5", "ring 0.16.20", "rw-stream-sink", + "serde", "sha2 0.10.8", "smallvec", "thiserror", @@ -3188,6 +3205,36 @@ dependencies = [ "trust-dns-resolver", ] +[[package]] +name = "libp2p-gossipsub" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385ae5f44e84f51e17014c9f1d98464121d3b1b182c167a0b4482d6250c61926" +dependencies = [ + "asynchronous-codec", + "base64 0.13.1", + "byteorder", + "bytes", + "fnv", + "futures", + "futures-timer", + "hex_fmt", + "instant", + "libp2p-core", + "libp2p-swarm", + "log", + "open-metrics-client", + "pin-project 1.1.5", + "prost", + "prost-build", + "rand 0.7.3", + "regex", + "serde", + "sha2 0.10.8", + "smallvec", + "unsigned-varint", +] + [[package]] name = "libp2p-identify" version = "0.33.0" @@ -3205,6 +3252,35 @@ dependencies = [ "smallvec", ] +[[package]] +name = "libp2p-kad" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eeaa28a4c7a8c574874e090c2a731ecc7b81595911fee425b552c799a20abbb" +dependencies = [ + "arrayvec 0.5.2", + "asynchronous-codec", + "bytes", + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-swarm", + "log", + "prost", + "prost-build", + "rand 0.7.3", + "serde", + "sha2 0.10.8", + "smallvec", + "thiserror", + "uint", + "unsigned-varint", + "void", +] + [[package]] name = "libp2p-metrics" version = "0.3.0" @@ -3751,6 +3827,7 @@ dependencies = [ "digest 0.9.0", "generic-array", "multihash-derive", + "serde", "sha2 0.9.9", "unsigned-varint", ] @@ -5120,7 +5197,7 @@ version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1790d1c4c0ca81211399e0e0af16333276f375209e71a37b67698a373db5b47a" dependencies = [ - "arrayvec", + "arrayvec 0.7.4", "borsh", "bytes", "num-traits", @@ -6396,6 +6473,7 @@ dependencies = [ "sqlx", "structopt", "strum", + "tauri", "tempfile", "testcontainers", "thiserror", @@ -6413,6 +6491,7 @@ dependencies = [ "tracing-appender", "tracing-futures", "tracing-subscriber 0.3.18", + "typeshare", "url", "uuid", "vergen", @@ -7437,6 +7516,28 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "typeshare" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04f17399b76c2e743d58eac0635d7686e9c00f48cd4776f00695d9882a7d3187" +dependencies = [ + "chrono", + "serde", + "serde_json", + "typeshare-annotation", +] + +[[package]] +name = "typeshare-annotation" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a615d6c2764852a2e88a4f16e9ce1ea49bb776b5872956309e170d63a042a34f" +dependencies = [ + "quote", + "syn 2.0.69", +] + [[package]] name = "ucd-trie" version = "0.1.6" diff --git a/README.md b/README.md index f60bcb1c..5e711674 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # `xmr-btc-swap` This is the monorepo containing the source code for all of our core projects: - - [`swap`](swap/README.md) contains the source code for the main swapping binaries, `asb` and `swap` - - [`gui`](src-gui/README.md) contains the new tauri based user interface - - [`tauri`](src-tauri/) contains the tauri bindings between binaries and user interface - - and other crates we use in our binaries -If you're just here for the software, head over to the [releases](https://github.com/UnstoppableSwap/xmr-btc-swap/releases/latest) tab and grab the binary for your operating system! If you're just looking for documentation, check out our [docs page](https://docs.unstoppableswap.net/) or our [github docs](docs/README.md). +- [`swap`](swap/README.md) contains the source code for the main swapping binaries, `asb` and `swap` +- [`gui`](src-gui/README.md) contains the new tauri based user interface +- [`tauri`](src-tauri/) contains the tauri bindings between binaries and user interface +- and other crates we use in our binaries + +If you're just here for the software, head over to the [releases](https://github.com/UnstoppableSwap/xmr-btc-swap/releases/latest) tab and grab the binary for your operating system! If you're just looking for documentation, check out our [docs page](https://docs.unstoppableswap.net/) or our [github docs](docs/README.md). diff --git a/docs/asb/README.md b/docs/asb/README.md index 88448b71..ccaa4279 100644 --- a/docs/asb/README.md +++ b/docs/asb/README.md @@ -172,7 +172,11 @@ First use `swap` or `asb` with the `export-bitcoin-wallet` subcommand. Output example: ```json -{"descriptor":"wpkh(tprv8Zgredacted.../84'/1'/0'/0/*)","blockheight":2415616,"label":"asb-testnet"} +{ + "descriptor": "wpkh(tprv8Zgredacted.../84'/1'/0'/0/*)", + "blockheight": 2415616, + "label": "asb-testnet" +} ``` The wallet can theoretically be directly imported into diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index aa1c0467..2e50a840 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -44,9 +44,12 @@ macro_rules! tauri_command { context: tauri::State<'_, Arc>, args: $request_name, ) -> Result<<$request_name as swap::cli::api::request::Request>::Response, String> { - <$request_name as swap::cli::api::request::Request>::request(args, context.inner().clone()) - .await - .to_string_result() + <$request_name as swap::cli::api::request::Request>::request( + args, + context.inner().clone(), + ) + .await + .to_string_result() } }; } diff --git a/swap/src/api/request.rs b/swap/src/api/request.rs index 0d7a37b9..d28b34df 100644 --- a/swap/src/api/request.rs +++ b/swap/src/api/request.rs @@ -27,8 +27,8 @@ use tracing::Instrument; use typeshare::typeshare; use uuid::Uuid; -/// This trait is implemented by all types of request args that -/// the CLI can handle. +/// This trait is implemented by all types of request args that +/// the CLI can handle. /// It provides a unified abstraction that can be useful for generics. #[allow(async_fn_in_trait)] pub trait Request { diff --git a/swap/src/cli.rs b/swap/src/cli.rs index a87f19cf..879775bd 100644 --- a/swap/src/cli.rs +++ b/swap/src/cli.rs @@ -1,3 +1,4 @@ +pub mod api; mod behaviour; pub mod cancel_and_refund; pub mod command; @@ -5,7 +6,6 @@ mod event_loop; mod list_sellers; pub mod tracing; pub mod transport; -pub mod api; pub use behaviour::{Behaviour, OutEvent}; pub use cancel_and_refund::{cancel, cancel_and_refund, refund}; diff --git a/swap/src/cli/api/request.rs b/swap/src/cli/api/request.rs index 8c2fa6fa..c8b8aab6 100644 --- a/swap/src/cli/api/request.rs +++ b/swap/src/cli/api/request.rs @@ -1,7 +1,7 @@ use super::tauri_bindings::TauriHandle; +use crate::bitcoin::{CancelTimelock, ExpiredTimelocks, PunishTimelock, TxLock}; use crate::cli::api::tauri_bindings::{TauriEmitter, TauriSwapProgressEvent}; use crate::cli::api::Context; -use crate::bitcoin::{CancelTimelock, ExpiredTimelocks, PunishTimelock, TxLock}; use crate::cli::{list_sellers as list_sellers_impl, EventLoop, SellerStatus}; use crate::libp2p_ext::MultiAddrExt; use crate::network::quote::{BidQuote, ZeroQuoteReceived}; diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs index e78a4666..d6cbd56a 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -1,10 +1,10 @@ +use crate::bitcoin::{bitcoin_address, Amount}; use crate::cli::api::request::{ BalanceArgs, BuyXmrArgs, CancelAndRefundArgs, ExportBitcoinWalletArgs, GetConfigArgs, GetHistoryArgs, ListSellersArgs, MoneroRecoveryArgs, Request, ResumeSwapArgs, StartDaemonArgs, WithdrawBtcArgs, }; use crate::cli::api::Context; -use crate::bitcoin::{bitcoin_address, Amount}; use crate::monero; use crate::monero::monero_address; use anyhow::Result; diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 0d01228d..631e5bd2 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -1,5 +1,5 @@ -use crate::cli::api::tauri_bindings::{TauriEmitter, TauriHandle, TauriSwapProgressEvent}; use crate::bitcoin::{ExpiredTimelocks, TxCancel, TxRefund}; +use crate::cli::api::tauri_bindings::{TauriEmitter, TauriHandle, TauriSwapProgressEvent}; use crate::cli::EventLoopHandle; use crate::network::cooperative_xmr_redeem_after_punish::Response::{Fullfilled, Rejected}; use crate::network::swap_setup::bob::NewSwap; diff --git a/swap/src/rpc/methods.rs b/swap/src/rpc/methods.rs index a239733e..76d1f4b0 100644 --- a/swap/src/rpc/methods.rs +++ b/swap/src/rpc/methods.rs @@ -1,10 +1,10 @@ +use crate::bitcoin::bitcoin_address; use crate::cli::api::request::{ get_current_swap, get_history, get_raw_states, suspend_current_swap, BalanceArgs, BuyXmrArgs, CancelAndRefundArgs, GetSwapInfoArgs, ListSellersArgs, MoneroRecoveryArgs, Request, ResumeSwapArgs, WithdrawBtcArgs, }; use crate::cli::api::Context; -use crate::bitcoin::bitcoin_address; use crate::monero::monero_address; use crate::{bitcoin, monero}; use anyhow::Result;