Commit Graph

829 Commits (8bc918c511a007c8bf76b3b8cf3c6461af725b66)
 

Author SHA1 Message Date
Franck Royer 2929a8f101
Use the correct protocol support 4 years ago
Franck Royer b62ef9c2d9
Harmonizing naming 4 years ago
Franck Royer 8fd2620b83
Improve names for messages 4 and 5 4 years ago
Franck Royer 33db688e3a
Bob peer id can be retrieved from the DB
This remove branches where Alice resumes from the DB but cannot contact
Bob.
4 years ago
Franck Royer a910bc2046
Box all messages in enum
The messages are very different, best to box them and save size on the
stack as an enum takes as much space on the stack than its bigger
variant.
4 years ago
Franck Royer d2a1937f51
Use `Message4` 4 years ago
Franck Royer 124d6f1ebb
Introduced Message 4 sent by Alice to replace message 2 response 4 years ago
Franck Royer edb93624f3
Introduce one shot code
To allow alice to be the requester for message 4.
4 years ago
Franck Royer 9a5e35c1bd
Rename `bob::Message2` to `Message5`
As per the proposed changed in the sequence diagram.
The aim is to have a unique terminology per message instead of having
the same name for 2 consequent messages that share the same behaviour.

Note that the aim is to remove the shared `RequestResponse` behaviours.
4 years ago
bors[bot] 91fe18a796
Merge #154
154: Clean up `lib.rs` r=D4nte a=D4nte

Do not remove it just yet as there are still issues with the CI but proceed with some clean up.

Merging this now to avoid further merge conflicts.

Co-authored-by: Franck Royer <franck@coblox.tech>
4 years ago
Franck Royer 10eeecfe54
Remove dependency of main.rs on lib.rs 4 years ago
Franck Royer f2a25ee49b
Move definitions out of lib.rs 4 years ago
Franck Royer b88a777bae
Remove dead code 4 years ago
bors[bot] e2170e60a7
Merge #155
155: Bob saves lock proof after received so he can resume swap r=da-kami a=da-kami

Introducing a new state was too much so I added the additional required information to the enum state rather than adding another struct. 

As discussed earlier we should cleanup the state machine (enum states vs data structs) at some point :)

Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
Daniel Karzel 33a9057b1f Move run_until is_target_state comparison functions into testutils 4 years ago
Daniel Karzel 3593f5323a Bob saves lock proof after received so he can resume swap 4 years ago
bors[bot] c5cfc2ce20
Merge #153
153: Remove newlines from import statements to avoid problems r=da-kami a=da-kami

Rust fmt automatically groups the imports (from top to bottom) as `pub use` `use crate` and `use`.
There is no need to introduce sections which cause annoyance when auto importing using the IDE.

Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
Daniel Karzel 433704e48c Top to bottom `pub mod` then `mod` then `pub use` then `use` (incl. `use crate` and `use self`) 4 years ago
Daniel Karzel 44c4b5dcea Remove newlines from import statements to avoid problems
Rust fmt automatically groups the imports (from top to bottom) as `pub use` `use crate` and `use`.
There is no need to introduce sections which cause annoyance when auto importing using the IDE.
4 years ago
bors[bot] 4e858197c9
Merge #149
149: Fix Alice redeem scenario r=da-kami a=da-kami

Follow up of #144, partial fix of https://github.com/comit-network/xmr-btc-swap/issues/137

 Fix Alice redeem scenario

- Properly check the timelocks before trying to redeem
- Distinguish different failure scenarios and reactions to it.
    - if we fail to construct the redeem transaction: wait for cancel.
    - if we fail to publish the redeem transaction: wait for cancel but let the user know that restarting the application will result in retrying to publish the tx.
    - if we succeed to publish the tx but then fail when waiting for finality, print error to the user (secreat already leaked, the user has to check manually if the tx was included)



Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
bors[bot] fbfc17c489
Merge #142
142: Rename Swap amounts to Swap req/res r=D4nte a=D4nte

As per #140

Question: Do we prefer `Negotiation Request/Response` to `Swap Request/Response`?

Co-authored-by: Franck Royer <franck@coblox.tech>
4 years ago
Franck Royer 8c76abcd37
Remove TODO
This can be tackle when migrating to SQLite
4 years ago
Franck Royer 898b8bf8b0
Remove dead code 4 years ago
Franck Royer ae8134f04e
Replace amounts messages with swap res/req 4 years ago
Daniel Karzel 6a75c840b5 Fix Alice redeem scenario
- Properly check the timelocks before trying to redeem
- Distinguish different failure scenarios and reactions to it.
    - if we fail to construct the redeem transaction: wait for cancel.
    - if we fail to publish the redeem transaction: wait for cancel but let the user know that restarting the application will result in retrying to publish the tx.
    - if we succeed to publish the tx but then fail when waiting for finality, print error to the user (secreat already leaked, the user has to check manually if the tx was included)
4 years ago
Daniel Karzel 9fa900dce8
Merge pull request #148 from comit-network/properly-wait-for-tx-finality-for-assertion-on-bitcoin-balance
Wait for Bob's refund finality
4 years ago
Daniel Karzel 8a7d746e96 Wait for Bob's refund finality
For Alice we ensure to wait for redeem/punish finality, so it should be the same for Bob.
4 years ago
bors[bot] d6bf66c1f4
Merge #150
150: Few improvements r=D4nte a=D4nte



Co-authored-by: Franck Royer <franck@coblox.tech>
4 years ago
Franck Royer 94045b9a69
Use builder in tests 4 years ago
Franck Royer c44b867d01
Delay the wrapping in Arc 4 years ago
Franck Royer 83b72c0a45
Make `make_init_state` and `init_loop` associated to `alice::SwapFactory` 4 years ago
Franck Royer c11042ff0d
Use `builder` terminology instead of `factory`
This is not really a factory as a factory design pattern is about
producing several instances.

In the current usage, we are only interested in one swap instance. Once
the swap instance is created, the factory becomes useless. Hence, it is
more of a builder pattern.
4 years ago
Franck Royer 9148af2dbe
`bob::SwapFactory` should be consumed once a swap is returned 4 years ago
Franck Royer 652bfa14a9
Remove unnecessary `pub` qualifiers 4 years ago
Franck Royer b21dc03ed0
`alice::SwapFactory` should be consumed once a swap is returned 4 years ago
Franck Royer 9b32409b8d
Remove unnecessary `allow(clippy)` 4 years ago
Franck Royer 9e3ef7ea24
Remove `StartingBalances` from release code 4 years ago
Franck Royer 181999e04f
Remove unnecessary `alice` qualifiers in `alice::SwapFactor` 4 years ago
Franck Royer 3bc76a91c6
Make `init_state` associated to `bob::SwapFactory` 4 years ago
Franck Royer f0e6e45d56
Remove unecessary `bob` qualifier 4 years ago
Franck Royer dbc633ea06
Remove unecessary `connect` qualifier 4 years ago
Franck Royer e26629b593
Remove unecessary fields from `bob::SwapFactory` 4 years ago
Franck Royer 3c68026cfe
Move init event loop in `bob::SwapFactory` 4 years ago
Franck Royer 96b1b18037
Keep terminology consistent
Also avoid redundant qualifiers.
4 years ago
bors[bot] 05669c749c
Merge #147
147: Refactor prod code after test refactoring r=da-kami a=da-kami

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

Took a bit more than expected, but this is really neat now!
The commits should be well-contained for reviewing, but 00835baa15 is quite big. 

I changed the abstraction on the way - out methods are finally named `run` and `run_until` which both take a swap - which makes way more sense I think :)

Also had to change the abstraction layers in `testutils` and introduced `Test` which specifies the swap amounts (that would usually come from the commandline and should not live in the factory as they are irrelevant for resumed swaps).

Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
Daniel Karzel 28429fa9fe Revert log statement 4 years ago
Daniel Karzel 37f619dbfc Move StartingBalances into protocol module 4 years ago
Daniel Karzel 41e335fc2d Error messages instead of unreachable
Currently this code is actually not reachable, but that is semantically applied by the program's flow (the resume command includes the swap direction).
It is still preferred to have an error message rather than an unreachable statement.
4 years ago
Daniel Karzel 2dceab28a4 Derive Default 4 years ago
Daniel Karzel acfd43ee79 Rename Test to TestContext and argument to ctx 4 years ago