Commit Graph

1115 Commits

Author SHA1 Message Date
Thomas Eizinger
0b17b1177a
Replace protocol definition in README with setup instructions
Fixes #262.
2021-03-05 15:56:00 +11:00
bors[bot]
ba9e92c4b9
Merge #275
275: `main` fn and error message improvements r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-05 04:55:41 +00:00
Thomas Eizinger
c826a28911
Add context if we fail to compute extended private key 2021-03-05 15:49:16 +11:00
Thomas Eizinger
1aa6d177bf
Improve error messages when determining BTC amount to be swapped 2021-03-05 15:49:16 +11:00
Thomas Eizinger
4138039ea0
Make sure all error messages start with an uppercase letter
These might potentially be shown to a user, let's make them all
consistent.
2021-03-05 15:49:15 +11:00
Thomas Eizinger
816e8b9b96
Add more context to fallible functions inside bitcoin::Wallet 2021-03-05 15:49:15 +11:00
Thomas Eizinger
5c24a46298
Improve error message if stuff fails directly in main 2021-03-05 15:49:15 +11:00
Thomas Eizinger
37f97ac471
Shorten function name
The variable will always be at least called `wallet`, hence we can
omit the `_wallet` postfix from the function name.
2021-03-05 15:49:14 +11:00
Thomas Eizinger
4f66269887
Move error message on sync _into_ the function
The bitcoin::Wallet::sync_wallet function doesn't do anything else
other than delegating. As such, we have just as much information
about what went wrong inside this function as we have outside.

By moving the .context call into the function, we can avoid repeating
us on every call-site.
2021-03-05 15:49:14 +11:00
Thomas Eizinger
5953037b81
Don't repeat the module name within the type 2021-03-05 15:49:13 +11:00
Thomas Eizinger
87f928f56c
Move const to function where it is used 2021-03-05 15:49:13 +11:00
Thomas Eizinger
4642e6c0e3
Simplify arguments to init_XYZ_wallet functions
This makes the function calls fit onto one line.
2021-03-05 15:49:11 +11:00
Thomas Eizinger
d0db6cba10
Favour individual logs over one in main 2021-03-05 15:48:42 +11:00
bors[bot]
2041f367c6
Merge #288
288: Switch to public stagenet node that works r=rishflab a=rishflab

The xmr.to node has been unreliable lately. The exan.tech node seems to
working.

@da-kami is following up with making this configurable. Lets get this in so we can get a release on Friday.

Co-authored-by: rishflab <rishflab@hotmail.com>
2021-03-05 04:35:33 +00:00
rishflab
754159c9f8 Switch to public stagenet node that works
The xmr.to node has been unreliable lately. The exan.tech node seems to
working.
2021-03-05 15:11:32 +11:00
bors[bot]
b7709e1200
Merge #287
287: Properly deal with messages on kraken websocket connection r=da-kami a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-05 03:50:36 +00:00
bors[bot]
1f40de15a3
Merge #284 #286
284: Rename `latest` release to `preview` r=thomaseizinger a=thomaseizinger

The latest release should refer to the latest non-pre release.
What we are doing here is actually publishing a preview release.

Fixes #281.

286: Update Cargo.lock for new version r=thomaseizinger a=thomaseizinger

I forgot about this in the last commit ...

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-05 03:03:41 +00:00
Thomas Eizinger
b178e95f95
Redo layout of eventloop module
1. Move internal types to the bottom and make them private
2. Sort public types by their importance
2021-03-05 14:02:24 +11:00
Thomas Eizinger
1822886cd0
Provide stronger isolation of kraken module
Instead of leaking the tokio::sync::Receiver type in our
return value, we create a newtype that implements the desired
interface. This allows us to get rid of the `RateService` structs
and instead implement `LatestRate` directly on top of this struct.

Given that `LatestRate` is only used within the event_loop module,
we move the definition of this type into there.
2021-03-05 13:56:25 +11:00
Thomas Eizinger
f6ed4d65b5
Properly deal with additional messages sent from kraken 2021-03-05 13:40:39 +11:00
Thomas Eizinger
7575d412b8
Add kraken_ticker CLI for local testing of the client 2021-03-05 13:39:42 +11:00
Thomas Eizinger
5ce9e5662c
Update Cargo.lock for new version
I forgot about this in the last commit ...
2021-03-05 13:38:20 +11:00
Thomas Eizinger
60d6d50246
Extract kraken websocket client into dedicated module 2021-03-05 13:37:51 +11:00
Thomas Eizinger
3e6e746852
Rename latest release to preview
The latest release should refer to the latest non-pre release.
What we are doing here is actually publishing a preview release.

Fixes #281.
2021-03-05 12:29:29 +11:00
bors[bot]
ed6dc924c9
Merge #283
283: Prepare for next release r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-05 01:11:30 +00:00
Thomas Eizinger
25c4639689
Prepare for next release 2021-03-05 11:43:44 +11:00
bors[bot]
5cb25edea0
Merge #276
276: Use Rust cache action instead of rolling it ourselves r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-04 07:31:59 +00:00
Thomas Eizinger
52433f7412
Use Rust cache action 2021-03-04 18:02:20 +11:00
bors[bot]
20f2e56e2d
Merge #271
271: Bob can verify that the XMR lock tx was published r=da-kami a=da-kami

The Monero `txhash` log was removed. I feel the user should have the possibility to verify that the transaction was actually published so I added the tx-hash to the confirmation output. 

We could potentially print the tx-hash when receiving the transfer proof already, but that might not add much value compared to printing it with the confirmations. 

Additionally we should allow the user to at least know when the XMR can be expected in the user's wallet, otherwise the swap ends like this:

```
2021-03-04 13:49:19   INFO Monero lock tx received 5 out of 5 confirmations
```

This is just not very informative - yes, the final transaction is an implementation detail, but I don't think we should hide the transactions from the user. By printing the tx-hash for spending from the lock-tx into the user wallet we ensure the user knows that the XMR can now be expected in the user wallet. 

--- 

To add context, here the complete log (with debug enabled) **before** this change: 

```
2021-03-04 13:30:46  DEBUG Database and seed will be stored in /Users/dakami/Library/Application Support/xmr-btc-swap
2021-03-04 13:30:46  DEBUG Starting monero-wallet-rpc on port 56145
2021-03-04 13:30:51  DEBUG Requesting quote
2021-03-04 13:30:51   INFO Received quote: 1 XMR = 0.00433500 BTC
2021-03-04 13:30:51   INFO Still got 0.01018746 BTC left in wallet, swapping ...
2021-03-04 13:30:51   INFO Spot price for 0.00500000 BTC is 1.153402537485 XMR
2021-03-04 13:30:52  DEBUG Starting execution setup with 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-03-04 13:30:55   INFO Published Bitcoin 3a6690a962191529892318819fb20e7f1ac4625400e64ee734056a9b2a17ad8f transaction as lock
2021-03-04 13:41:13  DEBUG Received Transfer Proof from 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-03-04 13:42:11   INFO Monero lock tx received 1 out of 5 confirmations
2021-03-04 13:45:33   INFO Monero lock tx received 2 out of 5 confirmations
2021-03-04 13:47:49   INFO Monero lock tx received 3 out of 5 confirmations
2021-03-04 13:48:56   INFO Monero lock tx received 4 out of 5 confirmations
2021-03-04 13:49:19   INFO Monero lock tx received 5 out of 5 confirmations
2021-03-04 13:49:19  DEBUG Encrypted signature sent
2021-03-04 13:49:19  DEBUG Alice acknowledged encrypted signature
2021-03-04 13:49:19  DEBUG watching for tx: e5569d3f0bcccac95252dffaebe74ead0360c09b76bc762de890aaa0e51afbcf
2021-03-04 13:49:20  DEBUG Received protocol error "missing transaction" from Electrum, retrying...
2021-03-04 13:49:22  DEBUG Received protocol error "missing transaction" from Electrum, retrying...
```



Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-04 06:24:59 +00:00
bors[bot]
88b3321ec5
Merge #268
268: Introduce `quote` protocol and display it to the user before they fund r=thomaseizinger a=thomaseizinger

Fixes #255.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-04 05:58:26 +00:00
Daniel Karzel
47a31760c0 Bob can verify the Monero txs by tx-hash
Print tx-hashes for monero transactions to allow Bob to look the transaction up in block explorer.

The story of Bab:
Our famous actor Bob has a brother named Bab.
In school they were often mixed up, because their names were so similar.
Eventually Bab renamed himself into Barbara, but that was even more confusing for now he
carried a female name even though he was not female. Bob wanted to help his brother and told him he
could just go for Bub. But that did not solve anything. Fun fact: Bub is actually married to Alice.
2021-03-04 16:51:55 +11:00
Thomas Eizinger
14dcd150af
Extract determine_btc_to_swap function and test it
We also instantiate tracing in to order to quickly validate, what
the output for the different scenarios looks like.
2021-03-04 16:27:08 +11:00
Thomas Eizinger
601bf07255
Introduce quote protocol and display it to the user before they fund
Previously, the user neither knew the price nor the maximum quantity
they could trade. We now request a quote from the user and display
it to them.

Fixes #255.
2021-03-04 16:26:27 +11:00
Thomas Eizinger
3da01ea44a
Rename local variables according to new protocol name 2021-03-04 16:20:54 +11:00
Thomas Eizinger
ead5db3f45
Re-order fields to group them semantically 2021-03-04 16:20:51 +11:00
bors[bot]
d727420424
Merge #274
274: Reduce workflow duplication r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-04 05:18:44 +00:00
bors[bot]
18f968d51c
Merge #270
270: Re-configure rustfmt to organize imports differently r=thomaseizinger a=thomaseizinger

Initially, I only set out to do a follow-up PR for e3a73d105b but stumbled over this rustfmt setting that I wanted to try out for a while already.

Enjoy! I already like it because imports take up less space and reduces the chances of merge conflicts.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-04 05:07:27 +00:00
Thomas Eizinger
ab68b28fd8
Reduce workflow duplication 2021-03-04 15:43:15 +11:00
Thomas Eizinger
bc176bc4fb
Minor import optimizations 2021-03-04 14:48:28 +11:00
Thomas Eizinger
6d9b21cb47
Change imports_granularity to module
This reduces the overall amount of LoC that imports take up in our
codebase by almost 100.
It also makes merge-conflicts less likely because there is less
grouping together of imports that may lead to layout changes which
in turn can cause merge conflicts.
2021-03-04 14:48:13 +11:00
Thomas Eizinger
2c8200621d
Move pub use into pub use block 2021-03-04 14:47:47 +11:00
Thomas Eizinger
45b5e29d40
Don't format tokio-tar 2021-03-04 14:47:44 +11:00
bors[bot]
6ae8b63018
Merge #267
267: Use gtar to create release archive on Mac r=thomaseizinger a=rishflab

Follow up commit uses 7zip to create a zip for windows and appends the binary with a .exe

Here are the releases produced by this PR on my fork:
https://github.com/rishflab/xmr-btc-swap/releases/tag/0.34.0
I have tested the above releases to work up to asking for a btc deposit on :
- [x] macOS
- [x] windows
- [ ] ubuntu

Fixes #251.

Co-authored-by: rishflab <rishflab@hotmail.com>
2021-03-04 03:47:03 +00:00
bors[bot]
d1363d130c
Merge #265
265: Replace quote with spot-price protocol r=thomaseizinger a=thomaseizinger

This is essentially functionally equivalent but includes some
cleanups by removing a layer of abstraction: `spot_price::Behaviour`
is now just a type-alias for a request-response behaviour.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-04 02:52:06 +00:00
bors[bot]
18980f4b8a
Merge #269
269: Monero address validity check r=da-kami a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-04 02:36:52 +00:00
Daniel Karzel
7504c6ceee Context for monero address parsing errors
Most of the errors are not user friendly, thus added context to tell the user the given address is incorrect.
2021-03-04 13:36:10 +11:00
rishflab
95b1558c8e Add create release archive action for ubuntu
gtar is not installed on ubuntu so tar has to be used
2021-03-04 12:29:35 +11:00
rishflab
13764161a3 Add create release archive action for windows
Windows users may not have a tar extractor installed by default so 7z
was used to create a zip archive. I attempted to add the action names to
 the strategy matrix so we dont need if statements to choose the
 appropriate create release archive action but github did not like when
 I passed a field under strategy.matrix.include into steps.uses.
2021-03-04 12:29:33 +11:00
Daniel Karzel
35d0e246d8 Monero address network check
Add a network check to ensure the given monero address is on the configured network.
2021-03-04 10:46:12 +11:00
rishflab
d88a235883 Use gtar to create release archive
tar was producing an archived that binary that was failing to execute on
 developer machines. Since gtar is not available on windows or ubuntu,
 the windows and ubuntu releases was removed.
2021-03-04 09:00:24 +11:00