mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-25 06:39:53 -04:00
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>
This commit is contained in:
parent
8aad1bdf75
commit
07f935bfbc
54 changed files with 3204 additions and 392 deletions
|
@ -374,7 +374,7 @@ async fn initialize_context(
|
|||
|
||||
let context_result = ContextBuilder::new(testnet)
|
||||
.with_bitcoin(Bitcoin {
|
||||
bitcoin_electrum_rpc_url: settings.electrum_rpc_url.clone(),
|
||||
bitcoin_electrum_rpc_urls: settings.electrum_rpc_urls.clone(),
|
||||
bitcoin_target_block: None,
|
||||
})
|
||||
.with_monero(Monero {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue