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:
- The response channels that Alice uses are not intact after restarting the application.
- 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