Commit Graph

174 Commits

Author SHA1 Message Date
Franck Royer
df237f82cf
Fix clippy warning 2020-12-22 13:50:28 +11:00
Franck Royer
49b84d84b9
Add address at the start
Do not carry peer id around as we currently only expect one peer.
2020-12-22 13:47:05 +11:00
Franck Royer
2abf65f3b6
Remove sleep that seems unnecessary 2020-12-21 10:25:36 +11:00
Franck Royer
4a4e23038b
Add logging to investigate add address race condition 2020-12-21 10:25:19 +11:00
Franck Royer
1a4bd0e2b4
Bob refunds swap after restart that requires communication
As Bob is dialing Alice, we now ensure that we are connected to Alice
at each step that needs communication.
If we are not connected, we proceed with dialing.

In an attempt to improve libp2p usage, we also add known address of
Alice first and only use peer_id to dial.
This ensures that we use the expected peer id.
2020-12-21 08:31:21 +11:00
bors[bot]
3db71997d3
Merge #99
99: Cleanup resume_from_database functions only used in tests r=da-kami a=da-kami

Follow up of https://github.com/comit-network/xmr-btc-swap/pull/88

Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-18 03:01:18 +00:00
bors[bot]
4f631c0c9b
Merge #98
98: Remove tor module r=da-kami a=da-kami

This removes the currently unused `tor module`.
Different `tokio` versions have been causing issues with the `tor` module in the past (i.e. `Cargo.lock` broken problem...). It started causing issues again when adding a dependency to `jsonrpc_client` working on https://github.com/comit-network/xmr-btc-swap/pull/97

We don't support `tor` at the moment and are no planning to add this feature initially as it is not super important to users. 
The functionality can easily added again at a later point.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-18 02:10:25 +00:00
bors[bot]
88c29dbce5
Merge #94
94: T1Expired state for Bob and check expiries in states after both locked r=da-kami a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-18 01:20:30 +00:00
Daniel Karzel
4046305474
Merge pull request #88 from comit-network/resume-swap-cli
Resume command and global database cl-parameter
2020-12-18 11:42:54 +11:00
Daniel Karzel
20893c1bb1 Cleanup Display for database states 2020-12-18 11:39:21 +11:00
Daniel Karzel
e6493784bf Change pin_mut! to select! 2020-12-18 11:37:02 +11:00
Daniel Karzel
773eebc723 Cleanup resume_from_database functions only used in tests 2020-12-18 10:50:32 +11:00
Daniel Karzel
e9681b6e2b Work in review comments 2020-12-17 19:10:24 +11:00
Daniel Karzel
43d05935e7 Remove tor module 2020-12-17 18:50:15 +11:00
Daniel Karzel
093cbaa4b4 Introduce T1Expired state for Bob properly and check expiries in states after both locked 2020-12-17 15:17:15 +11:00
Daniel Karzel
6d03d1bbff Resume command and global database cl-parameter 2020-12-15 21:40:52 +11:00
Franck Royer
71cf501c29
Delete bob::negotiate
This module was intended to contain helper functions for each step.

However, those are not needed except for the negotiate step.
A dedicated module is not needed for one function.
2020-12-15 16:53:50 +11:00
Franck Royer
19066200d1
Add a TODO to use existing helper functions
Helper functions already exist on the xmr-btc crate states, use them
like it is done in the bob module.
2020-12-15 16:51:23 +11:00
Franck Royer
84bec0631b
Rename alice::negotiate to steps
This module includes helper function for each state.
2020-12-15 16:49:38 +11:00
Franck Royer
53d13330c2
Remove dupe code 2020-12-15 16:45:06 +11:00
Franck Royer
5ba830f3bf
Replace swap recover terminology with resume 2020-12-15 11:52:00 +11:00
Franck Royer
8cc470a80e
Use -ed terminology for cancel state 2020-12-15 11:47:05 +11:00
Daniel Karzel
7cae6a9e4d
Add Bob restart test 2020-12-15 11:43:28 +11:00
Daniel Karzel
91d4d5da25
Cleanup swap execution to not return EventLoopHandle, refactor both_refund test 2020-12-15 11:43:28 +11:00
Daniel Karzel
3692046758
Bob's recover function 2020-12-15 11:43:27 +11:00
rishflab
143d8bc07d
Move message0 response handler out of NB 2020-12-15 11:43:24 +11:00
Daniel Karzel
4143394767
Add recovery function for Alice 2020-12-15 11:40:40 +11:00
rishflab
4b00141c29
Fix happy path test 2020-12-15 11:40:36 +11:00
Franck Royer
4ce8695dfc
Align with origin/database 2020-12-15 11:29:38 +11:00
Franck Royer
1a5b9f9fa9
Update tests after rebase 2020-12-15 10:19:45 +11:00
Franck Royer
c4cdd098fd
Use from instead of try_from for Alice state conversion 2020-12-15 10:19:03 +11:00
Franck Royer
caf903acda
wip: Add test for when bob restarts 2020-12-15 10:18:48 +11:00
Franck Royer
905fc6cf35
Save Bob state during swap 2020-12-15 10:18:46 +11:00
Franck Royer
64b021daf4
Save Alice states in db 2020-12-15 10:10:40 +11:00
Franck Royer
238f6a989d
Extract spend key as soon as possible 2020-12-15 09:18:23 +11:00
Franck Royer
c095693a5f
Refund swap if resumed from a step that requires further communication 2020-12-15 09:17:12 +11:00
Franck Royer
11cea9ba69
Remove passing alice peer id
The usage of the peer id is incorrect as we do not even check it when
dialing. For now, we can ignore it.
We can then re-introduce it and use it properly at a later stage.
2020-12-15 09:15:38 +11:00
rishflab
d8d6477ee9 Remove and fix comments 2020-12-14 11:56:14 +11:00
rishflab
7af4b6980a Test Alice refunds after Bob refund
Reworked Alice XmrLocked state transition handler to handle the
scenario when Alice received the encsig but Bob refunds.
Previously Alice was trying to redeem after receiving the encsig
without checking if t1 had elapsed.
2020-12-11 17:05:34 +11:00
rishflab
78c6a1a78f Add Bob refund execution 2020-12-11 16:59:29 +11:00
Daniel Karzel
03b8e5f52e Upgrade CLI for mainnet test 2020-12-11 14:46:29 +11:00
Franck Royer
c0478d7191
Move expiries to config
So they can be different for mainnet and regtest
2020-12-10 14:43:17 +11:00
Franck Royer
ef6e8fc723
Clean-up unused code 2020-12-10 14:28:54 +11:00
Franck Royer
e71bf7d8e9
Add comment regarding processing in network behaviour 2020-12-10 14:03:45 +11:00
Franck Royer
2c9fb7b1da
Rename var to match type name 2020-12-10 14:03:45 +11:00
Franck Royer
91d28682ed
Remove comments 2020-12-10 14:00:48 +11:00
Franck Royer
53aae5cf5f
Use anyhow macro as intended 2020-12-10 14:00:48 +11:00
Franck Royer
51cc44484b
Remove unneeded pub qualifiers 2020-12-10 14:00:47 +11:00
rishflab
9ba89194b0 Rename swarm driver to event loop 2020-12-10 13:29:53 +11:00
rishflab
f5d3d54b13 Prevent premature Bob t1 timeout
Bob was hitting the t1 timeout and entering cancel
instead of redeem. This was resolved by increasing
the timeouts to 50.
2020-12-10 13:29:53 +11:00