feat(monero-sys): Monero bindings (#303)

* feat(monero-sys): Initial commit. Regtest integration test. Wrapper around basic Wallet functions, depends on monero#9464

* refactor: remove unused monero-wallet crate

Removed the monero-wallet crate which was not being used anywhere in the codebase,
simplifying the project structure.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* change order of members in Cargo.toml

* fix monero submodule problem

* progress

* continue

* fix tests

* fix tests again

* introduce error handling

* update error message

* implement Wallet::sync

* add swap progress

* fix import path

* add check_tx_key, transfer, switch to anyhow

* add more functionality

* fix test -- todo: why is manager.connected() failing?

* update Cargo.lock

* cleanup api and tests, add wait_until_synced

* show lib tracing in test

* add wallet_dir to wallet manager, fix tests, start integration into swap

* add main/default wallet to WalletManager

* continue integration, add wait_for_confirmations

* feat(ci): Install Monero build dependencies

* feat(ci): extract monero build instructions into compose file, run monero-sys integration tests in ci.yml

* fix compile errors and monero-sys/tests

* satisfy clippy

* update git CI to checkout git submodules

* fix again: init submodules

* fix?

* fix(ci): increase max size of ccache to 10G

* fix(ci): Include manual build step for Monero before running cargo

* add armhf sources for apt

* add armhf before running apt update

* fix(monero-sys): MACOSX_DEPLOYMENT_TARGET=11.0

* remove armhf apt dpkg arch

* fix BlockHeight serialization breakage

* ci: make only binaries not tests

* fix: let tauri ignore changes to monero-sys/monero

* fix: don't implement Sync for monero-sys types, change close_wallet

* move mutex into Wallet

* close wallet on drop (test still failing)

* pipe monero logs to tracing

* do not emit c++ perf logs, add comments

* get test wallet_closing to pass

* fix(ci): increase swap file to allow fix issue where runners would run out of memory

* fix(ci): use make -j4 release everywhere

* fix: run ci on self hosted runner (more ram)

* start changing to dedicated wallet threads

* complete move to dedicated wallet threads

also improve various minor things.
tests not passing

* satisfy clippy

* add traces

* refactor monero-harness to use monero-sys

tests still fail because there is a connection is-
sue between the wallet and monerod.

* fix: wallet doesn't connect to monerod in harness

test still failing because the miner wallet doesn't
recognize its balance

* make minimal progress

* no progress

* fix(monero-sys): Build on x_api_add_new_functions_release, which has been rebased on release and includes criticial fixes

* feat(gui): Add a Introduction for new users (#287)

* feat(gui): add IntroductionModal component

* feat(gui): add interactivity to IntroductionModal

* feat(gui): create SlideTemplate component for IntroductionModal Slides

* feat(gui): add generic slides to IntroductionModal with images and content

* feat(gui): add Slide with SwapStatusAlert to IntroductionModal

* feat(gui): show the introduction only on the first app start

* feat(gui): make external links functional

* fix(gui): update github link to link to active repo

* feat(gui): replace old images with new mockups and update Slide05 content

* feat(gui): add CardSelectionGroup and CardSelectionOption components for improved card selection UI

* feat(gui): add FiatPricePreference slide to IntroductionModal

* feat(gui): save user preference regarding fiat prices

I set the initial store configuration for fetching fiat prices to false to avoid any calls to coingecko without user consent

* refactor(gui): remove old Slide05 component for improved codebase maintenance

* fix(gui): add UnstoppableSwap logo to FiatPricePreference slide

* refactor(gui): update image imports and improve slide content for introduction modal

* fix(gui): introduce ExternalLink component and update Slide05 to use it for external navigation

* fix(gui): replace webp images for introduction with svg mockups for improved quality

* fix(gui): change order of introduction slides, to asking for fiat price preference at the end

* refactor(gui): implement CardSelectionContext for managing card selection state

* refactor: texts in intro modakl

* fix(gui): update currency fetching SVG for improved design and clarity

* feat(gui): added changelog entry for introduction

---------

Co-authored-by: Binarybaron <binarybaron@protonmail.com>

* feat(swap): Upgrade monero-wallet-rpc to v0.18.4.0 (#314)

* Prepare release 1.0.0-rc.20 (#315)

Co-authored-by: UnstoppableSwap Botty <help@unstoppableswap.net>

* feat(ci): Limit ci.yml to one concurrent running job per git branch (#316)

* fix(ci): Set yarn network-timeout to 10 minutes to avoid spurious network failures (#317)

* feat(docs): Add darkness.su rendezvous point to docs

* fix(gui): Fetch alerts only once

* Prepare release 1.0.0-rc.21 (#318)

Co-authored-by: UnstoppableSwap Botty <help@unstoppableswap.net>

* upgrade(swap): Concurrent syncing, bdk upgrade, refactors (#180)

* upgrade sqlx to 0.8, add bdk_wallet and bdk_electrum

The new dependencies are part of the bdk upgrade and
include the improved wallet code.
They, too, depend on sqlite3.
However, they use a newer version than we currently use via sqlx.
This necessitated the sqlx upgrade.
This entailed trivial changes (use Pool directly instead of pool.acquire()).
We might have to fix the CI as well, I kept getting compile
errors from the macro until I ran swap/sqlx_dev_setup.sh.

* move old wallet code to extra module

* fix fee estimation for old client

* bump bitcoin crate, add new wallet constructor

* remove unused old Client, move code around for better readibility

* make Wallet generic over Persister (database) and move more code around for readibility

* add script history, start reimplementing client methods

* update some imports

* cargo fmt

* Add comments, fix fee estimation, address generation and status_of_script

* redo state update and wallet sync

* fix bitcoin address validation and more imports, use Amount everywhere

* fix tx cancel, lock, punish, redeem, refund

* fix bitcoin::Address de-/serialisation

* fix more address validation

* fix more address parsing and validation, also some more imports

* cargo fmt

* fix wallet initialization, start wallet migration

* fail test instead of ignoring it

* perform full scan on creation, load from db if it exists

* add more wallet info, fix wallet initialization

* fix: default to null in config

* migrate from old wallet if needed

* change something

* fix some tests

* temporarily patch bdk_wallet and bdk_electrum

* fix more tests

* fix missing rustls

* asb: only start tor client if register_hidden_service=true in the config

* fix: use p2wsh_signature_hash instead of p2wpkh_signature_hash

* fix some bitcoin address parsing and fee rate parsing

* dprint fmt

* add bitcoin-harness to this project and update to the new bitcoin version

* fix max_givible again

* create electrum client separately from wallet, clean up some code

* add comment

* ignore .env.development

* log config file path on ./asb config

* feat(monero-sys): Initial commit. Regtest integration test. Wrapper around basic Wallet functions, depends on monero#9464

* Revert "feat(monero-sys): Initial commit. Regtest integration test. Wrapper around basic Wallet functions, depends on monero#9464"

This reverts commit 14a5b4c348a109d2524657ffeba306422458ea44.

* upgrade to rust toolchain 1.81

* Use new bdk update for code from master

* fix

* remove

* fix: add empty .gitmodules file to fix Docker build

* fix: clean up submodule references

* fix: properly declare monero submodule with ignore flag

* fix(wallet, bdk): only reveal new address if absolutely necessary

* fix: private keys not loaded into bdk wallet

* refactor: sync wallet progress log

* dprint fmt

* refactor: move bitcoin-harness to outside repo

* refactor: remove redundant log message

* Display sync progress

* Remove redundant arg to  swap/tests/harness/mod.rs function

* fix: call rustls::crypto:💍:default_provider()

* dprint fmt

* refactor: remove debug code

* refactor: move old bdk wallet export to own function, clear log messages

* remove old migr for testnets (checksum mismatch), remove balance and stringified last revealed addresses from migration export

* use revalidate_network function, remove redundant drop

* Display progress of background tasks, TauriBackgroundProgressHandle struct

* fix: almost satisfy clippy

* fix: gen-bindings error

* feat: add BackgroundRefund background type

* feat: use builder pattern for constructing Bitcoin wallet

* dprint ftm

* sync electrum in seperate thread

* do not allow user to start sync while sync is in progress

* remove redundant log message

* display random buffer in AlertWithLinearProgress progress

* fix: use TauriContextStatusEvent.Available), dont show syncing wallet spinner if not syncing

* differentiate between TestWalletBuilder and WalletBuilder

* satisfy clippy

* remove custom BackgroundRefund event, move into background process architecture

* refactor

* dprint fmt

* progress: get unit tests compiling

* fix: bitcoin unit tests specify const values like sync_interval

* fix: get unit tests passing

* make clippy happy

* feat: display full sync progress, fix unit test import issues

* dprint fmt

* make clippy happy, use u32 for target_block and not usize

* always spawn tor for asb

* refactor: remove gen_background_progress_id and just use Uuid::new_v4()

* refactor(hooks.ts): clarify comment on useConservativeBitcoinSyncProgress

* fix typo

* refactor: do not let WalletBuilder take entire env struct

* dprint fmt

* refactor: remove default feature from workspace patch of bdk

* first try for concurrent syncing

* refactor: concurrent syncing

* fix(wallet.rs): Safely convert FeeRate from btc / kb to sats / kwu

* feat(wallet.rs): persist published Bitcoin transactions without requiring re-scan

This allows us to compute an updated Bitcoin balance without requiring a re-scan

* refactor(wallet.rs): use just 5 concurrent sync requests

* refactor: display snackbar error when Wallet refresh fails

* fix: add missing space

* dprint fmt

* refactor: fancy traits for the CumulativeProgress struct, allow limiting amount of callback calls

* make clippy happy

* dprint fmt

* refactor: clearly differntiate between SyncMutex and TokioMutex, use traits for converting to Arc<Mutex<_>>, move sync_ext into own moid

* fix: skip syncing if no spks in wallet

* fix: update bdk.sh to test migration from old wallet (pre 1.0.0 bdk) to new bdk

* fix: increase bitcoin_lock_confirmed_timeout in RegTest env to 5 minutes

* refactor: avoid usize where possible, create persistence only after full scan, transmit assumed_total for full scan to tauri, add some icons to progress displays

* make clippy happy

* fix(ci): change rust toolchain 1.81

* fix(cross compilation arm): use ring instead of aws-lc-rs

* fmt

* ignore failing rendezvous tests

* fix printing_status_change_doesnt_spam_on_same_status

* fix: given_bitcoin_address_network_mismatch_then_error test

* ignore list_sellers_should_report_all_registered_asbs_with_a_quote test

* feat: add tor icon

* refactor(wallet.rs): reorder struct by abstraction level

* refactor(bitcoin wallet): chunk size for syncing

* fix(integration tests): decrease sync interval to 3s

* fix(integration tests): parse_rpc_err method to take new bdk error, not old one

* add changelog entry

---------

Co-authored-by: Binarybaron <binarybaron@protonmail.com>
Co-authored-by: Mohan <86064887+binarybaron@users.noreply.github.com>

* amend: CHANGELOG.md

* Prepare release 1.1.0-rc.1 (#325)

Co-authored-by: UnstoppableSwap Botty <help@unstoppableswap.net>

* fix(ci): Extract gen-bindings-verbose from gen-bindings

* Prepare release 1.1.0-rc.2 (#326)

* amend: add comma after new package.json entry

* revert: delete rc.1, rc.2 releases

* Prepare release 1.1.0-rc.3 (#327)

Co-authored-by: UnstoppableSwap Botty <help@unstoppableswap.net>

* fix: Issues with 1.1.0-rc (#328)

* bump(rust): Toolchain to 1.82

* bump(tauri): Bump some Tauri peer-dependencies

* fix(gui): Prefer maker with known version, bump MIN_ASB_VERSION to 1.1.0-rc.3

* amend: CHANGELOG.md

* Prepare release 1.1.0 (#329)

* feat: log enviroment info (#332)

* Add justfile (#335)

* fix(swap): Add retry logic for Bitcoin wallet sync (#333)

* docs: add repo overview (#337)

* Prepare release 1.1.1 (#338)

Co-authored-by: UnstoppableSwap Botty <help@unstoppableswap.net>

* rebase

* add monero-sys to swap/Cargo.toml

* progress rebase

* rebase

* Fix integration test

* Fix tests then break them again

* fix monero integration test harness

Integration tests were failing because the wallet/
node couldn't keep up with the amount of blocks we
generated and took some time before it even reali-
zed it was out of sync.
That lead to unrecognized balances.

Fix: we wait 0.25 seconds between each new block.
This gives the wallet/node enough time to realize
it's out of sync.

* Fix errors - happy_path goes to btc is redeemed

* fix: couldn't create walllet from keys

By not using an empty password

* fix happy_path: refresh wallet before sweeping

* Handle missing Monero node (#348)

* Allow automatic Monero node selection

* amend

* remove unused bridge.h file

* fix(ci): Use ubuntu-latest instead of self hosted runner

* fix(Dockerfile): Use rust 1.82, install apt packages required for Monero compilation

* add docs

* use scan_transactions instead of syncing monero wallet

When redeeming the Monero we, instead of doing a full scan,
simpyl import the Monero lock transaction by it's id.
This avoids a full scan before redeeming and should speed up the process
siginficantly.

* uniform naming of monero lock_transfer_proof and migration

* breaking: re-send lock transfer proof in cooperative redeem response

* add retry logic to blockchain height fetching, adjust tracing output

* fix merge

* remove unused variables

* satisfy clippy

* fmt

* changes

* add seed export to ffi bindings

* remove ccache from ci, don't manually build Monero codebase

Since monero-sys is tightly integrated into the Cargo build system, the
build output of the Monero codebase is stored in the same target dire-
ctory as all other Rust build output and is thus cached by our existing
cache solution.

* really stop building Monero manually in CI

* print monero-cpp logs in test

* use default cargo caching action instead of rust-cache

This commit introduces the default github cache action because
rust-cache doesn't cache our own code, only our dependencies.

* don't install ccache in ci

* debug missing openssl

* update changelog

* ci: run on self hosted runnr

* fix forward_cpp_log panic

* write logs to stderr instead of stdout

This enables us to `println` something and users
can just `asb export-monero-wallet > wallet.txt`
after which `wallet.txt` will contain just the wallet
seed.

* Revert "ci: run on self hosted runnr"

This reverts commit 157dfa7dc5bac025a9fc0eefe996880230274928.

* feat: ci run on large (expensive!!!) github runners, only run on non-draft PRs and only do this until we find a way around this

* run on large windows runenrs

* add asb-testnet command

* add --trace to ExportMoneroWallet

* ci: agressive caching (delegate to cargo instead of doing by hand)

* fix: pin dtolnay/rust-toolchain to @v1

* switch to actions-rust-lang/setup-rust-toolchain@v1

* fix: dont manually call cache for cargo dirs, let this be done by actions-rust-lang/setup-rust-toolchain instead

* disbale -D warnings in CI

* don't refresh wallet before getting balance

* ci: agressive caching to s3

* Change creation height to restore height in export-monero-wallet output

* update changelog

* concrete example in changelog

* add docker ignore

* limit monero build to just one core

* dont .dockerignore the .git folder because we need it for sub directories

* copy .git

* dont copy .git

* Dockerfile: run git submodule sync before updating

* only include -mmacosx-version-min=11.0 on mac os

* add retry convenience function

* improve error messages in monero-sys

* remove transfer proof from state6, retry redeem_xmr and refund_xmr

* install libabsl-dev on ubuntu ci

* fix(monero-sys): Disable BUILD_TESTS, TREZOR_DEBUG, USE_DEVICE_TREZOR, HIDAPI_FOUND, GTEST_HAS_ABSL CMake flags

* alice: store transfer proof in more states, only use latest state for coop redeem

* BUILD_SHARED_LIBS OFF

* install libasl in docker

* dont link against absl google

* print multiaddr when confirming new address

* dont build device_trezor, dont link hidapi and usb-1.0

* use MONERO_WALLET_CRYPTO_LIBRARY to cn

* fix trezor shit

* link against stub trezor impl

* still include trezor in build (stub implementation)

* remove DEVICE_TREZOR_READY

* fmt

* dont include ledger and trezor support

* ci: dont fail fast

* feat(monero-sys): Link boost statically

* feat(monero-sys): Link OpenSSL (ssl and crypto libraries) statically

* breaking: remove monero.wallet_rpc_url in asb config, take monero.daemon_url instead

* fix MoneroDaemon::is_available

* add test case for special paths

* fix simple test (was failing because tx fee wasn't considered

* add ffi sanitization test commands to justfile. todo: run these in CI

* add dep on futures crate for testing

* improve comments

* just fmt

* remove ThreadSanatizer as it doesn't work well with c++ bindings

* update mem test command to use nightly cargo

* fix(bob): Only warn if .expired_timelock(..) check fails in BtcLocked state

* Resolve merge conflicts and add missing imports - Merged workflow configuration changes, CHANGELOG.md, tracing_util.rs, tauri_bindings.rs, network swap_setup alice.rs - Added missing imports for monero::Amount, url::Url, Duration, wallet types - Some API changes in monero wallet still need to be addressed

* fix merge conflicts

* dprint fmt, remove unused progress bars

* link unbound statically (works on mac)

* link protobuf dynamically (works on mac)

* install libnghttp2-dev in linux for building, add justfile command for installing brew deps

* install libevent-dev and libexpat1-dev on linux

* Dockerfile: install libnghttp2-dev, libevent-dev, libexpat1-dev and build in debug mode

* set CMAKE_DISABLE_FIND_PACKAGE_HIDAPI

* if ci: -j1, else -j4 for monero-sys

* println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu");

* print full libp2p network errors

* add migrate steps for wallet files to changelog

* fix dockerfiel to use ubuntu24

* fix build ubuntu

* fix(monero-sys): opt-level = 2

* opt-level = 0

* version: bump to 2.1.0-beta

* include monero_cpp in tracing

* bump version to 2.1.0-beta.2

* fmt

* fix  merge conflict in vscode.settings

* use uint64_t instead o fu_int64_t

* dynamically detect mac os brew prefix folder

* fmt

* add todo

* remove unused coce

* update docs for monero-wallet-rpc removal

* Revert "dynamically detect mac os brew prefix folder"

This reverts commit b55cbe3e115a3f98935815b7d37cb975c8f1a012.

* update comment/test

* try fix monero harness test

* catch exceptions in c++ ffi calls, for some methods calls .expect() on the rust side now

* force debug monero-sys mode

* Reapply "dynamically detect mac os brew prefix folder"

This reverts commit 0b340417525c085d213e6b6c1310410cd29dcc91.

* fix tests

* update synchronized() method

* don't force refresh before sweep

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: einliterflasche <einliterflasche@pm.me>
Co-authored-by: b-enedict <92430555+b-enedict@users.noreply.github.com>
Co-authored-by: unstoppableswap-botty <binarybaron_bot@proton.me>
Co-authored-by: UnstoppableSwap Botty <help@unstoppableswap.net>
Co-authored-by: Raphael <81313171+Einliterflasche@users.noreply.github.com>
Co-authored-by: root <root@vmd145754.contaboserver.net>
This commit is contained in:
Mohan 2025-06-17 10:55:50 +02:00 committed by GitHub
parent 26eaf06ecf
commit 2e6d324ab8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
77 changed files with 5683 additions and 2280 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "unstoppableswap-gui-rs"
version = "2.0.3"
version = "2.1.0-beta.2"
authors = [ "binarybaron", "einliterflasche", "unstoppableswap" ]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -9,7 +9,7 @@ description = "GUI for XMR<>BTC Atomic Swaps written in Rust"
[lib]
name = "unstoppableswap_gui_rs_lib"
crate-type = [ "lib", "cdylib", "staticlib" ]
crate-type = [ "lib", "staticlib" ]
[build-dependencies]
tauri-build = { version = "^2.0.0", features = [ "config-json5" ] }

View file

@ -378,7 +378,7 @@ async fn initialize_context(
bitcoin_target_block: None,
})
.with_monero(Monero {
monero_daemon_address: settings.monero_node_url.clone(),
monero_node_address: settings.monero_node_url.clone(),
})
.with_json(false)
.with_debug(true)

View file

@ -1,6 +1,6 @@
{
"productName": "UnstoppableSwap",
"version": "2.0.3",
"version": "2.1.0-beta.2",
"identifier": "net.unstoppableswap.gui",
"build": {
"devUrl": "http://localhost:1420",