From e7ff02958dbf96e95cbc1fae3ecc2bf51a57c22a Mon Sep 17 00:00:00 2001 From: Binarybaron Date: Sat, 11 Oct 2025 15:27:50 +0200 Subject: [PATCH] dprint fmt --- .../monero/components/WalletActionButtons.tsx | 6 +++++- swap-asb/Cargo.toml | 2 +- swap-core/src/bitcoin.rs | 8 ++++---- swap-core/src/bitcoin/cancel.rs | 6 +++--- swap-core/src/bitcoin/early_refund.rs | 4 ++-- swap-core/src/bitcoin/lock.rs | 8 ++++---- swap-core/src/bitcoin/punish.rs | 2 +- swap-core/src/bitcoin/redeem.rs | 12 ++++++------ swap-core/src/bitcoin/refund.rs | 10 +++++----- swap-core/src/monero/primitives.rs | 14 ++++++++------ swap-env/src/config.rs | 2 +- swap-env/src/prompt.rs | 8 ++++---- swap-machine/src/alice/mod.rs | 10 +++++----- swap-machine/src/bob/mod.rs | 12 ++++++------ swap-machine/src/common/mod.rs | 6 +++--- swap-orchestrator/Cargo.toml | 2 +- swap-orchestrator/src/main.rs | 4 ++-- swap-orchestrator/src/prompt.rs | 2 +- swap-serde/src/electrum.rs | 2 +- swap-serde/src/libp2p.rs | 2 +- swap-serde/src/monero.rs | 6 +++--- throttle/src/throttle.rs | 2 +- utils/gpg_keys/readme.md | 2 +- 23 files changed, 69 insertions(+), 63 deletions(-) diff --git a/src-gui/src/renderer/components/pages/monero/components/WalletActionButtons.tsx b/src-gui/src/renderer/components/pages/monero/components/WalletActionButtons.tsx index 0cbc49c3..31825c6b 100644 --- a/src-gui/src/renderer/components/pages/monero/components/WalletActionButtons.tsx +++ b/src-gui/src/renderer/components/pages/monero/components/WalletActionButtons.tsx @@ -101,7 +101,11 @@ export default function WalletActionButtons({ - + { setRestoreHeightDialogOpen(true); diff --git a/swap-asb/Cargo.toml b/swap-asb/Cargo.toml index 1a96a163..ac6b1027 100644 --- a/swap-asb/Cargo.toml +++ b/swap-asb/Cargo.toml @@ -24,8 +24,8 @@ monero-sys = { path = "../monero-sys" } swap = { path = "../swap" } swap-env = { path = "../swap-env" } swap-feed = { path = "../swap-feed" } +swap-machine = { path = "../swap-machine" } swap-serde = { path = "../swap-serde" } -swap-machine = { path = "../swap-machine"} # Async tokio = { workspace = true, features = ["process", "fs", "net", "parking_lot", "rt"] } diff --git a/swap-core/src/bitcoin.rs b/swap-core/src/bitcoin.rs index 42d4e480..3a842e87 100644 --- a/swap-core/src/bitcoin.rs +++ b/swap-core/src/bitcoin.rs @@ -16,21 +16,21 @@ pub use crate::bitcoin::timelocks::{BlockHeight, ExpiredTimelocks}; pub use ::bitcoin::amount::Amount; pub use ::bitcoin::psbt::Psbt as PartiallySignedTransaction; pub use ::bitcoin::{Address, AddressType, Network, Transaction, Txid}; -pub use ecdsa_fun::Signature; pub use ecdsa_fun::adaptor::EncryptedSignature; pub use ecdsa_fun::fun::Scalar; +pub use ecdsa_fun::Signature; use ::bitcoin::hashes::Hash; use ::bitcoin::secp256k1::ecdsa; use ::bitcoin::sighash::SegwitV0Sighash as Sighash; -use anyhow::{Context, Result, bail}; +use anyhow::{bail, Context, Result}; use bdk_wallet::miniscript::descriptor::Wsh; use bdk_wallet::miniscript::{Descriptor, Segwitv0}; use bitcoin_wallet::primitives::ScriptStatus; -use ecdsa_fun::ECDSA; use ecdsa_fun::adaptor::{Adaptor, HashTranscript}; use ecdsa_fun::fun::Point; use ecdsa_fun::nonce::Deterministic; +use ecdsa_fun::ECDSA; use rand::{CryptoRng, RngCore}; use serde::{Deserialize, Serialize}; use sha2::Sha256; @@ -261,8 +261,8 @@ pub fn current_epoch( pub mod bitcoin_address { use anyhow::{Context, Result}; use bitcoin::{ - Address, address::{NetworkChecked, NetworkUnchecked}, + Address, }; use serde::Serialize; use std::str::FromStr; diff --git a/swap-core/src/bitcoin/cancel.rs b/swap-core/src/bitcoin/cancel.rs index e76686a1..8a523757 100644 --- a/swap-core/src/bitcoin/cancel.rs +++ b/swap-core/src/bitcoin/cancel.rs @@ -1,13 +1,13 @@ use crate::bitcoin; use crate::bitcoin::{ - Address, Amount, BlockHeight, PublicKey, Transaction, TxLock, build_shared_output_descriptor, + build_shared_output_descriptor, Address, Amount, BlockHeight, PublicKey, Transaction, TxLock, }; -use ::bitcoin::Weight; use ::bitcoin::sighash::SighashCache; use ::bitcoin::transaction::Version; +use ::bitcoin::Weight; use ::bitcoin::{ - EcdsaSighashType, OutPoint, ScriptBuf, Sequence, TxIn, TxOut, Txid, locktime::absolute::LockTime as PackedLockTime, secp256k1, sighash::SegwitV0Sighash as Sighash, + EcdsaSighashType, OutPoint, ScriptBuf, Sequence, TxIn, TxOut, Txid, }; use anyhow::Result; use bdk_wallet::miniscript::Descriptor; diff --git a/swap-core/src/bitcoin/early_refund.rs b/swap-core/src/bitcoin/early_refund.rs index 4d4be9dc..94e49a6d 100644 --- a/swap-core/src/bitcoin/early_refund.rs +++ b/swap-core/src/bitcoin/early_refund.rs @@ -1,7 +1,7 @@ use crate::bitcoin; use ::bitcoin::sighash::SighashCache; -use ::bitcoin::{EcdsaSighashType, Txid, sighash::SegwitV0Sighash as Sighash}; -use ::bitcoin::{ScriptBuf, secp256k1}; +use ::bitcoin::{secp256k1, ScriptBuf}; +use ::bitcoin::{sighash::SegwitV0Sighash as Sighash, EcdsaSighashType, Txid}; use anyhow::{Context, Result}; use bdk_wallet::miniscript::Descriptor; use bitcoin::{Address, Amount, Transaction}; diff --git a/swap-core/src/bitcoin/lock.rs b/swap-core/src/bitcoin/lock.rs index 07ad653f..aebd7cfb 100644 --- a/swap-core/src/bitcoin/lock.rs +++ b/swap-core/src/bitcoin/lock.rs @@ -1,10 +1,10 @@ -use crate::bitcoin::{Address, Amount, PublicKey, Transaction, build_shared_output_descriptor}; +use crate::bitcoin::{build_shared_output_descriptor, Address, Amount, PublicKey, Transaction}; use ::bitcoin::psbt::Psbt as PartiallySignedTransaction; use ::bitcoin::{OutPoint, TxIn, TxOut, Txid}; -use anyhow::{Context, Result, bail}; +use anyhow::{bail, Context, Result}; use bdk_wallet::miniscript::Descriptor; use bdk_wallet::psbt::PsbtUtils; -use bitcoin::{ScriptBuf, Sequence, locktime::absolute::LockTime as PackedLockTime}; +use bitcoin::{locktime::absolute::LockTime as PackedLockTime, ScriptBuf, Sequence}; use bitcoin_wallet::primitives::Watchable; use serde::{Deserialize, Serialize}; @@ -195,8 +195,8 @@ impl Watchable for TxLock { #[cfg(test)] mod tests { use super::*; - use crate::bitcoin::Amount; use crate::bitcoin::wallet::TestWalletBuilder; + use crate::bitcoin::Amount; use ::bitcoin::psbt::Psbt as PartiallySignedTransaction; // Basic setup function for tests diff --git a/swap-core/src/bitcoin/punish.rs b/swap-core/src/bitcoin/punish.rs index d4bd661a..c9a72302 100644 --- a/swap-core/src/bitcoin/punish.rs +++ b/swap-core/src/bitcoin/punish.rs @@ -1,6 +1,6 @@ use crate::bitcoin::{self, Address, Amount, PunishTimelock, Transaction, TxCancel, Txid}; use ::bitcoin::sighash::SighashCache; -use ::bitcoin::{EcdsaSighashType, secp256k1, sighash::SegwitV0Sighash as Sighash}; +use ::bitcoin::{secp256k1, sighash::SegwitV0Sighash as Sighash, EcdsaSighashType}; use ::bitcoin::{ScriptBuf, Weight}; use anyhow::{Context, Result}; use bdk_wallet::miniscript::Descriptor; diff --git a/swap-core/src/bitcoin/redeem.rs b/swap-core/src/bitcoin/redeem.rs index cfd8a805..eea10ead 100644 --- a/swap-core/src/bitcoin/redeem.rs +++ b/swap-core/src/bitcoin/redeem.rs @@ -1,18 +1,18 @@ use crate::bitcoin::{ - Address, Amount, EmptyWitnessStack, EncryptedSignature, NoInputs, NotThreeWitnesses, PublicKey, - SecretKey, TooManyInputs, Transaction, TxLock, verify_encsig, verify_sig, + verify_encsig, verify_sig, Address, Amount, EmptyWitnessStack, EncryptedSignature, NoInputs, + NotThreeWitnesses, PublicKey, SecretKey, TooManyInputs, Transaction, TxLock, }; -use ::bitcoin::{Txid, sighash::SegwitV0Sighash as Sighash}; -use anyhow::{Context, Result, bail}; +use ::bitcoin::{sighash::SegwitV0Sighash as Sighash, Txid}; +use anyhow::{bail, Context, Result}; use bdk_wallet::miniscript::Descriptor; use bitcoin::sighash::SighashCache; +use bitcoin::{secp256k1, ScriptBuf}; use bitcoin::{EcdsaSighashType, Weight}; -use bitcoin::{ScriptBuf, secp256k1}; use bitcoin_wallet::primitives::Watchable; -use ecdsa_fun::Signature; use ecdsa_fun::adaptor::{Adaptor, HashTranscript}; use ecdsa_fun::fun::Scalar; use ecdsa_fun::nonce::Deterministic; +use ecdsa_fun::Signature; use sha2::Sha256; use std::collections::HashMap; use std::sync::Arc; diff --git a/swap-core/src/bitcoin/refund.rs b/swap-core/src/bitcoin/refund.rs index 23e98790..e4371b12 100644 --- a/swap-core/src/bitcoin/refund.rs +++ b/swap-core/src/bitcoin/refund.rs @@ -1,12 +1,12 @@ use crate::bitcoin; use crate::bitcoin::{ - Address, Amount, EmptyWitnessStack, NoInputs, NotThreeWitnesses, PublicKey, TooManyInputs, - Transaction, TxCancel, verify_sig, + verify_sig, Address, Amount, EmptyWitnessStack, NoInputs, NotThreeWitnesses, PublicKey, + TooManyInputs, Transaction, TxCancel, }; use ::bitcoin::sighash::SighashCache; -use ::bitcoin::{EcdsaSighashType, Txid, sighash::SegwitV0Sighash as Sighash}; -use ::bitcoin::{ScriptBuf, Weight, secp256k1}; -use anyhow::{Context, Result, bail}; +use ::bitcoin::{secp256k1, ScriptBuf, Weight}; +use ::bitcoin::{sighash::SegwitV0Sighash as Sighash, EcdsaSighashType, Txid}; +use anyhow::{bail, Context, Result}; use bdk_wallet::miniscript::Descriptor; use bitcoin_wallet::primitives::Watchable; use curve25519_dalek::scalar::Scalar; diff --git a/swap-core/src/monero/primitives.rs b/swap-core/src/monero/primitives.rs index 63a34445..a079fbb9 100644 --- a/swap-core/src/monero/primitives.rs +++ b/swap-core/src/monero/primitives.rs @@ -1,10 +1,10 @@ use crate::bitcoin; -use anyhow::{Result, bail}; +use anyhow::{bail, Result}; pub use curve25519_dalek::scalar::Scalar; use monero::Address; use rand::{CryptoRng, RngCore}; -use rust_decimal::Decimal; use rust_decimal::prelude::*; +use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; use std::convert::TryFrom; use std::fmt; @@ -382,10 +382,12 @@ impl MoneroAddressPool { impl From<::monero::Address> for MoneroAddressPool { fn from(address: ::monero::Address) -> Self { - Self(vec![ - LabeledMoneroAddress::new(address, Decimal::from(1), "user address".to_string()) - .expect("Percentage 1 is always valid"), - ]) + Self(vec![LabeledMoneroAddress::new( + address, + Decimal::from(1), + "user address".to_string(), + ) + .expect("Percentage 1 is always valid")]) } } diff --git a/swap-env/src/config.rs b/swap-env/src/config.rs index 9913b7b5..60538eb5 100644 --- a/swap-env/src/config.rs +++ b/swap-env/src/config.rs @@ -1,7 +1,7 @@ use crate::defaults::GetDefaults; use crate::env::{Mainnet, Testnet}; use crate::prompt; -use anyhow::{Context, Result, bail}; +use anyhow::{bail, Context, Result}; use config::ConfigError; use libp2p::core::Multiaddr; use rust_decimal::Decimal; diff --git a/swap-env/src/prompt.rs b/swap-env/src/prompt.rs index 1c4a39e5..6a6c30fc 100644 --- a/swap-env/src/prompt.rs +++ b/swap-env/src/prompt.rs @@ -1,15 +1,15 @@ use std::path::{Path, PathBuf}; use crate::defaults::{ - DEFAULT_MAX_BUY_AMOUNT, DEFAULT_MIN_BUY_AMOUNT, DEFAULT_SPREAD, default_rendezvous_points, + default_rendezvous_points, DEFAULT_MAX_BUY_AMOUNT, DEFAULT_MIN_BUY_AMOUNT, DEFAULT_SPREAD, }; -use anyhow::{Context, Result, bail}; +use anyhow::{bail, Context, Result}; use console::Style; use dialoguer::Confirm; -use dialoguer::{Input, Select, theme::ColorfulTheme}; +use dialoguer::{theme::ColorfulTheme, Input, Select}; use libp2p::Multiaddr; -use rust_decimal::Decimal; use rust_decimal::prelude::FromPrimitive; +use rust_decimal::Decimal; use url::Url; /// Prompt user for data directory diff --git a/swap-machine/src/alice/mod.rs b/swap-machine/src/alice/mod.rs index d257c91e..51048351 100644 --- a/swap-machine/src/alice/mod.rs +++ b/swap-machine/src/alice/mod.rs @@ -1,17 +1,17 @@ -use crate::common::{CROSS_CURVE_PROOF_SYSTEM, Message0, Message1, Message2, Message3, Message4}; -use anyhow::{Context, Result, anyhow, bail}; +use crate::common::{Message0, Message1, Message2, Message3, Message4, CROSS_CURVE_PROOF_SYSTEM}; +use anyhow::{anyhow, bail, Context, Result}; use rand::{CryptoRng, RngCore}; use serde::{Deserialize, Serialize}; use sigma_fun::ext::dl_secp256k1_ed25519_eq::CrossCurveDLEQProof; use std::fmt; use std::sync::Arc; use swap_core::bitcoin::{ - CancelTimelock, ExpiredTimelocks, PunishTimelock, Transaction, TxCancel, TxEarlyRefund, - TxPunish, TxRedeem, TxRefund, Txid, current_epoch, + current_epoch, CancelTimelock, ExpiredTimelocks, PunishTimelock, Transaction, TxCancel, + TxEarlyRefund, TxPunish, TxRedeem, TxRefund, Txid, }; use swap_core::monero; -use swap_core::monero::ScalarExt; use swap_core::monero::primitives::{BlockHeight, TransferProof, TransferRequest, WatchRequest}; +use swap_core::monero::ScalarExt; use swap_env::env::Config; use uuid::Uuid; diff --git a/swap-machine/src/bob/mod.rs b/swap-machine/src/bob/mod.rs index 6a6ea70d..5fe5ea85 100644 --- a/swap-machine/src/bob/mod.rs +++ b/swap-machine/src/bob/mod.rs @@ -1,9 +1,9 @@ -use crate::common::{CROSS_CURVE_PROOF_SYSTEM, Message0, Message1, Message2, Message3, Message4}; -use anyhow::{Context, Result, anyhow, bail}; +use crate::common::{Message0, Message1, Message2, Message3, Message4, CROSS_CURVE_PROOF_SYSTEM}; +use anyhow::{anyhow, bail, Context, Result}; use bitcoin_wallet::primitives::Subscription; -use ecdsa_fun::Signature; use ecdsa_fun::adaptor::{Adaptor, HashTranscript}; use ecdsa_fun::nonce::Deterministic; +use ecdsa_fun::Signature; use monero::BlockHeight; use rand::{CryptoRng, RngCore}; use serde::{Deserialize, Serialize}; @@ -12,11 +12,11 @@ use sigma_fun::ext::dl_secp256k1_ed25519_eq::CrossCurveDLEQProof; use std::fmt; use std::sync::Arc; use swap_core::bitcoin::{ - self, CancelTimelock, ExpiredTimelocks, PunishTimelock, Transaction, TxCancel, TxLock, Txid, - current_epoch, + self, current_epoch, CancelTimelock, ExpiredTimelocks, PunishTimelock, Transaction, TxCancel, + TxLock, Txid, }; -use swap_core::monero::ScalarExt; use swap_core::monero::primitives::WatchRequest; +use swap_core::monero::ScalarExt; use swap_core::monero::{self, TransferProof}; use swap_serde::bitcoin::address_serde; use uuid::Uuid; diff --git a/swap-machine/src/common/mod.rs b/swap-machine/src/common/mod.rs index 80bae536..ff724830 100644 --- a/swap-machine/src/common/mod.rs +++ b/swap-machine/src/common/mod.rs @@ -1,15 +1,15 @@ -use crate::alice::AliceState; use crate::alice::is_complete as alice_is_complete; -use crate::bob::BobState; +use crate::alice::AliceState; use crate::bob::is_complete as bob_is_complete; +use crate::bob::BobState; use anyhow::Result; use async_trait::async_trait; use conquer_once::Lazy; use libp2p::{Multiaddr, PeerId}; use serde::{Deserialize, Serialize}; use sha2::Sha256; -use sigma_fun::HashTranscript; use sigma_fun::ext::dl_secp256k1_ed25519_eq::{CrossCurveDLEQ, CrossCurveDLEQProof}; +use sigma_fun::HashTranscript; use std::convert::TryInto; use swap_core::bitcoin; use swap_core::monero::{self, MoneroAddressPool}; diff --git a/swap-orchestrator/Cargo.toml b/swap-orchestrator/Cargo.toml index a30ab2a4..f214518f 100644 --- a/swap-orchestrator/Cargo.toml +++ b/swap-orchestrator/Cargo.toml @@ -8,6 +8,7 @@ name = "orchestrator" path = "src/main.rs" [dependencies] +anyhow = { workspace = true } bitcoin = { workspace = true } chrono = "0.4.41" compose_spec = "0.3.0" @@ -17,7 +18,6 @@ serde_yaml = "0.9.34" swap-env = { path = "../swap-env" } toml = { workspace = true } url = { workspace = true } -anyhow = { workspace = true } [build-dependencies] anyhow = { workspace = true } diff --git a/swap-orchestrator/src/main.rs b/swap-orchestrator/src/main.rs index 3638a29d..c981cf96 100644 --- a/swap-orchestrator/src/main.rs +++ b/swap-orchestrator/src/main.rs @@ -4,8 +4,8 @@ mod images; mod prompt; use crate::compose::{ - ASB_DATA_DIR, DOCKER_COMPOSE_FILE, IntoSpec, OrchestratorDirectories, OrchestratorImage, - OrchestratorImages, OrchestratorInput, OrchestratorNetworks, + IntoSpec, OrchestratorDirectories, OrchestratorImage, OrchestratorImages, OrchestratorInput, + OrchestratorNetworks, ASB_DATA_DIR, DOCKER_COMPOSE_FILE, }; use std::path::PathBuf; use swap_env::config::{ diff --git a/swap-orchestrator/src/prompt.rs b/swap-orchestrator/src/prompt.rs index 9b58fb55..85085729 100644 --- a/swap-orchestrator/src/prompt.rs +++ b/swap-orchestrator/src/prompt.rs @@ -1,4 +1,4 @@ -use dialoguer::{Select, theme::ColorfulTheme}; +use dialoguer::{theme::ColorfulTheme, Select}; use swap_env::prompt as config_prompt; use url::Url; diff --git a/swap-serde/src/electrum.rs b/swap-serde/src/electrum.rs index 35e23070..9c36f12a 100644 --- a/swap-serde/src/electrum.rs +++ b/swap-serde/src/electrum.rs @@ -1,6 +1,6 @@ pub mod urls { use serde::de::Unexpected; - use serde::{Deserialize, Deserializer, de}; + use serde::{de, Deserialize, Deserializer}; use serde_json::Value; use url::Url; diff --git a/swap-serde/src/libp2p.rs b/swap-serde/src/libp2p.rs index 2a96629b..23f4cf2a 100644 --- a/swap-serde/src/libp2p.rs +++ b/swap-serde/src/libp2p.rs @@ -1,7 +1,7 @@ pub mod multiaddresses { use libp2p::Multiaddr; use serde::de::Unexpected; - use serde::{Deserialize, Deserializer, de}; + use serde::{de, Deserialize, Deserializer}; use serde_json::Value; pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> diff --git a/swap-serde/src/monero.rs b/swap-serde/src/monero.rs index 28e27b1f..e317fc78 100644 --- a/swap-serde/src/monero.rs +++ b/swap-serde/src/monero.rs @@ -12,11 +12,11 @@ pub enum network { pub mod private_key { use hex; - use monero::PrivateKey; use monero::consensus::{Decodable, Encodable}; + use monero::PrivateKey; use serde::de::Visitor; use serde::ser::Error; - use serde::{Deserializer, Serializer, de}; + use serde::{de, Deserializer, Serializer}; use std::fmt; use std::io::Cursor; @@ -100,7 +100,7 @@ pub mod amount { } pub mod address { - use anyhow::{Context, Result, bail}; + use anyhow::{bail, Context, Result}; use std::str::FromStr; #[derive(thiserror::Error, Debug, Clone, Copy, PartialEq)] diff --git a/throttle/src/throttle.rs b/throttle/src/throttle.rs index eb08e9c6..c092d643 100644 --- a/throttle/src/throttle.rs +++ b/throttle/src/throttle.rs @@ -2,7 +2,7 @@ // MIT License use std::pin::Pin; -use std::sync::{Arc, Mutex, mpsc}; +use std::sync::{mpsc, Arc, Mutex}; use std::time::{self, /* SystemTime, UNIX_EPOCH, */ Duration}; pub fn throttle(closure: F, delay: Duration) -> Throttle diff --git a/utils/gpg_keys/readme.md b/utils/gpg_keys/readme.md index dbb9b3b0..0fe40a9a 100644 --- a/utils/gpg_keys/readme.md +++ b/utils/gpg_keys/readme.md @@ -34,4 +34,4 @@ gpg: Signature made [date] gpg: Good signature from "..." ``` -The warning `This key is not certified with a trusted signature` is expected unless you've explicitly trusted the key. \ No newline at end of file +The warning `This key is not certified with a trusted signature` is expected unless you've explicitly trusted the key.