GithubHelp home page GithubHelp logo

comit-network / xmr-btc-swap Goto Github PK

View Code? Open in Web Editor NEW
603.0 19.0 75.0 6.46 MB

Bitcoin–Monero Cross-chain Atomic Swap

License: GNU General Public License v3.0

Rust 99.77% Shell 0.04% Shell 0.19%
bitcoin hacktoberfest monero atomic-swap rust

xmr-btc-swap's Introduction

XMR to BTC Atomic Swap

This repository hosts an MVP for atomically swapping BTC to XMR. It implements the protocol described in section 3 of this paper.

More information about the protocol in this presentation and this blog post.

Currently, swaps are only offered in one direction with the swap CLI on the buying side (send BTC, receive XMR). We are working on implementing a protocol where XMR moves first, but are currently blocked by advances on Monero itself. You can read this blogpost for more information.

Quick Start

  1. Download the latest swap binary release for your operating system.
  2. Find a seller to swap with:
./swap --testnet list-sellers
  1. Swap with a seller:
./swap --testnet buy-xmr --receive-address <YOUR MONERO ADDRESS> --change-address <YOUR BITCOIN CHANGE ADDRESS> --seller <SELLER MULTIADDRESS>

For more detailed documentation on the CLI, see this README.

Becoming a Market Maker

Swapping of course needs two parties - and the CLI is only one of them: The taker that occasionally starts a swap with a market maker.

If you are interested in becoming a market maker you will want to run the second binary provided in this repository: asb - the Automated Swap Backend. Detailed documentation for the asb can be found in this README.

Safety

This software is using cryptography that has not been formally audited. While we do our best to make it safe, it is up to the user to evaluate whether or not it is safe to use for their purposes. Please also see section 15 and 16 of the license.

Keep in mind that swaps are complex protocols, it is recommended to not do anything fancy when moving coins in and out. It is not recommended to bump fees when swapping because it can have unpredictable side effects.

Contributing

We encourage community contributions whether it be a bug fix or an improvement to the documentation. Please have a look at the contribution guidelines.

Rust Version Support

Please note that only the latest stable Rust toolchain is supported. All stable toolchains since 1.70 should work.

Contact

Feel free to reach out to us in the COMIT-Monero Matrix channel.

xmr-btc-swap's People

Contributors

andresmc1995 avatar binarybaron avatar bonomat avatar bors[bot] avatar c22 avatar comit-botty-mc-botface avatar d4nte avatar da-kami avatar delta1 avatar dependabot[bot] avatar ikmckenz avatar jerzybrzoska avatar lescuer97 avatar luckysori avatar pokkst avatar rishflab avatar samouraidev avatar steverusso avatar thomaseizinger avatar xscd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xmr-btc-swap's Issues

[SP] Automated Swap Backend

The Service Provider (SP) also runs a backend that has the role to execute swaps. The backend...

  • #174 WIP - automatically executes a swap when reached via the p2p interface.
  • gets any related configuration items for a config file, the config file has reasonable defaults.
  • provides an API to allow the website to access the current rate.
  • uses kraken mid-market rate as rate.
  • uses an up-to-date rate when locking the Bitcoin asset.
  • does not proceed with swap execution if predicted Bitcoin quantity to sell is above a configurable ratio of total balance.
  • uses bitcoind wallet as Bitcoin Wallet.
  • uses monero-wallet-rpc as Monero Wallet.
  • prints Bitcoin cancellation, Bitcoin punishment transactions when computed
  • prints Monero (refund) private key when the protocol allows (Bitcoin refunded)
  • can run several swaps concurrently.
  • Bonus: bundles the swap website, allowing the SP operator to just proxy from their favourite webserver.

Experimental P2P App

I was reading your Medium and is very fascinating, I think so that could be interesting the idea to have an experimental P2P App to test swaps between Bitcoin and Monero.

Change `dialing` to be related to the trading roles and independent of the protocol roles

Problem

Currently Bob always dials Alice to establish a connection for the swap. If we want to allow swaps in both directions, this does not make sense, because the taker would always have to dial the maker, because only the maker's dial information is (publicly) available.

Note, that this comes with the implication that the swap tool would have a mode that is only to be used by a taker, and a maker would run different (automated) software that is set up to just listen (no matter what if Alice or Bob on the protocol level).

Goal

Be able to dial the maker as a taker.

(Possible solutions / recommendations yet to be discussed)

Migrate libp2p implementation from response channel usage to one shot protocols

Currently, Alice replies through response channel. They become invalid if the connection with Bob drops (while waiting for a transaction to be confirmed for example). By moving away from response channels, we:

  • increase the number of scenarios where the swap can be resumed upon a restart. We currently abort the swap if an issue occurs and the next message is Alice responding to Bob
  • Improve robustness, we are currently not able to proceed with testnet swap across this internet due to connection being drop and the current design.

[User] Swap CLI

The user only needs the swap CLI to execute swap, blockchain node requirements are listed as part of the users stories.

As a user, ...:

#178 - Bitcoin wallet:

  • I am not expected to run a Bitcoin full node or any Bitcoin software to execute a swap.
  • I need to deposit Bitcoin funds to the CLI before attempting to execute a swap.
  • I can request a Bitcoin address for deposit by running the deposit command.
  • I can request the CLI's bitcoin balance by running the balance command.
  • I can withdraw any leftover bitcoin by using the withdraw command.

Monero wallet:

  • I need to run a monero-wallet-rpc instance that will be used by the CLI as a Monero Wallet.
  • I do not need to load my monero wallet, the swap-tool will create a temporary wallet for watching the chain, and the redeemed monero funds will be stored in another wallet that is created using generate_from_keys.
  • Bonus: I do not have to transfer fund from the new created wallet manually, the CLI handles that for me and I do not even need to be aware of the creation of the temporary wallet. The only thing I have to provide is an address where the redeemed Monero end up.

Config:

  • #161 (needs follow up after Bitcoin wallet changes) - I can configure global parameters (ie, not specific to a given swap) using a configuration file which has reasonable default values.

Swap:

  • I can execute a swap by running the swap command.
  • I can resume a swap execution using resume <swap id> command, this will make a best effort to successfully complete the swap.
  • I can check pending swaps using list command, do note that this command can only be ran if the CLI is stopped (and hence, no swaps are being executed).
  • I can check all swaps ever made using list --all command.
  • I do not expect for the CLI to automatically recover funds if the swap is cancelled (see [1]).
  • #170 WIP - I can get the Bitcoin cancellation transaction and have it broadcasted by the CLI using the cancel command. I can force the CLI to broadcast despite expiry not being reached with --force. Unclear whether the CLI would then change the state of the swap at this stage. A read-only command may yield better recovery results. The CLI still prints current blockchain block and cancel expiry blockheight.
  • #170 WIP - I can get the Bitcoin refund transaction and have it broadcasted by the CLI using the refund command. I can force the CLI to broadcast despite expiry not being reached with --force. Unclear whether the CLI would then change the state of the swap at this stage. A read-only command may yield better recovery results. The CLI still prints current blockchain block and punish expiry blockheight.
  • I can get the Monero refund private key, if the protocol allows it, and have it loaded in a new wallet of my monero-wallet-rpc using refund command. User does not refund Monero.
  • Bonus: I get notified (warn log) if an expiry has passed during swap execution.

Resume test results

Resuming swaps tested on test-/stagenet

Summary

Bob

Bob's resume only works after XMR lock tx received the necessary confirmations. If Bob tries to resume the swap before XMR was locked and confirmed Bob will not be able to resume, but will wait for refund (no matter what the timelocks are). This happens due to two problems:

  1. The response channels that Alice uses are not intact after restarting the application.
  2. Bob does not record Alice's lock proof (message 2) by saving a separate state after receiving Message2. So, when restarted Bob waits for the lock proof again, which never arrives. The time-window of this failure is closed once XMR lock transactions has the necessary confirmations and Bob transitions to XmrLocked.

Other problems:

  • When Bob is started in BtcLocked with punish timelock already expired but Alice had not punished, Bob will send cancel tx, but not the refund tx. So Bob sends cancel, but then directly transitions to punished. This makes no sense - either not send cancel and stop or send cancel and try to refund.

Alice

  • After EncSigLearned Alice may fail when trying to redeem. There is a bug where we always publish the redeem tx on her side in that state without taking timelocks in account (Bob already moved and cancelled, Alice redeem always fails, she never transitions and never refunds / punishes). See:
    AliceState::EncSigLearned {
    state3,
    encrypted_signature,
    } => {
    // TODO: Evaluate if it is correct for Alice to Redeem no matter what.
    // If cancel timelock expired she should potentially not try redeem. (The
    // implementation gives her an advantage.)
    let signed_tx_redeem = match build_bitcoin_redeem_transaction(
    encrypted_signature,
    &state3.tx_lock,
    state3.a.clone(),
    state3.s_a,
    state3.B,
    &state3.redeem_address,
    ) {
    Ok(tx) => tx,
    Err(_) => {
    state3
    .wait_for_cancel_timelock_to_expire(bitcoin_wallet.as_ref())
    .await?;
    let state = AliceState::CancelTimelockExpired { state3 };
    let db_state = (&state).into();
    db.insert_latest_state(swap_id, Swap::Alice(db_state))
    .await?;
    return run_until(
    state,
    is_target_state,
    event_loop_handle,
    bitcoin_wallet,
    monero_wallet,
    config,
    swap_id,
    db,
    )
    .await;
    }
    };
    // TODO(Franck): Error handling is delicate here.
    // If Bob sees this transaction he can redeem Monero
    // e.g. If the Bitcoin node is down then the user needs to take action.
    publish_bitcoin_redeem_transaction(
    signed_tx_redeem,
    bitcoin_wallet.clone(),
    config,
    )
    .await?;
    let state = AliceState::BtcRedeemed;
  • There are multiple ToDos for broadcasting Alice's cancel tx in code that can lead to failure.
    // TODO(Franck): Maybe the cancel transaction is already mined, in this case,
    // the broadcast will error out.
    let sig_a = a.sign(tx_cancel.digest());
    let sig_b = tx_cancel_sig_bob.clone();
    let tx_cancel = tx_cancel
    .clone()
    .add_signatures(&tx_lock, (a.public(), sig_a), (B, sig_b))
    .expect("sig_{a,b} to be valid signatures for tx_cancel");
    // TODO(Franck): Error handling is delicate, why can't we broadcast?
    bitcoin_wallet
    .broadcast_signed_transaction(tx_cancel)
    .await?;
    // TODO(Franck): Wait until transaction is mined and returned mined
    // block height

Additional Comments

Validate that Alice's timeout error Error: Failed to receive dial connection from Bob is already fixed by #123 - If this is not fixed than Alice will never properly transition to refunding the XMR!

Details

Swap Cargo Run Commands

run alice:

run --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice sell-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name alice --receive-btc 0.0006 --send-xmr 0.03

run bob:

run --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --receive-xmr 0.03 --send-btc 0.0006 --connect-addr /ip4/127.0.0.1/tcp/9876 --connect-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi

Resume Alice

Resume in XmrLocked, before

Status: Both redeem successfully

Alice log

Before resume:

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice sell-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name alice --receive-btc 0.0006 --send-xmr 0.03
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
warning: unreachable statement
   --> swap/src/protocol/alice/swap.rs:217:25
    |
215 |                           panic!("Alice panics in XmrLocked before waiting for EncSig");
    |                           -------------------------------------------------------------- any code following this expression is unreachable
216 | 
217 | /                         let wait_for_enc_sig =
218 | |                             wait_for_bitcoin_encrypted_signature(&mut event_loop_handle);
    | |_________________________________________________________________________________________^ unreachable statement
    |
    = note: `#[warn(unreachable_code)]` on by default

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 38.18s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice sell-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name alice --receive-btc 0.0006 --send-xmr 0.03`
2021-01-11T07:51:32.717221Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T07:51:32.718751Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice
2021-01-11T07:51:32.958234Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice/seed.pem
2021-01-11T07:51:33.357389Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.00429521 BTC
2021-01-11T07:51:33.363298Z  INFO swap: Connection to Monero wallet succeeded, balance: 29.305946330000 XMR
2021-01-11T07:51:33.554304Z  INFO swap: Swap sending 0.030000000000 XMR and receiving 0.00060000 BTC started with ID ef0128ad-2394-4071-bea4-7f5e8cb49726
2021-01-11T07:51:33.555957Z  INFO swap: Own Peer-ID: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T07:51:33.559673Z  INFO swap::protocol::alice::swap: Current state:started
2021-01-11T07:52:26.228414Z  INFO swap::protocol::alice: Sent amounts response
2021-01-11T07:52:29.935937Z  INFO swap::protocol::alice::state: Producing first message
2021-01-11T07:52:37.901083Z  INFO swap::protocol::alice::swap: Current state:negotiated
2021-01-11T07:56:22.926101Z  INFO swap::protocol::alice::swap: Current state:btc is locked
2021-01-11T07:56:30.237700Z  INFO swap::monero::wallet: Monero tx broadcasted!, tx hash: TxHash("1cfd8d3aa315f522d4e60604edbe5dfe0e3be44e55323905293a9039858c41f2")
2021-01-11T07:56:30.247523Z  INFO swap::protocol::alice::swap: Current state:xmr is locked
thread 'main' panicked at 'Alice panics in XmrLocked before waiting for EncSig', swap/src/protocol/alice/swap.rs:215:25
stack backtrace:
...
Process finished with exit code 101

resume command:

run --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice resume sell-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name alice --swap-id ef0128ad-2394-4071-bea4-7f5e8cb49726 

Resume logs:

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice resume sell-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name alice --swap-id ef0128ad-2394-4071-bea4-7f5e8cb49726
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
    Finished dev [unoptimized + debuginfo] target(s) in 26.12s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice resume sell-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name alice --swap-id ef0128ad-2394-4071-bea4-7f5e8cb49726`
2021-01-11T08:29:24.949124Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T08:29:24.952124Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice
2021-01-11T08:29:25.379176Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice/seed.pem
2021-01-11T08:29:25.788886Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.00474521 BTC
2021-01-11T08:29:25.797020Z  INFO swap: Connection to Monero wallet succeeded, balance: 29.275862560000 XMR
2021-01-11T08:29:25.798181Z  INFO swap: Own Peer-ID: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T08:29:25.801402Z  INFO swap::protocol::alice::swap: Current state:btc is redeemed

Process finished with exit code 0

Bob logs

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --receive-xmr 0.03 --send-btc 0.0006 --connect-addr /ip4/127.0.0.1/tcp/9876 --connect-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
    Finished dev [unoptimized + debuginfo] target(s) in 31.74s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --receive-xmr 0.03 --send-btc 0.0006 --connect-addr /ip4/127.0.0.1/tcp/9876 --connect-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi`
2021-01-11T07:52:25.507943Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T07:52:25.509614Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T07:52:25.683416Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T07:52:25.687603Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03150796 BTC
2021-01-11T07:52:25.689590Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.030000000000 XMR
2021-01-11T07:52:26.209327Z  INFO swap: Swap sending 0.00060000 BTC and receiving 0.030000000000 XMR started with ID ebea6a47-f4b9-4a06-a449-99de63996ad0
2021-01-11T07:52:26.213502Z  INFO swap::protocol::bob::swap: Current state: started
2021-01-11T07:52:26.213825Z  INFO swap::protocol::bob::event_loop: dialing alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T07:52:26.226181Z  INFO swap::protocol::bob: Requesting amounts from: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T07:52:26.229278Z  INFO swap::protocol::bob::event_loop: Amounts received from Alice
2021-01-11T07:52:37.888738Z  INFO swap::protocol::bob::swap: Current state: negotiated
2021-01-11T07:52:37.890430Z  INFO swap::protocol::bob::state: a01a296d0c41a145ed0ef5a0196ebd73fa46221a7364790a3961571ad5f6a53e
2021-01-11T07:52:37.893464Z  INFO swap::bitcoin::wallet: Bitcoin tx broadcasted! TXID = a01a296d0c41a145ed0ef5a0196ebd73fa46221a7364790a3961571ad5f6a53e
2021-01-11T07:52:37.904006Z  INFO swap::protocol::bob::swap: Current state: btc is locked
2021-01-11T07:56:30.240224Z  INFO swap::protocol::bob::swap: Received XMR lock transaction transfer proof from Alice, watching for transfer confirmations
2021-01-11T08:13:29.905024Z  INFO swap::protocol::bob::swap: Current state: xmr is locked
2021-01-11T08:13:29.915663Z  INFO swap::protocol::bob::event_loop: dialing alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T08:13:29.938778Z  INFO swap::protocol::bob::event_loop: Alice acknowledged message 3 received
2021-01-11T08:13:29.942445Z  INFO swap::protocol::bob::swap: Current state: encrypted signature is sent
2021-01-11T08:13:31.392893Z  INFO swap::protocol::bob::swap: Current state: btc is redeemed
2021-01-11T08:13:34.503184Z  INFO swap::protocol::bob::swap: Current state: xmr is redeemed

Process finished with exit code 0

Resume Bob

Resume in BtcLocked, before XMR lock proof was received

Status: Fails to resume because Bob does not receive lock proof of Alice due to response channel being closed

Alice log

Before Bob's resume:

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice sell-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name alice --receive-btc 0.0006 --send-xmr 0.03
    Finished dev [unoptimized + debuginfo] target(s) in 1.10s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice sell-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name alice --receive-btc 0.0006 --send-xmr 0.03`
2021-01-11T06:01:44.491393Z  INFO swap::trace: Initialized tracing with level: TRACE
2021-01-11T06:01:44.493190Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice
2021-01-11T06:01:44.659558Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice/seed.pem
2021-01-11T06:01:44.710756Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.00339521 BTC
2021-01-11T06:01:44.714055Z DEBUG monero_harness::rpc::wallet: get balance of account index 0 RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "balance": 29426281550000,
    "blocks_to_unlock": 0,
    "multisig_import_needed": false,
    "per_subaddress": [{
      "account_index": 0,
      "address": "5BTH2ahg4EVjUpZomNZnqwEc5o1CjCo4CPt8k5CFFXapELc9UuXbDGoCuXT8kX9Ezz2n9qDkjLBWqVYawai3Qv4P94riuNi",
      "address_index": 0,
      "balance": 29426281550000,
      "blocks_to_unlock": 0,
      "label": "Primary account",
      "num_unspent_outputs": 3,
      "time_to_unlock": 0,
      "unlocked_balance": 29426281550000
    }],
    "time_to_unlock": 0,
    "unlocked_balance": 29426281550000
  }
}
2021-01-11T06:01:44.714223Z  INFO swap: Connection to Monero wallet succeeded, balance: 29.426281550000 XMR
2021-01-11T06:01:44.872983Z  INFO swap: Swap sending 0.030000000000 XMR and receiving 0.00060000 BTC started with ID 0e737682-d110-4f55-b8ce-677a023de12b
2021-01-11T06:01:44.874790Z  INFO swap: Own Peer-ID: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:01:44.878367Z  INFO swap::protocol::alice::swap: Current state:started
2021-01-11T06:01:44.878597Z TRACE swap::protocol::alice::steps: Starting negotiate
2021-01-11T06:03:35.423521Z DEBUG swap::network::request_response: enter read_request
2021-01-11T06:03:35.424865Z DEBUG swap::protocol::alice::amounts: Received amounts request
2021-01-11T06:03:35.425070Z  INFO swap::protocol::alice: Sent amounts response
2021-01-11T06:03:35.425173Z DEBUG swap::network::request_response: enter write_response
2021-01-11T06:03:39.424906Z DEBUG swap::network::request_response: enter read_request
2021-01-11T06:03:39.716778Z DEBUG swap::protocol::alice::message0: Received Message0
2021-01-11T06:03:39.716883Z  INFO swap::protocol::alice::state: Producing first message
2021-01-11T06:03:43.479602Z DEBUG swap::protocol::alice: Sent Message0
2021-01-11T06:03:43.479754Z DEBUG swap::network::request_response: enter write_response
2021-01-11T06:03:48.390624Z DEBUG swap::network::request_response: enter read_request
2021-01-11T06:03:48.395216Z DEBUG swap::protocol::alice::message1: Received Message1
2021-01-11T06:03:48.406212Z DEBUG swap::protocol::alice: Sent Message1
2021-01-11T06:03:48.406359Z DEBUG swap::network::request_response: enter write_response
2021-01-11T06:03:48.428636Z DEBUG swap::network::request_response: enter read_request
2021-01-11T06:03:48.430159Z DEBUG swap::protocol::alice::message2: Received Message2
2021-01-11T06:03:48.443739Z  INFO swap::protocol::alice::swap: Current state:negotiated
2021-01-11T06:08:48.471214Z  INFO swap::protocol::alice::swap: Current state:btc is locked
2021-01-11T06:08:54.684693Z DEBUG monero_harness::rpc::wallet: transfer RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "amount": 30000000000,
    "fee": 83720000,
    "multisig_txset": "",
    "tx_blob": "",
    "tx_hash": "bfb02f9bab86ff68865c1fa14cbeb6f75afc7b7ad1d8209637e900eb50ffa56b",
    "tx_key": "e16c8d453e588312020d1f6c795347ed460b31c7450fcfb2861db43385b63e0b",
    "tx_metadata": "",
    "unsigned_txset": "",
    "weight": 1445
  }
}
2021-01-11T06:08:54.684941Z  INFO swap::monero::wallet: Monero tx broadcasted!, tx hash: TxHash("bfb02f9bab86ff68865c1fa14cbeb6f75afc7b7ad1d8209637e900eb50ffa56b")
2021-01-11T06:08:54.685081Z DEBUG swap::monero::wallet:   Transfer proof: TransferProof { tx_hash: TxHash("bfb02f9bab86ff68865c1fa14cbeb6f75afc7b7ad1d8209637e900eb50ffa56b"), tx_key: PrivateKey { scalar: Scalar{
	bytes: [225, 108, 141, 69, 62, 88, 131, 18, 2, 13, 31, 108, 121, 83, 71, 237, 70, 11, 49, 199, 69, 15, 207, 178, 134, 29, 180, 51, 133, 182, 62, 11],
} } }
2021-01-11T06:08:54.685357Z DEBUG swap::protocol::alice: Sent Message2
2021-01-11T06:08:54.695535Z  INFO swap::protocol::alice::swap: Current state:xmr is locked

Bob log

(log before restart not recorded for this scenario)

Resume command:

run --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 36786d68-c6d6-413d-9dae-adf7ec183647

Log after resume:

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 36786d68-c6d6-413d-9dae-adf7ec183647
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
    Finished dev [unoptimized + debuginfo] target(s) in 35.22s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 36786d68-c6d6-413d-9dae-adf7ec183647`
2021-01-11T06:10:29.330347Z  INFO swap::trace: Initialized tracing with level: TRACE
2021-01-11T06:10:29.332095Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T06:10:29.655315Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T06:10:29.663182Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03331255 BTC
2021-01-11T06:10:30.346022Z DEBUG monero_harness::rpc::wallet: get balance of account index 0 RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "balance": 30000000000,
    "blocks_to_unlock": 0,
    "multisig_import_needed": false,
    "per_subaddress": [{
      "account_index": 0,
      "address": "5393oD4pkUAgYWnMVoCwLE1k2YtbBYzvWhq4ATeJSDLQ9CtUzPVGbx61962VngEQBPUg62czaJ55bMiZydHvaVSwTmbXyUP",
      "address_index": 0,
      "balance": 30000000000,
      "blocks_to_unlock": 0,
      "label": "Primary account",
      "num_unspent_outputs": 1,
      "time_to_unlock": 0,
      "unlocked_balance": 30000000000
    }],
    "time_to_unlock": 0,
    "unlocked_balance": 30000000000
  }
}
2021-01-11T06:10:30.346130Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.030000000000 XMR
2021-01-11T06:10:30.348645Z  INFO swap::protocol::bob::swap: Current state: btc is locked
2021-01-11T06:10:30.705841Z DEBUG swap::protocol::bob::event_loop: Attempt to dial Alice
2021-01-11T06:10:30.706060Z  INFO swap::protocol::bob::event_loop: dialing alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi

Resume in BtcLocked, after XMR lock proof was received

Status: Fails to resume because Bob does not record the lock proof received, upon restart waits for it again.
Note that this failure window is until XMR lock tx received the necessary confirmations!

Bob log

Before resume:

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --receive-xmr 0.03 --send-btc 0.0006 --connect-addr /ip4/127.0.0.1/tcp/9876 --connect-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
warning: unreachable statement
   --> swap/src/protocol/bob/swap.rs:154:29
    |
152 |   ...     panic!("Bob panics in BtcLocked after receiving Alice's lock proof (msg2) but before XMR confirmations are finished.");
    |           ----------------------------------------------------------------------------------------------------------------------- any code following this expression is unreachable
153 |   ...
154 | / ...     let xmr_lock_watcher = state3.clone()
155 | | ...         .watch_for_lock_xmr(monero_wallet.as_ref(), msg2);
    | |______________________________________________________________^ unreachable statement
    |
    = note: `#[warn(unreachable_code)]` on by default

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 31.41s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --receive-xmr 0.03 --send-btc 0.0006 --connect-addr /ip4/127.0.0.1/tcp/9876 --connect-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi`
2021-01-11T06:45:39.686687Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T06:45:39.689384Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T06:45:40.083382Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T06:45:40.088677Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03271102 BTC
2021-01-11T06:45:40.090141Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.000000000000 XMR
2021-01-11T06:45:40.378042Z  INFO swap: Swap sending 0.00060000 BTC and receiving 0.030000000000 XMR started with ID 293b1948-54d0-4439-a095-529c2a4b8f06
2021-01-11T06:45:40.381018Z  INFO swap::protocol::bob::swap: Current state: started
2021-01-11T06:45:40.382546Z  INFO swap::protocol::bob::event_loop: dialing alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:45:40.395650Z  INFO swap::protocol::bob: Requesting amounts from: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:45:40.399084Z  INFO swap::protocol::bob::event_loop: Amounts received from Alice
2021-01-11T06:45:53.619125Z  INFO swap::protocol::bob::swap: Current state: negotiated
2021-01-11T06:45:53.620780Z  INFO swap::protocol::bob::state: 89eeecd23546b21c0a17657405cbf0ec298160807f181f1727520793e69b2f9d
2021-01-11T06:45:53.624140Z  INFO swap::bitcoin::wallet: Bitcoin tx broadcasted! TXID = 89eeecd23546b21c0a17657405cbf0ec298160807f181f1727520793e69b2f9d
2021-01-11T06:45:53.633937Z  INFO swap::protocol::bob::swap: Current state: btc is locked
2021-01-11T06:48:36.233912Z  INFO swap::protocol::bob::swap: Received XMR lock transaction transfer proof from Alice, watching for transfer confirmations
thread 'main' panicked at 'Bob panics in BtcLocked after receiving Alice's lock proof (msg2) but before XMR confirmations are finished.', /Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap/src/protocol/bob/swap.rs:152:29
stack backtrace:
...

Process finished with exit code 101

Resume command:

run --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 293b1948-54d0-4439-a095-529c2a4b8f06

Logs after resume:

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 293b1948-54d0-4439-a095-529c2a4b8f06
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
    Finished dev [unoptimized + debuginfo] target(s) in 32.19s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 293b1948-54d0-4439-a095-529c2a4b8f06`
2021-01-11T06:55:21.412412Z  INFO swap::trace: Initialized tracing with level: DEBUG
2021-01-11T06:55:21.414062Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T06:55:21.567823Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T06:55:21.573815Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03210949 BTC
2021-01-11T06:55:21.575287Z DEBUG monero_harness::rpc::wallet: get balance of account index 0 RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "balance": 0,
    "blocks_to_unlock": 0,
    "multisig_import_needed": false,
    "time_to_unlock": 0,
    "unlocked_balance": 0
  }
}
2021-01-11T06:55:21.575368Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.000000000000 XMR
2021-01-11T06:55:21.577703Z  INFO swap::protocol::bob::swap: Current state: btc is locked
2021-01-11T06:55:21.584248Z DEBUG swap::protocol::bob::event_loop: Attempt to dial Alice
2021-01-11T06:55:21.584460Z  INFO swap::protocol::bob::event_loop: dialing alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi

Started in Debug mode to prove that Bob never starts watching XMR transfer status, because lock proof was not recorded as state.

Alice log

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice sell-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name alice --receive-btc 0.0006 --send-xmr 0.03
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
    Finished dev [unoptimized + debuginfo] target(s) in 34.97s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice sell-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name alice --receive-btc 0.0006 --send-xmr 0.03`
2021-01-11T06:44:25.665484Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T06:44:25.667195Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice
2021-01-11T06:44:26.058245Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice/seed.pem
2021-01-11T06:44:26.457761Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.00384521 BTC
2021-01-11T06:44:26.461166Z  INFO swap: Connection to Monero wallet succeeded, balance: 29.366113940000 XMR
2021-01-11T06:44:26.643710Z  INFO swap: Swap sending 0.030000000000 XMR and receiving 0.00060000 BTC started with ID ffef988f-1e73-4b45-b93c-3914a00fd935
2021-01-11T06:44:26.645150Z  INFO swap: Own Peer-ID: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:44:26.650395Z  INFO swap::protocol::alice::swap: Current state:started
2021-01-11T06:45:40.398188Z  INFO swap::protocol::alice: Sent amounts response
2021-01-11T06:45:44.521346Z  INFO swap::protocol::alice::state: Producing first message
2021-01-11T06:45:53.628006Z  INFO swap::protocol::alice::swap: Current state:negotiated
2021-01-11T06:48:23.649566Z  INFO swap::protocol::alice::swap: Current state:btc is locked
2021-01-11T06:48:36.230923Z  INFO swap::monero::wallet: Monero tx broadcasted!, tx hash: TxHash("114e4bd74d747198f3692da16879c854936e0e488d350a9cc8d8a2718ebea9ec")
2021-01-11T06:48:36.240297Z  INFO swap::protocol::alice::swap: Current state:xmr is locked

Resume in XmrLocked, before EncSig sent

Status: Both redeem successfully

Bob log

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --receive-xmr 0.03 --send-btc 0.0006 --connect-addr /ip4/127.0.0.1/tcp/9876 --connect-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
warning: unreachable statement
   --> swap/src/protocol/bob/swap.rs:196:21
    |
194 |                     panic!("Bob panics when entering XmrLocked (before sending encsig)");
    |                     --------------------------------------------------------------------- any code following this expression is unreachable
195 | 
196 |                     event_loop_handle.dial().await?;
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
    |
    = note: `#[warn(unreachable_code)]` on by default

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 34.80s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --receive-xmr 0.03 --send-btc 0.0006 --connect-addr /ip4/127.0.0.1/tcp/9876 --connect-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi`
2021-01-11T06:14:16.107055Z  INFO swap::trace: Initialized tracing with level: TRACE
2021-01-11T06:14:16.108853Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T06:14:16.271084Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T06:14:16.275449Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03331255 BTC
2021-01-11T06:14:16.277018Z DEBUG monero_harness::rpc::wallet: get balance of account index 0 RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "balance": 30000000000,
    "blocks_to_unlock": 0,
    "multisig_import_needed": false,
    "per_subaddress": [{
      "account_index": 0,
      "address": "5393oD4pkUAgYWnMVoCwLE1k2YtbBYzvWhq4ATeJSDLQ9CtUzPVGbx61962VngEQBPUg62czaJ55bMiZydHvaVSwTmbXyUP",
      "address_index": 0,
      "balance": 30000000000,
      "blocks_to_unlock": 0,
      "label": "Primary account",
      "num_unspent_outputs": 1,
      "time_to_unlock": 0,
      "unlocked_balance": 30000000000
    }],
    "time_to_unlock": 0,
    "unlocked_balance": 30000000000
  }
}
2021-01-11T06:14:16.277129Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.030000000000 XMR
2021-01-11T06:14:16.774100Z  INFO swap: Swap sending 0.00060000 BTC and receiving 0.030000000000 XMR started with ID af240ef4-a36c-4993-bf52-742b3cb64de0
2021-01-11T06:14:16.776577Z  INFO swap::protocol::bob::swap: Current state: started
2021-01-11T06:14:16.776632Z DEBUG swap::protocol::bob::event_loop: Attempt to dial Alice
2021-01-11T06:14:16.776849Z  INFO swap::protocol::bob::event_loop: dialing alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:14:16.786146Z TRACE swap::protocol::bob::swap: Starting negotiate
2021-01-11T06:14:16.786358Z  INFO swap::protocol::bob: Requesting amounts from: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:14:16.788789Z DEBUG swap::network::request_response: enter read_response
2021-01-11T06:14:16.791298Z DEBUG swap::protocol::bob::amounts: Received amounts response
2021-01-11T06:14:16.791337Z  INFO swap::protocol::bob::event_loop: Amounts received from Alice
2021-01-11T06:14:20.916471Z DEBUG swap::protocol::bob: Sent Message0
2021-01-11T06:14:20.949201Z DEBUG swap::network::request_response: enter read_response
2021-01-11T06:14:25.845241Z DEBUG swap::protocol::bob::message0: Received Message0
2021-01-11T06:14:31.160909Z DEBUG swap::protocol::bob: Sent Message1
2021-01-11T06:14:31.163947Z DEBUG swap::network::request_response: enter read_response
2021-01-11T06:14:31.180839Z DEBUG swap::protocol::bob::message1: Received Message1
2021-01-11T06:14:31.202235Z DEBUG swap::protocol::bob: Sent Message2
2021-01-11T06:14:31.203833Z DEBUG swap::network::request_response: enter read_response
2021-01-11T06:14:31.212859Z  INFO swap::protocol::bob::swap: Current state: negotiated
2021-01-11T06:14:31.212922Z DEBUG swap::protocol::bob::event_loop: Attempt to dial Alice
2021-01-11T06:14:31.213335Z DEBUG swap::protocol::bob::event_loop: Already connected to Alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:14:31.217004Z  INFO swap::protocol::bob::state: 99a2d6580c03b80d25e1af2f550964663c228d374be4de06acf7738a800f9707
2021-01-11T06:14:31.219560Z  INFO swap::bitcoin::wallet: Bitcoin tx broadcasted! TXID = 99a2d6580c03b80d25e1af2f550964663c228d374be4de06acf7738a800f9707
2021-01-11T06:14:31.228987Z  INFO swap::protocol::bob::swap: Current state: btc is locked
2021-01-11T06:18:45.927086Z DEBUG swap::protocol::bob::event_loop: Attempt to dial Alice
2021-01-11T06:18:45.927332Z DEBUG swap::protocol::bob::event_loop: Already connected to Alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:19:37.498912Z DEBUG swap::protocol::bob::message2: Received Message2
2021-01-11T06:19:37.499229Z  INFO swap::protocol::bob::swap: Received XMR lock transaction transfer proof from Alice, watching for transfer confirmations
2021-01-11T06:19:37.499302Z DEBUG swap::protocol::bob::swap: Transfer proof: TransferProof { tx_hash: TxHash("03370adb44ab514b3b798840d4bca8c1cfac96b13d1fa1d40626b0b028a50e0e"), tx_key: PrivateKey { scalar: Scalar{
	bytes: [162, 40, 139, 16, 229, 216, 184, 40, 210, 2, 28, 114, 40, 210, 69, 1, 183, 131, 16, 19, 14, 65, 135, 15, 156, 138, 82, 162, 37, 172, 115, 14],
} } }
2021-01-11T06:19:38.112687Z DEBUG monero_harness::rpc::wallet: transfer RPC response: {
  "error": {
    "code": -1,
    "message": "Failed to get transaction from daemon"
  },
  "id": "1",
  "jsonrpc": "2.0"
}
2021-01-11T06:19:39.727700Z DEBUG monero_harness::rpc::wallet: transfer RPC response: {
  "error": {
    "code": -1,
    "message": "Failed to get transaction from daemon"
  },
  "id": "1",
  "jsonrpc": "2.0"
}
2021-01-11T06:19:41.390887Z DEBUG monero_harness::rpc::wallet: transfer RPC response: {
  "error": {
    "code": -1,
    "message": "Failed to get transaction from daemon"
  },
  "id": "1",
  "jsonrpc": "2.0"
}
2021-01-11T06:19:43.008837Z DEBUG monero_harness::rpc::wallet: transfer RPC response: {
  "error": {
    "code": -1,
    "message": "Failed to get transaction from daemon"
  },
  "id": "1",
  "jsonrpc": "2.0"
}
...
2021-01-11T06:30:03.067650Z DEBUG monero_harness::rpc::wallet: transfer RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "confirmations": 5,
    "in_pool": false,
    "received": 30000000000
  }
}
2021-01-11T06:30:03.080201Z  INFO swap::protocol::bob::swap: Current state: xmr is locked
thread 'main' panicked at 'Bob panics when entering XmrLocked (before sending encsig)', /Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap/src/protocol/bob/swap.rs:194:21
stack backtrace:
...

Resume command:

run --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id af240ef4-a36c-4993-bf52-742b3cb64de0

Logs after resume:

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id af240ef4-a36c-4993-bf52-742b3cb64de0
    Finished dev [unoptimized + debuginfo] target(s) in 1.11s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id af240ef4-a36c-4993-bf52-742b3cb64de0`
2021-01-11T06:34:04.970295Z  INFO swap::trace: Initialized tracing with level: TRACE
2021-01-11T06:34:04.971964Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T06:34:05.152744Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T06:34:05.542708Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03271102 BTC
2021-01-11T06:34:05.545960Z DEBUG monero_harness::rpc::wallet: get balance of account index 0 RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "balance": 30000000000,
    "blocks_to_unlock": 0,
    "multisig_import_needed": false,
    "per_subaddress": [{
      "account_index": 0,
      "address": "5393oD4pkUAgYWnMVoCwLE1k2YtbBYzvWhq4ATeJSDLQ9CtUzPVGbx61962VngEQBPUg62czaJ55bMiZydHvaVSwTmbXyUP",
      "address_index": 0,
      "balance": 30000000000,
      "blocks_to_unlock": 0,
      "label": "Primary account",
      "num_unspent_outputs": 1,
      "time_to_unlock": 0,
      "unlocked_balance": 30000000000
    }],
    "time_to_unlock": 0,
    "unlocked_balance": 30000000000
  }
}
2021-01-11T06:34:05.546092Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.030000000000 XMR
2021-01-11T06:34:05.549541Z  INFO swap::protocol::bob::swap: Current state: xmr is locked
2021-01-11T06:34:05.558192Z DEBUG swap::protocol::bob::event_loop: Attempt to dial Alice
2021-01-11T06:34:05.559401Z  INFO swap::protocol::bob::event_loop: dialing alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:34:05.580958Z DEBUG swap::protocol::bob: Sent Message3
2021-01-11T06:34:05.582883Z DEBUG swap::network::request_response: enter read_response
2021-01-11T06:34:05.585830Z  INFO swap::protocol::bob::event_loop: Alice acknowledged message 3 received
2021-01-11T06:34:05.597078Z  INFO swap::protocol::bob::swap: Current state: encrypted signature is sent
2021-01-11T06:34:06.715119Z  INFO swap::protocol::bob::swap: Current state: btc is redeemed
2021-01-11T06:34:08.511227Z DEBUG monero_harness::rpc::wallet: generate_from_keys RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "address": "55wh6zpJuWN6xBVGxMqMVYVb8MVr76LQMEHvz2J6ASz25JNxJe6LVQTRpgBZGwXbbMZ4ks4uL7YAMFADaBgcHaMWKbvANHM",
    "info": "Wallet has been generated successfully."
  }
}
2021-01-11T06:34:08.521366Z  INFO swap::protocol::bob::swap: Current state: xmr is redeemed

Process finished with exit code 0

Alice logs

Note: Not waiting for redeem to pass (has been proven that it does with other swaps):

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice sell-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name alice --receive-btc 0.0006 --send-xmr 0.03
    Finished dev [unoptimized + debuginfo] target(s) in 0.97s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice sell-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name alice --receive-btc 0.0006 --send-xmr 0.03`
2021-01-11T06:12:18.211579Z  INFO swap::trace: Initialized tracing with level: TRACE
2021-01-11T06:12:18.217001Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice
2021-01-11T06:12:18.411429Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice/seed.pem
2021-01-11T06:12:18.807800Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.00339521 BTC
2021-01-11T06:12:18.809911Z DEBUG monero_harness::rpc::wallet: get balance of account index 0 RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "balance": 29396197830000,
    "blocks_to_unlock": 8,
    "multisig_import_needed": false,
    "per_subaddress": [{
      "account_index": 0,
      "address": "5BTH2ahg4EVjUpZomNZnqwEc5o1CjCo4CPt8k5CFFXapELc9UuXbDGoCuXT8kX9Ezz2n9qDkjLBWqVYawai3Qv4P94riuNi",
      "address_index": 0,
      "balance": 29396197830000,
      "blocks_to_unlock": 8,
      "label": "Primary account",
      "num_unspent_outputs": 3,
      "time_to_unlock": 0,
      "unlocked_balance": 19606788430000
    }],
    "time_to_unlock": 0,
    "unlocked_balance": 19606788430000
  }
}
2021-01-11T06:12:18.810061Z  INFO swap: Connection to Monero wallet succeeded, balance: 29.396197830000 XMR
2021-01-11T06:12:19.016634Z  INFO swap: Swap sending 0.030000000000 XMR and receiving 0.00060000 BTC started with ID 8114504e-ef7b-41ff-852c-784db818b44f
2021-01-11T06:12:19.017649Z  INFO swap: Own Peer-ID: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T06:12:19.020263Z  INFO swap::protocol::alice::swap: Current state:started
2021-01-11T06:12:19.020323Z TRACE swap::protocol::alice::steps: Starting negotiate
2021-01-11T06:14:16.787836Z DEBUG swap::network::request_response: enter read_request
2021-01-11T06:14:16.790268Z DEBUG swap::protocol::alice::amounts: Received amounts request
2021-01-11T06:14:16.790409Z  INFO swap::protocol::alice: Sent amounts response
2021-01-11T06:14:16.790502Z DEBUG swap::network::request_response: enter write_response
2021-01-11T06:14:20.917595Z DEBUG swap::network::request_response: enter read_request
2021-01-11T06:14:21.231952Z DEBUG swap::protocol::alice::message0: Received Message0
2021-01-11T06:14:21.232094Z  INFO swap::protocol::alice::state: Producing first message
2021-01-11T06:14:25.540858Z DEBUG swap::protocol::alice: Sent Message0
2021-01-11T06:14:25.540984Z DEBUG swap::network::request_response: enter write_response
2021-01-11T06:14:31.162291Z DEBUG swap::network::request_response: enter read_request
2021-01-11T06:14:31.166458Z DEBUG swap::protocol::alice::message1: Received Message1
2021-01-11T06:14:31.178900Z DEBUG swap::protocol::alice: Sent Message1
2021-01-11T06:14:31.179042Z DEBUG swap::network::request_response: enter write_response
2021-01-11T06:14:31.203227Z DEBUG swap::network::request_response: enter read_request
2021-01-11T06:14:31.204668Z DEBUG swap::protocol::alice::message2: Received Message2
2021-01-11T06:14:31.222509Z  INFO swap::protocol::alice::swap: Current state:negotiated
2021-01-11T06:19:31.246502Z  INFO swap::protocol::alice::swap: Current state:btc is locked
2021-01-11T06:19:37.495621Z DEBUG monero_harness::rpc::wallet: transfer RPC response: {
  "id": "1",
  "jsonrpc": "2.0",
  "result": {
    "amount": 30000000000,
    "fee": 83890000,
    "multisig_txset": "",
    "tx_blob": "",
    "tx_hash": "03370adb44ab514b3b798840d4bca8c1cfac96b13d1fa1d40626b0b028a50e0e",
    "tx_key": "a2288b10e5d8b828d2021c7228d24501b78310130e41870f9c8a52a225ac730e",
    "tx_metadata": "",
    "unsigned_txset": "",
    "weight": 1448
  }
}
2021-01-11T06:19:37.495844Z  INFO swap::monero::wallet: Monero tx broadcasted!, tx hash: TxHash("03370adb44ab514b3b798840d4bca8c1cfac96b13d1fa1d40626b0b028a50e0e")
2021-01-11T06:19:37.495984Z DEBUG swap::monero::wallet:   Transfer proof: TransferProof { tx_hash: TxHash("03370adb44ab514b3b798840d4bca8c1cfac96b13d1fa1d40626b0b028a50e0e"), tx_key: PrivateKey { scalar: Scalar{
	bytes: [162, 40, 139, 16, 229, 216, 184, 40, 210, 2, 28, 114, 40, 210, 69, 1, 183, 131, 16, 19, 14, 65, 135, 15, 156, 138, 82, 162, 37, 172, 115, 14],
} } }
2021-01-11T06:19:37.496255Z DEBUG swap::protocol::alice: Sent Message2
2021-01-11T06:19:37.496623Z DEBUG swap::network::request_response: enter write_response
2021-01-11T06:19:37.505937Z  INFO swap::protocol::alice::swap: Current state:xmr is locked
2021-01-11T06:34:05.582184Z DEBUG swap::network::request_response: enter read_request
2021-01-11T06:34:05.584875Z DEBUG swap::protocol::alice::message3: Received Message3
2021-01-11T06:34:05.584986Z DEBUG swap::network::request_response: enter write_response
2021-01-11T06:34:05.601143Z  INFO swap::protocol::alice::swap: Current state:encrypted signature is learned
2021-01-11T06:34:05.618026Z  INFO swap::protocol::alice::steps: Attempting to publish bitcoin redeem txn
2021-01-11T06:34:05.754195Z  INFO swap::bitcoin::wallet: Bitcoin tx broadcasted! TXID = 552c38ddc96a935a07fd2828fd7fee8e9538e2343378693b7ac3f44954192bed

Resume in EncSigSent before watching BTC redeem

Status: Both redeem successfully.

Bob log

Before resume

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --receive-xmr 0.03 --send-btc 0.0006 --connect-addr /ip4/127.0.0.1/tcp/9876 --connect-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
warning: unreachable statement
   --> swap/src/protocol/bob/swap.rs:237:21
    |
235 |                     panic!("Bob panics in EncSigSent before watching for redeem btc");
    |                     ------------------------------------------------------------------ any code following this expression is unreachable
236 | 
237 |                     let state_clone = state.clone();
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
    |
    = note: `#[warn(unreachable_code)]` on by default

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 26.69s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --receive-xmr 0.03 --send-btc 0.0006 --connect-addr /ip4/127.0.0.1/tcp/9876 --connect-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi`
2021-01-11T07:02:04.978503Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T07:02:04.980242Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T07:02:05.132212Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T07:02:05.136871Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03210949 BTC
2021-01-11T07:02:05.138581Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.000000000000 XMR
2021-01-11T07:02:05.684410Z  INFO swap: Swap sending 0.00060000 BTC and receiving 0.030000000000 XMR started with ID 98494411-c130-4077-b5a9-338ed0f0fc0f
2021-01-11T07:02:05.687637Z  INFO swap::protocol::bob::swap: Current state: started
2021-01-11T07:02:05.688074Z  INFO swap::protocol::bob::event_loop: dialing alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T07:02:05.699186Z  INFO swap::protocol::bob: Requesting amounts from: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T07:02:05.702856Z  INFO swap::protocol::bob::event_loop: Amounts received from Alice
2021-01-11T07:02:19.030875Z  INFO swap::protocol::bob::swap: Current state: negotiated
2021-01-11T07:02:19.033847Z  INFO swap::protocol::bob::state: 4aaca94b958fb6a91245de0478ba1faaddba988d4410165b1f1d103efb15deab
2021-01-11T07:02:19.035446Z  INFO swap::bitcoin::wallet: Bitcoin tx broadcasted! TXID = 4aaca94b958fb6a91245de0478ba1faaddba988d4410165b1f1d103efb15deab
2021-01-11T07:02:19.045997Z  INFO swap::protocol::bob::swap: Current state: btc is locked
2021-01-11T07:08:40.758473Z  INFO swap::protocol::bob::swap: Received XMR lock transaction transfer proof from Alice, watching for transfer confirmations
2021-01-11T07:27:32.301318Z  INFO swap::protocol::bob::swap: Current state: xmr is locked
2021-01-11T07:27:32.681432Z  INFO swap::protocol::bob::event_loop: Alice acknowledged message 3 received
2021-01-11T07:27:32.770874Z  INFO swap::protocol::bob::swap: Current state: encrypted signature is sent
thread 'main' panicked at 'Bob panics in EncSigSent before watching for redeem btc', /Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap/src/protocol/bob/swap.rs:235:21
stack backtrace:
...

Process finished with exit code 101

resume command:

run --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 98494411-c130-4077-b5a9-338ed0f0fc0f

After resume:

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 98494411-c130-4077-b5a9-338ed0f0fc0f
   Compiling swap v0.1.0 (/Users/dakami/CoBloX/repos/xmr-btc-swap_comit-network/swap)
    Finished dev [unoptimized + debuginfo] target(s) in 31.43s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 98494411-c130-4077-b5a9-338ed0f0fc0f`
2021-01-11T07:30:15.909390Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T07:30:15.911244Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T07:30:16.230837Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T07:30:16.241257Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03150796 BTC
2021-01-11T07:30:16.243755Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.000000000000 XMR
2021-01-11T07:30:16.246137Z  INFO swap::protocol::bob::swap: Current state: encrypted signature is sent
2021-01-11T07:30:16.287492Z  INFO swap::protocol::bob::swap: Current state: btc is redeemed
2021-01-11T07:30:18.346661Z  INFO swap::protocol::bob::swap: Current state: xmr is redeemed

Process finished with exit code 0

Bob in BtcLocked, punish timelock already expired but Alice has not punished

Expected: Bob would try to refund (?)
Actual: Bob send canel, but then transitions to punished.

Bob logs:

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 91f1efc9-3402-400d-87f1-c7a3b716111f
    Finished dev [unoptimized + debuginfo] target(s) in 0.87s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 91f1efc9-3402-400d-87f1-c7a3b716111f`
2021-01-11T21:52:55.997920Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T21:52:56.030827Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T21:52:56.337495Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T21:52:56.580896Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03090643 BTC
2021-01-11T21:52:56.636202Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.000000000000 XMR
2021-01-11T21:52:56.659027Z  INFO swap::protocol::bob::swap: Current state: btc is locked
2021-01-11T21:52:56.699862Z  INFO swap::protocol::bob::swap: Current state: cancel timelock is expired
2021-01-11T21:52:56.833499Z  INFO swap::bitcoin::wallet: Bitcoin tx broadcasted! TXID = f93bd37d242865f573501adc3554dbbf6c53bb7ef4b6ef6380599fe25c73b528
2021-01-11T21:52:56.843660Z  INFO swap::protocol::bob::swap: Current state: btc is cancelled
2021-01-11T21:52:56.855759Z  INFO swap::protocol::bob::swap: Current state: btc is punished

Process finished with exit code 0

Resume Both

Both resume in XMR Locked

Status: Both redeem correctly.

Alice Log

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice resume sell-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name alice --swap-id 4e770b6f-f358-4163-bf93-ff226cf7ab3d
    Finished dev [unoptimized + debuginfo] target(s) in 0.37s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/alice resume sell-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name alice --swap-id 4e770b6f-f358-4163-bf93-ff226cf7ab3d`
2021-01-11T05:43:21.063088Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T05:43:21.064524Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice
2021-01-11T05:43:21.231584Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/alice/seed.pem
2021-01-11T05:43:21.241645Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.00294521 BTC
2021-01-11T05:43:21.245474Z  INFO swap: Connection to Monero wallet succeeded, balance: 29.426281550000 XMR
2021-01-11T05:43:21.246240Z  INFO swap: Own Peer-ID: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T05:43:21.248238Z  INFO swap::protocol::alice::swap: Current state:xmr is locked
2021-01-11T05:43:27.841992Z  INFO swap::protocol::alice::swap: Current state:encrypted signature is learned
2021-01-11T05:43:27.859860Z  INFO swap::protocol::alice::steps: Attempting to publish bitcoin redeem txn
2021-01-11T05:43:28.267564Z  INFO swap::bitcoin::wallet: Bitcoin tx broadcasted! TXID = 3234794f2ebecb6f036090cfc9e959e4431b1c7f476af1440b90d6d8c73f8c88
2021-01-11T05:53:28.651329Z  INFO swap::protocol::alice::swap: Current state:btc is redeemed

Process finished with exit code 0

Bob log

/Users/dakami/.cargo/bin/cargo run --color=always --package swap --bin swap -- --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc http://dakami:[email protected]:18332 --bitcoin-wallet-name bob --monero-wallet-rpc http://127.0.0.1:18084/json_rpc --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 323aaf4c-e809-4418-a29a-51a233b84833
    Finished dev [unoptimized + debuginfo] target(s) in 0.29s
     Running `target/debug/swap --data-dir /Users/dakami/CoBloX/TEMP/swap-data-dir/bob resume buy-xmr --bitcoind-rpc 'http://dakami:[email protected]:18332' --bitcoin-wallet-name bob --monero-wallet-rpc 'http://127.0.0.1:18084/json_rpc' --counterpart-addr /ip4/127.0.0.1/tcp/9876 --counterpart-peer-id 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi --swap-id 323aaf4c-e809-4418-a29a-51a233b84833`
2021-01-11T05:43:27.636668Z  INFO swap::trace: Initialized tracing with level: INFO
2021-01-11T05:43:27.638629Z  INFO swap: Database and Seed will be stored in directory: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob
2021-01-11T05:43:27.795882Z  INFO swap::config::seed: Read in seed from file: /Users/dakami/CoBloX/TEMP/swap-data-dir/bob/seed.pem
2021-01-11T05:43:27.802851Z  INFO swap: Connection to Bitcoin wallet succeeded, balance: 0.03391408 BTC
2021-01-11T05:43:27.804515Z  INFO swap: Connection to Monero wallet succeeded, balance: 0.030000000000 XMR
2021-01-11T05:43:27.807139Z  INFO swap::protocol::bob::swap: Current state: xmr is locked
2021-01-11T05:43:27.811335Z  INFO swap::protocol::bob::event_loop: dialing alice: 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-01-11T05:43:27.834518Z  INFO swap::protocol::bob::event_loop: Alice acknowledged message 3 received
2021-01-11T05:43:27.838879Z  INFO swap::protocol::bob::swap: Current state: encrypted signature is sent
2021-01-11T05:43:29.276398Z  INFO swap::protocol::bob::swap: Current state: btc is redeemed
2021-01-11T05:43:31.883741Z  INFO swap::protocol::bob::swap: Current state: xmr is redeemed

Process finished with exit code 0

Monero wallet management for `refund` scenarios

Problem

The ASB can currently not avoid refund scenarios. If Bob does not go through with the swap and refunds (for whatever reason) Alice will refund as well.
When Alice refunds she uses generate_from_keys to claim the XMR - which unloads her default wallet. There is currently no logic to reload the default wallet - the wallet created by refund will stay loaded which can affect other swaps currently ongoing concurrently.

We don't expect these scenarios to happen very often, but nevertheless we have to fix Alice to reload her default wallet so she has funds for swapping after a refund scenario.

Potential Solution

As soon as generate_from_keys finishes the default wallet is reloaded (using open_wallet).
Additionally the wallet should be wrapped in a Mutex to avoid unguarded concurrent access.
Note: Make sure that generate_from_keys is called with an appropriate rescan_height for refund scenarios - otherwise creating the refund wallet can take significant amounts of time on stage/mainnet!

Check TxLockBtc and TxLockXmr UTXO's match swap amounts

We should check that the quantities of xmr and btc locked on the blockchain matches what Alice and Bob agreed upon in the negotiation phase.

This should be done when Bob watches for xmr locked and Alice watches for btc locked.

Problems to be fixed after manual tests on test-/stagenet

The following issues have to be fixed by adding e2e tests for edge cases:

  • Bob does not record Alice's lock proof (message 2) by saving a separate state after receiving Message2. So, when restarted Bob waits for the lock proof again, which never arrives. The time-window of this failure is closed once XMR lock transactions has the necessary confirmations and Bob transitions to XmrLocked.
  • #149 - After EncSigLearned Alice may fail when trying to redeem. There is a bug where we always publish the redeem tx on her side in that state without taking timelocks in account (Bob already moved and cancelled, Alice redeem always fails, she never transitions and never refunds / punishes).

Once those two issues above are done we should add more e2e tests for remaining edge cases (stop application after each state and see if the application behaves as expected after resuming).

Details to failure scenarios can be found in #135

Note: Scenarios involving the cancel path should not be actioned because for the MVP we will focus on manual recovery.

Remove secrets from db storage

We currently store secret keys in the DB. We should get these secrets from the wallets or a seed. It is probably not a good idea to save the users secrets to disk.

Swap demo website MVP

Summary of current state of CLI/ASB setup

CLI behaviour:

  1. Run the swap tool (no command/parameters needed, default to demo ASB)
  2. Send as much BTC as you want to CLI to be swapped
  3. The swap starts once the BTC "deposit" tx is in mempool

The demo ASB has the following restrictions:

  1. Limit swaps to max 0.5 XMR

Website MVP

The MVP does not have to display a rate but a static webpage is sufficient to get the user started.

The user needs the information:

  1. Where to download the CLI binary
  2. A field where the user can enter the XMR address where the funds should be retrieved (so that copy-able command can be generated)
  3. Copy-able command to run the CLI (e.g "open a terminal and run ./swap_cli buy-xmr --receive-address [xmr_address]")
  4. What is expected once the CLI is started (e.g. "Transfer 0.001 BTC that will be swapped")

No sys dependencies needed when running the CLI

When building the project on the raspberry I noticed that we currently have two dependencies, openssl and protobuf, which might also have to be available at runtime.

I temporarily solved this by installing the necessary libraries on the raspberry:

# install openssp dependencies
sudo apt install -y libssl-dev
# install protobuf dependency
sudo apt install -y protobuf-compiler

In order to allow easy use of the CLI we have to ensure that there are no external dependencies.

Alice has to wait for Bitcoin confirmations before locking XMR

Problem

When Alice observes the Bitcoin lock transaction in the mempool she does not wait for confirmations but acts with sending the Monero lock transaction immediately.

Note that for redeeming the Monero the behaviour of not waiting for Bitcoin transactions it OK, because Bob can redeem the Monero as soon as he learned the missing key part from the tx in the mempool.

Goal

Properly wait for confirmations as specified in the config.

Bad API: Swap ID should not be an argument for swap()/run_until()

Currently the swap() and run_until() functions take the swap id as an argument. The problem with this is we can retrieve an in-progress swap from the db using a swap_id and start executing it with a swap_id that does not match the swap_id we used to retrieve it.

We should re-design this API and use the type system to prevent the caller from making mistakes like this.

Protect against rogue key attack during key generation

Situation

Currently, Alice sends to Bob the following keys in alice::Message0:

  • Bitcoin public key A;
  • Monero public spend key S_a^xmr;
  • Bitcoin public key S_a^btc; and
  • Monero private view key v_a.

Bob replies with his own bob::Message0:

  • Bitcoin public key B;
  • Monero public spend key S_b^xmr;
  • Bitcoin public key S_b^btc; and
  • Monero private view key v_b.

I've been thinking about what Bob can do with the information in alice::Message0 before he commits to his own keys.

Possible attacks

Monero shared output

For instance, S_a^xmr + S_b^xmr is the public spend key of their Monero shared output, so Bob could theoretically adaptively choose his S_b^xmr = S_r - S_a^xmr, with knowledge of the the corresponding private key s_r for the rogue key S_r, so that when combined S_a^xmr + S_b^xmr = S_a^xmr + S_r - S_a^xmr = S_r giving control to Bob over the shared output immediately.

In practice, because we attach a DLEQ proof to bob::Message0 which proves knowledge of the secret key for S_b^xmr, Bob doesn't actually have the ability to choose a key that would cancel out Alice's, because he cannot compute the private key corresponding to the public key S_r - S_a^xmr thanks to the discrete log problem being hard.

I can't imagine this DLEQ proof ever being removed, so I would say this is safe.

It's worth noting that Bob could also exploit prior knowledge of S_a^btc in the same way. Similarly, Alice is protected by the DLEQ proof that Bob must provide which proves knowledge of s_b so that Bob cannot choose S_b^btc adaptively.

Bitcoin shared output

The Bitcoin shared output is not an aggregation of keys, but a multisignature Bitcoin script, so in its current state it is not susceptible to the same kind of rogue key attack.

On the other hand, this could change. As soon as BIP340 hits we would probably construct this output using Schnorr signatures to make the protocol truly scriptless. The output would be vulnerable to the rogue key attack outlined above and we would have to modify the protocol slightly.

Monero private view keys

The private view keys are already being exchanged publicly because there's nothing tricky to do with them.

Conclusion

In my opinion, the key generation phase is currently safe.

I still recommend we future-proof our protocol before it becomes too cumbersome to modify it. I think the Monero output will always remain protected by the required DLEQ proof, but the Bitcoin one would be vulnerable after a predictable upgrade to the protocol (i.e. using BIP340).

I would replace the current 2-round key generation phase with a 3-generation phase which uses a commitment scheme to protect Alice:

  1. Alice sends commitment to her keys to Bob.
  2. Bob sends his keys in the open to Alice.
  3. Alice sends the opening of her commitment to Bob.

This is the same procedure we followed for our Grin-Bitcoin protocol. We could implement it in a similar way by sending a hash of all the keys concatenated in a particular order as the commitment.

Use Typesafety with expiries

Currently, t1 and t2 are represented as u32. Instead we should introduce two newtypes:

  • BlockHeight: The (absolute) block height of a transaction or the expiry in absolute block height
  • RelativeHeight: The relative height to express an expiry (from the moment to which a transaction is mined).

And ensure that it is not possible to sum 2 BlockHeights but only a BlockHeight and one (or two) RelativeHeight.

Random port for Alice's listen address in the tests

Problem

Currently we use get_port to get a free port when starting tests.
This seems to cause trouble when running tests in parallel. Generally, it is unnecessary to depend on another library for this, when we can automatically get a random free port assigned by the operating system.

Goal

Let the OS assign a port by passing 0 to the multi-addr.
We need to wait for the NewListenAddr event then but we need to do that anyway to make sure the Swarm is ready.

Bitcoin DevKit Wallet

Replace the bitcoind wallet with bdk wallet

  • Implement wallet traits using bdk
    We also used the electrum http API in addition to bdk as bdk did not have all the functionality we needed
  • Create docker compose to start electrum and bitcoind
  • Try using bitcoind as backend instead of electrum
    We could not get it working after a day so we gave up
  • e2e tests passing using docker compose to start electrum and

Automate container start/shutdown so tests can run in CI

  • Decide whether to use test containers or docker compose
    We decided to use test containers. Sharing volumes seems to be the only hurdle

Validate assumptions

Testing of these assumptions may not require an electrum testcontainer to be implemented.

  • Validate assumption: Test containers allows volumes to be created/defined.
  • Validate assumption: Test containers allows volumes to be shared.
  • Validate assumption: We can clean up volumes after the test has completed
  • Validate assumption: We can use the GenericImage and do not need to create custom test containers

Implement Test containers

  • Spin up electrum using testcontainer and bitcoind using the working docker compose file. Tests passing .
  • Spin up electrum and bitcoind using test containers. Tests passing.

Cleanup tasks/ Potential problems

  • BDK wallet requires sync() to be called to update its internal database. It is not clear whether calls made from wallet.client() read the internal database or execute a rpc.
  • Architecture: Should we move sync() to seperate thread and call it in a loop?
  • Extracting tx from the tx_lock psbt and then converting that extracted tx back into a psbt causes signing of the tx to fail with the bdk wallet. This issue was resolved by removing this conversion. This means that the psbt is sent from bob to Alice rather than the tx.
  • Cleanup container code. The args should come from a struct. Cleanup/refactor the initialisattion code.
  • Generate the wallet descriptor from the seed
  • Update the config to use electrum instead of bitcoind

Deterministic `peer-id` for Alice

Problem

At the moment Bob dials Alice, thus Alice's peer ID has to be given to Bob upon startup.
However, Alice does not have a deterministic peer ID at the moment, but a new one every time.
This is very cumbersome when testing and frankly should not be like this.

Goal

Alice has the same peer ID every time the software is started.

Proposal

Use a static, generated seed similar to what we do on cnd.

Watch For Deposit

Problem

The buy-xmr tool generates and displays a bitcoin address for the user to fund. These funds are used to buy Monero. Currently we are manually checking that these funds have arrived before commencing the swap. This does not fit with the goal of providing a streamlined UX.

Potential Solution

Assumption: We do not really care how the buy-xmr tool is funded. All that matters is that is has enough funds to execute the swap.

The buy-xmr tool should watch for the funds and automatically commence the swap when they are confirmed.

Loop on bdk_wallet.get_balance() until the balance is sufficient for the swap.

Potential Issues

  1. get_balance() requires the wallet to be synced. Syncing could take a while.
  2. The get_balance API doesn't mention anything about UTXO confirmations. The swap could begin execution but fail when it comes to building/publishing/ waiting for TxLock to confirm.

Stagenet Swap

Objectives

  • Ensure that the software is usable on mainnet without fund loss.
  • Learn technical restrictions of the software and protocol.
  • Understand whether and what manual recovery tools would be needed by the
    user for a MVP.

Dev Tasks

  • Test punishment #54
  • Test refund (Implement bob cancel + refund logic) #72
  • Add assertions to check if balances are correct after punish test #72
  • Introduce recursive function to allow test of punish and refund path and facilitate recovery #41
  • Poll on the swarm using an event loop #65
  • Save states in database and test recovery form said states #56
  • Update CLI to pass DB parameters and allow recovery from it #88
  • Review CI run to reduce current ~40min execution #69

Mainnet execution

  • Do a successful swap in mainnet
  • Do a swap in mainnet, restart Alice mid-swap
  • Do a swap in mainnet, restart bob mid-swap

Ensure our release workflow works

  1. Somehow trigger it automatically to create "nightly" releases
  2. Have our existing workflow attach the binaries to these releases

Out of scope:
Promote one of these nightly releases to a stable release.
This is more complicated because we would have to somehow manage the version number properly as well.

Wallet initialization per command and initial setup

Problem

At the moment we always create both wallets no matter what command we execute. That is not user friendly, as some commands only need the bitcoin wallet.

However, the initial setup is attached to this problem as well, because currently the initial configuration is tied to the init_wallets function. This needs some untangling.

Goal

  • Start only the wallet(s) needed for each command.
  • Ask the user for required configuration information when needed (i.e. not for the complete configuration)

Clean up tasks

Align Database state with actual swap state and change TryFrom to From

Rename T1/T2 to CancelTimelock/PunishTimelock

For clarity purposes

Move tests in src

  • Done

The run_until function has been created to test restart scenarios.
However, it is used by release code because the e2e test are in the swap/tests folder that use release code.

The tests should in a test module under swap/src. This would allow more flexibility in separating test only code (using #[cfgtest)] compiler attribute` and release code

Remove swap/src/lib.rs file

  • Done

The swap create is a binary crate that provides a CLI.
It has a lib.rs and bin/swap.rs files.

This is an issue because it does not allow us to get clippy warnings from unused code.
It is also unnecessary.

This is cannot be done until the task above is done.

Move test specific code under #[cfg(test)]

  • Done

The run_until feature that allows to stop the execution when a certain state is reached is purely for test purposes. Then is_complete is passed for release code.

Such condition should not exist in release code and should be hidden behind #[cfg(test)].

Merge both crates

  • Done

Currently we have two crates:

  • xmr-btc: an unopinionated library to execute an xmr-btc swap
  • swap: a binary that uses xmr-btc

The separation is creating some issue:

  • It is unclear what code in xmr-btc is used or unused, as we are removing a bunch of test #68 that are historically here because previous version of the implementation
  • The codebase is not mature enough to really understand how opinionated xmr-btc should be, for example, a generator implementation to run the swap is present
    pub fn action_generator<N, M, B>(
    but not use in swap.

Merging both crates in one would allow code clean-up and reduce friction to move forward.
As a result, swap should be a binary crate and lib.rs should be removed.

Remove dupe code

  • Done

A number of helper functions are existing in xmr-btc crate on the State structs. (e.g. xmr_btc::bob::State4::watch_for_redeem_btc). We have reproduced this code in swap::alice::swap, we should instead adapt the xmr_btc functions and use them in swap.

Type timelocks

  • Done

Currently we use relative timelock and block heights. Both concepts are represented with u32. We should use a different newtype for each and only implement the arithmetic operations that make sense:

  • block height + relative timelock
  • compare block heights

And that's it.

Avoid wallet-rpc error message when watching for txlock (Bob)

Problem

On Bobs side we see multiple of these errors on the monero-wallet-rpc when starting to watch for the txlock transaction:

2021-01-06 06:04:54.490	E !ok || (res.txs.size() != 1 && res.txs_as_hex.size() != 1). THROW EXCEPTION: error::wallet_internal_error

This error happens when we query to see Alice's transaction, but Bob's wallet has not picked it up yet - i.e. it did not arrive in the mempool of the node yet. I was not expecting this in my current setup (both parties use the same node but different wallet-rpc instances), but from the Debug log of the swap I can see:

2021-01-06T00:15:22.903280Z DEBUG monero_harness::rpc::wallet: transfer RPC response: {
  "error": {
    "code": -1,
    "message": "Failed to get transaction from daemon"
  },
  "id": "1",
  "jsonrpc": "2.0"
}

It might be a bit confusing to users, but it is not harmful. Eventually the transaction is found and is checked for confirmations.

Goal

Don't confuse the user with cryptic errors.

Proposal

One way to remove it would be to just give Bob's wallet a delay for looking for the confirmations.
Generally, since we expect at least 10 confirmations we don't have to check immediately and every second.

Polling for changes to balance / transactions does not scale

Problem

At the moment, when watching for transactions, we bombard the Bitcoin/Monero setup by checking every second. This is currently hardcoded.

Goal

A scalable solution for waiting until a certain event (transaction included, balance changed, etc)

Better Error handling for calcuation errors (notably subtractions)

Problem

Currently, if we try to swap amounts that are smaller than the transaction fee, we run into an overflow error:

value: tx_lock.lock_amount().as_sat() - TX_FEE,

This is not a scenario that should be very common in production - unless people want to "give the tool a try" before actually using if for larger amounts ;)

I would recommend to handle errors on calculations in a more explanatory way using context rather than changing the logic. This might not only concern the code part stated as example above but should be done for all calculations where it is important to give the user context.

Goal

The user should not get an overflow error that does not explain why the application failed.

[SP] Swap Website

Service Provider (SP) hosts a website for users to use the service. When I navigate to the swap website, as a user...

  • I can select the Bitcoin quantity I want to sell.
  • I can see an approximate Monero quantity that the SP is willing to trade.
  • I can get the swap cli command to run to execute the swap with the SP with the chosen quantities.
  • I can navigate to the installation instructions/binaries of the swap CLI.

Add windows support to swap_cli

Only linux and Mac OS builds are currently supported for the swap cli because:

  • Monero installer does not support decoding of the downloaded Windows Monero cli package
  • Feature gate tokio-tar because it doesn't build on windows
  Compiling tokio-tar v0.2.0 (D:\a\xmr-btc-swap\xmr-btc-swap\tokio-tar)
680
error[E0433]: failed to resolve: could not find `os` in `fs`
681
   --> tokio-tar\src\entry.rs:583:28
682
    |
683
583 |                 tokio::fs::os::windows::symlink_file(src, dst).await
684
    |                            ^^ could not find `os` in `fs`
685

686
error: aborting due to previous error
687

688
For more information about this error, try `rustc --explain E0433`.
689
error: could not compile `tokio-tar`

Address the above issue/s for windows support

CLI user Bitcoin wallet strategy

Problem

Currently we don't have a coherent strategy and flow for the Bitcoin wallet on the user side (CLI)
Currently the CLI wallet only offers a deposit command - which was the minimal requirement to make a swap with the ASB (automated swap backend) possible.
We need a coherent strategy for Bitcoin wallet management, that offers a good usability for the showcase setup.

There are two main questions to be answered:

  1. Are we expecting the user to do multiple swaps with the Bitcoin wallet?
  2. Should the user be in control of the Bitcoin wallet?

A - The user is not in control of the wallet

If we answer question 1. with NO, i.e. the user uses the tool for one specific swap (or very sporadic swaps that don't require leaving money in the tool I would suggest the following solution:

  1. The user provides a fallback Bitcoin address for each swap.
  2. If Bitcoin is refunded the fallback address is used
  3. If Bitcoin is redeemed, but the user sent too much funds to the CLI, the remaining Bitcoin are transferred to the fallback-address.
  4. When triggering a swap the tool will print an address to be funded that the user has to send funds to.
  5. There are no extra commands for the wallet.

Note that this strategy has the risk that, if something goes wrong on the way, it might be hard for the user to recover the funds.
We might still need withdraw/balance commands for power users, but that could be seen as additional feature.

B - The user in control of the wallet

If we answer question 1. with YES, i.e. we expect the user to do multiple swaps, it will be in the user's interest to transfer a larger amount of Bitcoin to the swap tool once to save transaction fees. If we expect that the user should have the commands. (This would give the feel of a power user application.)

Recommendation: Combined solution

I think the strategies can be combined. If the user specifies a fallback address the remaining funds or refunded Bitcoin can end up on the fallback address. If no fallback is specified it would stay within the swap tool.

The swap tool offers deposit, balance and withdraw commands but they are not advertised. Power users will find out anyway.

It is not much work to provide the commands (and we might need them anyway for failure scenarios).
But, to offer a user experience with less interaction we would have to implement scenario A as well.

The hard part is, that if we default to the CLI wallet then user might always default and then has to use the commands. We could do it the other way round - always ask for a fallback address, but power users can specify the one of the swap tool itself. (Bit weird, but coherent...)

Goal

A coherent Bitcoin wallet strategy, for the CLI that offers best usability for the showcase application.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.