Commit Graph

1005 Commits (0dc3943d9c3bf3305083b819d63d53b676de4b4b)

Author SHA1 Message Date
Daniel Karzel 0dc3943d9c
Update default Monero node URLs and info
xmr.to nodes are not served at the xmr.to domain but moved to melo.tools
3 years ago
Daniel Karzel ab24f7bce5
Revert "Prepare release 0.8.0"
This reverts commit 50da9580
3 years ago
bors[bot] b7a832eb7a
Merge #616
616: Don't spam the user while waiting for BTC to be deposited r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
Thomas Eizinger 2c8bbe4913
Remove left-over "half" of log message
With the move to using tracing's fields, this log message was not
properly updated.
3 years ago
Daniel Karzel 6abf83f4ad
Sort seller list inside of `list_sellers`
By sorting the list inside we have a more deterministic output that makes processing in JSON easier.
3 years ago
Thomas Eizinger cacfc50fb2
Don't spam the user while waiting for BTC 3 years ago
Thomas Eizinger 56a48e71ef
Add failing test that shows spamming of output 3 years ago
Thomas Eizinger 56ea23c2a3
Assert log output for `determine_btc_to_swap` 3 years ago
Thomas Eizinger a347dd8b97
Move helper structs below tests 3 years ago
COMIT Botty McBotface 50da958078 Prepare release 0.8.0 3 years ago
Thomas Eizinger 714514edbc
Provide a commit-specific version output
For builds made directly on the tag, the output of `--version` will
not change. For builds not made on a tagged commit, the output will
look something like this:

```
> swap --version

swap 0.7.0-117-g93161f9
```

Fixes #409.
3 years ago
Thomas Eizinger 5c37fe6733
Make struct-opt docs more consistent
- Remove dots from the of help messages
- Unify wording
3 years ago
Thomas Eizinger 987f8abb9d
Include unreachable nodes in table output
We emit an `info!` log for every peer that we discover but only ever
emitted a `debug!` log if we fail to connect. This leads to a situation
where the user would run `swap list-sellers`, the logs would say
"Discovered XYZ at ABC" but then get a potentially empty table.

To not confuse the user, we include unreachable nodes in the table output.
For example:

```
Connected to rendezvous point, discovering nodes in 'xmr-btc-swap-testnet' namespace ...
Discovered peer 12D3KooWPZ69DRp4wbGB3wJsxxsg1XW1EVZ2evtVwcARCF3a1nrx at /dns4/ac4hgzmsmekwekjbdl77brufqqbylddugzze4tel6qsnlympgmr46iid.onion/tcp/8765
+-------+--------------+--------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------+
| PRICE | MIN_QUANTITY | MAX_QUANTITY | STATUS      | ADDRESS                                                                                                                                |
+============================================================================================================================================================================================+
| ???   | ???          | ???          | Unreachable | /dns4/ac4hgzmsmekwekjbdl77brufqqbylddugzze4tel6qsnlympgmr46iid.onion/tcp/8765/p2p/12D3KooWPZ69DRp4wbGB3wJsxxsg1XW1EVZ2evtVwcARCF3a1nrx |
+-------+--------------+--------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------+
```
3 years ago
Thomas Eizinger 09f395a26b
Don't print level and time for `list-sellers`
This is now consistent with the `buy-xmr` command.
3 years ago
Thomas Eizinger 40eccd089f
Change `--data-dir` for `--data-base-dir` 3 years ago
Thomas Eizinger 3b1789fe07
Make things private if possible 3 years ago
Thomas Eizinger 8f50eb2f34
Utilize tracing's fields more 3 years ago
Thomas Eizinger 9119ce5cc4
Tidy up log messages across the codebase
1. Clearly separate the log messages from any fields that are
captured. The log message itself should be meaningful because it
depends on the underlying formatter, how/if the fields are displayed.
2. Some log messages had very little context, expand that.
3. Wording of errors was inconsistent, hopefully all errors should
now start with `Failed to ...`.
4. Some log messages were duplicated across multiple layers (like opening
the database).
5. Some log messages were split into two where one part is now an `error!`
and the 2nd part is an `info!` on what is happening next.
6. Where appropriate, punctuation has been removed to not interrupt
the reader's flow.
3 years ago
Thomas Eizinger 78480547d5
Don't import tracing's macros
Log statements end up getting changed constantly and having to clean
up imports after that is annoying, for example, if the last `info!`
in a file disappears, you end up with an unused import warning.

Fully qualifying tracing's macros prevents that and also communicates
clearly that we are using tracing and not log.
3 years ago
Thomas Eizinger 1d0d38cd48
Explain why we clear the `bip32_derivation` map 3 years ago
Thomas Eizinger acfd2dd6bb
Store Monero receive address in database and load it on resume 3 years ago
Thomas Eizinger 5463bde4f8
Add a mandatory `--change-address` parameter to `buy-xmr`
Fixes #513.
3 years ago
Thomas Eizinger 683d565679
Make variable naming consistent 3 years ago
Thomas Eizinger 8b59ac26ba
Replace sorting with slice pattern matching
Sorting `psbt.output` by `witness_script` is at times pointless
because it might be set to `None`. To be more robust, we pattern
match against the produced transaction.
3 years ago
Thomas Eizinger 348fca0827
Add isolated test for `list_sellers` function 3 years ago
Thomas Eizinger e642f5c148
Extend `SwarmExt` with ability to listen on TCP localhost
The CLI's transport doesn't support memory addresses and it also shouldn't support those by default. To be able to use it in tests, we extend the `SwarmExt` trait with the ability to listen on local TCP addresses with a random port.
3 years ago
rishflab 93a0692998
Integrate rendezvous protocol into ASB
The rendezvous protocol allows us to register all of our external
addresses. Hence, the first step is to allow the user to configure
external addresses as part of the config. In the future, there might
be an automated way of determining these.

To register with a rendezvous node, the user needs to configure which
one. CoBloX is running a rendezvous node that acts as the default by
every spec-compliant node will do the job just fine. This behaviour
is optional which is why our custom behaviour is wrapped in a `Toggle`.

We also want our node to re-register after half the time of the
registration has passed. To make this simpler and allow for testing in
isolation, we create a custom behaviour that wraps the libp2p rendezvous
behaviour.
3 years ago
Daniel Karzel ff10edd8a4
Add the `list-sellers` command to the CLI
This command uses a rendezvous node to find sellers (i.e. ASBs) and query them for quotes.
Sellers, that can be dialed and queried for a quote will be listed.
3 years ago
Daniel Karzel f45cde84ab
`comfy-table` instead of `prettytable-rs` 3 years ago
Thomas Eizinger b4fafeba6b
Allow large enum variant lint
The docs say one needs to measure the impact of this before taking
action. We didn't measure anything. Let's not take any action.
3 years ago
Thomas Eizinger e163942850
Merge transport and behaviour module into network 3 years ago
Daniel Karzel ff8cca2e27
Pass in CLI behaviour when creating swarm
This allows us to reuse the swarm setup with a different behaviour for discovering ASBs with a rendezvous node.
3 years ago
bors[bot] 4cd27e372c
Merge #604
604: Bump torut from 0.1.9 to 0.1.10 r=thomaseizinger a=dependabot[bot]

Bumps [torut](https://github.com/teawithsand/torut) from 0.1.9 to 0.1.10.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/teawithsand/torut/releases">torut's releases</a>.</em></p>
<blockquote>
<h2>Release 0.1.10</h2>
<p>Deprecated onion services V2 and all stuff associated with it.
Updated tokio version.
Implemented std::error::Error for error types in this crate, support for these errors is very basic and all that was done was implementing Error trait for existing error types. No error structure refactoring was done.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="8a26ddde79"><code>8a26ddd</code></a> Implemented std::error::Error for error types</li>
<li><a href="c5cee8a369"><code>c5cee8a</code></a> Implemented std::error::Error for error types</li>
<li><a href="caed51d697"><code>caed51d</code></a> Deprecated v2 onion service stuff</li>
<li><a href="87bcde20bb"><code>87bcde2</code></a> Updated tokio version</li>
<li>See full diff in <a href="https://github.com/teawithsand/torut/compare/v0.1.9...v0.1.10">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=torut&package-manager=cargo&previous-version=0.1.9&new-version=0.1.10)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

You can trigger a rebase of this PR by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
bors[bot] 72673fa166
Merge #605
605: Merge `--seller-addr` and `--seller-peer-id` into `--seller` parameter r=thomaseizinger a=thomaseizinger

This simplifies the CLI's interface.

It wills also play nicely with https://github.com/comit-network/xmr-btc-swap/pull/593.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
Thomas Eizinger d49f4ea60d
Test saving and loading of addresses in isolation 3 years ago
Thomas Eizinger ec4234fbb9
Merge `--seller-addr` and `--seller-peer-id` into `--seller` parameter
This simplifies the CLI's interface.
3 years ago
Thomas Eizinger c2daf7a11e
Make use of torut's errors implementing `std::error::Error`
Anyhow all the things!
3 years ago
Thomas Eizinger 8057b45e17
Test new reachability function in tests 3 years ago
Thomas Eizinger 92ed8d9c04
Refuse to dial addresses via Tor that are almost certainly not reachable
For now, this just concerns loopback addresses.
3 years ago
Thomas Eizinger ec59184e85
Refactor `fmt_as_address_string` to return a structured value
Instead of formatting to a string right away, we parse the multiaddress
into a stricter data structure that only allows the kind of addresses
we can dial through Tor.

This will allow us to perform further checks on the parsed address.
3 years ago
bors[bot] b708d5a4dd
Merge #585
585: Configurable kraken websocket url via the ASB config r=thomaseizinger a=cimble-code

- Allows the ASB operator to configure a custom kraken websocket url via the ASB config. 
- Addresses the issue of price control first brought up [here](https://github.com/comit-network/xmr-btc-swap/discussions/571)

>  Gotya. 
There is a relatively easy to implement (but temporary) solution for that. We could let the user configure the kraken websocket url via the ASB config. That way you can plug in your own service. The only requirement is that your service publishes prices updates in the same format as [kraken](https://docs.kraken.com/websockets/), e.g. : 

_Originally posted by @bonomat in https://github.com/comit-network/xmr-btc-swap/discussions/571#discussioncomment-885535_

Co-authored-by: Your Name <you@example.com>
3 years ago
Your Name 665ea503d2 Make price ticker ws url configurable 3 years ago
Daniel Karzel dc89a837e7
Do not actively set `KeepAlice::No` for `swap_setup`
Closing the connection upon completing the `swap_setup` protocol caused problems on the ASB side, because the CLI would close the connection before the last message was properly processed. This would result in swaps going into execution on the CLI side, but not on the ASB side.
The CLI ensures an open connection to the ASB over the complete course of a swap. So it does not make much sense to allow a protocol to close the connection (the CLI would immediately redial).
For the Alice we set the initial `KeepAlive` to `10` seconds because Bob is expected to request a spot price in reasonable time after opening a connection on the protocol. Since Tor connections can take some time we set 10 seconds fow now for resilience.
3 years ago
Daniel Karzel cd14e22cdf
Longer timeout (120 secs) for `swap_setup` protocol
Given that we combined the `spot_price` and the `execution_setup` messaging into one protocol we should allow the protocol to take longer than 60 seconds to complete.
This is especially important for connections over Tor, where messaging can take significantly longer than over clearnet.
I ran some tests with Tor and did not run into issues with the 60 seconds, but we get very close to the timeout, so we better make it more resilient by adding more time.
3 years ago
Daniel Karzel fd18a07426
Flush and close `swap_setup` substreams
When swapping on testnet we ran into a problem where the CLI started the swap after sending all messages successfully, but the ASB ran into a `connection closed` error at the end of the `swap_setup` and the swap state machine was never actually triggered.

Flushing and closing the stream on both sides should ensure that we don't run into this problem and both parties gracefully exit the protocol.
3 years ago
Daniel Karzel c2c9e975ef
Quote protocol asb/cli instead of alice/bob
The quote protocol has no relation to the protocol roles but to the application hence the rename.
3 years ago
Daniel Karzel c0070f8fa7
Move files from `protocol` to appropriate module
Some network and application specific code does not belong in the protocol module and was moved.
Eventloop, recovery and the outside behaviour were moved to the respective application module because they are application specific.

The `swap_setup` was moved into the network module because upon change both sides will have to be changed and should thus stay close together.
3 years ago
Daniel Karzel 818147a629
`swap_setup` instead of `spot_price` and `execution_setup`
Having `spot_price` and `execution_setup` as separate protocols did not bring any advantages, but was problematic because we had to ensure that `execution_setup` would be triggered after `spot_price`. Because of this dependency it is better to combine the protocols into one.

Combining the protocols also allows a refactoring to get rid of the `libp2p-async-await` dependency.

Alice always listens for the `swap_setup` protocol. When Bob opens a substream on that protocol the spot price is communicated, and then all execution setup messages (swap-id and signature exchange).
3 years ago
Daniel Karzel 529de8d5fd
ASB aborts if CLI does not lock BTC
Includes a new state that is used to await BTC lock tx finality. Upon starting the swap we initially only wait for the BTC lock tx to be seen in the mempool.
This is guarded by a short timeout (3 mins), because it is assumed that in the current setup (sport_price + execution_setup only triggered upon funds being available already) the lock transaction should be picked up almost instanly after the execution setup succeeded.
3 years ago
Daniel Karzel c4c798ea20
Timeout on `execution_setup` for ASB
Similar to the CLI the ASB has to ensure that the execution_setup is executed within a certain time.
Without a timeout the price (returned by `spot_price` would be guaranteed with the CLI indefinitely.
3 years ago