mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-24 22:19:37 -04:00
dprint fmt
This commit is contained in:
parent
7102962898
commit
c1c45571f0
20 changed files with 151 additions and 74 deletions
27
Cargo.toml
27
Cargo.toml
|
@ -1,16 +1,24 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = [ "electrum-pool", "monero-rpc", "monero-rpc-pool", "monero-sys", "monero-seed", "src-tauri", "swap", "swap-env", "swap-fs", "swap-feed", "swap-serde", "throttle"]
|
members = [
|
||||||
|
"electrum-pool",
|
||||||
|
"monero-rpc",
|
||||||
|
"monero-rpc-pool",
|
||||||
|
"monero-seed",
|
||||||
|
"monero-sys",
|
||||||
|
"src-tauri",
|
||||||
|
"swap",
|
||||||
|
"swap-env",
|
||||||
|
"swap-feed",
|
||||||
|
"swap-fs",
|
||||||
|
"swap-serde",
|
||||||
|
"throttle",
|
||||||
|
]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
serde_json = "1"
|
|
||||||
tokio = { version = "1", features = ["rt-multi-thread", "time", "macros", "sync"] }
|
|
||||||
futures = { version = "0.3", default-features = false, features = ["std"] }
|
|
||||||
tracing = { version = "0.1", features = ["attributes"] }
|
|
||||||
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "ansi", "env-filter", "time", "tracing-log", "json"] }
|
|
||||||
bitcoin = { version = "0.32", features = ["rand", "serde"] }
|
bitcoin = { version = "0.32", features = ["rand", "serde"] }
|
||||||
|
futures = { version = "0.3", default-features = false, features = ["std"] }
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
libp2p = { version = "0.53.2" }
|
libp2p = { version = "0.53.2" }
|
||||||
monero = { version = "0.12", features = ["serde_support"] }
|
monero = { version = "0.12", features = ["serde_support"] }
|
||||||
|
@ -18,7 +26,12 @@ rand = "0.8"
|
||||||
reqwest = { version = "0.12", default-features = false, features = ["json"] }
|
reqwest = { version = "0.12", default-features = false, features = ["json"] }
|
||||||
rust_decimal = { version = "1", features = ["serde-float"] }
|
rust_decimal = { version = "1", features = ["serde-float"] }
|
||||||
rust_decimal_macros = "1"
|
rust_decimal_macros = "1"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = "1"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
|
tokio = { version = "1", features = ["rt-multi-thread", "time", "macros", "sync"] }
|
||||||
|
tracing = { version = "0.1", features = ["attributes"] }
|
||||||
|
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "ansi", "env-filter", "time", "tracing-log", "json"] }
|
||||||
typeshare = "1.0"
|
typeshare = "1.0"
|
||||||
url = { version = "2", features = ["serde"] }
|
url = { version = "2", features = ["serde"] }
|
||||||
uuid = { version = "1", features = ["v4"] }
|
uuid = { version = "1", features = ["v4"] }
|
||||||
|
|
|
@ -66,9 +66,7 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This repository provides Flatpak packages for
|
This repository provides Flatpak packages for
|
||||||
<a href="https://github.com/eigenwallet/core"
|
<a href="https://github.com/eigenwallet/core">eigenwallet GUI.</a>
|
||||||
>eigenwallet GUI.</a
|
|
||||||
>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="install-section">
|
<div class="install-section">
|
||||||
|
|
|
@ -1639,7 +1639,9 @@ impl FfiWallet {
|
||||||
/// Store the wallet state.
|
/// Store the wallet state.
|
||||||
fn store(&mut self, path: &str) {
|
fn store(&mut self, path: &str) {
|
||||||
let_cxx_string!(path = path);
|
let_cxx_string!(path = path);
|
||||||
self.inner.pinned().store(&path)
|
self.inner
|
||||||
|
.pinned()
|
||||||
|
.store(&path)
|
||||||
.context("Failed to store wallet: FFI call failed with exception")
|
.context("Failed to store wallet: FFI call failed with exception")
|
||||||
.expect("Shouldn't panic");
|
.expect("Shouldn't panic");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Badge } from "@mui/material";
|
import { Badge } from "@mui/material";
|
||||||
import { useIsSwapRunning, useResumeableSwapsCountExcludingPunished } from "store/hooks";
|
import {
|
||||||
|
useIsSwapRunning,
|
||||||
|
useResumeableSwapsCountExcludingPunished,
|
||||||
|
} from "store/hooks";
|
||||||
|
|
||||||
export default function UnfinishedSwapsBadge({
|
export default function UnfinishedSwapsBadge({
|
||||||
children,
|
children,
|
||||||
|
@ -10,7 +13,9 @@ export default function UnfinishedSwapsBadge({
|
||||||
const isSwapRunning = useIsSwapRunning();
|
const isSwapRunning = useIsSwapRunning();
|
||||||
const resumableSwapsCount = useResumeableSwapsCountExcludingPunished();
|
const resumableSwapsCount = useResumeableSwapsCountExcludingPunished();
|
||||||
|
|
||||||
const displayedResumableSwapsCount = isSwapRunning ? resumableSwapsCount - 1 : resumableSwapsCount;
|
const displayedResumableSwapsCount = isSwapRunning
|
||||||
|
? resumableSwapsCount - 1
|
||||||
|
: resumableSwapsCount;
|
||||||
|
|
||||||
if (displayedResumableSwapsCount > 0) {
|
if (displayedResumableSwapsCount > 0) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -22,7 +22,8 @@ export default function SendTransactionModal({
|
||||||
const pendingApprovals = usePendingSendMoneroApproval();
|
const pendingApprovals = usePendingSendMoneroApproval();
|
||||||
const hasPendingApproval = pendingApprovals.length > 0;
|
const hasPendingApproval = pendingApprovals.length > 0;
|
||||||
|
|
||||||
const [successResponse, setSuccessResponse] = useState<SendMoneroResponse | null>(null);
|
const [successResponse, setSuccessResponse] =
|
||||||
|
useState<SendMoneroResponse | null>(null);
|
||||||
|
|
||||||
const showSuccess = successResponse !== null;
|
const showSuccess = successResponse !== null;
|
||||||
|
|
||||||
|
@ -42,13 +43,20 @@ export default function SendTransactionModal({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{!showSuccess && !hasPendingApproval && (
|
{!showSuccess && !hasPendingApproval && (
|
||||||
<SendTransactionContent balance={balance} onClose={onClose} onSuccess={setSuccessResponse} />
|
<SendTransactionContent
|
||||||
|
balance={balance}
|
||||||
|
onClose={onClose}
|
||||||
|
onSuccess={setSuccessResponse}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{!showSuccess && hasPendingApproval && (
|
{!showSuccess && hasPendingApproval && (
|
||||||
<SendApprovalContent onClose={onClose} />
|
<SendApprovalContent onClose={onClose} />
|
||||||
)}
|
)}
|
||||||
{showSuccess && (
|
{showSuccess && (
|
||||||
<SendSuccessContent onClose={onClose} successDetails={successResponse} />
|
<SendSuccessContent
|
||||||
|
onClose={onClose}
|
||||||
|
successDetails={successResponse}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import { Box, Button, Typography } from "@mui/material";
|
import { Box, Button, Typography } from "@mui/material";
|
||||||
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
|
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
|
||||||
import { FiatPiconeroAmount, PiconeroAmount } from "renderer/components/other/Units";
|
import {
|
||||||
|
FiatPiconeroAmount,
|
||||||
|
PiconeroAmount,
|
||||||
|
} from "renderer/components/other/Units";
|
||||||
import MonospaceTextBox from "renderer/components/other/MonospaceTextBox";
|
import MonospaceTextBox from "renderer/components/other/MonospaceTextBox";
|
||||||
import ArrowOutwardIcon from "@mui/icons-material/ArrowOutward";
|
import ArrowOutwardIcon from "@mui/icons-material/ArrowOutward";
|
||||||
import { SendMoneroResponse } from "models/tauriModel";
|
import { SendMoneroResponse } from "models/tauriModel";
|
||||||
|
@ -15,10 +18,12 @@ export default function SendSuccessContent({
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
successDetails: SendMoneroResponse | null;
|
successDetails: SendMoneroResponse | null;
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
const address = successDetails?.address;
|
const address = successDetails?.address;
|
||||||
const amount = successDetails?.amount_sent;
|
const amount = successDetails?.amount_sent;
|
||||||
const explorerUrl = getMoneroTxExplorerUrl(successDetails?.tx_hash, isTestnet());
|
const explorerUrl = getMoneroTxExplorerUrl(
|
||||||
|
successDetails?.tx_hash,
|
||||||
|
isTestnet(),
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
@ -36,30 +41,68 @@ export default function SendSuccessContent({
|
||||||
<CheckCircleIcon sx={{ fontSize: 64, mt: 3 }} />
|
<CheckCircleIcon sx={{ fontSize: 64, mt: 3 }} />
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: 1,
|
gap: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h4">Transaction Published</Typography>
|
<Typography variant="h4">Transaction Published</Typography>
|
||||||
<Box sx={{ display: "flex", flexDirection: "row", alignItems: "center", gap: 1 }}>
|
<Box
|
||||||
<Typography variant="body1" color="text.secondary">Sent</Typography>
|
sx={{
|
||||||
<Typography variant="body1" color="text.primary">
|
display: "flex",
|
||||||
<PiconeroAmount amount={amount} fixedPrecision={4}/>
|
flexDirection: "row",
|
||||||
</Typography>
|
alignItems: "center",
|
||||||
<Typography variant="body1" color="text.secondary">(<FiatPiconeroAmount amount={amount} />)</Typography>
|
gap: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="body1" color="text.secondary">
|
||||||
|
Sent
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body1" color="text.primary">
|
||||||
|
<PiconeroAmount amount={amount} fixedPrecision={4} />
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body1" color="text.secondary">
|
||||||
|
(<FiatPiconeroAmount amount={amount} />)
|
||||||
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ display: "flex", flexDirection: "row", alignItems: "center", gap: 1 }}>
|
<Box
|
||||||
<Typography variant="body1" color="text.secondary">to</Typography>
|
sx={{
|
||||||
<Typography variant="body1" color="text.primary">
|
display: "flex",
|
||||||
<MonospaceTextBox>{address.slice(0, 8)} ... {address.slice(-8)}</MonospaceTextBox>
|
flexDirection: "row",
|
||||||
</Typography>
|
alignItems: "center",
|
||||||
|
gap: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="body1" color="text.secondary">
|
||||||
|
to
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body1" color="text.primary">
|
||||||
|
<MonospaceTextBox>
|
||||||
|
{address.slice(0, 8)} ... {address.slice(-8)}
|
||||||
|
</MonospaceTextBox>
|
||||||
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 1 }}>
|
<Box
|
||||||
<Button onClick={onClose} variant="contained" color="primary">Done</Button>
|
sx={{
|
||||||
<Button color="primary" size="small" endIcon={<ArrowOutwardIcon />} onClick={() => open(explorerUrl)}>View on Explorer</Button>
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button onClick={onClose} variant="contained" color="primary">
|
||||||
|
Done
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
size="small"
|
||||||
|
endIcon={<ArrowOutwardIcon />}
|
||||||
|
onClick={() => open(explorerUrl)}
|
||||||
|
>
|
||||||
|
View on Explorer
|
||||||
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
|
@ -514,16 +514,15 @@ export async function sendMoneroTransaction(
|
||||||
const response = await sendMonero(args);
|
const response = await sendMonero(args);
|
||||||
|
|
||||||
// Refresh balance and history after sending - but don't let this block the response
|
// Refresh balance and history after sending - but don't let this block the response
|
||||||
Promise.all([
|
Promise.all([getMoneroBalance(), getMoneroHistory()])
|
||||||
getMoneroBalance(),
|
.then(([newBalance, newHistory]) => {
|
||||||
getMoneroHistory(),
|
store.dispatch(setBalance(newBalance));
|
||||||
]).then(([newBalance, newHistory]) => {
|
store.dispatch(setHistory(newHistory));
|
||||||
store.dispatch(setBalance(newBalance));
|
})
|
||||||
store.dispatch(setHistory(newHistory));
|
.catch((refreshErr) => {
|
||||||
}).catch(refreshErr => {
|
console.error("Failed to refresh wallet data after send:", refreshErr);
|
||||||
console.error("Failed to refresh wallet data after send:", refreshErr);
|
// Could emit a toast notification here
|
||||||
// Could emit a toast notification here
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -379,7 +379,7 @@ pub fn query_user_for_initial_config(testnet: bool) -> Result<Config> {
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
Ok(Config {
|
Ok(Config {
|
||||||
data: Data { dir: data_dir},
|
data: Data { dir: data_dir },
|
||||||
network: Network {
|
network: Network {
|
||||||
listen: listen_addresses,
|
listen: listen_addresses,
|
||||||
rendezvous_point: rendezvous_points, // keeping the singular key name for backcompat
|
rendezvous_point: rendezvous_points, // keeping the singular key name for backcompat
|
||||||
|
|
|
@ -26,4 +26,4 @@ tokio = { workspace = true }
|
||||||
tokio-tungstenite = { version = "0.15", features = ["rustls-tls"] }
|
tokio-tungstenite = { version = "0.15", features = ["rustls-tls"] }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
tracing-subscriber = { workspace = true }
|
tracing-subscriber = { workspace = true }
|
||||||
url = { workspace = true }
|
url = { workspace = true }
|
||||||
|
|
|
@ -3,11 +3,11 @@ pub mod rate;
|
||||||
pub mod traits;
|
pub mod traits;
|
||||||
|
|
||||||
// Re-exports for convenience
|
// Re-exports for convenience
|
||||||
pub use kraken::{connect, PriceUpdates, Error as KrakenError};
|
pub use kraken::{connect, Error as KrakenError, PriceUpdates};
|
||||||
pub use rate::{Rate, FixedRate, KrakenRate};
|
pub use rate::{FixedRate, KrakenRate, Rate};
|
||||||
pub use traits::LatestRate;
|
pub use traits::LatestRate;
|
||||||
|
|
||||||
// Core functions
|
// Core functions
|
||||||
pub fn connect_kraken(url: url::Url) -> anyhow::Result<kraken::PriceUpdates> {
|
pub fn connect_kraken(url: url::Url) -> anyhow::Result<kraken::PriceUpdates> {
|
||||||
kraken::connect(url)
|
kraken::connect(url)
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,8 +177,9 @@ mod tests {
|
||||||
.sell_quote(bitcoin::Amount::ONE_BTC)
|
.sell_quote(bitcoin::Amount::ONE_BTC)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let xmr_factor =
|
let xmr_factor = xmr_no_spread.into().as_piconero_decimal()
|
||||||
xmr_no_spread.into().as_piconero_decimal() / xmr_with_spread.into().as_piconero_decimal() - ONE;
|
/ xmr_with_spread.into().as_piconero_decimal()
|
||||||
|
- ONE;
|
||||||
|
|
||||||
assert!(xmr_with_spread < xmr_no_spread);
|
assert!(xmr_with_spread < xmr_no_spread);
|
||||||
assert_eq!(xmr_factor.round_dp(8), TWO_PERCENT); // round to 8 decimal
|
assert_eq!(xmr_factor.round_dp(8), TWO_PERCENT); // round to 8 decimal
|
||||||
|
@ -186,4 +187,4 @@ mod tests {
|
||||||
// it is really close
|
// it is really close
|
||||||
// to two percent
|
// to two percent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub trait LatestRate {
|
||||||
pub trait PriceFeed: Sized {
|
pub trait PriceFeed: Sized {
|
||||||
type Error: std::error::Error + Send + Sync + 'static;
|
type Error: std::error::Error + Send + Sync + 'static;
|
||||||
type Update;
|
type Update;
|
||||||
|
|
||||||
async fn connect(url: url::Url) -> Result<Self, Self::Error>;
|
async fn connect(url: url::Url) -> Result<Self, Self::Error>;
|
||||||
async fn next_update(&mut self) -> Result<Self::Update, Self::Error>;
|
async fn next_update(&mut self) -> Result<Self::Update, Self::Error>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,9 @@ swap-env = { path = "../swap-env" }
|
||||||
swap-feed = { path = "../swap-feed" }
|
swap-feed = { path = "../swap-feed" }
|
||||||
swap-fs = { path = "../swap-fs" }
|
swap-fs = { path = "../swap-fs" }
|
||||||
swap-serde = { path = "../swap-serde" }
|
swap-serde = { path = "../swap-serde" }
|
||||||
throttle = { path = "../throttle" }
|
|
||||||
tauri = { version = "2.0", features = ["config-json5"], optional = true, default-features = false }
|
tauri = { version = "2.0", features = ["config-json5"], optional = true, default-features = false }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
throttle = { path = "../throttle" }
|
||||||
time = "0.3"
|
time = "0.3"
|
||||||
tokio = { workspace = true, features = ["process", "fs", "net", "parking_lot", "rt"] }
|
tokio = { workspace = true, features = ["process", "fs", "net", "parking_lot", "rt"] }
|
||||||
tokio-tungstenite = { version = "0.15", features = ["rustls-tls"] }
|
tokio-tungstenite = { version = "0.15", features = ["rustls-tls"] }
|
||||||
|
|
|
@ -7,13 +7,13 @@ pub use event_loop::{EventLoop, EventLoopHandle};
|
||||||
pub use network::behaviour::{Behaviour, OutEvent};
|
pub use network::behaviour::{Behaviour, OutEvent};
|
||||||
pub use network::rendezvous::RendezvousNode;
|
pub use network::rendezvous::RendezvousNode;
|
||||||
pub use network::transport;
|
pub use network::transport;
|
||||||
pub use swap_feed::{FixedRate, KrakenRate, LatestRate, Rate};
|
|
||||||
pub use recovery::cancel::cancel;
|
pub use recovery::cancel::cancel;
|
||||||
pub use recovery::punish::punish;
|
pub use recovery::punish::punish;
|
||||||
pub use recovery::redeem::{redeem, Finality};
|
pub use recovery::redeem::{redeem, Finality};
|
||||||
pub use recovery::refund::refund;
|
pub use recovery::refund::refund;
|
||||||
pub use recovery::safely_abort::safely_abort;
|
pub use recovery::safely_abort::safely_abort;
|
||||||
pub use recovery::{cancel, refund};
|
pub use recovery::{cancel, refund};
|
||||||
|
pub use swap_feed::{FixedRate, KrakenRate, LatestRate, Rate};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub use network::rendezvous;
|
pub use network::rendezvous;
|
||||||
|
|
|
@ -8,8 +8,6 @@ use crate::protocol::alice::swap::has_already_processed_enc_sig;
|
||||||
use crate::protocol::alice::{AliceState, ReservesMonero, State3, Swap};
|
use crate::protocol::alice::{AliceState, ReservesMonero, State3, Swap};
|
||||||
use crate::protocol::{Database, State};
|
use crate::protocol::{Database, State};
|
||||||
use crate::{bitcoin, monero};
|
use crate::{bitcoin, monero};
|
||||||
use swap_feed::{LatestRate};
|
|
||||||
use swap_env::env;
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use futures::future;
|
use futures::future;
|
||||||
use futures::future::{BoxFuture, FutureExt};
|
use futures::future::{BoxFuture, FutureExt};
|
||||||
|
@ -20,10 +18,12 @@ use libp2p::{PeerId, Swarm};
|
||||||
use moka::future::Cache;
|
use moka::future::Cache;
|
||||||
use monero::Amount;
|
use monero::Amount;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::convert::{TryInto};
|
use std::convert::TryInto;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use swap_env::env;
|
||||||
|
use swap_feed::LatestRate;
|
||||||
use tokio::sync::{mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
use tokio::time::timeout;
|
use tokio::time::timeout;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -615,7 +615,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct EventLoopHandle {
|
pub struct EventLoopHandle {
|
||||||
swap_id: Uuid,
|
swap_id: Uuid,
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use swap_feed::LatestRate;
|
|
||||||
use swap_env::env;
|
|
||||||
use crate::network::quote::BidQuote;
|
use crate::network::quote::BidQuote;
|
||||||
use crate::network::rendezvous::XmrBtcNamespace;
|
use crate::network::rendezvous::XmrBtcNamespace;
|
||||||
use crate::network::swap_setup::alice;
|
use crate::network::swap_setup::alice;
|
||||||
|
@ -19,6 +17,8 @@ use libp2p::swarm::NetworkBehaviour;
|
||||||
use libp2p::{Multiaddr, PeerId};
|
use libp2p::{Multiaddr, PeerId};
|
||||||
use std::task::Poll;
|
use std::task::Poll;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use swap_env::env;
|
||||||
|
use swap_feed::LatestRate;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub mod transport {
|
pub mod transport {
|
||||||
|
|
|
@ -36,10 +36,10 @@ use swap::protocol::alice::{run, AliceState};
|
||||||
use swap::protocol::{Database, State};
|
use swap::protocol::{Database, State};
|
||||||
use swap::seed::Seed;
|
use swap::seed::Seed;
|
||||||
use swap::{bitcoin, monero};
|
use swap::{bitcoin, monero};
|
||||||
use swap_feed;
|
|
||||||
use swap_env::config::{
|
use swap_env::config::{
|
||||||
initial_setup, query_user_for_initial_config, read_config, Config, ConfigNotInitialized,
|
initial_setup, query_user_for_initial_config, read_config, Config, ConfigNotInitialized,
|
||||||
};
|
};
|
||||||
|
use swap_feed;
|
||||||
use tracing_subscriber::filter::LevelFilter;
|
use tracing_subscriber::filter::LevelFilter;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
@ -195,7 +195,8 @@ pub async fn main() -> Result<()> {
|
||||||
tracing::info!(%bitcoin_balance, "Bitcoin wallet balance");
|
tracing::info!(%bitcoin_balance, "Bitcoin wallet balance");
|
||||||
|
|
||||||
// Connect to Kraken
|
// Connect to Kraken
|
||||||
let kraken_price_updates = swap_feed::connect_kraken(config.maker.price_ticker_ws_url.clone())?;
|
let kraken_price_updates =
|
||||||
|
swap_feed::connect_kraken(config.maker.price_ticker_ws_url.clone())?;
|
||||||
|
|
||||||
let kraken_rate = KrakenRate::new(config.maker.ask_spread, kraken_price_updates);
|
let kraken_rate = KrakenRate::new(config.maker.ask_spread, kraken_price_updates);
|
||||||
let namespace = XmrBtcNamespace::from_is_testnet(testnet);
|
let namespace = XmrBtcNamespace::from_is_testnet(testnet);
|
||||||
|
|
|
@ -507,7 +507,7 @@ impl ContextBuilder {
|
||||||
data_dir: data_dir.clone(),
|
data_dir: data_dir.clone(),
|
||||||
log_dir: log_dir.clone(),
|
log_dir: log_dir.clone(),
|
||||||
},
|
},
|
||||||
swap_lock,
|
swap_lock,
|
||||||
tasks,
|
tasks,
|
||||||
tauri_handle: self.tauri_handle,
|
tauri_handle: self.tauri_handle,
|
||||||
tor_client: tor,
|
tor_client: tor,
|
||||||
|
@ -554,7 +554,7 @@ impl Context {
|
||||||
pub fn cleanup(&self) -> Result<()> {
|
pub fn cleanup(&self) -> Result<()> {
|
||||||
// TODO: close all monero wallets
|
// TODO: close all monero wallets
|
||||||
// call store(..) on all wallets
|
// call store(..) on all wallets
|
||||||
|
|
||||||
// TODO: This doesn't work because "there is no reactor running, must be called from the context of a Tokio 1.x runtime"
|
// TODO: This doesn't work because "there is no reactor running, must be called from the context of a Tokio 1.x runtime"
|
||||||
// let monero_manager = self.monero_manager.clone();
|
// let monero_manager = self.monero_manager.clone();
|
||||||
// tokio::spawn(async move {
|
// tokio::spawn(async move {
|
||||||
|
@ -802,7 +802,12 @@ async fn request_and_open_monero_wallet(
|
||||||
}
|
}
|
||||||
|
|
||||||
SeedChoice::Legacy => {
|
SeedChoice::Legacy => {
|
||||||
let wallet = request_and_open_monero_wallet_legacy(legacy_data_dir, env_config, daemon).await?;
|
let wallet = request_and_open_monero_wallet_legacy(
|
||||||
|
legacy_data_dir,
|
||||||
|
env_config,
|
||||||
|
daemon,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
let seed = Seed::from_file_or_generate(legacy_data_dir)
|
let seed = Seed::from_file_or_generate(legacy_data_dir)
|
||||||
.await
|
.await
|
||||||
.context("Failed to extract seed from wallet")?;
|
.context("Failed to extract seed from wallet")?;
|
||||||
|
@ -812,7 +817,10 @@ async fn request_and_open_monero_wallet(
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extract seed from the wallet
|
// Extract seed from the wallet
|
||||||
tracing::info!("Extracting seed from wallet directory: {}", legacy_data_dir.display());
|
tracing::info!(
|
||||||
|
"Extracting seed from wallet directory: {}",
|
||||||
|
legacy_data_dir.display()
|
||||||
|
);
|
||||||
let seed = Seed::from_monero_wallet(&wallet)
|
let seed = Seed::from_monero_wallet(&wallet)
|
||||||
.await
|
.await
|
||||||
.context("Failed to extract seed from wallet")?;
|
.context("Failed to extract seed from wallet")?;
|
||||||
|
@ -824,7 +832,8 @@ async fn request_and_open_monero_wallet(
|
||||||
// If we don't have a tauri handle, we use the seed.pem file
|
// If we don't have a tauri handle, we use the seed.pem file
|
||||||
// This is used for the CLI to monitor the blockchain
|
// This is used for the CLI to monitor the blockchain
|
||||||
None => {
|
None => {
|
||||||
let wallet = request_and_open_monero_wallet_legacy(legacy_data_dir, env_config, daemon).await?;
|
let wallet =
|
||||||
|
request_and_open_monero_wallet_legacy(legacy_data_dir, env_config, daemon).await?;
|
||||||
let seed = Seed::from_file_or_generate(legacy_data_dir)
|
let seed = Seed::from_file_or_generate(legacy_data_dir)
|
||||||
.await
|
.await
|
||||||
.context("Failed to extract seed from wallet")?;
|
.context("Failed to extract seed from wallet")?;
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
use std::{path::PathBuf, sync::Arc, time::Duration};
|
use std::{path::PathBuf, sync::Arc, time::Duration};
|
||||||
|
|
||||||
use throttle::{throttle, Throttle};
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use monero::{Address, Network};
|
use monero::{Address, Network};
|
||||||
use monero_sys::WalletEventListener;
|
use monero_sys::WalletEventListener;
|
||||||
pub use monero_sys::{Daemon, WalletHandle as Wallet, WalletHandleListener};
|
pub use monero_sys::{Daemon, WalletHandle as Wallet, WalletHandleListener};
|
||||||
|
use throttle::{throttle, Throttle};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::cli::api::{
|
use crate::cli::api::{
|
||||||
|
|
|
@ -6,7 +6,6 @@ edition = "2024"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "src/throttle.rs"
|
path = "src/throttle.rs"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue