Commit Graph

866 Commits (af2938a39aa13ac0ead78b2218410480a43e25b7)

Author SHA1 Message Date
Thomas Eizinger c0785ab05a
"Buffer" all requests to Alice until we are connected
We use the "precondition" feature of the `tokio::select!` macro to
avoid polling certain futures. In particular, we skip polling all
futures that - when resolved - require us to send a message to Alice.
3 years ago
Thomas Eizinger 1b0c29b424
Use bmrng to model communicaton of Alice's EventLoop with the handle
This allows us to delay the ACKing of the encrypted signature up until
the swap has actually requested it.

Similarly, it allows us to wait for the ACK of the transfer proof within
the swap before continuing.
3 years ago
Thomas Eizinger 1c47b32681
Use bmrng to model communicaton of Bob's EventLoop with the handle
bmrng is a library providing a request-response channel that allows
the receiving end of the channel to send a response back to the sender.
This allows us to more accurately implement the functions on the
`EventLoopHandle`. In particular, we now _wait_ for the ACK of specific
messages from the other party before resolving the future.

For example, when sending the encrypted signature, the async function
on the `EventLoopHandle` does not resolve until we received the ACK
from the other party.

We also delete the `Channels` abstraction in favor of directly creating
bmrng channels. This allows us to directly control the channel buffer
which we set to 1 because we don't need more than that on Bob's side.
3 years ago
Thomas Eizinger 958e5b12bc
Don't match on expired_timelocks and race it in a select in parallel
There is no point in first checking for the expired timelocks and
then constructing a `select!` that also watches for the timelock to
expiry.

We can simply only have the select! invocation to achieve the same
effect. In case the timelock is already expired, this future will
resolve immediately.

Normally, the polling order of `select!` is pseudo-random. We
configure it to be _biased_ here to make sure the futures are polled
in order.
3 years ago
Thomas Eizinger dbe03ba1cf
Timeout Bob's execution-setup after 10 seconds
The execution setup is our only libp2p protocol that doesn't have
a timeout built-in. Hence, if anything fails on Alice's side, we
would wait here forever.

Wrapping the future in a timeout ensures that we fail eventually
if this protocol doesn't succeed.
3 years ago
Thomas Eizinger 5d75f1adba
Remove import line in favor of FQ macro usage 3 years ago
Thomas Eizinger 4c2e254543
Don't log subscription
This object is very verbose and not meant to be logged.
3 years ago
Thomas Eizinger 5b230bc75f
Don't import tracing macros
Typing them out is quicker than constantly adjusting imports.
3 years ago
Thomas Eizinger 90a7760124
Add some log statements to bob::cancel 3 years ago
Thomas Eizinger 3f54b39281
Make all error messages start with an uppercase letter 3 years ago
Thomas Eizinger 0ef9d97679
Remove delegation functions in favor of public fields
We don't need to hide the fields of this Behaviour as the only reason
for why this struct exists is because libp2p forces us to compose our
NetworkBehaviours into a new struct.
3 years ago
Thomas Eizinger b1d0ae8db7
Remove dead code
No codepath constructs this event, we can delete the associated code.
3 years ago
Daniel Karzel 2135a6e53e
Alice resumes swaps 3 years ago
Daniel Karzel b6e4fb4f9d
Improve comment 3 years ago
Daniel Karzel d233e9914e
Avoid problems when re-ordering / changing Bob's states
Make it explicit in which states we are able NOT to cancel/refund.
3 years ago
Daniel Karzel e6dd194f77
next_state loop always exits in final state
Otherwise we can run into scenarios where the loop never properly exits.
3 years ago
Daniel Karzel d90496931b
Save Alice's peer-id in the db for Bob
This allows loading the seller-peer-id from the database upon resuming a swap.
Thus, the parameters `--seller-peer-id` is removed for the `resume` command.
Other than the peer-id the multi address of a seller can change and thus is
still a parameter. This parameter might become optional once we add DHT support.
3 years ago
Daniel Karzel bc442bcad3
Await 10 confirmations of lock tx in refund
Awaiting the confirmations in an earlier state can cause trouble with resuming
swaps with short cancel expiries (test scenarios).
Since it is the responsibility of the refund state to ensure that the XMR can
be sweeped, we now ensure that the lock transaction has 10 confirmations before
refunding the XMR using generate_from_keys.
3 years ago
Daniel Karzel 1c129d58c4
Distinguish loading all swaps for alice or bob on db level 3 years ago
Daniel Karzel 183e8f02de
Wait for lock tx and send transfer proof in separate state
Sending the transfer transaction in a distinct state helps ensuring
that we do not send the Monero lock transaction twice in a restart
scenario.
Waiting for the first transaction confirmation in a separate state
helps ensuring that we send the transfer proof in a restart scenario.
3 years ago
Daniel Karzel dfd69c9c80
Alice aborts if any timelock expired before locking XMR
Once we resume unfinished swaps upon startup we have to ensure that
it is safe for Alice to act.
If Bob has locked BTC it is only make sense for Alice to lock up the
XMR as long as no timelock has expired. Hence we abort if the BTC is
locked, but any timelock expired already.
3 years ago
bors[bot] 6df26109aa
Merge #389
389: Bump bdk-testutils from 0.3.0 to 0.4.0 r=thomaseizinger a=dependabot[bot]

Bumps [bdk-testutils](https://github.com/bitcoindevkit/bdk) from 0.3.0 to 0.4.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/bitcoindevkit/bdk/releases">bdk-testutils's releases</a>.</em></p>
<blockquote>
<h2>v0.4.0</h2>
<p>The v0.4.0 release brings updated dependencies, more sanity checks and an overhauled API to build transactions.</p>
<p>You can find the full v0.4.0 changelog on GitHub.</p>
<p>As always, thanks to everybody who contributed to this release!</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/bitcoindevkit/bdk/blob/master/CHANGELOG.md">bdk-testutils's changelog</a>.</em></p>
<blockquote>
<h2>[v0.5.0] - [v0.4.0]</h2>
<h3>Misc</h3>
<h4>Changed</h4>
<ul>
<li>Updated <code>electrum-client</code> to version <code>0.7</code></li>
</ul>
<h3>Wallet</h3>
<h4>Changed</h4>
<ul>
<li><code>FeeRate</code> constructors <code>from_sat_per_vb</code> and <code>default_min_relay_fee</code> are now <code>const</code> functions</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="e3f893dbd1"><code>e3f893d</code></a> Bump version to 0.4.0</li>
<li><a href="3f5513a2d6"><code>3f5513a</code></a> Update 'bdk-macros', 'bdk-testutils', 'bdk-testutils-macros' dep versions</li>
<li><a href="fcf5e971a6"><code>fcf5e97</code></a> Bump 'bdk-macros' version to 0.3.0</li>
<li><a href="cdf7b33104"><code>cdf7b33</code></a> Bump 'bdk-testutils' version to 0.3.0</li>
<li><a href="7bbff79d4b"><code>7bbff79</code></a> Bump 'bdk-testutils-macros' version to 0.3.0</li>
<li><a href="3a2b8bdb85"><code>3a2b8bd</code></a> Small CHANGELOG cleanup</li>
<li><a href="7843732e17"><code>7843732</code></a> [descriptor] Perform additional checks before using a descriptor</li>
<li><a href="6092c6e789"><code>6092c6e</code></a> Don't fix tokio minor version</li>
<li><a href="b61427c07b"><code>b61427c</code></a> [policy] Allow specifying a policy path for <code>Multisig</code></li>
<li><a href="fa2610538f"><code>fa26105</code></a> [policy] Remove the <code>TooManyItemsSelected</code> error</li>
<li>Additional commits viewable in <a href="https://github.com/bitcoindevkit/bdk/compare/v0.3.0...v0.4.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=bdk-testutils&package-manager=cargo&previous-version=0.3.0&new-version=0.4.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
dependabot[bot] 8440cb9d9a
Bump monero from 0.10.0 to 0.11.1
Bumps [monero](https://github.com/monero-rs/monero-rs) from 0.10.0 to 0.11.1.
- [Release notes](https://github.com/monero-rs/monero-rs/releases)
- [Commits](https://github.com/monero-rs/monero-rs/compare/v0.10.0...v0.11.1)

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
dependabot[bot] 04fc870756
Bump bdk-testutils from 0.3.0 to 0.4.0
Bumps [bdk-testutils](https://github.com/bitcoindevkit/bdk) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/bitcoindevkit/bdk/releases)
- [Changelog](https://github.com/bitcoindevkit/bdk/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bitcoindevkit/bdk/compare/v0.3.0...v0.4.0)

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Thomas Eizinger 52b9a78de2
Alice to validate Bob's PSBT for correctness
In order for the re-construction of TxLock to be meaningful, we limit
`Message2` to the PSBT instead of the full struct. This is a breaking
change in the network layer.

The PSBT is valid if:

- It has at most two outputs (we allow a change output)
- One of the outputs pays the agreed upon amount to a shared output script

Resolves #260.
3 years ago
Thomas Eizinger 8576894c10
Split bitcoin::Wallet functions into various impl blocks
This allows us to construct instances of bitcoin::Wallet for test
purposes that use a different blockchain and database implementation.

We also parameterize the electrum-client to make it possible to
construct a bitcoin::Wallet for tests that doesn't have one. This
is necessary because the client validates the connection as it is
constructed and we don't want to provide an Electrum backend for
unit tests.
3 years ago
Thomas Eizinger b9d8cbeaa2
Rename testutils to harness
This allows us to bring in a dependency named `testutils`.
3 years ago
Thomas Eizinger 11b45cd8c0
Move messages into `protocol` module
This allows us to remove all visibility modifiers from the message
fields because child modules (in this case {alice,bob}::state) can
always access private fields of structs.

It also moves the messages into a more natural place. Previously,
they were defined within the network layer even though they are
independent of the libp2p implementation.
3 years ago
Thomas Eizinger e130448200
Make as many fields of Alice's states private as possible
To achieve this, we need to add some pure helpers to the state structs.
This has the added benefit that we can reduce the amount of code within
the swap function.
3 years ago
Thomas Eizinger 7f5715e147
Remove unnecessary serde implementations 3 years ago
Thomas Eizinger c539465925
Make it possible to create random public keys
This is useful for tests.
3 years ago
rishflab 86f312e143 Safely abort swap if TxLock is not confirmed in a reasonable time
If TxLock does not confirm in a reasonable amount of time, Alice should
give up on the swap rather than waiting forever. Watching for TxLock in
the mempool is not required and it causes unnecessary complexity. What
if Alice does not see the transaction in mempool but it is already
confirmed? She will abort the swap for no reason.
3 years ago
Thomas Eizinger 01739eddb1
Introduce a more flexible transaction subscription system
Instead of watching for status changes directly on bitcoin::Wallet,
we return a Subscription object back to the caller. This subscription
object can be re-used multiple times.

Among other things, this now allows callers of `broadcast` to decide
on what to wait for given the returned Subscription object.

The new API is also more concise which allows us to remove some of
the functions on the actor states in favor of simple inline calls.

Co-authored-by: rishflab <rishflab@hotmail.com>
3 years ago
bors[bot] 6fb495b6ab
Merge #383 #385 #386
383: Improve resilience of balance assertions r=thomaseizinger a=thomaseizinger

The final commit is the relevant patch!

It sits on top of several refactoring commits that happened while I was debugging why things didn't work as expected. Turned out to be reasonably useful so I just left them in :)

385: Bump anyhow from 1.0.39 to 1.0.40 r=thomaseizinger a=dependabot[bot]

Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.39 to 1.0.40.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/dtolnay/anyhow/releases">anyhow's releases</a>.</em></p>
<blockquote>
<h2>1.0.40</h2>
<ul>
<li>Reduce memory footprint of errors on Rust versions 1.51+ (<a href="https://github-redirect.dependabot.com/dtolnay/anyhow/issues/145">#145</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="704622f25d"><code>704622f</code></a> Release 1.0.40</li>
<li><a href="64ac0c00a9"><code>64ac0c0</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/dtolnay/anyhow/issues/145">#145</a> from dtolnay/addrof</li>
<li><a href="ef082670ea"><code>ef08267</code></a> Eliminate functionally duplicate vtable methods on rustc 1.51+</li>
<li><a href="1295b1fef9"><code>1295b1f</code></a> Add additional builds on 1.50 and 1.51 validating addr_of codepath</li>
<li><a href="be89adf403"><code>be89adf</code></a> Detect whether ptr::addr_of is supported by current compiler</li>
<li><a href="ac64560c42"><code>ac64560</code></a> Switch object_ref return from real ref to Ref ptr</li>
<li><a href="2987c9b59e"><code>2987c9b</code></a> Ignore redundant_else pedantic clippy lint</li>
<li><a href="827bb9d4c6"><code>827bb9d</code></a> Catch some warnings in addr_of-related codepaths</li>
<li><a href="ce0041866d"><code>ce00418</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/dtolnay/anyhow/issues/144">#144</a> from dtolnay/ptr</li>
<li><a href="3c32aa7dcd"><code>3c32aa7</code></a> Relax Sized bound on Own, Ref, Mut ptrs</li>
<li>Additional commits viewable in <a href="https://github.com/dtolnay/anyhow/compare/1.0.39...1.0.40">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=anyhow&package-manager=cargo&previous-version=1.0.39&new-version=1.0.40)](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>

386: Bump hyper from 0.14.4 to 0.14.5 r=thomaseizinger a=dependabot[bot]

Bumps [hyper](https://github.com/hyperium/hyper) from 0.14.4 to 0.14.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/hyperium/hyper/releases">hyper's releases</a>.</em></p>
<blockquote>
<h2>v0.14.5</h2>
<h2>Bug Fixes</h2>
<ul>
<li><strong>client:</strong> omit default port from automatic Host headers (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2441">#2441</a>) (<a href="0b11eee9bd">0b11eee9</a>)</li>
<li><strong>headers:</strong> Support multiple Content-Length values on same line (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2471">#2471</a>) (<a href="48fdaf1606">48fdaf16</a>, closes <a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2470">#2470</a>)</li>
<li><strong>server:</strong> skip automatic Content-Length headers when not allowed (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2216">#2216</a>) (<a href="8cbf9527df">8cbf9527</a>, closes <a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2215">#2215</a>)</li>
</ul>
<h2>Features</h2>
<ul>
<li><strong>client:</strong> allow HTTP/0.9 responses behind a flag (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2473">#2473</a>) (<a href="68d4e4a3db">68d4e4a3</a>, closes <a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2468">#2468</a>)</li>
<li><strong>server:</strong> add <code>AddrIncoming::from_listener</code> constructor (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2439">#2439</a>) (<a href="4c946af49c">4c946af4</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/hyperium/hyper/blob/master/CHANGELOG.md">hyper's changelog</a>.</em></p>
<blockquote>
<h3>v0.14.5 (2021-03-26)</h3>
<h4>Bug Fixes</h4>
<ul>
<li><strong>client:</strong> omit default port from automatic Host headers (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2441">#2441</a>) (<a href="0b11eee9bd">0b11eee9</a>)</li>
<li><strong>headers:</strong> Support multiple Content-Length values on same line (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2471">#2471</a>) (<a href="48fdaf1606">48fdaf16</a>, closes <a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2470">#2470</a>)</li>
<li><strong>server:</strong> skip automatic Content-Length headers when not allowed (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2216">#2216</a>) (<a href="8cbf9527df">8cbf9527</a>, closes <a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2215">#2215</a>)</li>
</ul>
<h4>Features</h4>
<ul>
<li><strong>client:</strong> allow HTTP/0.9 responses behind a flag (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2473">#2473</a>) (<a href="68d4e4a3db">68d4e4a3</a>, closes <a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2468">#2468</a>)</li>
<li><strong>server:</strong> add <code>AddrIncoming::from_listener</code> constructor (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2439">#2439</a>) (<a href="4c946af49c">4c946af4</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="98e7e0bd15"><code>98e7e0b</code></a> v0.14.5</li>
<li><a href="895e4cf3fb"><code>895e4cf</code></a> refactor(ffi): return null ptr instead of aborting in C API (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2478">#2478</a>)</li>
<li><a href="68d4e4a3db"><code>68d4e4a</code></a> feat(client): allow HTTP/0.9 responses behind a flag (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2473">#2473</a>)</li>
<li><a href="51ed71b0a6"><code>51ed71b</code></a> docs(client): use Method::POST to match the example in <a href="https://hyper.rs/guide">https://hyper.rs/guide</a>...</li>
<li><a href="41f99578a5"><code>41f9957</code></a> refactor(dependencies): update to socket2 v0.4.0 (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2472">#2472</a>)</li>
<li><a href="48fdaf1606"><code>48fdaf1</code></a> fix(headers): Support multiple Content-Length values on same line (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2471">#2471</a>)</li>
<li><a href="eb0e718696"><code>eb0e718</code></a> docs(body): add links to to_bytes and aggregate (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2464">#2464</a>)</li>
<li><a href="297a068454"><code>297a068</code></a> docs(examples): upgrade tokio version (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2456">#2456</a>)</li>
<li><a href="34085afef6"><code>34085af</code></a> docs(examples): use hyper v0.14 and full feature (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2451">#2451</a>)</li>
<li><a href="8cbf9527df"><code>8cbf952</code></a> fix(server): skip automatic Content-Length headers when not allowed (<a href="https://github-redirect.dependabot.com/hyperium/hyper/issues/2216">#2216</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/hyperium/hyper/compare/v0.14.4...v0.14.5">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=hyper&package-manager=cargo&previous-version=0.14.4&new-version=0.14.5)](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: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
3 years ago
bors[bot] a18c071559
Merge #384
384: Include author information in the `--help` text r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
Thomas Eizinger 0a82ce989b
Improve resilience of balance assertions
Sometimes, a single sync is not enough because we are still waiting
for the block to be mined.

We introduce an abstraction that loops on fetching the latest balance
with a certain timeout for asserting the balance.
3 years ago
Thomas Eizinger a4c70dfe94
Don't call as_ref() unless necessary 3 years ago
Thomas Eizinger 4ab7e83806
Make use of `cargo test`s scoped test output
By using `test_writer`, cargo can automatically scope the output
of the test to the relevant thread and will also only output it
if the test fails or is run with `--nocapture`.
3 years ago
Thomas Eizinger 908dae3442
Inline tracing initialization
This code snippet is so short, it might as well be inlined to give
the test more control over what it wants to log.
3 years ago
Thomas Eizinger c01cccb288
Use `tracing-log` feature flag instead of manual initialization
This also formats `log` events more nicely. Instead of

```
Mar 29 09:46:16.775  INFO log: Found message after comparing 82 lines log.target="testcontainers::core::wait_for_message" log.module_path="testcontainers::core::wait_for_message" log.file="/home/thomas/.cargo/registry/src/github.com-1ecc6299db9ec823/testcontainers-0.12.0/src/core/wait_for_message.rs" log.line=35
```

We now have

```
Mar 29 09:57:15.860  INFO testcontainers::core::wait_for_message: Found message after comparing 81 lines
```
3 years ago
Thomas Eizinger c5827f84ca
Refactor recursive function to loop
This should get rid of the ever-growing stack size issue.
3 years ago
Thomas Eizinger fc175a3f53
De-couple state from Monero wallet 3 years ago
Thomas Eizinger 42b6368298
Use full-qualified path for tracing macros
Saves an import line and makes it clear that we are using tracing.
3 years ago
Thomas Eizinger 5616683d7d
Monero confirmations are a u64
Trying to deserialize the number as a u32 caused deserialization
errors.
3 years ago
Thomas Eizinger 1b63d5486d
Move tick to the beginning of the loop
This ensures that we always wait for the provided interval, even in
the case of a `continue` which happens if there is an error within
the RPC call.
3 years ago
Thomas Eizinger 393ed45b9e
Say who we are in the `--help` message
The message now says:

swap 0.3.0
The COMIT guys <hello@comit.network>
CLI for swapping BTC for XMR

USAGE:
    swap [FLAGS] [OPTIONS] <SUBCOMMAND>

...
3 years ago
Thomas Eizinger 39b27e37d8
Delete empty file 3 years ago
rishflab a3e85526c6 Specify LANG env variable for monero wallet rpc for unix systems
By specifying the language we can look for a specific string to check if
 monero wallet rpc is ready
3 years ago
rishflab bc902ea63a Use language agnostic heuristic to check if monero_wallet_rpc is ready
Our strategy of searching for a english string to determine if
monero_wallet_rpc is ready is not compatible with languages other than
english. Instead we assume the monero rpc is ready if it has stopped
writing to stdout. We make a json rpc request to confirm this. A better
solution would have been to configure the monero_wallet_rpc to always
output in english but there is not command line argument to configure
the language.

Closes #353.
3 years ago
bors[bot] 7397cb5990
Merge #359
359: Bump bdk from 0.4.0 to 0.5.0 r=thomaseizinger a=dependabot[bot]

Bumps [bdk](https://github.com/bitcoindevkit/bdk) from 0.4.0 to 0.5.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/bitcoindevkit/bdk/blob/master/CHANGELOG.md">bdk's changelog</a>.</em></p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="f7944e871b"><code>f7944e8</code></a> Bump version to 0.5.0</li>
<li><a href="2fea1761c1"><code>2fea176</code></a> Bump deps version</li>
<li><a href="fa27ae210f"><code>fa27ae2</code></a> Update version in lib.rs</li>
<li><a href="46fa41470e"><code>46fa414</code></a> Update CHANGELOG with the new release tag</li>
<li><a href="8ebe7f0ea5"><code>8ebe7f0</code></a> Merge commit 'refs/pull/308/head' of github.com:bitcoindevkit/bdk into releas...</li>
<li><a href="eb85390846"><code>eb85390</code></a> Merge commit 'refs/pull/309/head' of github.com:bitcoindevkit/bdk into releas...</li>
<li><a href="dc83db273a"><code>dc83db2</code></a> better derivation path building</li>
<li><a href="201bd6ee02"><code>201bd6e</code></a> better derivation path building</li>
<li><a href="396ffb42f9"><code>396ffb4</code></a> handle descriptor xkey origin</li>
<li><a href="9cf62ce874"><code>9cf62ce</code></a> [ci] Manually install libclang-common-10-dev to 'check-wasm' job</li>
<li>Additional commits viewable in <a href="https://github.com/bitcoindevkit/bdk/compare/v0.4.0...v0.5.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=bdk&package-manager=cargo&previous-version=0.4.0&new-version=0.5.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>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
bors[bot] 9c9b1e4f0c
Merge #370
370: No Bitcoin deposit for Alice r=da-kami a=da-kami

The message to deposit Bitcoin only applies to Bob, not Alice.
Alice does not require any initial Bitcoin.

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Thomas Eizinger 1057d115d1
Re-order bob::event_loop based on importance 3 years ago
Thomas Eizinger 638a169a04
Buffer transfer proof if we are not connected to Bob
The request-response behaviour that is used for sending the transfer
proof actually has a functionality for buffering a message if we
are currently not connected. However, the request-response behaviour
also emits a dial attempt and **drops** all buffered messages if this
dial attempt fails. For us, the dial attempt will very likely always
fail because Bob is very likely behind NAT and we have to wait for
him to reconnect to us.

To mitigate this, we build our own buffer within the EventLoop and
send transfer proofs as soon as we are connected again.

Resolves #348.
3 years ago
Thomas Eizinger cde3f0f74a
Remove connection handling from swap execution
The swap should not be concerned with connection handling. This is
the responsibility of the overall application.

All but the execution-setup NetworkBehaviour are `request-response`
behaviours. These have built-in functionality to automatically emit
a dial attempt in case we are not connected at the time we want to
send a message. We remove all of the manual dialling code from the
swap in favor of this behaviour.

Additionally, we make sure to establish a connection as soon as the
EventLoop gets started. In case we ever loose the connection to Alice,
we try to re-establish it.
3 years ago
Daniel Karzel 1e2a3c2d32 No Bitcoin deposit for Alice
The message to deposit Bitcoin only applies to Bob, not Alice.
Alice does not require any initial Bitcoin.
3 years ago
Thomas Eizinger 804b34f6b0
Listen on all swarm events instead of just behaviour events 3 years ago
Thomas Eizinger 2200fce3f3
Pass Swarm into EventLoop
This reduces the amount of arguments we need to pass into the eventloop
at the expense of slightly more setup of the swarm.
3 years ago
Thomas Eizinger 2c9ab4f6eb
Improve code structure and error messages for running swaps
The quote message was repeated and we should set the overall
failure into a context to know what went wrong.
3 years ago
Thomas Eizinger 0c0a322a8f
Rename module to better represent what it contains
This module provides an implementation of the RequestResponseCodec
using a cbor serialization.
3 years ago
Thomas Eizinger 1de0b39b32
Unify encrypted-signature protocol to a single one 3 years ago
Thomas Eizinger 9979cc9f1f
Unify transfer-proof protocol to a single one
Previously, we had two implementations of this protocol. To reduce
code size, we make Alice and Bob use the same implementation.
3 years ago
Thomas Eizinger 9d0b9abde0
Introduce helper function for mapping RequestResponseEvent
Decomposing a RequestResponseEvent is quite verbose. We can introduce
a helper function that does the matching for us and delegates to
specific `From` implementations for the protocol specific bits.
3 years ago
Thomas Eizinger 73f30320a6
Seed should neither be Clone nor Copy
It is better to not copy around secret data within our process to
make heartbleed-like attacks harder.
3 years ago
Thomas Eizinger 96b2a76971
Take advantage of upgraded electrum-client dependency
The new version implements std::error::Error and fixes a bug that
allows us to use the default config again.
3 years ago
dependabot[bot] 7f6299075c
Bump bdk from 0.4.0 to 0.5.0
Bumps [bdk](https://github.com/bitcoindevkit/bdk) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/bitcoindevkit/bdk/releases)
- [Changelog](https://github.com/bitcoindevkit/bdk/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bitcoindevkit/bdk/compare/v0.4.0...v0.5.0)

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
bors[bot] 968502827a
Merge #339
339: Bump dependency versions r=thomaseizinger a=thomaseizinger

Otherwise it will take a long time for dependabot to update all of
these.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
bors[bot] 097197783c
Merge #351
351: Show the actual BTC amount and fee to be swapped r=da-kami a=da-kami

We got user feedback, that it is confusing that the amount "found" in the wallet does not match the amount actually being swapped, thus with this PR we explicitly display the amount swapped and fees.

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
bors[bot] 189a13c063
Merge #319
319: Alice sweeps refunded funds into default wallet r=da-kami a=da-kami

Alice's refund scenario starts with generating the temporary wallet
from keys to claim the XMR which results in Alice' unloading the wallet.
Alice then loads her original wallet to be able to handle more swaps.
Since Alice is in the role of the long running daemon handling concurrent
swaps, the operation to close, claim and re-open her default wallet must
be atomic.
This PR adds an additional step, that sweeps all the refunded XMR back into
the default wallet. In order to ensure that this is possible, Alice has to
ensure that the locked XMR got enough confirmations.
These changes allow us to assert Alice's balance after refunding.

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Daniel Karzel 62079fc342 Punish scenario falls back to refund or fails
If we enter a punish scenario we can be sure the punish timelock is expired.
Thus, we must be able to punish unless Bob published the refund transaction.
There is no benefit in racing punish against refund here, because we cannot recover from a punish tx failure anyway.

The logic was changed to:
Try to broadcast punish tx and await finality.
  If either punish broadcasting of finality fails, try to fetch the refund transaction.
    If it is available extract Bob's Monero key part and transition to refund.
    If refund tx is not available fail without a status update.

Note that we do not distinguish different errors upon failure of punish, because
we cannot recover anyway. If we fail to retrieve Bob's refund tx, we just exit without
a status update so punish can be retried by resuming the swap.
3 years ago
Thomas Eizinger a228349d8b
Bump dependency versions
Otherwise it will take a long time for dependabot to update all of
these.
3 years ago
Daniel Karzel 668d34080d Show the actual BTC amount and fee to be swapped 3 years ago
Thomas Eizinger f49f8977d3
Remove dead code 3 years ago
Daniel Karzel 396c4177a6 Alice sweeps refunded funds into default wallet
Since Alice's refund scenario starts with generating the temporary wallet
from keys to claim the XMR which results in Alice' unloading the wallet.
Alice then loads her original wallet to be able to handle more swaps.
Since Alice is in the role of the long running daemon handling concurrent
swaps, the operation to close, claim and re-open her default wallet must
be atomic.
This PR adds an additional step, that sweeps all the refunded XMR back into
the default wallet. In order to ensure that this is possible, Alice has to
ensure that the locked XMR got enough confirmations.
These changes allow us to assert Alice's balance after refunding.
3 years ago
Thomas Eizinger 16dfea035b
Simplify code within BobState::XmrLockProofReceived
To achieve this, we decompose `watch_for_locked_xmr` into two parts:

1. A non-self-consuming function to construct a `WatchRequest`
2. A state transition that can now consume `self` again because
it is only called once within the whole select! expression.

Ideally, we would move more logic onto this state transition (like
comparing the actual amounts and fail the transition if it is not
valid). Doing so would have an unfortunate side-effect: We would
always wait for the full confirmations before checking whether or
not we actually receive enough XMR.

This allows us to have state transitions that consume self.
3 years ago
Thomas Eizinger 338f4b82e5
Introduce dedicated bob::State6 for cancelling 3 years ago
Thomas Eizinger c32ef92cf5
Simplify code within BobState::EncSigSent 3 years ago
Thomas Eizinger 09e2d5b5d7
Simplify code within BobState::XmrLocked
By reducing the number of local variables, we can greatly simplify
this piece of code.
3 years ago
Thomas Eizinger 776a50137d
Use tokio::select macro instead of function
This is slightly less verbose and therefore hopefully easier to read.
3 years ago
Thomas Eizinger b1affe3ecf
Insert latest state and call run_until only once
Instead of calling this function in all the branches, we can simply
make the whole match statement evaluate to the new state and perform
this functionality at the very end.
3 years ago
Thomas Eizinger 0d8962762a
Use early return to reduce one level of indentation 3 years ago
Thomas Eizinger 05849505b1
Inline `wait_for_bitcoin_refund`
This function is essentially a single select! statement and can
easily be inlined into the swap state machine.
3 years ago
Thomas Eizinger 8c9285f1f9
Inline step function because it has been reduced to a single statement 3 years ago
Thomas Eizinger afb7e816a1
Don't wait for confirmations again
We only call this function within `CancelTimelockExpired`. There is
no need to check the confirmations again.
3 years ago
Thomas Eizinger c92f2dbc77
Move more domain knowledge onto the `TxCancel` type 3 years ago
Thomas Eizinger 75aec95b0c
Introduce monero::TransferRequest
This allows us to move critical crypto logic onto `State3` which
holds all the necessary data which consequently allows us to get
rid of `lock_xmr` altogether by inlining it into the swap function.
The reduced indirection improves readability.
3 years ago
Thomas Eizinger d682433ec9
Move `EventLoopHandle` next to its impl block
This struct is not that important so it can move further down.
3 years ago
Thomas Eizinger e77f1729b4
Move `extract_monero_private_key` onto TxRefund
This functionality is domain-specific to the refund transaction.
Move it onto there.
3 years ago
Thomas Eizinger a1e065b4e7
Simplify racing cancel timelock against learning enc-sig 3 years ago
Thomas Eizinger 575893fb51
Use domain types in fn signature instead of messages
This simplifies usage witin the swap module.
3 years ago
Thomas Eizinger 64b71d0b16
Remove unnecessary pinning 3 years ago
Daniel Karzel 105e291e67 Update the application name for `--version` print
swap --version
xmr-btc-swap 0.3.0

asb --version
xmr-btc-asb 0.3.0
3 years ago
Daniel Karzel 07542d75ac prepare 0.3 release 3 years ago
bors[bot] d487aa3c5b
Merge #327 #330 #331
327: Bump actions/setup-python from v1 to v2.2.1 r=thomaseizinger a=dependabot[bot]

Bumps [actions/setup-python](https://github.com/actions/setup-python) from v1 to v2.2.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/actions/setup-python/releases">actions/setup-python's releases</a>.</em></p>
<blockquote>
<h2>v2.2.1</h2>
<ul>
<li>Fix PyPy3 issues with Windows</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="3105fb18c0"><code>3105fb1</code></a> fix is_windows (<a href="https://github.com/actions/setup-python/issues/172">#172</a>)</li>
<li><a href="8c5ea631b2"><code>8c5ea63</code></a> Adding support for more PyPy versions and installing them on-flight (<a href="https://github.com/actions/setup-python/issues/168">#168</a>)</li>
<li><a href="2831efe49a"><code>2831efe</code></a> Improve find-python to add &quot;Scripts&quot; folder to PATH on Windows machines (<a href="https://github.com/actions/setup-python/issues/169">#169</a>)</li>
<li><a href="3b3f2de1b1"><code>3b3f2de</code></a> update pypy3 to point to 3.6 (<a href="https://github.com/actions/setup-python/issues/164">#164</a>)</li>
<li><a href="723e46dad7"><code>723e46d</code></a> CODEOWNERS needs the org name for teams</li>
<li><a href="195f5c388b"><code>195f5c3</code></a> Create CODEOWNERS</li>
<li><a href="41b7212b16"><code>41b7212</code></a> Update README.md (<a href="https://github.com/actions/setup-python/issues/145">#145</a>)</li>
<li><a href="878156f1de"><code>878156f</code></a> Inject LD_LIBRARY_PATH library path into Python manifest install and setup (#...</li>
<li><a href="c181ffa198"><code>c181ffa</code></a> Add Environment Files (<a href="https://github.com/actions/setup-python/issues/138">#138</a>)</li>
<li><a href="1ce870e10f"><code>1ce870e</code></a> Fix links in documentation (<a href="https://github.com/actions/setup-python/issues/135">#135</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/actions/setup-python/compare/v1...3105fb18c05ddd93efea5f9e0bef7a03a6e9e7df">compare view</a></li>
</ul>
</details>
<br />


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>

330: Bump dialoguer from 0.7.1 to 0.8.0 r=thomaseizinger a=dependabot[bot]

Bumps [dialoguer](https://github.com/mitsuhiko/dialoguer) from 0.7.1 to 0.8.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/mitsuhiko/dialoguer/blob/master/CHANGELOG.md">dialoguer's changelog</a>.</em></p>
<blockquote>
<h2>0.8.0</h2>
<h3>Enhancements</h3>
<ul>
<li><code>Input::validate_with</code> can take a <code>FnMut</code> (allowing multiple references)</li>
</ul>
<h3>Breaking</h3>
<ul>
<li><code>Input::interact*</code> methods take <code>&amp;mut self</code> instead of <code>&amp;self</code></li>
</ul>
<h2>0.7.0</h2>
<h3>Enhancements</h3>
<ul>
<li>Added <code>wait_for_newline</code> to <code>Confirm</code></li>
<li>More secure password prompt</li>
<li>More documentation</li>
<li>Added <code>interact_text</code> method for input prompt</li>
<li>Added <code>inline_selections</code> to <code>ColorfulTheme</code></li>
</ul>
<h3>Breaking</h3>
<ul>
<li>Removed <code>theme::CustomPromptCharacterTheme</code></li>
<li><code>Input</code> validators now take the input type <code>T</code> as arg</li>
<li><code>Confirm</code> has no <code>default</code> value by default now</li>
</ul>
<h2>0.6.2</h2>
<h3>Enhancements</h3>
<ul>
<li>Updating some docs</li>
</ul>
<h2>0.6.1</h2>
<h3>Bugfixes</h3>
<ul>
<li><code>theme::ColorfulTheme</code> default styles are for stderr</li>
</ul>
<h2>0.6.0</h2>
<h3>Breaking</h3>
<ul>
<li>Removed <code>theme::SelectionStyle</code> enum</li>
<li>Allowed more customization for <code>theme::Theme</code> trait by changing methods</li>
<li>Allowed more customization for <code>theme::ColorfulTheme</code> by changing members</li>
<li>Renamed prompt <code>Confirmation</code> to <code>Confirm</code></li>
<li>Renamed prompt <code>PasswordInput</code> to <code>Password</code></li>
<li>Renamed prompt <code>OrderList</code> to <code>Sort</code></li>
<li>Renamed prompt <code>Checkboxes</code> to <code>MultiSelect</code></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="2c3fe6b646"><code>2c3fe6b</code></a> Release 0.8.0</li>
<li><a href="64f5f9c6f5"><code>64f5f9c</code></a> Allow confirm with no choice (<a href="https://github.com/mitsuhiko/dialoguer/issues/101">#101</a>)</li>
<li><a href="0250090f95"><code>0250090</code></a> Update some docs in confirm prompt</li>
<li><a href="a76fb72c54"><code>a76fb72</code></a> Merge pull request <a href="https://github.com/mitsuhiko/dialoguer/issues/102">#102</a> from spenserblack/typo-fix</li>
<li><a href="3dd93bb75a"><code>3dd93bb</code></a> Fix typo: ereased -&gt; erased</li>
<li><a href="7ea6275caa"><code>7ea6275</code></a> Update CI for i686 ubuntu</li>
<li><a href="af664807da"><code>af66480</code></a> Allow FnMut for validate (<a href="https://github.com/mitsuhiko/dialoguer/issues/96">#96</a>)</li>
<li><a href="2b5722d0f5"><code>2b5722d</code></a> Update README.md</li>
<li><a href="2df3a705eb"><code>2df3a70</code></a> Update ci.yml</li>
<li><a href="8cebf522b3"><code>8cebf52</code></a> Merge pull request <a href="https://github.com/mitsuhiko/dialoguer/issues/94">#94</a> from mitsuhiko/remove-travis</li>
<li>Additional commits viewable in <a href="https://github.com/mitsuhiko/dialoguer/compare/0.7.1...0.8.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dialoguer&package-manager=cargo&previous-version=0.7.1&new-version=0.8.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>

331: Bump tokio from 1.0.2 to 1.3.0 r=thomaseizinger a=dependabot[bot]

Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.0.2 to 1.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/tokio-rs/tokio/releases">tokio's releases</a>.</em></p>
<blockquote>
<h2>Tokio v1.3.0</h2>
<h3>Added</h3>
<ul>
<li>coop: expose an <code>unconstrained()</code> opt-out (<a href="https://github.com/tokio-rs/tokio/issues/3547">#3547</a>)</li>
<li>net: add <code>into_std</code> for net types without it (<a href="https://github.com/tokio-rs/tokio/issues/3509">#3509</a>)</li>
<li>sync: add <code>same_channel</code> method to <code>mpsc::Sender</code> (<a href="https://github.com/tokio-rs/tokio/issues/3532">#3532</a>)</li>
<li>sync: add <code>{try_,}acquire_many_owned</code> to <code>Semaphore</code> (<a href="https://github.com/tokio-rs/tokio/issues/3535">#3535</a>)</li>
<li>sync: add back <code>RwLockWriteGuard::map</code> and <code>RwLockWriteGuard::try_map</code> (<a href="https://github.com/tokio-rs/tokio/issues/3348">#3348</a>)</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>sync: allow <code>oneshot::Receiver::close</code> after successful <code>try_recv</code> (<a href="https://github.com/tokio-rs/tokio/issues/3552">#3552</a>)</li>
<li>time: do not panic on <code>timeout(Duration::MAX)</code> (<a href="https://github.com/tokio-rs/tokio/issues/3551">#3551</a>)</li>
</ul>
<h3>Documented</h3>
<ul>
<li>doc: doc aliases for pre-1.0 function names (<a href="https://github.com/tokio-rs/tokio/issues/3523">#3523</a>)</li>
<li>io: fix typos (<a href="https://github.com/tokio-rs/tokio/issues/3541">#3541</a>)</li>
<li>io: note the EOF behaviour of <code>read_until</code> (<a href="https://github.com/tokio-rs/tokio/issues/3536">#3536</a>)</li>
<li>io: update <code>AsyncRead::poll_read</code> doc (<a href="https://github.com/tokio-rs/tokio/issues/3557">#3557</a>)</li>
<li>net: update <code>UdpSocket</code> splitting doc (<a href="https://github.com/tokio-rs/tokio/issues/3517">#3517</a>)</li>
<li>runtime: add link to <code>LocalSet</code> on <code>new_current_thread</code> (<a href="https://github.com/tokio-rs/tokio/issues/3508">#3508</a>)</li>
<li>runtime: update documentation of thread limits (<a href="https://github.com/tokio-rs/tokio/issues/3527">#3527</a>)</li>
<li>sync: do not recommend <code>join_all</code> for <code>Barrier</code> (<a href="https://github.com/tokio-rs/tokio/issues/3514">#3514</a>)</li>
<li>sync: documentation for <code>oneshot</code> (<a href="https://github.com/tokio-rs/tokio/issues/3592">#3592</a>)</li>
<li>sync: rename <code>notify</code> to <code>notify_one</code> (<a href="https://github.com/tokio-rs/tokio/issues/3526">#3526</a>)</li>
<li>time: fix typo in <code>Sleep</code> doc (<a href="https://github.com/tokio-rs/tokio/issues/3515">#3515</a>)</li>
<li>time: sync <code>interval.rs</code> and <code>time/mod.rs</code> docs (<a href="https://github.com/tokio-rs/tokio/issues/3533">#3533</a>)</li>
</ul>
<h2>Tokio v1.2.0</h2>
<h3>Added</h3>
<ul>
<li>signal: make <code>Signal::poll_recv</code> method public (<a href="https://github.com/tokio-rs/tokio/issues/3383">#3383</a>)</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>time: make <code>test-util</code> paused time fully deterministic (<a href="https://github.com/tokio-rs/tokio/issues/3492">#3492</a>)</li>
</ul>
<h3>Documented</h3>
<ul>
<li>sync: link to new broadcast and watch wrappers (<a href="https://github.com/tokio-rs/tokio/issues/3504">#3504</a>)</li>
</ul>
<h2>Tokio v1.1.1</h2>
<p>Forward ports 1.0.3 fix.</p>
<h3>Fixed</h3>
<ul>
<li>io: memory leak during shutdown (<a href="https://github.com/tokio-rs/tokio/issues/3477">#3477</a>).</li>
</ul>
<h2>Tokio v1.1.0</h2>
<h3>Added</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="d0e4dd1d7b"><code>d0e4dd1</code></a> chore: prepare Tokio v1.3.0 (<a href="https://github.com/tokio-rs/tokio/issues/3597">#3597</a>)</li>
<li><a href="872bc09e83"><code>872bc09</code></a> examples: update chat example (<a href="https://github.com/tokio-rs/tokio/issues/3587">#3587</a>)</li>
<li><a href="db1d90453c"><code>db1d904</code></a> util: fuse PollSemaphore (<a href="https://github.com/tokio-rs/tokio/issues/3578">#3578</a>)</li>
<li><a href="05eeea570e"><code>05eeea5</code></a> coop: expose an unconstrained() opt-out (<a href="https://github.com/tokio-rs/tokio/issues/3547">#3547</a>)</li>
<li><a href="f70b9b84f7"><code>f70b9b8</code></a> sync: documenation for oneshot (<a href="https://github.com/tokio-rs/tokio/issues/3592">#3592</a>)</li>
<li><a href="704de8c01b"><code>704de8c</code></a> stream: remove duplicate <code>doc(test(..))</code> &amp; <code>cfg_attr</code> declarations (<a href="https://github.com/tokio-rs/tokio/issues/3571">#3571</a>)</li>
<li><a href="47be928444"><code>47be928</code></a> sync: yield initial value in WatchStream (<a href="https://github.com/tokio-rs/tokio/issues/3576">#3576</a>)</li>
<li><a href="e06b257e09"><code>e06b257</code></a> sync: add same_channel method to mpsc Senders (<a href="https://github.com/tokio-rs/tokio/issues/3532">#3532</a>)</li>
<li><a href="0867a6fc03"><code>0867a6f</code></a> util: add pollable mpsc::Sender (<a href="https://github.com/tokio-rs/tokio/issues/3490">#3490</a>)</li>
<li><a href="0d838bf5ad"><code>0d838bf</code></a> io: fix link to std src in util (<a href="https://github.com/tokio-rs/tokio/issues/3568">#3568</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/tokio-rs/tokio/compare/tokio-1.0.2...tokio-1.3.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tokio&package-manager=cargo&previous-version=1.0.2&new-version=1.3.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
dependabot[bot] 47544764d9
Bump tokio from 1.0.2 to 1.3.0
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.0.2 to 1.3.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.0.2...tokio-1.3.0)

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
bors[bot] 7f6f2408a3
Merge #332
332: Bump base64 from 0.12.3 to 0.13.0 r=thomaseizinger a=dependabot[bot]

Bumps [base64](https://github.com/marshallpierce/rust-base64) from 0.12.3 to 0.13.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md">base64's changelog</a>.</em></p>
<blockquote>
<h1>0.13.0</h1>
<ul>
<li>Config methods are const</li>
<li>Added <code>EncoderStringWriter</code> to allow encoding directly to a String</li>
<li><code>EncoderWriter</code> now owns its delegate writer rather than keeping a reference to it (though refs still work)
<ul>
<li>As a consequence, it is now possible to extract the delegate writer from an <code>EncoderWriter</code> via <code>finish()</code>, which returns <code>Result&lt;W&gt;</code> instead of <code>Result&lt;()&gt;</code>. If you were calling <code>finish()</code> explicitly, you will now need to use <code>let _ = foo.finish()</code> instead of just <code>foo.finish()</code> to avoid a warning about the unused value.</li>
</ul>
</li>
<li>When decoding input that has both an invalid length and an invalid symbol as the last byte, <code>InvalidByte</code> will be emitted instead of <code>InvalidLength</code> to make the problem more obvious.</li>
</ul>
<h1>0.12.2</h1>
<ul>
<li>Add <code>BinHex</code> alphabet</li>
</ul>
<h1>0.12.1</h1>
<ul>
<li>Add <code>Bcrypt</code> alphabet</li>
</ul>
<h1>0.12.0</h1>
<ul>
<li>A <code>Read</code> implementation (<code>DecoderReader</code>) to let users transparently decoded data from a b64 input source</li>
<li>IMAP's modified b64 alphabet</li>
<li>Relaxed type restrictions to just <code>AsRef&lt;[ut8]&gt;</code> for main <code>encode*</code>/<code>decode*</code> functions</li>
<li>A minor performance improvement in encoding</li>
</ul>
<h1>0.11.0</h1>
<ul>
<li>Minimum rust version 1.34.0</li>
<li><code>no_std</code> is now supported via the two new features <code>alloc</code> and <code>std</code>.</li>
</ul>
<h1>0.10.1</h1>
<ul>
<li>Minimum rust version 1.27.2</li>
<li>Fix bug in streaming encoding (<a href="https://github.com/marshallpierce/rust-base64/pull/90">#90</a>): if the underlying writer didn't write all the bytes given to it, the remaining bytes would not be retried later. See the docs on <code>EncoderWriter::write</code>.</li>
<li>Make it configurable whether or not to return an error when decoding detects excess trailing bits.</li>
</ul>
<h1>0.10.0</h1>
<ul>
<li>Remove line wrapping. Line wrapping was never a great conceptual fit in this library, and other features (streaming encoding, etc) either couldn't support it or could support only special cases of it with a great increase in complexity. Line wrapping has been pulled out into a <a href="https://crates.io/crates/line-wrap">line-wrap</a> crate, so it's still available if you need it.
<ul>
<li><code>Base64Display</code> creation no longer uses a <code>Result</code> because it can't fail, which means its helper methods for common
configs that <code>unwrap()</code> for you are no longer needed</li>
</ul>
</li>
<li>Add a streaming encoder <code>Write</code> impl to transparently base64 as you write.</li>
<li>Remove the remaining <code>unsafe</code> code.</li>
<li>Remove whitespace stripping to simplify <code>no_std</code> support. No out of the box configs use it, and it's trivial to do yourself if needed: <code>filter(|b| !b&quot; \n\t\r\x0b\x0c&quot;.contains(b)</code>.</li>
<li>Detect invalid trailing symbols when decoding and return an error rather than silently ignoring them.</li>
</ul>
<h1>0.9.3</h1>
<ul>
<li>Update safemem</li>
</ul>
<h1>0.9.2</h1>
<ul>
<li>Derive <code>Clone</code> for <code>DecodeError</code>.</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="b4fc91325e"><code>b4fc913</code></a> v0.13.0</li>
<li><a href="bba4c5d11e"><code>bba4c5d</code></a> Merge pull request <a href="https://github.com/marshallpierce/rust-base64/issues/145">#145</a> from marshallpierce/mp/cleanup</li>
<li><a href="42967320b3"><code>4296732</code></a> Add docs and other cleanup</li>
<li><a href="6bb3556633"><code>6bb3556</code></a> Merge pull request <a href="https://github.com/marshallpierce/rust-base64/issues/144">#144</a> from untitaker/invalid-bytes-not-length</li>
<li><a href="5b40e0c04e"><code>5b40e0c</code></a> Merge pull request <a href="https://github.com/marshallpierce/rust-base64/issues/142">#142</a> from marshallpierce/mp/string-writer</li>
<li><a href="8b1ae22bab"><code>8b1ae22</code></a> Rename StrWrite to StrConsumer</li>
<li><a href="27ccb6591e"><code>27ccb65</code></a> fix tests</li>
<li><a href="d15cd384e1"><code>d15cd38</code></a> Give better error messages when decoding data with trailing newlines</li>
<li><a href="5a56885c65"><code>5a56885</code></a> Introduce StrWriter to allow ESW to wrap both a String and a &amp;mut String</li>
<li><a href="2dc0296d2a"><code>2dc0296</code></a> Merge pull request <a href="https://github.com/marshallpierce/rust-base64/issues/143">#143</a> from marshallpierce/mp/invalid-length-doc</li>
<li>Additional commits viewable in <a href="https://github.com/marshallpierce/rust-base64/compare/v0.12.3...v0.13.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=base64&package-manager=cargo&previous-version=0.12.3&new-version=0.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>
3 years ago
bors[bot] 2c385ee7d9
Merge #321
321: Properly handle concurrent messages to and from peers r=thomaseizinger a=thomaseizinger

Previously, we were forwarding incoming messages from peers to all
swaps that were currently running. That is obviously wrong. The new
design scopes an `EventLoopHandle` to a specific PeerId to avoid
this problem.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
dependabot[bot] e6fda4a787
Bump base64 from 0.12.3 to 0.13.0
Bumps [base64](https://github.com/marshallpierce/rust-base64) from 0.12.3 to 0.13.0.
- [Release notes](https://github.com/marshallpierce/rust-base64/releases)
- [Changelog](https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md)
- [Commits](https://github.com/marshallpierce/rust-base64/compare/v0.12.3...v0.13.0)

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
dependabot[bot] 64351a29b5
Bump dialoguer from 0.7.1 to 0.8.0
Bumps [dialoguer](https://github.com/mitsuhiko/dialoguer) from 0.7.1 to 0.8.0.
- [Release notes](https://github.com/mitsuhiko/dialoguer/releases)
- [Changelog](https://github.com/mitsuhiko/dialoguer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/dialoguer/compare/0.7.1...0.8.0)

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
bors[bot] 113f2fa385
Merge #322
322: Refactor `ExecutionParams` and harmonize sync intervals of wallets r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
bors[bot] fc28609a96
Merge #323 #324
323: Minor fixes r=thomaseizinger a=rishflab



324: Enable dependabot r=thomaseizinger a=thomaseizinger



Co-authored-by: rishflab <rishflab@hotmail.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
Thomas Eizinger e54d26b26c
Improve log messages by including PeerId 3 years ago
Thomas Eizinger a57f88d1b4
Properly handle concurrent messages to and from peers
Previously, we were forwarding incoming messages from peers to all
swaps that were currently running. That is obviously wrong. The new
design scopes an `EventLoopHandle` to a specific PeerId to avoid
this problem.
3 years ago
Thomas Eizinger ce78075932
Make Monero and Bitcoin wallet use a generalized sync interval
We define the sync interval as 1/10th of the blocktime. For the
special case of our tests, we however check at max once per second.
The tests have a super fast blocktime. As such we shouldn't hammer
the nodes with a request every 100ms.
3 years ago
Thomas Eizinger 09c41f89c4
Rename ExecutionParams to EnvironmentConfig 3 years ago
Thomas Eizinger bc43ed6ebd
Pass execution params directly into wallet for initialization
This reduces the amount of parameters that we need to pass in.
3 years ago
Thomas Eizinger 7213907a79
Group bitcoin and monero fields together 3 years ago
bors[bot] 95acbc6277
Merge #307
307: Reduce load on electrum r=thomaseizinger a=rishflab

.

Co-authored-by: rishflab <rishflab@hotmail.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
rishflab 8675d88727 Don't wait for tx lock confirmed after broadcast
Bob does not care whether tx lock is confirmed. That is alice's problem.
This wait was introduced to remedy a bug in status_of_script() which was
 failing when called on a transaction with no confirmations.
3 years ago
rishflab f5e6ba18e0 Use different address for redeem and punish
Having the same address could potentially cause issues when subscribing
to transactions by script
3 years ago
bors[bot] 345bc5b316
Merge #320
320: Fix env filter for asb r=thomaseizinger a=thomaseizinger

1. The asb didn't log any if the statements within main.rs
2. We were initializing unnecessary filters that don't make any sense
for the asb. warp and http are not used and the harness-es are for
test only.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
bors[bot] 9ed5ca9a04
Merge #317
317: Fix monero refresh interval r=thomaseizinger a=thomaseizinger

The comparison should be the MAXIMUM of the two values, not the
minimum, otherwise we always refresh at an interval of 1 second.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
Thomas Eizinger 9e3a104b42
Disable timestamp if we log to a non-interactive terminal
A non-interactive terminal is likely something along the lines of
journalctl which captures a timestamp by itself. In theory, it could
also be just a logfile but we rather accept this limitation and keep
the configuration surface simple rather than exposing another config
switch.
3 years ago
Thomas Eizinger edb8851ce2
Fix env filter for asb
1. The asb didn't log any if the statements within main.rs
2. We were initializing unnecessary filters that don't make any sense
for the asb. warp and http are not used and the harness-es are for
test only.
3 years ago
Thomas Eizinger 273cf15631
Introduce `Watchable` abstraction for Bitcoin wallet
We have a repeated pattern where we construct one of our
Tx{Cancel,Redeem,Punish,Refund,Lock} transactions and wait until
the status of this transaction changes. We can make this more
ergonomic by creating and implementing a `Watchable` trait that
gives access to the TxId and relevant script for this transaction.
This allows us to remove a parameter from the `watch_until_status`
function.

Additionally, there is a 2nd pattern: "Completing" one of these
transaction and waiting until they are confirmed with the configured
number of blocks for finality. We can make this more ergonomic by
returning a future from `broadcast` that callers can await in case
they want to wait for the broadcasted transaction to reach finality.
3 years ago
Thomas Eizinger a0830f099f
Pass relevant execution params into wallet instead of via functions
The execution params don't change throughout the lifetime of the
program. They can be set in the wallet at the very beginning.
This simplifies the interface of the wallet functions.
3 years ago
Thomas Eizinger 84ea092a1b
Remove unnecessary state variables by constructing TXs on demand 3 years ago
rishflab e5c0158597
Greatly reduce load onto the Electrum backend
We achieve our optimizations in three ways:

1. Batching calls instead of making them individually.

To get access to the batch calls, we replace all our
calls to the HTTP interface with RPC calls.

2. Never directly make network calls based on function
calls on the wallet.

Instead, inquiring about the status of a script always
just returns information based on local data. With every
call, we check when we last refreshed the local data and
do so if the data is considered to be too old. This
interval is configurable.

3. Use electrum's notification feature to get updated
with the latest blockheight.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Rishab Sharma <rishflab@hotmail.com>
3 years ago
Thomas Eizinger e17cbadccb
Don't add signatures to transaction unless necessary
In order to compute the cancel TxID, we don't need to add the
signatures.
3 years ago
Thomas Eizinger 6beb732e35
Eliminate `build_bitcoin_punish_transaction`
We reduce indirection by constructing TxPunish directly based off
`State3` and make the type itself more powerful by moving the logic
of completing it with a signature onto it.
3 years ago
Daniel Karzel d85c0ce57c Re-introduce punish test 3 years ago
Daniel Karzel ea05c306e0 Alice spawns swaps outside the event loop
Instead of spawning the swap inside the event loop we send the swap back
to the caller to be spawned. This means we no longer need the remote handle
that was only used in the tests.
This now properly logs the swap results in production.
It also gives us more control over Alice's swap in the tests.
3 years ago
Thomas Eizinger dd6c66a594
Move completing of Bitcoin redeem tx onto RedeemTx
This allows us to have access to RedeemTx from within the scope
of the state transition which we are going to need for more
efficient watching of what happens to this TX on the blockchain.
3 years ago
rishflab 21429f24b2
Inline wait_for_locked_bitcoin() that is only called once
Reduce indirection.
3 years ago
rishflab 6a3e4802f1
Remove redundant reference 3 years ago
rishflab 458a8d594a
Rename fn param to correctly reflect underlying type 3 years ago
rishflab 752e5be8f3
Cleanup test logging 3 years ago
Thomas Eizinger 2704245ed5
Fix monero refresh interval
The comparison should be the MAXIMUM of the two values, not the
minimum, otherwise we always refresh at an interval of 1 second.
3 years ago
bors[bot] a02389f8bd
Merge #314
314: Remove CLI config file in favour of parameters r=thomaseizinger a=da-kami

Fixes #282 

The CLI has sensible default values for all parameters,
thus a config file is not really an advantage but just
keeps getting in our way, so re remove it.

Trait impls on `Data` needed for structopt, see https://docs.rs/structopt/0.3.21/structopt/#default-values

Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
bors[bot] 8505d76561
Merge #311
311: Add asb to release including ARM build r=da-kami a=da-kami

https://github.com/da-kami/xmr-btc-swap/releases/tag/0.3-test

The asb ARM build does neither run tests on CI not smoke test for the binary upon release because the there is no standard runner for ARM. One can configure a self-hosted one but I think that might be an overkill: https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners

I did download the produced ARM tar, unpack and test on the raspi, it works :)

Concerning openssl depdency see:

https://github.com/da-kami/xmr-btc-swap/runs/2093523365?check_suite_focus=true
https://www.reddit.com/r/rust/comments/axaq9b/opensslsys_error_when_crosscompiling_for/


Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Daniel Karzel 0091b6cdaf Remove CLI config file in favour of parameters
The CLI has sensible default values for all parameters,
thus a config file is not really an advantage but just
keeps getting in our way, so re remove it.
3 years ago
Daniel Karzel 442c377490 Remove openssl dependency
Upgrade tokio-tungstenite to 0.14 and use feature flag rustls-tls
to get rid of the openssl dependency.
3 years ago
Daniel Karzel 58c33f8468 Add asb to release including ARM build 3 years ago
rishflab 7cb198aea1 Remove pointless todo
The container is defined in the tests module indicating it is only
suitable for these tests
3 years ago
rishflab 9f534996ee Remove unused capability to configure bitcoind docker version tag
We only use one version of this container
3 years ago
rishflab 7b1d901ea0 Fix incorrectly formatted tag 3 years ago
bors[bot] 009597ac49
Merge #306
306: Fix logging and retrying of Monero transaction watching r=thomaseizinger a=thomaseizinger

Hopefully, this should also reduce the load because I am not asking the node every second.

Related: https://github.com/comit-network/xmr-btc-swap/issues/202

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Daniel Karzel <daniel@comit.network>
3 years ago
Daniel Karzel be52892e65
Monero wallet should not know about all execution params
Instead of passing all execution params in we only make the monero_avg_block_time known to the monero wallet.
3 years ago
Thomas Eizinger 82738b111e
Refactor `monero::Wallet::watch_for_transfer` to not use `backoff`
Instead, we use a regular loop and extract everything into a function
that can be independently tested.
`backoff` would be useful to retry the actual call to the node.
3 years ago
Thomas Eizinger 7e0c44ad1d
Add avg monero block time to execution params 3 years ago
Thomas Eizinger d560e69203
Make durations more readable by using extension methods from `time` 3 years ago
Thomas Eizinger ecff1d1cbe
Remove indirection of constants
We never use these constants anywhere else, inline them.
3 years ago
Thomas Eizinger bac0f11898
Disable `backoff`s `max_elapsed_time` functionality
This config setting makes backoff stop retrying if we didn't get an
error within this timeframe.
For us, this results in backoff not actually doing anything.

The connection to kraken is very long-running. It might be active
for hours without failing. However, the default value for
`max_elapsed_time` is set to 15 minutes. As such, once the connection
fails any time after that, backoff doesn't actually retry the operation
but just gives up.

Fixes #303.
3 years ago
Thomas Eizinger 9ad2160c69
Refactor the kraken module to automatically re-connect on errors
In order to be able to re-connect on certain errors, we model
connection errors separately from parsing errors. We also change
the API of the whole module to no longer forward all errors to
the subscribers but instead, only update the subscribers with
either a latest rate or a permanent failure in case we exhausted
all our options to re-connect the websocket.

To model all of this properly, we introduce to sub-modules so that
each submodule can have their own `Error` type.

Resolves #297.
3 years ago
Thomas Eizinger c560b3b21a
Introduce `RateUpdate` type alias to reduce duplication 3 years ago
Thomas Eizinger fd5b38739a
Remove constant in favor of inlining string
This removes an import and simplifies the `connect_async` call.
3 years ago
Thomas Eizinger 142e5e2d3a
Use tracing macros by fully-qualifying them 3 years ago
bors[bot] cc131ecf60
Merge #293
293: Some friday evening goodies r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
3 years ago
Thomas Eizinger 08923a14f3
Simplify GET request for block tip height 3 years ago
Thomas Eizinger e9d7d9299c
Simplify the GET request to the tx status URL 3 years ago
Thomas Eizinger 418ad7089d
Make tests more readable by following arrange-act-assert 3 years ago