diff --git a/Cargo.lock b/Cargo.lock index 72409ec7..8b2d2816 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4747,7 +4747,7 @@ dependencies = [ [[package]] name = "libp2p-community-tor" version = "0.5.0" -source = "git+https://github.com/umgefahren/libp2p-tor#8215104570a550cb3909a15c33af203387e88274" +source = "git+https://github.com/umgefahren/libp2p-tor?branch=main#8215104570a550cb3909a15c33af203387e88274" dependencies = [ "anyhow", "arti-client", diff --git a/src-gui/src/renderer/background.ts b/src-gui/src/renderer/background.ts index 70a0b496..37819d5c 100644 --- a/src-gui/src/renderer/background.ts +++ b/src-gui/src/renderer/background.ts @@ -1,11 +1,12 @@ import { listen } from "@tauri-apps/api/event"; -import { TauriSwapProgressEventWrapper, TauriContextStatusEvent, TauriLogEvent, BalanceResponse, TauriDatabaseStateEvent, TauriTimelockChangeEvent, TauriBackgroundRefundEvent } from "models/tauriModel"; +import { TauriSwapProgressEventWrapper, TauriContextStatusEvent, TauriLogEvent, BalanceResponse, TauriDatabaseStateEvent, TauriTimelockChangeEvent, TauriBackgroundRefundEvent, TauriTorEvent } from "models/tauriModel"; import { contextStatusEventReceived, receivedCliLog, rpcSetBalance, timelockChangeEventReceived, rpcSetBackgroundRefundState } from "store/features/rpcSlice"; import { swapProgressEventReceived } from "store/features/swapSlice"; import logger from "utils/logger"; import { updatePublicRegistry, updateRates } from "./api"; import { checkContextAvailability, getSwapInfo, initializeContext, updateAllNodeStatuses } from "./rpc"; import { store } from "./store/storeRenderer"; +import { torEventReceived } from "store/features/torSlice"; // Update the public registry every 5 minutes const PROVIDER_UPDATE_INTERVAL = 5 * 60 * 1_000; @@ -56,7 +57,6 @@ export async function setupBackgroundTasks(): Promise { }); listen("cli-log-emitted", (event) => { - logger.info("Received cli log event", event.payload); store.dispatch(receivedCliLog(event.payload)); }); diff --git a/src-gui/src/renderer/components/modal/swap/pages/DebugPage.tsx b/src-gui/src/renderer/components/modal/swap/pages/DebugPage.tsx index 49bbdbe1..a88ccbfd 100644 --- a/src-gui/src/renderer/components/modal/swap/pages/DebugPage.tsx +++ b/src-gui/src/renderer/components/modal/swap/pages/DebugPage.tsx @@ -35,7 +35,7 @@ export default function DebugPage() { data={cliState} label="Swap Daemon State (exposed via API)" /> - + diff --git a/src-gui/src/renderer/components/modal/swap/pages/in_progress/ReceivedQuotePage.tsx b/src-gui/src/renderer/components/modal/swap/pages/in_progress/ReceivedQuotePage.tsx index fe5a49a1..d91ce404 100644 --- a/src-gui/src/renderer/components/modal/swap/pages/in_progress/ReceivedQuotePage.tsx +++ b/src-gui/src/renderer/components/modal/swap/pages/in_progress/ReceivedQuotePage.tsx @@ -2,6 +2,6 @@ import CircularProgressWithSubtitle from "../../CircularProgressWithSubtitle"; export default function ReceivedQuotePage() { return ( - + ); } diff --git a/src-gui/src/store/features/rpcSlice.ts b/src-gui/src/store/features/rpcSlice.ts index 96cee9b2..3c547547 100644 --- a/src-gui/src/store/features/rpcSlice.ts +++ b/src-gui/src/store/features/rpcSlice.ts @@ -63,7 +63,8 @@ export const rpcSlice = createSlice({ receivedCliLog(slice, action: PayloadAction) { const buffer = action.payload.buffer; const logs = getLogsAndStringsFromRawFileString(buffer); - slice.logs = slice.logs.concat(logs); + const logsWithoutExisting = logs.filter(log => !slice.logs.includes(log)); + slice.logs = slice.logs.concat(logsWithoutExisting); }, contextStatusEventReceived( slice, diff --git a/src-gui/src/store/middleware/storeListener.ts b/src-gui/src/store/middleware/storeListener.ts index 81115b82..901e16b2 100644 --- a/src-gui/src/store/middleware/storeListener.ts +++ b/src-gui/src/store/middleware/storeListener.ts @@ -1,10 +1,11 @@ import { createListenerMiddleware } from "@reduxjs/toolkit"; -import { getAllSwapInfos, checkBitcoinBalance, updateAllNodeStatuses, fetchSellersAtPresetRendezvousPoints } from "renderer/rpc"; +import { getAllSwapInfos, checkBitcoinBalance, updateAllNodeStatuses, fetchSellersAtPresetRendezvousPoints, getSwapInfo } from "renderer/rpc"; import logger from "utils/logger"; import { contextStatusEventReceived } from "store/features/rpcSlice"; import { addNode, setFetchFiatPrices, setFiatCurrency } from "store/features/settingsSlice"; import { updateRates } from "renderer/api"; import { store } from "renderer/store/storeRenderer"; +import { swapProgressEventReceived } from "store/features/swapSlice"; export function createMainListeners() { const listener = createListenerMiddleware(); @@ -30,6 +31,23 @@ export function createMainListeners() { }, }); + // Listener for: + // - when a swap is released (fetch bitcoin balance) + // - when a swap progress event is received (update the swap info) + listener.startListening({ + actionCreator: swapProgressEventReceived, + effect: async (action) => { + if (action.payload.event.type === "Released") { + logger.info("Swap released, updating bitcoin balance..."); + await checkBitcoinBalance(); + } + + // Update the swap info + logger.info("Swap progress event received, updating swap info from database..."); + await getSwapInfo(action.payload.swap_id); + }, + }); + // Update the rates when the fiat currency is changed listener.startListening({ actionCreator: setFiatCurrency, diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 4bedbe9b..1dd947f9 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -42,7 +42,7 @@ hex = "0.4" jsonrpsee = { version = "0.16.2", features = [ "server" ] } jsonrpsee-core = "0.16.2" libp2p = { version = "0.53.2", features = [ "tcp", "yamux", "dns", "noise", "request-response", "ping", "rendezvous", "identify", "macros", "cbor", "json", "tokio", "serde", "rsa" ] } -libp2p-community-tor = { git = "https://github.com/umgefahren/libp2p-tor", features = [ "listen-onion-service" ] } +libp2p-community-tor = { git = "https://github.com/umgefahren/libp2p-tor", branch = "main", features = [ "listen-onion-service" ] } monero = { version = "0.12", features = [ "serde_support" ] } monero-rpc = { path = "../monero-rpc" } once_cell = "1.19"