Bitcoin–Monero Cross-chain Atomic Swap
Find a file
Mohan 07f935bfbc
feat(protocol): Early Bitcoin refund (#344)
* feat(protocol): Early Bitcoin refund

Alice can choose to let Bob refund his Bitcoin early (before TxCancel timelock expires)

* feat: Let Bob check for TxEarlyRefund

* fix: compile errors
feat(alice): if we cannot lock Monero within 2 minutes, early refund bitcoin

* satisfy clippy

* fix(gui): Emit tauri event when Bitcoin is early refunded

* tests progress

* rename AliceStates

* progress: working prototype!

* add unit tests for tx_early_refund construction (tx_early_refund_can_be_constructed_and_signed, tx_early weight check)

* fix compile error in swap/tests/alice_zero_xmr_early_refund.rs

* only make [`tx_early_refund_sig_bob`] optional in state machine, not message machine

* feat: working integration test alice_zero_xmr_early_refund.rs

* fix tests

* add changelog entry, add integration test with broken monero-wallet-rpc simulation

* amend

* amend changelog

* nitpick

* feat(gui): Bump MIN_ASB_VERSION to 2.0.0

* feat(bob): explicitly check for tx_early_rewfund

* refactor(bob): Assume tx_early_refund will not be published if timelock has expired

* add todo

* refactor

* refactor(swap): Differentiate between BtcRefundPublished, BtcEarlyRefundPublished, BtcEarlyRefunded and BtcRefunded

* refactor: move weight of tx_early into TX_EARLY_REFUND_WEIGHT const

* efactor(swap): Differentiate between BtcRefundPublished,BtcEarlyRefundPublished, BtcEarlyRefunded and BtcRefunded

* small refactors

* nitpciks

* dprint fmt

* add context to get_raw_transaction

* refactor: remove duplicated code in watch_for_redeem_btc, dprint fmt

* fix: parse -5 electrum transaction not found error correctly

* refactor: send btc_refund_finalized flag to tauri with BtcRefunded state

* remove uncessary .context

* dprint dfmt

* remove unused import

* refactor: explicitly mark state3.expired_timelocks(...) as transient error when locking Monero

* use .context instead of ok_or_else(...)

* fix: in get_raw_transaction also check for "missing transaction"

* add 4 different types of tauri events for different refund states

* display BobStateName.BtcEarlyRefunded as done state

* add global bottom to DialogContentText

* fix(gui): Add missing padding in SwapDialog

* proof of concept: electrum load balancer

* load balancer progress

* wrap Mutex<Vec<Arc<BdkElectrumClient<Client>>>> in electrum_balancer in another Arc, free locks as fast as possible

* refactor

* refactor(electrum balancer): use OnceCell to do lazy initilization

* tests

* refactor(electrum): enhance error handling with MultiError for comprehensive failure analysis

This commit introduces a robust MultiError system for the Electrum balancer that collects
and exposes all individual node failures, enabling better error analysis and decision making.

Key improvements:
- Add MultiError struct with methods for inspecting all collected errors from failed nodes
- Modify electrum_balancer::call() to return MultiError instead of single Error
- Enhance Client::get_tx() to properly detect transaction-not-found across multiple nodes
- Add call_async_with_multi_error() method for detailed async error analysis
- Improve error tracing and logging throughout the Bitcoin wallet operations
- Add comprehensive test coverage for MultiError functionality and edge cases
- Remove obsolete should_retry_on_error() logic in favor of MultiError inspection

The MultiError type maintains backward compatibility through automatic conversion to Error
while providing rich error analysis capabilities for callers that need detailed failure
information. This particularly improves handling of transaction-not-found scenarios where
different nodes may return different error formats.

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

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

* add changelog entry for electrum node balancing

* refactors of electrum balancer

* only warn if .check_for_tx_early_refund fails

* clippy

* remove verbose message

* use AtomicUsize

* final touches

* log libp2p crates

* merge master

* display LinearProgressWithSubtitle as indeterminate if progress=100%

* let broadcast return a MultiError, log all libp2p crates

* nitpick

* make clippy happy

* log "kind" for join_all load balancer

* add kind to join_all method, show warning alert if alice takes a long time to redeem Bitcoin

* parse multierrors correctly

* fmt

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-11 20:40:16 +02:00
.cargo feat(asb + cli): Redact logs + unify tracing infrastructure (#1733) (#55) 2024-09-01 18:13:43 +02:00
.github feat(protocol): Early Bitcoin refund (#344) 2025-06-11 20:40:16 +02:00
.vscode feat(protocol): Early Bitcoin refund (#344) 2025-06-11 20:40:16 +02:00
dev-docs refactor(gui): Update MUI to v7 (#383) 2025-06-06 22:31:33 +02:00
dev_scripts dev: Add code2prompt scripts to extract entire codebase into single file (#285) 2025-04-15 14:59:38 +02:00
docs refactor(gui): Update MUI to v7 (#383) 2025-06-06 22:31:33 +02:00
monero-harness refactor(gui): Update MUI to v7 (#383) 2025-06-06 22:31:33 +02:00
monero-rpc feat(protocol): Early Bitcoin refund (#344) 2025-06-11 20:40:16 +02:00
monero-wallet refactor(gui): Update MUI to v7 (#383) 2025-06-06 22:31:33 +02:00
src-gui feat(protocol): Early Bitcoin refund (#344) 2025-06-11 20:40:16 +02:00
src-tauri feat(protocol): Early Bitcoin refund (#344) 2025-06-11 20:40:16 +02:00
swap feat(protocol): Early Bitcoin refund (#344) 2025-06-11 20:40:16 +02:00
utils/gpg_keys fix: Remove .DS_STORE file 2024-07-26 14:44:40 +02:00
.gitignore upgrade(swap): Concurrent syncing, bdk upgrade, refactors (#180) 2025-05-18 22:54:03 +02:00
.gitmodules upgrade(swap): Concurrent syncing, bdk upgrade, refactors (#180) 2025-05-18 22:54:03 +02:00
AGENT.md fix(dprint): Ignore .git folder 2025-05-26 21:05:28 +02:00
Cargo.lock Release version 1.1.7 (#377) 2025-06-04 16:36:37 +02:00
Cargo.toml refactor(gui): Update MUI to v7 (#383) 2025-06-06 22:31:33 +02:00
CHANGELOG.md feat(protocol): Early Bitcoin refund (#344) 2025-06-11 20:40:16 +02:00
CONTRIBUTING.md docs(dev): switch test instructions to nextest (#361) 2025-05-27 11:05:49 +02:00
Dockerfile fix(Dockerfile): Use swarm base debian version for builder and executor 2024-11-15 01:18:14 +01:00
dprint.json refactor(gui): Update MUI to v7 (#383) 2025-06-06 22:31:33 +02:00
justfile refactor(gui): Update MUI to v7 (#383) 2025-06-06 22:31:33 +02:00
LICENSE Change license to GPLv3 2020-10-12 17:13:25 +11:00
README.md docs(dev): switch test instructions to nextest (#361) 2025-05-27 11:05:49 +02:00
rust-toolchain.toml fix: Issues with 1.1.0-rc (#328) 2025-05-19 12:43:27 +02:00

UnstoppableSwap

This is the monorepo containing the source code for all of our core projects:

  • swap contains the source code for the main swapping binaries, asb and swap
  • gui contains the new tauri based user interface
  • tauri contains the tauri bindings between binaries and user interface
  • and other crates we use in our binaries

If you're just here for the software, head over to the releases tab and grab the binary for your operating system! If you're just looking for documentation, check out our docs page or our github docs.

Join our Matrix room to follow development more closely.

Screenshot 2024-11-21 at 6 19 03 PM

Running tests

This repository uses cargo-nextest to run the test suite.

cargo install cargo-nextest
cargo nextest run