Commit Graph

968 Commits (962b648911a304a443b31ceb3e97e6b6167a7fbd)

Author SHA1 Message Date
Thomas Eizinger e79ac4563b
Delete unused code 3 years ago
TDevD 5da075f533 fix typo 3 years ago
COMIT Botty McBotface 3f2d094f65
Prepare release 0.6.0 3 years ago
Daniel Karzel 1de907b176
Change default Monero mainnet node to xmr.to
It appears to be more stable.
Encountered issues with the previous setup, `monero-wallet-rpc` logs:

```
2021-05-24 04:23:54.852	E !r. THROW EXCEPTION: tools::error::no_connection_to_daemon
2021-05-24 04:23:54.857	E Exception at while refreshing, what=no connection to daemon
```
3 years ago
bors[bot] ded9ea1b79
Merge #525
525: Bitcoin transaction published state r=da-kami a=da-kami

This improves the error handling on the ASB.
Once the Bitcoin redeem transaction is seen in mempool, the state machine cannot transition to a cancel scenario anymore because at that point the CLI will have redeemed the Monero.
The additional state then waits for transaction finality and prevents re-publishing the transaction.

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
bors[bot] 284733d359
Merge #522
522: Add support for arm architecture to Swap CLI r=da-kami a=bonomat

Tested locally on my RPI4

Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
3 years ago
Daniel Karzel 01af9a5676
Bitcoin transaction published state
This improves the error handling on the ASB.
Once the Bitcoin redeem transaction is seen in mempool, the state machine cannot transition to a cancel scenario anymore because at that point the CLI will have redeemed the Monero.
The additional state then waits for transaction finality.
3 years ago
bors[bot] db319d0a90
Merge #520
520: Cli json logging r=da-kami a=da-kami

Combining `--json` with the debug file logger was a pita, so I stopped and went for a simpler approach:

If `--json` is given we just log to terminal - **no** logfiles will be created in `{data-dir}/logs`. 
The `--debug` flag applies to `--json` (i.e. if not given it will just print json on info level). We could change that to automatically fallback to debug - could add a `required_if` dependency via strucopt/clap but I did not want to invest more time into thinking about this.

Note on extending binary functionality:
As discussed with @thomaseizinger recently, we will have to think about multiple binaries soon, i.e. a binary that focuses to be used to building on top of it (that always logs json) and potientially keeping a simple CLI that is more user friendly. This also goes towards more clearly separating the application code from re-usable protocol / network code. 


Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Philipp Hoenisch 21babf9678
Support armv7 architecture for monero-wallet-rpc.
This allows us to run swap cli on a raspberry pi 4.
3 years ago
Philipp Hoenisch a445ddd2bd
Print download URL while downloading. 3 years ago
Philipp Hoenisch f6c7410457
Upgrade monero-wallet-rpc to version 2.0 3 years ago
bors[bot] ba33e1acc1
Merge #519
519: Avoid application error upon `--help` r=da-kami a=da-kami

Our `preview` release is currently broken because of this issue.

The way we use clap's `get_matches_from_safe` caused parsing errors upon `--help` and `--version` to be bubbled up to the application - which causes the application to exit with an error when running `--help` and `--version`.
This is solved by using `get_matches_from` instead of `get_matches_from_safe` which handles these known clap commands internally and exits early. 

Added smoke tests to CI so we catch such kind of problems in the future. Smoke testing by calling `--help` is cheap and should be OK in CI.

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Daniel Karzel fb9fb21c2b
CLI log statements to be more JSON friendly
Values to be logged as fields.
Upon starting a swap we print the swap-id as well.
3 years ago
Daniel Karzel 0187d9ef4f
Introduce `--json` flag for the CLI
When `--json` is used the CLI does not log to file, but only on the command line in json output.
3 years ago
bors[bot] 0032e820af
Merge #512
512: Bump libp2p from 0.37.1 to 0.38.0 r=thomaseizinger a=dependabot[bot]

Bumps [libp2p](https://github.com/libp2p/rust-libp2p) from 0.37.1 to 0.38.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/libp2p/rust-libp2p/releases">libp2p's releases</a>.</em></p>
<blockquote>
<h2>v0.38.0</h2>
<p>See individual <a href="https://github.com/libp2p/rust-libp2p/blob/HEAD/CHANGELOG.md">changelogs</a> for details.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/libp2p/rust-libp2p/blob/master/CHANGELOG.md">libp2p's changelog</a>.</em></p>
<blockquote>
<h2>Version 0.38.0 [2021-05-17]</h2>
<ul>
<li>Update individual crates.
<ul>
<li><code>libp2p-core</code></li>
<li><code>libp2p-gossipsub</code></li>
<li><code>libp2p-noise</code></li>
<li><code>libp2p-pnet</code></li>
<li><code>libp2p-wasm-ext</code></li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="0b7ee3fa92"><code>0b7ee3f</code></a> *: Prepare v0.38.0 (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2072">#2072</a>)</li>
<li><a href="c5bcada2c2"><code>c5bcada</code></a> protocols/gossipsub: Rework connection keep-alive (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2043">#2043</a>)</li>
<li><a href="9c5dd84099"><code>9c5dd84</code></a> build(deps): Update snow requirement from 0.7.1 to 0.8.0 (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2068">#2068</a>)</li>
<li><a href="1fdac073fc"><code>1fdac07</code></a> build(deps): Bump actions-rs/toolchain from 1 to 1.0.7 (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2069">#2069</a>)</li>
<li><a href="10fcc1c485"><code>10fcc1c</code></a> build(deps): Bump actions-rs/cargo from 1 to 1.0.3 (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2070">#2070</a>)</li>
<li><a href="82c8b1a4b3"><code>82c8b1a</code></a> build(deps): Bump actions/checkout from 2 to 2.3.4 (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2071">#2071</a>)</li>
<li><a href="43a8ad8fc2"><code>43a8ad8</code></a> protocols/relay/examples: Add client server instructions (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2060">#2060</a>)</li>
<li><a href="8988ac247e"><code>8988ac2</code></a> protocols/mdns: Fix discovered event emission. (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2065">#2065</a>)</li>
<li><a href="5c541a16f1"><code>5c541a1</code></a> build(deps): update salsa20 requirement from 0.7 to 0.8 (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2062">#2062</a>)</li>
<li><a href="d931f36428"><code>d931f36</code></a> transport/wasm-ext: Support dialing <code>Multiaddr</code> with <code>/p2p</code> protocol (<a href="https://github-redirect.dependabot.com/libp2p/rust-libp2p/issues/2058">#2058</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/libp2p/rust-libp2p/compare/v0.37.1...v0.38.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=libp2p&package-manager=cargo&previous-version=0.37.1&new-version=0.38.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>
3 years ago
Daniel Karzel 9ff29ae491
CLI `--help` and `--version` are handled correctly
Since we introduced our own parsing function for command line arguments, we have to make sure that clap's behaviour is handled correctly.
Clap's `get_matches_from_safe` returns an error of a certain kind, of which `ErrorKind::HelpDisplayed` and `ErrorKind::VersionDisplayed ` have to be handled to properly print the help/version and exit the program.
The clap error includes the message, so we print help/version in main now and ensure the program exits with `0` afterwards.
3 years ago
Daniel Karzel 22bf48c287
Fix bug that breaks swap ID for logging 3 years ago
bors[bot] bdb88f89cb
Merge #490
490: Mainnet switch r=da-kami a=da-kami

Fixes  #446
Fixes #360 
Fixes #506 
Fixes #478 

To be precise: It is actually a testnet switch, because I think mainnet should be default.

I took several assumptions on the way (e.g. network support, ...).

At this stage any feedback welcome :)

TODO:

- [ ] successful mainnet swap with this code base before merging :)

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Daniel Karzel 2db470f099
Bitcoin=2 Monero=10 default finality confirmations
It is currently not expected that ASB and CLI are used for swaps > 10_000$ equivalent to XMR/BTC, thus the finality confirmations were reduced to an equivalent of 20 mins of work (2 blocks for Bitcoin, 10 for Monero).
Monero enforces 10 unlocking blocks until the balance is spendable, so the finality confirmations cannot be set lower than 10.
3 years ago
Daniel Karzel 6694e4f4e0
Ensure that output of lock script is at tx-output index `0`
We subscribe to transactions upon broadcast, where we use output index `0` for the subscription.
In order to ensure that this subscription is guaranteed to be for the locking script (and not a change output) we now ensure that the locking script output is always at index `0` of the outputs of the transaction.

We chose this solution because otherwise we would have to add more information to broadcasting a transaction.
This solution is less intrusive, because the order of transaction outputs should not have any side effects and ensuring index `0` makes the whole behaviour more deterministic.
3 years ago
Daniel Karzel bae38a712f
Sync on interval instead of ping
Since we don't rely on long running subscriptions anymore we can remove the ping that was used to ensure a connection refresh.
3 years ago
Daniel Karzel efb51820b1
Poll block headers for latest block on each iteration
The Electrum block-header subscription did not provide us with block headers, because upon the connection being closed by a node the subscription would end.
Re-newing the the subscription upon re-connect is not easily achievable, that's why we opted for a polling mode for now, where we start a block header subscription on every update iteration, that is only used once (when the subscription is made).
3 years ago
Daniel Karzel f2e43ea565
Let testnet setup reflect mainnet
Our test values should reflect what we test on mainnet more closely to avoid bugs that are only observed when using mainnet settings.
3 years ago
Daniel Karzel 4dd696ebe1
Fix `monero-wallet-rpc` startup for mainnet CLI
There is no `--mainnet` flag.
Since we cannot just pass an empty string to `.arg()` we use the `.args()` method to pass nothing for mainnet and the respective flags for stagenet and testnet.
3 years ago
Daniel Karzel 1aaffb09f9
Refactor ASB test-/mainnet default dir init 3 years ago
Daniel Karzel cfa85e0bad
Simplify ASB initial setup signature 3 years ago
Daniel Karzel 7f8af7926d
ASB config may specify finality confirmations
By default the finality confirmations of the network's `env::Config` will be applied and no finality confirmations will be persisted on disk in the config file.
It is however possible to set finality confirmations in the config file for bitcoin and monero for power users at their own risk.
If set the defaults will be overwritten with the parameter from the config file upon startup.
3 years ago
Daniel Karzel af60d3bb54
Network check upon spot price request 3 years ago
Daniel Karzel 02974811ad
Activate mainnet for the ASB
To run the ASB on testnet, one actively has to provide the `--testnet` flag.
Mainnet and testnet data and config are separated into sub-folders, i.e. `{data/config-dir}/asb/testnet` and `{data-dir}/asb/mainnet`.
The initial setup is also per network. If (default) config for the network cannot be found the initial setup is triggered.
Startup includes network check to ensure the bitcoin/monero network in config file is the same as the one in the `env::Config`.

Note: Wallet initialization is done with the network set in the `env::Config`, the network saved in the config file is just to indicate what network the config file is for.
3 years ago
Daniel Karzel 9ac5b635d7
Introduce own de-/serializable `monero::Network` 3 years ago
Daniel Karzel 69cf12620d
Activate mainnet for the CLI
This includes testing CLI commandline args
Clap's `default_value_with` actually did not work on `Subcommand`s because the parent's flags were not picked up.
This was fixed by changing parameters dependent on testnet/mainnet to options.
This problem should have been detected by tests, that's why the command line parameter tests were finally (re-)added.

Thanks to @rishflab for some pre-work for this.
3 years ago
dependabot[bot] 6c206c7067
Bump libp2p from 0.37.1 to 0.38.0
Bumps [libp2p](https://github.com/libp2p/rust-libp2p) from 0.37.1 to 0.38.0.
- [Release notes](https://github.com/libp2p/rust-libp2p/releases)
- [Changelog](https://github.com/libp2p/rust-libp2p/blob/master/CHANGELOG.md)
- [Commits](https://github.com/libp2p/rust-libp2p/compare/v0.37.1...v0.38.0)

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Thomas Eizinger a3f436104f
Use tokio-tar from crates.io 3 years ago
Thomas Eizinger 75c5db53b2
Remove tokio-tar from workspace in favor of git dependency
Fixes #315.
Fixes #227.
3 years ago
Daniel Karzel 1cdc23de32
Explicitly specify `monero-wallet-rpc` deamon port
In order to allow people to plug into public nodes / be more flexible with their own setup we now enforce specifying the monero daemon port to be used by the `monero-wallet-rpc`.
3 years ago
Daniel Karzel 343badbb4b
Remove duplication and cleanup
In the past we had problems with flags/parameter changes several times, where on instance was changed, buy another one was missed. This should mitigate this problem.
This patch introduces structs for all duplicated parameters and uses flatten to only have one point for changes.

Additionally removes all mentions of `alice` from the commands / variables. This code is on an application level and should not be concerned with swap protocol roles.
3 years ago
Daniel Karzel 4e1f3f82bd
Remove `param` from names
Did not add any value, more readable with just bitcoin and monero.
3 years ago
Daniel Karzel 657ac1e2e4
Bitcoin parameters that can be reused
Get rid of parameter duplication.
3 years ago
Daniel Karzel a489564857
Remove unused Electrum HTTP default URL 3 years ago
Philipp Hoenisch 493545d07f
Improve logging for Swap Cli. 3 years ago
Philipp Hoenisch 4f45a26a83
Move check for max_giveable into the function. 3 years ago
Philipp Hoenisch 7fc5a47619
Add checks to max_giveable amount.
We need to check two things:
- balance to be higher than dust amount (546).
- balance to be higher than min-relay fee.

Additionally, the tx_builder might fail if not enough funds are in the wallet to pay for the overall transaction fees.
3 years ago
Philipp Hoenisch 26e0383e17
Apply suggestions from code review
Co-authored-by: Daniel Karzel <daniel.karzel@coblox.tech>
3 years ago
Philipp Hoenisch fc0cceb180
Toggle json logs using commandline flag. 3 years ago
Philipp Hoenisch 316f95c65b
Always log whole causality chain for errors. 3 years ago
Philipp Hoenisch c011e95062
Improve logging by adding details as fields instead of into the msg. 3 years ago
Philipp Hoenisch 1706b36800
Log exchange rate at each state. 3 years ago
bors[bot] 227c383d76
Merge #481
481: Min buy amount r=da-kami a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Daniel Karzel 652aae9590
Introduce a minimum buy amount
Introduces a minimum buy Bitcoin amount similar to the maximum amount already present.
For the CLI the minimum amount is enforced by waiting until at least the minimum is available as max-giveable amount.
3 years ago
Daniel Karzel 6d3cf0af91
Include too low balance into Alice's error 3 years ago
Daniel Karzel 1d62f4916c
Move `max_buy` and `ask_spread` into config
Max-buy and spread is not something that one would configure on every run.
More convenient to keep this in the config.

The max-buy Bitcoin value was adapted to `0.02` which is more reasonable for mainnet.
Activated feature `serde-float` to serialize the spread (Decimal) as float instead of string.

```
...

[maker]
max_buy_btc = 0.02
ask_spread = 0.02
```
3 years ago
Philipp Hoenisch 330269a1e9
Update assert_weight test to account for a range up to 8 bytes.
Weights fluctuate because of the length of the signatures. Valid ecdsa signatures can have 68, 69, 70, 71, or 72 bytes. Since most of our transactions have 2 signatures the weight can be up to 8 bytes less than the static weight (4 bytes per signature).
3 years ago
Daniel Karzel 538b25a6dd
Only create config-directory on init success
We should only create the file if the user finished the initial setup correctly.
3 years ago
bors[bot] d96e20a5b0
Merge #479
479: Use rust_decimal in estimate_fee function. r=bonomat a=bonomat

Follow-up PR from #466 

Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
3 years ago
Philipp Hoenisch b5073e3052
Use rust_decimal in estimate_fee function. 3 years ago
Daniel Karzel 23d9637a4b
Work in review comments 3 years ago
Daniel Karzel daa572e5bf
Move recovery commands in dedicated module
Less clutter in the folder structure.
3 years ago
Daniel Karzel 4deb96a3c5
ASB manual recovery commands
Adds `cancel`, `refund`, `punish`, `redeem` and `safely-abort` commands to the ASB that can be used to trigger the specific scenario for the swap by ID.
3 years ago
Daniel Karzel efcd39eeef
Add info messages to each subcommand
`asb --help` :

(...)

SUBCOMMANDS:
    balance         Prints the Bitcoin and Monero balance. Requires the monero-wallet-rpc to be running.
    help            Prints this message or the help of the given subcommand(s)
    history         Prints swap-id and the state of each swap ever made.
    start           Main command to run the ASB.
    withdraw-btc    Allows withdrawing BTC from the internal Bitcoin wallet.
3 years ago
Daniel Karzel 0c616c7437
Move loading the state into the function
In the production code it is a weird indirection that we load the state and then pass in the state and the database.
In the tests we have one additional load by doing it inside the command, but loading from the db is not expensive.
3 years ago
Daniel Karzel 89b3d07eba
Network protocol tests for spot_price behaviour
Each test spawns swarm for Alice and Bob that only contains the spot_price behaviours and uses a memory transport.
Tests cover happy path (i.e. expected price is returned) and error scenarios.
Implementation of `TestRate` on `LatestRate` allows testing rate fetch error and quote calculation error behaviour.

Thanks to @thomaseizinger for ramping up the test framework for comit-rs in the past!
3 years ago
Daniel Karzel 03a0dc73cd
Alice's spot_price Behaviour reports back Error
Instead of handling all errors on the inside spot_price errors are bubbled up (as `SwapRequestDeclined`).
This allows us to test both Alice's and Bob's behaviour for all scenarios.
3 years ago
Daniel Karzel 5aac76598d
Decouple ASB/CLI Errors from Error sent over wire
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.
3 years ago
Daniel Karzel 52f648e1de
Alice's spot price logic into dedicated behaviour
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`).
3 years ago
Daniel Karzel ea76ae5821
Return proper error to CLI for all expected scenarios
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.
3 years ago
Daniel Karzel f6497778ed
Add resume-only mode for the ASB
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.
3 years ago
Philipp Hoenisch 0090e3b48e
Typo 3 years ago
Philipp Hoenisch 59a55dcbdd
Remove todo for cleanup note. 3 years ago
Philipp Hoenisch e93eeb81a2
Added some proptests. 3 years ago
Philipp Hoenisch 040cce1eb6
Format all the files 3 years ago
Philipp Hoenisch 68ae47edf4
Log error message. 3 years ago
Philipp Hoenisch aebdb063f1
Remove TODO 3 years ago
Philipp Hoenisch 9fb1a43f29
Rename variable. 3 years ago
Philipp Hoenisch cfdbacfbb5
Add comment.
The weight of our transactions can fluctuate by +-2 wu because our transactions have 2 signatures
3 years ago
Philipp Hoenisch e69a2c9111
Apply suggestions from code review
Co-authored-by: Daniel Karzel <daniel.karzel@coblox.tech>
3 years ago
Philipp Hoenisch dc8dd5af28
Add relative and absolute max transaction fee. 3 years ago
Philipp Hoenisch dc6ab0fa52
Ensure that constant weights do not go out of sync with code. 3 years ago
Philipp Hoenisch 7fe9087bc2
Pull trait-bounds up one level for easier testing. 3 years ago
Philipp Hoenisch 77f6f11a7f
Pass address/fees into State0 instead of passing in the wallet. 3 years ago
Philipp Hoenisch 14c5a4f025
Add upper bound for bitcoin fees of 100,000 satoshi.
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.
3 years ago
Philipp Hoenisch 46e0449b8e
Add config/argument to swap/asb to configure bitcoin tx fees. 3 years ago
Philipp Hoenisch 9e8b788aa9
Rename weight constants. 3 years ago
Philipp Hoenisch ee90c228b4
Dynamically calculate fees using electrum's estimate_fee.
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.
3 years ago
Philipp Hoenisch 38540b4de5
Dynamically chose fee for TxCancel.
Bob chooses the fee for TxCancel because he is the one that cares.
3 years ago
Philipp Hoenisch 1012e39527
Dynamically chose fee for TxRefund and TxPunish.
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.
3 years ago
Philipp Hoenisch d5c1b6693e
Dynamically chose fee for TxRedeem.
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.
3 years ago
Philipp Hoenisch 002e7b38c3
Define TX_FEE within test files only. 3 years ago
Philipp Hoenisch 1db7586632
Increase timeout sending/receiving protocol messages. 3 years ago
bors[bot] e7785d2c83
Merge #434
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>
3 years ago
bors[bot] cf1c448b7c
Merge #460
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>
3 years ago
bors[bot] 1244b30094
Merge #459
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>
3 years ago
Daniel Karzel 69f7565746
!fixup Different default directories for CLI and ASB
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.
3 years ago
Thomas Eizinger dd6bfd3bf4
Extend RPC client for monerod with binary requests 3 years ago
Daniel Karzel b0ffeeab1d
Different default directories for CLI and ASB
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.
3 years ago
Daniel Karzel 08fecb8fe3
Peer check for incoming transfer proofs
Bob validates that incoming transfer proof messages are coming from the peer-id of Alice.
Currently Bob will ignore any transfer proof message that is not coming from the counterparty peer-id associated to the current swap in execution.
Once we add support for trying to save received transfer proofs for swaps that are currently not in execution we can also adapy allowing this for different counterparty peer-ids. This requires access to the database in Bob's event loop.
3 years ago
Daniel Karzel 3c2dfa830a
Peer check for incoming encrypted signatures
Alice validates that incoming encsig messages are coming from the peer-id that is associated with the swap.
Encsig message from a peer-id different to the one associated with the swap are ignored.
3 years ago
Thomas Eizinger 1820139786
Use dprint for formatting Cargo.toml files
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.
3 years ago
Philipp Hoenisch ea6e2f8f09
Simplify `to_address_string` by implying more context on the structure. 3 years ago
Philipp Hoenisch c8e6db24f8
Derive Tor secret key from seed. 3 years ago
Philipp Hoenisch 3a5395d7a5
Optimize torut features.
OnionV2 addresses are being deprecated and will be fully phased out on 15.10.2021: https://blog.torproject.org/v2-deprecation-timeline
3 years ago