Commit Graph

819 Commits

Author SHA1 Message Date
Thomas Eizinger
f4827e3fa4
Improve time formatting of log output
Previously, the time was formatted as ISO8601 timestamps which is
barely readable by humans. Activating the `chrono` feature allows
us to format with a different format string. The output now looks
like this:

2021-03-01 11:59:52  DEBUG Database and seed will be stored in /home/thomas/.local/share/xmr-btc-swap
2021-03-01 11:59:52  DEBUG Starting monero-wallet-rpc on port 40673
2021-03-01 11:59:59  DEBUG Still got 0.00009235 BTC left in wallet, swapping ...
2021-03-01 11:59:59  DEBUG Dialing alice at 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-03-01 11:59:59  DEBUG Requesting quote for 0.00008795 BTC

There is a double space after the time which is already fixed in
tracing-subscriber but not yet released.

See https://github.com/tokio-rs/tracing/issues/1271.
2021-03-02 09:50:16 +11:00
Thomas Eizinger
a82e82edd5
Tell the user about the monero-wallet-rpc download
Fixes #242.
2021-03-02 09:50:16 +11:00
Thomas Eizinger
06e3bccaa6
Don't print PeerId when requesting quote
Bob always just talks to one party, the PeerId is just noise.
2021-03-02 09:50:16 +11:00
Thomas Eizinger
cbef577e2d
Inform user that we are going to swap the remainder of the balance 2021-03-02 09:50:15 +11:00
Thomas Eizinger
b7c3524b4f
Abort the eventloop if the dialling fails 2021-03-02 09:50:14 +11:00
Thomas Eizinger
4e9e186462
Don't log things the user doesn't care about
The user configured neither a Bitcoin wallet backend nor the monero-wallet-rpc so let's not tell them about it.

Fixes #244.
2021-03-02 09:49:55 +11:00
Thomas Eizinger
6b74761e34
Remove tracing context
The swap_cli can only do one swap at a time, no need for the swap ID span.
2021-03-02 09:49:55 +11:00
Thomas Eizinger
3d2d447fba
Improve error message
YMMV but I think this sounds better.
2021-03-02 09:49:55 +11:00
Thomas Eizinger
bbbe5f7ae8
Demote / promote log messages to their appropriate level 2021-03-02 09:49:53 +11:00
Thomas Eizinger
7387884e6d
Move log messages to the appropriate abstraction layer
Log messages are ideally as close to the functionality they are talking about, otherwise we might end up repeating ourselves on several callsites or the log messages gets outdated if the behaviour changes.
2021-03-02 09:49:33 +11:00
Thomas Eizinger
b8df4a3145
Inline tracing configuration for swap_cli
This allows us to configure the presentation separately from the ASB.
2021-03-02 09:49:33 +11:00
Thomas Eizinger
a0e7c6ecf7
Don't Arc the AtomicU32
We never clone this type, there is no need to wrap it in an `Arc`.
2021-03-02 09:49:33 +11:00
Thomas Eizinger
40dcf0355a
Simplify Transfer::transfer return type
We never use the fee returned from this function, remove it.
2021-03-02 09:49:30 +11:00
bors[bot]
1de3fa486e
Merge #247
247: Calculate max_giveable based on spending script size r=da-kami a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-03-01 05:27:28 +00:00
bors[bot]
108bc4c3ab
Merge #246
246: Change anyhow! to bail! in error scenarios r=da-kami a=da-kami

Unfortunately I handled the two failure scenarios in the ASB wrong - I thought that was fixed already, but that was different logic in a different PR. 

😬😬😬

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-01 04:50:57 +00:00
Thomas Eizinger
9f0b1c5cbe
Calculate max_giveable based on spending script size 2021-03-01 15:35:45 +11:00
Daniel Karzel
8c40ee1da4 Change anyhow! to bail! in error scenarios 2021-03-01 14:24:44 +11:00
bors[bot]
7251588e79
Merge #233
233: ASB max sell amount r=thomaseizinger a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-01 01:47:34 +00:00
bors[bot]
5ddf41721e
Merge #238
238: Bob error handling r=thomaseizinger a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-03-01 01:31:24 +00:00
bors[bot]
6cffb86c10
Merge #237
237: Swap CLI buys xmr by default if no subcommand given r=rishflab a=rishflab

- [x] Needs watch for deposit functionality from #236 


Closes #234 

Co-authored-by: rishflab <rishflab@hotmail.com>
2021-03-01 00:18:46 +00:00
rishflab
975d604405 Test to ensure default alice peer id and multi addr is valid 2021-03-01 11:00:30 +11:00
rishflab
9a82b572ec Default to buy xmr using default trait 2021-03-01 10:58:04 +11:00
rishflab
d6d67f62f1 Swap cli executes BuyXmr path if subcommand is not given 2021-03-01 10:37:59 +11:00
rishflab
60de6a9219 Remove intermediate structs in cli arguments
These intermediate structs were creating unnecessary noise. The peer id
and multiaddr fields are going to be removed in the future further
reducing the need to have seperate structs for cancel, resume and
refund.
2021-03-01 10:37:59 +11:00
bors[bot]
9a32f7d405
Merge #236
236: Some wallet cleanup + watch for deposit r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-02-28 23:26:31 +00:00
bors[bot]
b08618fd90
Merge #239
239: Remove windows from the release r=da-kami a=da-kami

At the moment windows fails to build. This has to be fixed before it is re-added to the release.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-02-28 22:37:57 +00:00
Daniel Karzel
06be66700e Remove windows from the release
At the moment windows fails to build. This has to be fixed before it is re-added to the release.
2021-02-26 18:11:18 +11:00
Daniel Karzel
bb1537d6f2 Error feedback for the user upon communication errors
If communication with the other party fails the program should stop and the user should see the respective error.
Communication errors are handled in the event-loop. Upon a communication error the event loop is stopped.
Since the event loop is only stopped upon error the Result returned from the event loop is Infallible.

If one of the two futures, event loop and swap,  finishes (success/failure) the other future should be stopped as well.
We use tokio::selec! to stop either future if the other stops.
2021-02-26 17:18:12 +11:00
Daniel Karzel
019d6c725a Maximum sell amount for ASB that defaults to 0.5 XMR 2021-02-26 16:48:27 +11:00
bors[bot]
bb0377c6c7
Merge #232
232: ASB only sends quote response if sufficient XMR balance r=da-kami a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-02-26 05:17:48 +00:00
Daniel Karzel
e66e84085b Rename Bob's Behavior Failure to CommunicationError
Failure does not express what the error represents. It is only used for communication
errors for quote requests, receiving the XMR transfer proof and sending the encryption signature.
2021-02-26 16:02:44 +11:00
bors[bot]
08b036142f
Merge #235
235: monero-rpc debug log for moner-harness tests  r=thomaseizinger a=da-kami

This allows us to see the response from the monerod client on debug.
When the monero-harness was split up into harness and rpc this was overlooked.
We need the debug logs to investigate the monero harness CI fail bug.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-02-26 04:34:00 +00:00
Thomas Eizinger
f472070546
Remove --send-btc in favor of swapping the available balance
If the current balance is 0, we wait until the user deposits money
to the given address. After that, we simply swap the full balance.

Not only does this simplify the interface by removing a parameter,
but it also integrates the `deposit` command into the `buy-xmr`
command.

Syncing a wallet that is backed by electrum includes transactions
that are part of the mempool when computing the balance.
As such, waiting for a deposit is a very quick action because it
allows us to build our lock transaction on top of the yet to be
confirmed deposit transactions.

This patch introduces another function to the `bitcoin::Wallet` that
relies on the currently statically encoded fee rate. To make sure
future developers don't forget to adjust both, we extract a function
that "selects" a fee rate and return the constant from there.

Fixes #196.
2021-02-26 14:36:59 +11:00
Thomas Eizinger
32cb0eb896
Rename build_tx_lock_psbt to send_to_address
Being defined on the wallet itself, a more generic name fits better
on what this function actually does.
2021-02-26 14:36:59 +11:00
Thomas Eizinger
67fe01a2ef
Remove BuildTxLockPsbt and GetNetwork traits
These traits were only used once within the `TxLock` constructor.
Looking at the rest of the codebase, we don't really seem to follow
any abstractions here where the protocol shouldn't know about the
exact types that is being passed in.

As such, these types are just noise and might as well be removed in
favor of simplicity.
2021-02-26 14:36:58 +11:00
Thomas Eizinger
6c38d66864
Remove Tx arguments from add_signatures functions
The only reason we need this argument is because we need to access
the output descriptor. We can save that one ahead of time at when
we construct the type.
2021-02-26 14:36:58 +11:00
Thomas Eizinger
0f8fbd087f
Make all fields of bitcoin::Wallet private
This reveals that the `network` field is actually unused.
2021-02-26 14:36:58 +11:00
Thomas Eizinger
1876d17ba4
Remove map_err in favor of ?
`?` maps the error automatically.
2021-02-26 14:36:57 +11:00
Thomas Eizinger
7d324d966a
Remove syncing wallet log
BDK already has a log line for the sync that we could enable if we
wanted such a log.
Additionally, _we_ are not actually syncing the wallet, bdk is so our
log line was lying. It should have said "calling bdk to sync wallet".
2021-02-26 14:36:57 +11:00
bors[bot]
93d59398af
Merge #231
231: Error only on close message when fetching the rate r=thomaseizinger a=da-kami

Ping/Pong messages disturb the rate requests quite frequently resulting in failed swap setup because there is no rate available.

As a result messages Ping, Pong and Binary are now ignored and not reported as error.


Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-02-26 02:33:13 +00:00
bors[bot]
e3457bea79
Merge #230
230: Use testnet demo defaults if config file or cli args are not provided r=thomaseizinger a=rishflab

Closes #229 

Also connects to the ASB running by default if peer id and addr are not supplied in the cli args 


`swap_cli -- buy-xmr --send-btc 0.0006` will trigger a swap

Co-authored-by: rishflab <rishflab@hotmail.com>
2021-02-26 02:18:15 +00:00
Daniel Karzel
1f1b3a95bc Logging for different scenarios when reading from rate stream 2021-02-26 12:44:49 +11:00
rishflab
abc9aaa327 Use default alice peer id and multiaddr if not specified in cli args 2021-02-26 11:57:07 +11:00
Daniel Karzel
570832cd37 Add monero rpc log filter to harness tracing
This allows us to see the response from the monerod client on debug.
When the monero-harness was split up into harness and rpc this was overlooked.
We need the debug logs to investigate the monero harness CI fail bug.
2021-02-26 11:43:41 +11:00
Daniel Karzel
cad6a1c3a7 ABS only sends quote response if sufficient XMR balance 2021-02-26 11:12:32 +11:00
rishflab
f52567155a Use default testnet config if config file path not specified 2021-02-26 09:16:22 +11:00
Daniel Karzel
fc2c08c7c9 Error only on close message when fetching the rate
Messages Ping, Pong and Binary are ignored and not reported as error.
2021-02-25 12:52:38 +11:00
bors[bot]
fffa679f42
Merge #226
226: Monero wallet rpc installer and executor r=thomaseizinger a=rishflab

Fixes #224


Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: rishflab <rishflab@hotmail.com>
2021-02-25 00:22:41 +00:00
rishflab
51c16f23d8
Download and run monero wallet rpc on swap cli startup
If the monero wallet rpc has not already been downloaded we download the monero cli package and extract the wallet rpc. The unneeded files are cleaned up. The monero wallet rpc is started on a random port which is provided to the swap cli.

We added a fork of tokio-tar via a git subtree because we needed a tokio-tar version that was compatible with tokio 1.0. Remove this subtree in favor of a regular cargo dependency when this PR merges: https://github.com/vorot93/tokio-tar/pull/3.
2021-02-25 11:21:41 +11:00
Thomas Eizinger
18ba8f49c4 Merge commit 'fec26926a83de45ff0ec6870608b9828d20fdc8d' as 'tokio-tar' 2021-02-25 11:20:47 +11:00