42 Commits

Author SHA1 Message Date
binarybaron
119b8714ef fix(tauri): Let watcher sleep even if we fail to get current swaps 2024-10-09 16:46:29 +02:00
binarybaron
8f33fe5b41
feat(tauri, gui): Send event on changes to details, timelocks and tx_lock confirmations (#100)
- Send event when new swap state is inserated into database. The event only has the `swap_id` attached. The frontend then sends a request to the `get_swap_info` command to retrieve the updated version
- Send event when the Bitcoin lock transaction gets a new confirmation 
- A new `watcher` daemon runs contineously and sends an event when the timelock updated. The event has the the `swap_id` and the timelock attached
- Display logs on `ProcessExitedPage` (if swap was stopped prematurely)
- Rename `CliLogEmittedEvent` to `TauriLogEvent`
- Apply env_filter to tracing terminal writer to silence logging from other crates
- Add `.env.*` files in `src-gui` to `.gitingore`

Closes #93 and #12
2024-10-09 15:06:57 +02:00
binarybaron
253e0b0cf6
feat(gui, tauri): Save settings in Tauri storage (#102)
- Implemented dual persistence strategy:
  - **User Settings**: Persisted across app restarts using `tauri-plugin-store`.
  - **Transient State**: Persisted across page reloads using `sessionStorage`.
- Added `settingsSlice` reducer for managing persistent user settings.
- Updated Redux store configuration to handle multiple persistence layers.
- Added a new Settings page in the GUI where users can specify custom Electrum RPC URLs for Bitcoin and Monero node URLs.
  - Users can input their preferred Electrum server (`ssl://host:port`) and Monero daemon (`http://host:port`).
  - Input fields include validation to ensure correct URL formats.
  - Settings persist across application restarts using Tauri's storage plugin.
  - A reset option is available to revert to default settings.
- Improved the Daemon Controller in the Help page:
  - Renamed `RpcControlBox` to `DaemonControlBox` for clarity.
  - Users can now start the daemon manually if it isn't running or has failed.
  - Added a "Restart GUI" button to apply new settings immediately.
  - Displayed the daemon's status within the controller.
- Upgraded Tauri and related plugins to stable version `2.0.0`:
  - Updated `tauri`, `tauri-build`, and `tauri-utils` to `2.0.0`.
  - Ensured compatibility with the latest stable release.
- Updated Tauri plugins to version `2.0.0`:
  - `tauri-plugin-clipboard-manager`
  - `tauri-plugin-shell`
  - Added new plugins:
    - `tauri-plugin-store` for settings persistence.
    - `tauri-plugin-process` to enable application relaunch.
- Deferred Context initialization until explicitly triggered from the frontend.
  - Moved Context setup from the `setup` function to a new `initialize_context` Tauri command.
  - Allows the application to start without immediately initializing the backend context.
  - Context initialization now considers user-provided settings for Electrum and Monero nodes.
- Introduced a `ValidatedTextField` component for form inputs with validation logic.
  - Provides immediate feedback on input validity.
  - Used in the Settings page for Electrum and Monero node URLs.
- If the user provides an override Monero remote daemon, we check if it reachable and on the correct network before starting the `monero-wallet-rpc`
- Changed `bitcoin_confirmation_target` type from `usize` to `u16`.
2024-10-08 12:57:01 +02:00
Einliterflasche
7b79ad6abe
feat(cli+tauri): Send logs from host to guest (#90)
* feat(tauri): send logs from cli to tauri

---------

Co-authored-by: binarybaron <binarybaron@unstoppableswap.net>
Co-authored-by: binarybaron <86064887+binarybaron@users.noreply.github.com>
2024-09-26 17:09:46 +06:00
binarybaron
97510a8619
refactor(gui): Swap state stepper to use Tauri events (#77)
Previously we used the data we fetched via the rpc (`GetSwapInfo` call, saved in redux in `rpc.swapInfos`) to decide what to display in the state stepper to the user. The state stepper is displayed at the bottom of the `SwapDialog`.

However, we are moving away from our depedence on periodic rpc calls and towards relying more and more on the events we receive from the Host (from Tauri). Our goal is to rely solely on the Tauri events for everything displayed about the currently running swap.

This PR includes the following changes:
- refactor the `SwapStateStepper` such that it relies only on the Tauri events
- emit two new Tauri events (`EncryptedSignatureSent`, `CancelTimelockExpired`) in the state machine
- correctly emit `BtcRefunded` Tauri event after Bitcoin refund transaction is published
- differentiate between `"Waiting for them to redeem the Bitcoin"` and `"Revealing encrypted signature to the other party"` on the `SwapStatePage` (content displayed in the center of the `SwapDialog`)
2024-09-23 03:31:24 +06:00
binarybaron
f91255ff76
feat(cli): Add span with swap_id to all logs caused by swap (#96)
* feat(cli): Add span with swap_id to all logs caused by swap
2024-09-23 00:56:25 +06:00
binarybaron
167e031172
feat(gui): Allow discovery of sellers via connecting to rendezvous point (#83)
We,
- add a new list_sellers Tauri IPC command
- we rename the Seller struct to AliceAddress to name clash
2024-09-19 00:40:51 +02:00
binarybaron
beccd23280
fix(cli): Remove malicious node.moneroworld remote node (#85)
The moneroworld node has been confirmed to have been operated by Chainalysis, a company specialising in blockchain surveillance. They are collecting the ip addresses of anyone who connects to the node.

See https://www.digilol.net/blog/chainanalysis-malicious-xmr.html
2024-09-18 22:48:30 +02:00
Einliterflasche
9d1151c3d3
feat(cli, gui, tauri): Emit events on Monero transaction confirmation update and redeem transaction publication (#57)
We now,
- emit a Tauri event when the Monero lock transaction receives a new confirmation
- emit a Tauri event with a list of transaction hashes once we have published the Monero redeem transaction 
- gui: display the confirmations and txids

This PR closes #12.
2024-09-18 17:53:13 +02:00
binarybaron
5bb33fe35d
fix(asb): Allow history command to be run while asb is running (#82)
This applies the following PRs from upstream to our fork:
* fix(asb): Allow history command to be run while asb is running (#1724)
* Allow history command to be executed while asb is running by opening database in read-only mode (#1722)

---------

Co-authored-by: einliterflasche <einliterflasche@pm.me>
Co-authored-by: Einliterflasche <81313171+Einliterflasche@users.noreply.github.com>
2024-09-17 17:32:21 +02:00
binarybaron
0a122d57d3
chore(swap): Disable cargo tauri integration feature by default (#74) 2024-09-09 22:08:50 +02:00
binarybaron
6a3a0a5458
Merge pull request #73 from UnstoppableSwap/gui/allow-logs-of-swap-button
feat(gui): Display logs of specific swap on press of button on history page
2024-09-09 21:49:45 +02:00
binarybaron
c486ca5de9
feat(gui): Display logs of specific swap on press of button on history page 2024-09-09 21:31:54 +02:00
binarybaron
bd1a3db898
fix: Format cooperative redeem reject using thiserror (#1716) (#71) 2024-09-09 20:43:31 +02:00
binarybaron
063f9dbf9b
feat(gui, swap): allow change-address to be omitted and default to internal wallet (#68)
This PR:
- allows --change-address to be omitted and default to internal wallet address (https://github.com/comit-network/xmr-btc-swap/pull/1709). This is a change that is merged from upstream into our fork
- adds the necessary components for the tauri integration and the ui components to allow toggling between internal vs external refund address

Co-authored-by: binarybaron <86064887+binarybaron@users.noreply.github.com>
Co-authored-by: Einliterflasche <81313171+Einliterflasche@users.noreply.github.com>
Co-authored-by: Byron Hambly <byron@hambly.dev>
2024-09-09 19:47:15 +02:00
binarybaron
e4141c763b
feat(tauri): Initialize Context in background (#59)
This PR does the following:
- The Context (including Bitcoin wallet, Monero wallet, ...) is initialized in the background. This allows the window to be displayed instantly upon startup.
- Host sends events to Guest about progress of Context initialization. Those events are used to display an alert in the navigation bar.
- If a Tauri command is invoked which requires the Context to be available, an error will be returned
- As soon as the Context becomes available the `Guest` requests the history and Bitcoin balance
- Re-enables Material UI animations
2024-09-03 12:28:30 +02:00
binarybaron
792fbbf746
feat(asb + cli): Redact logs + unify tracing infrastructure (#1733) (#55)
* feat(asb + cli): Redact logs + unify tracing infrastructure (#1733)

Applies the changes from https://github.com/comit-network/xmr-btc-swap/pull/1733 to this fork

---------

Co-authored-by: Einliterflasche <81313171+Einliterflasche@users.noreply.github.com>
2024-09-01 18:13:43 +02:00
binarybaron
bcd2d95f03
feat(cli): Change default testnet electrum server (#54) 2024-08-29 14:30:40 +02:00
binarybaron
d913206062
feat(gui): Preserve global state across page reloads (#48) 2024-08-29 13:38:11 +02:00
binarybaron
c7c7cf1886
Merge pull request #37 from UnstoppableSwap/tauri-feature-flag
Introducing a feature flag in the swap crate that conditionally enables the tauri depencendy. This allows compiling the swap crate without the heavy tauri dependency. This also enables us to build arm binaries in the CI again.

This closes #32 and #34
2024-08-28 22:54:28 +02:00
binarybaron
8208b2f8cc
feat(cli): Change default electrum testnet server 2024-08-28 13:55:15 +02:00
binarybaron
57c153de99
refactor(cli): Refactor RPC server and fix tests
- Use the Request trait introduced in https://github.com/UnstoppableSwap/xmr-btc-swap/pull/10 for the RPC server
- Delegate deserialization of RPC server method parameters to serde by using structs like BuyXmrArgs
- Remove `get_raw_states` RPC server method because it's not used
- Fix RPC server tests including removing test for the "log reference id" feature which was removed as part of https://github.com/UnstoppableSwap/xmr-btc-swap/pull/10
- Rename GetCurrentSwap struct to GetCurrentSwapArgs
2024-08-28 12:18:58 +02:00
binarybaron
ca25e0454f fix(tauri, gui): Allow Tauri command to be called with empty arguments
- Allow Tauri command to be called with empty arguments
- Add struct for GetSwapInfosAllArgs
2024-08-27 22:34:21 +02:00
binarybaron
de1f77bf80 fix(tauri_bindings): Emit swap id with WaitingForBtcDeposit event 2024-08-27 22:34:21 +02:00
binarybaron
b2475763a7 chore(swap): Remove redundant clone of BidQuote 2024-08-27 17:55:30 +02:00
Einliterflasche
c562e352f2 refactor(cli): Builder pattern for constructing Context 2024-08-27 17:55:03 +02:00
binarybaron
015c956273 fix(swap): Clippy errors (too many arguments, redundant clone) 2024-08-26 18:03:04 +02:00
binarybaron
dc3c937333 fix(swap): Unit test compilation errors 2024-08-26 18:03:04 +02:00
Einliterflasche
a57e3aff75
clean: use dprint 2024-08-26 16:19:11 +02:00
binarybaron
26f0f54864
Merge branch 'master' into tauri-events 2024-08-26 16:10:28 +02:00
binarybaron
349035d321
refactor(tauri, swap): move rpc api to cli/api 2024-08-26 15:41:00 +02:00
binarybaron
4939d63524
refactor(swap, tauri_bindings): Overhaul API architecture and introduce Tauri events
- Implement trait-based request handling in api/request.rs
- Add Tauri bindings and event system in api/tauri_bindings.rs
- Refactor CLI command parsing and execution in cli/command.rs
- Update RPC methods to use new request handling approach
- Emit Tauri events in swap/src/protocol/bob/swap.rs
- Add typescript type bindings use typeshare crate
2024-08-26 15:18:11 +02:00
Einliterflasche
5962effa50
docs: update READMEs (#25) 2024-08-23 13:26:10 +02:00
Einliterflasche
c897c4c6e9 Fix swap/src/bin/swap.rs import issue 2024-08-12 11:29:05 +02:00
binarybaron
718132b8b4
feat: Kill monero-wallet-rpc on GUI exit 2024-08-10 12:56:19 +02:00
binarybaron
47821cbe79
wip: WithdrawDialog migrated to Tauri IPC 2024-08-09 19:03:28 +02:00
binarybaron
92034a5be8
refactor: remover Arc for start_daemon 2024-08-09 16:38:07 +02:00
binarybaron
630f4c6f23
chore: Add description to Cargo.toml for GUI 2024-08-09 15:26:26 +02:00
binarybaron
b769251665
wip: remove Request struct, imports failing 2024-08-09 12:42:22 +02:00
binarybaron
693f4297c5
wip: remove Request for object and call functions like buy_xmr directly 2024-08-09 01:30:45 +02:00
binarybaron
2e1b6f6b43
feat: swap history tauri connector 2024-08-08 12:02:59 +02:00
binarybaron
709a2820c4
feat: cargo project at root 2024-08-08 00:49:04 +02:00