What goes over the wire should not be coupled to the errors being printed.
For the CLI and ASB we introduce a separate error enum that is used for logging.
When sending over the wire the errors are mapped to and from the `network::spot_price::Error`.
As part of Bob-specific spot_price code was moved from the network into bob.
Clearly separation of the network API from bob/alice.
Move Alice's spot price logic into a dedicated network behaviour that handles all the logic.
The new behaviour encapsulates the complete state necessary for spot price request decision making.
The network behaviour cannot handle asynchronous calls, thus the balance is managed inside the spot price and has to updated regularly from the outside to ensure the spot price balance check has up to date data.
At the moment the balance is updated upon an incoming quote requests.
Code that is relevant for both ASB and CLI remains in the `network::spot_price` module (e.g. `network::spot_price::Error`).
When a CLI requests a spot price have some errors that are expected, where we can provide a proper error message for the CLI:
- Balance of ASB too low
- Buy amount sent by CLI exceeds maximum buy amount accepted by ASB
- ASB is running in maintenance mode and does not accept incoming swap requests
All of these errors returns a proper error to the CLI and prints a warning in the ASB logs.
Any other unexpected error will result in closing the channel with the CLI and printing an error in the ASB logs.
Resume-only is a maintenance mode where no swaps are accepted but unfinished swaps are resumed.
This is achieve by ignoring incoming spot-price requests (that would lead to execution setup) in the event-loop.
466: Add support to dynamically chose bitcoin transaction fees. r=bonomat a=bonomat
Resolves#443 (Bitcoin only).
@da-kami /@thomaseizinger: do you know how fees work in Monero?
If not, I'll read up on it and to come up with a proper strategy.
Monero Fees will be covered in #470
Note:
The there is a hardcoded relative and absolute upper bound. I personally feel safer if this is hardcoded for now as it is too easy to get wrong.
At the time of writing, this equals roughly USD $56.
Eventually we will want to make this also configurable.
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
Co-authored-by: Philipp Hoenisch <philipp@coblox.tech>
Fees are hard to compute and it is too easy to get wrong and lose a lot of money. Hence, a hardcoded maximum of 100,000 satoshi for a single transaction is in place.
Electrum has an estimate-fee feature which takes as input the block you want a tx to be included.
The result is a recommendation of BTC/vbyte.
Using this recommendation and the knowledge about the size of our transactions we compute an appropriate fee.
The size of the transactions were taken from real transactions as published on bitcoin testnet.
Note: in reality these sizes might fluctuate a bit but not for much.
Alice chooses the fee for TxPunish because she is the one that cares.
Bob chooses the fee for TxRefund because he is the one that cares.
Note must be taken here because if the fee is too low (e.g. < min tx fee) then she might not be able to publish TxRedeem at all.
Alice chooses the fee for TxRedeem because she is the one that cares. Note must be taken here because if the fee is too low (e.g. < min tx fee) then she might not be able to publish TxRedeem at all.
473: Bump rust_decimal from 1.12.4 to 1.13.0 r=thomaseizinger a=dependabot[bot]
Bumps [rust_decimal](https://github.com/paupino/rust-decimal) from 1.12.4 to 1.13.0.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/paupino/rust-decimal/commits/1.13.0">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rust_decimal&package-manager=cargo&previous-version=1.12.4&new-version=1.13.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually 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>
471: Remove torut patch to custom fork. r=bonomat a=bonomat
https://github.com/teawithsand/torut/pull/10 was merged and a new version released.
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
464: Add short description of how to configure Tor. r=bonomat a=bonomat
@da-kami : Is this the right place to document this?
Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
Co-authored-by: Philipp Hoenisch <philipp@coblox.tech>
468: Bump rust_decimal from 1.12.3 to 1.12.4 r=thomaseizinger a=dependabot[bot]
Bumps [rust_decimal](https://github.com/paupino/rust-decimal) from 1.12.3 to 1.12.4.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/paupino/rust-decimal/commits">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rust_decimal&package-manager=cargo&previous-version=1.12.3&new-version=1.12.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually 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>
469: Bump tracing-subscriber from 0.2.17 to 0.2.18 r=thomaseizinger a=dependabot[bot]
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.2.17 to 0.2.18.
<details>
<summary>Commits</summary>
<ul>
<li><a href="dd49b99016"><code>dd49b99</code></a> subscriber: prepare to release 0.2.18 (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1384">#1384</a>)</li>
<li><a href="d9e8eceafd"><code>d9e8ece</code></a> tracing: prepare to release 0.1.26 (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1383">#1383</a>)</li>
<li><a href="8d428b25d7"><code>8d428b2</code></a> core: prepare to release v0.1.18</li>
<li><a href="848ee2d157"><code>848ee2d</code></a> docs: document span.in_scope() at top-level (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1344">#1344</a>)</li>
<li><a href="88b176cdb5"><code>88b176c</code></a> tracing: impl <code>From\<EnteredSpan></code> for <code>Option\<Id></code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1325">#1325</a>)</li>
<li><a href="ccfa2cc687"><code>ccfa2cc</code></a> core: add support for <code>Arc\<dyn Subscriber + ...></code></li>
<li><a href="f9a3f17fbb"><code>f9a3f17</code></a> tracing: add an example of <code>tracing</code> in a panic hook (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1375">#1375</a>)</li>
<li><a href="e63d8e454b"><code>e63d8e4</code></a> core: add <code>Subscriber</code> impl for <code>Box\<dyn Subscriber + ...></code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1358">#1358</a>)</li>
<li><a href="1e8446eaa0"><code>1e8446e</code></a> subscriber: support special chars in span names (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1368">#1368</a>)</li>
<li><a href="396d9f42a5"><code>396d9f4</code></a> chore: fix cargo docs warnings (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/1362">#1362</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.2.17...tracing-subscriber-0.2.18">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tracing-subscriber&package-manager=cargo&previous-version=0.2.17&new-version=0.2.18)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually 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>
434: Introduce monero-wallet crate r=thomaseizinger a=thomaseizinger
This PR:
1. ~Introduce a crate for the epee binary serialization as a serde format~: Released here: https://github.com/comit-network/monero-epee-bin-serde
2. Extends the MoneroRPC client with two binary calls
3. Introduces a `monero-wallet` crate that for now just provides functionality for choosing random key offsets. Together with the the ability to produce bulletproofs and ring signatures, this should be enough for signing Monero transactions locally.
(1) and (2) are a prerequisite for (3).
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
462: Bump rust_decimal from 1.12.2 to 1.12.3 r=thomaseizinger a=dependabot[bot]
Bumps [rust_decimal](https://github.com/paupino/rust-decimal) from 1.12.2 to 1.12.3.
<details>
<summary>Commits</summary>
<ul>
<li><a href="322e3d1a40"><code>322e3d1</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/paupino/rust-decimal/issues/363">#363</a> from paupino/version/1.12.3</li>
<li><a href="74f1a06b7d"><code>74f1a06</code></a> Version 1.12.3</li>
<li><a href="6c0a1dbff4"><code>6c0a1db</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/paupino/rust-decimal/issues/362">#362</a> from paupino/issue/361</li>
<li><a href="010868df10"><code>010868d</code></a> Fixes an issue whereby rounding small negative numbers towards zero would cau...</li>
<li><a href="bb9b05c05a"><code>bb9b05c</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/paupino/rust-decimal/issues/358">#358</a> from paupino/feautre/min-version</li>
<li><a href="831fb9ae2e"><code>831fb9a</code></a> Use precompiled version of cargo make</li>
<li><a href="2e80bff136"><code>2e80bff</code></a> Relax when CI should be run</li>
<li><a href="c862d1dd41"><code>c862d1d</code></a> Use stable toolchain for file format/clippy checks</li>
<li><a href="571f5c06d1"><code>571f5c0</code></a> Switch back to --workspace for cargo check compatible functions</li>
<li><a href="c64b400844"><code>c64b400</code></a> Revert to --all for older toolchain</li>
<li>Additional commits viewable in <a href="https://github.com/paupino/rust-decimal/compare/1.12.2...1.12.3">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rust_decimal&package-manager=cargo&previous-version=1.12.2&new-version=1.12.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually 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>
460: Different default directories for CLI and ASB r=da-kami a=da-kami
Fixes#437
Using the same default directory as data-/config-dir has caused unwanted side effects when running both applications on the same machine.
Use these directory names:
- ASB: `xmr-btc-swap-asb`
- CLI: `xmr-btc-swap-cli`
Since the functionality is now application specific the respective functions were moved into the appropriate module of the application.
Co-authored-by: Daniel Karzel <daniel@comit.network>
459: Use dprint for formatting Cargo.toml files r=thomaseizinger a=thomaseizinger
Invoking cargo tomlfmt on all files is a PITA and as we can see from
the CI scripts, it is often forgotten to as new crates are added to
the workspace.
Using dprint for toml files fixes this.
Unfortunately, we can't use dprint for Rust code yet because there
hasn't been a release of rustfmt in quite a while but we are already
using features from a newer rustfmt via rustup.
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Using the same default directory as data-/config-dir has caused unwanted side effects when running both applications on the same machine.
Use these directory names:
- ASB: xmr-btc-swap/asb
- CLI: xmr-btc-swap/cli
Since the functionality is now application specific the respective functions were moved into the appropriate module of the application.
This is fairly bare-bones for now and only contains one piece of
functionality: choosing random key offsets.
More functionality for actually signing Monero transactions will
be added later.
451: Peer id check for transfer proof and encsig messages r=da-kami a=da-kami
Fixes#416
The second commit will be relevant for changes planned in #411
@thomaseizinger with #411 we will need access to Bob's database in the eventloop, this might influence design decisions for #401
Co-authored-by: Daniel Karzel <daniel@comit.network>
Using the same default directory as data-/config-dir has caused unwanted side effects when running both applications on the same machine.
Use these directory names:
- ASB: xmr-btc-swap-asb
- CLI: xmr-btc-swap-cli
Since the functionality is now application specific the respective functions were moved into the appropriate module of the application.