Commit Graph

197 Commits

Author SHA1 Message Date
Franck Royer
59708c57e6
Move Alice and Bob db states in separate modules 2020-12-23 15:26:08 +11:00
Franck Royer
b410de01df
Move state.rs under database module
The types in state are only used for the database
2020-12-23 15:20:24 +11:00
Franck Royer
8c7964bfee
Rename storage.rs to database.rs to reduce terminology variants 2020-12-23 15:17:27 +11:00
Franck Royer
5ed18469e4
Move db state conversion with db type definition
Those conversion are specific to the database and should be defined with
in the database module.
2020-12-23 15:11:09 +11:00
Franck Royer
2a778f5644
Remove overzealous clippy overrides
We have overridden a number of clippy warnings such as
"large enum variant".

Considering that we have a number of issues
 with the stack size in CI, it is more prudent to follow clippy's advice
 and box larger items so that the enum does not take larger space.

Do note that an instance of the enum always takes as much space as its
largest variant.
2020-12-23 15:06:43 +11:00
Franck Royer
cdf2800fa5
Align clippy lints
Lints in `main.rs` are not used if there is a `lib.rs` file.
2020-12-23 14:33:29 +11:00
Franck Royer
ece689f5ca
There is only one binary, we should use main.rs naming convention 2020-12-23 14:22:04 +11:00
Franck Royer
4150e75488
Replace Try_From state conversion with From for Bob 2020-12-23 14:12:29 +11:00
Franck Royer
5d1b10cc58
Align Bob DB states with swap states 2020-12-23 14:12:29 +11:00
Franck Royer
e541f7b83d
Replace TryFrom with From for Alice states 2020-12-23 14:12:29 +11:00
Franck Royer
69e1c2bb27
Align Alice DB states with swap states 2020-12-23 14:12:29 +11:00
Franck Royer
a31db63e54
Improve state names and display 2020-12-23 14:12:29 +11:00
Franck Royer
f0736d0906
Remove Refund timelock and T0/T1/T2
There are no refund timelock, only a cancellation timelock and punish
timelock.

Refund can be done as soon as the cancellation transaction is published.
2020-12-23 14:12:26 +11:00
Franck Royer
405e377f79
Rename EncSign to EncSig
`EncSig` means "encrypted signature", the item,
not be confused with "signing", the action
2020-12-23 13:41:55 +11:00
bors[bot]
9c83ca52ad
Merge #107
107: Ensure that Bob can cancel correctly if T1 expired and Alice did not … r=da-kami a=da-kami

Bob has to check for the possibility to cancel in every state after he locked the BTC.
Otherwise Bob will try to perform actions that don't have any point and it might be impossible to use the `resume` command because it will always fail in trying to go on with Alice even though that might not be possible.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-23 01:16:42 +00:00
Franck Royer
297b15e3ce
Remove async block when it is not needed 2020-12-23 09:17:56 +11:00
Franck Royer
1fa812b727
Separate Buy/Sell for resume command
To avoid confusing the user on whether person should enter a listen addr
or a connect peer id and address
2020-12-23 09:17:39 +11:00
Daniel Karzel
a692cf9299 Remove all short-codes because they don't add value at the moment 2020-12-22 18:10:13 +11:00
Daniel Karzel
c9d492d155 Only wait for xmr-lock until t1 expired 2020-12-22 17:08:17 +11:00
Daniel Karzel
83ce6f2c85 Ensure that Bob can cancel correctly if T1 expired and Alice did not move
Bob has to check for the possibility to cancel in every state after he locked the BTC.
Otherwise Bob will try to perform actions that don't have any point.
2020-12-22 16:27:25 +11:00
Daniel Karzel
8296490764
Merge pull request #111 from comit-network/trace-xmr-btc
Fix tracing subscribe filter for xmr-btc`
2020-12-22 16:17:27 +11:00
Daniel Karzel
5f8b7f2624 Fix tracing subscribe filter for xmr-btc` 2020-12-22 14:11:55 +11:00
Franck Royer
40a27a2438
Remove dead code 2020-12-22 13:50:36 +11:00
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