Commit Graph

916 Commits (196557b37704ce5481847daacb96b07fbf0b660c)
 

Author SHA1 Message Date
Thomas Eizinger b7c3524b4f
Abort the eventloop if the dialling fails 4 years ago
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.
4 years ago
Thomas Eizinger 6b74761e34
Remove tracing context
The swap_cli can only do one swap at a time, no need for the swap ID span.
4 years ago
Thomas Eizinger 3d2d447fba
Improve error message
YMMV but I think this sounds better.
4 years ago
Thomas Eizinger bbbe5f7ae8
Demote / promote log messages to their appropriate level 4 years ago
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.
4 years ago
Thomas Eizinger b8df4a3145
Inline tracing configuration for swap_cli
This allows us to configure the presentation separately from the ASB.
4 years ago
Thomas Eizinger a0e7c6ecf7
Don't Arc the AtomicU32
We never clone this type, there is no need to wrap it in an `Arc`.
4 years ago
Thomas Eizinger 40dcf0355a
Simplify `Transfer::transfer` return type
We never use the fee returned from this function, remove it.
4 years ago
Daniel Karzel 96115da039 Wait for wallet to catch up instead of block generation
The monero harness wallet always starts a miner that mines new blocks every second.
This can conflict with additionally triggering block generation  and cause this error:

```
monero_rpc::rpc::monerod: generate blocks response: {
  "error": {
    "code": -7,
    "message": "Block not accepted"
  },
  "id": "1",
  "jsonrpc": "2.0"
}
```

Since the miner is generating blocks anyway we can wait for the wallet to catch up.
Refresh is done upon querying the balance, thus the refresh calls were removed.
4 years ago
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>
4 years ago
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>
4 years ago
Thomas Eizinger 9f0b1c5cbe
Calculate max_giveable based on spending script size 4 years ago
Daniel Karzel 8c40ee1da4 Change anyhow! to bail! in error scenarios 4 years ago
bors[bot] 7251588e79
Merge #233
233: ASB max sell amount r=thomaseizinger a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
bors[bot] 5ddf41721e
Merge #238
238: Bob error handling r=thomaseizinger a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
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>
4 years ago
rishflab 975d604405 Test to ensure default alice peer id and multi addr is valid 4 years ago
rishflab 9a82b572ec Default to buy xmr using default trait 4 years ago
rishflab d6d67f62f1 Swap cli executes BuyXmr path if subcommand is not given 4 years ago
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.
4 years ago
bors[bot] 9a32f7d405
Merge #236
236: Some wallet cleanup + watch for deposit r=thomaseizinger a=thomaseizinger



Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
4 years ago
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>
4 years ago
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.
4 years ago
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.
4 years ago
Daniel Karzel 019d6c725a Maximum sell amount for ASB that defaults to 0.5 XMR 4 years ago
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>
4 years ago
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.
4 years ago
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>
4 years ago
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.
4 years ago
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.
4 years ago
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.
4 years ago
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.
4 years ago
Thomas Eizinger 0f8fbd087f
Make all fields of `bitcoin::Wallet` private
This reveals that the `network` field is actually unused.
4 years ago
Thomas Eizinger 1876d17ba4
Remove `map_err` in favor of `?`
`?` maps the error automatically.
4 years ago
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".
4 years ago
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>
4 years ago
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>
4 years ago
Daniel Karzel 1f1b3a95bc Logging for different scenarios when reading from rate stream 4 years ago
rishflab abc9aaa327 Use default alice peer id and multiaddr if not specified in cli args 4 years ago
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.
4 years ago
Daniel Karzel cad6a1c3a7 ABS only sends quote response if sufficient XMR balance 4 years ago
rishflab f52567155a Use default testnet config if config file path not specified 4 years ago
Daniel Karzel fc2c08c7c9 Error only on close message when fetching the rate
Messages Ping, Pong and Binary are ignored and not reported as error.
4 years ago
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>
4 years ago
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.
4 years ago
Thomas Eizinger 18ba8f49c4 Merge commit 'fec26926a83de45ff0ec6870608b9828d20fdc8d' as 'tokio-tar' 4 years ago
Thomas Eizinger fec26926a8 Squashed 'tokio-tar/' content from commit 43dd166
git-subtree-dir: tokio-tar
git-subtree-split: 43dd166d0f3aff67891cd1c1bf4d6bfb984bb789
4 years ago
bors[bot] 74352ee136
Merge #225
225: Asb refund reload main wallet r=da-kami a=da-kami

Fixes #211 

Please review by commit and read the commit messages.

Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
Daniel Karzel 0945cee459 Remove traits in favour of public functions 4 years ago