Commit Graph

890 Commits

Author SHA1 Message Date
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
Thomas Eizinger
fec26926a8 Squashed 'tokio-tar/' content from commit 43dd166
git-subtree-dir: tokio-tar
git-subtree-split: 43dd166d0f3aff67891cd1c1bf4d6bfb984bb789
2021-02-25 11:20:47 +11:00
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>
2021-02-24 23:53:56 +00:00
Daniel Karzel
0945cee459 Remove traits in favour of public functions 2021-02-25 10:34:22 +11:00
Daniel Karzel
578d23d7fc Proper encapsulation of wallet boundaries through private fields 2021-02-25 10:30:24 +11:00
Daniel Karzel
947bcb6192 ASB reloads the default wallet after generate_from_keys atomically 2021-02-25 00:34:05 +11:00
Daniel Karzel
684cbe4d0b Remember monero wallet-height for Alice's refund scenario 2021-02-25 00:34:05 +11:00
Daniel Karzel
fa04775188 Rename function explicit to cancellation to cancel
For transitioning to state4 we either go into a redeem or a cancellation scenario.
The function name state4 is misleading, because it is only used for cancellation scenarios.
2021-02-25 00:34:05 +11:00
Daniel Karzel
1404057dbe Remove misleading TODO
This TDOO is misleading, because - to our current knowledge - it is impossible for
Bob to retrieve the exact inclusion block-height of the lock transaction (send by Alice).
The wallet RPC is only capable of retrieving the inclusion block height of a transaction
through `get_payments` and `get_bulk_payments` which requires the `payment_id`.
The `payment_id` can be retrieved through `get_transfer_by_txid` which states
"Show information about a transfer to/from this address." - however the address that the
transfer goes to is not part of Bob's wallet yet! Thus, it is impossible for Bob to use
`get_transfer_by_txid` which in turn means Bob is unable to use `get_payments`.

The only possible way for Bob to know the exact inclusion block/height of the lock transaction
would be if Alice sends it over to Bob. But for that Alice would have to extract it she would have
to wait for confirmation - which she currently does not and might never do. Even if she does await
the first confirmation before sending the transfer proof the solution for retrieving the inclusion
block-height is not fleshed out on her side yet.
2021-02-25 00:34:05 +11:00
Daniel Karzel
9f1deb9fdc Wrap the Monero wallet client in a Mutex
In order to ensure that we can atomically generate_from_keys and then reload a wallet,
we have to wrap the client of the monero wallet RPC inside a mutex.
When introducing the Mutex I noticed that several inner RPC calls were leaking to the
swap crate monero wallet. As this is a violation of boundaries I introduced the traits
`GetAddress`, `WalletBlockHeight` and `Refresh`.

Note that the monero wallet could potentially know its own public view key and
public spend key. If we refactor the wallet to include this information upon wallet
creation we can also generate addresses using `monero::Address::standard`.
2021-02-25 00:33:58 +11:00
bors[bot]
ff8d997aa2
Merge #223
223: Create github workflow to build swap_cli binary on release r=thomaseizinger a=rishflab

Fixes #222 

Co-authored-by: rishflab <rishflab@hotmail.com>
2021-02-24 07:37:55 +00:00
Daniel Karzel
aed8358fb7 Remove dead code 2021-02-24 14:00:17 +11:00
rishflab
9a4c5df368 Create github workflow to build swap_cli binary on release 2021-02-23 16:50:11 +11:00
bors[bot]
2654879ff3
Merge #218
218: Cleanup dependencies r=thomaseizinger a=thomaseizinger

Fixes https://github.com/comit-network/xmr-btc-swap/issues/208.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2021-02-23 05:02:55 +00:00
bors[bot]
fb2057453a
Merge #219 #221
219: Rename variables to add to understanding the code r=da-kami a=da-kami



221: Fix/improve comment explaining TxRefund encsigning r=thomaseizinger a=rishflab



Co-authored-by: Daniel Karzel <daniel@comit.network>
Co-authored-by: rishflab <rishflab@hotmail.com>
2021-02-23 03:37:26 +00:00
Thomas Eizinger
33cf609020
Update bitcoin-harness to latest version
This finally removes the openssl dependency completely from our
dependency tree.
2021-02-23 14:30:33 +11:00
Thomas Eizinger
66db8e1851
Remove unnecessary log dependency
By updating `tracing_log`, we can access the re-export. That we need
to initialize the `tracing_log` adaptor.

The usage of `log::LevelFilter` for the `init_tracing` function was
conceptually incorrect. We should be using a type from the `tracing`
library here.
2021-02-23 14:30:32 +11:00
Thomas Eizinger
498fae9f64
Remove native-tls feature from monero-rpc
1. `monero-rpc` is not in the position to decide about the TLS backend
an application should use.
2. We don't use TLS encrypted communication to my knowledge so we don't
have to activate this feature anywhere else.
2021-02-23 14:30:20 +11:00
Thomas Eizinger
03078f328c
Split monero-harness into harness and rpc
This allows us to move `monero-harness` and `bitcoin-harness` into
`[dev-dependencies]` of `swap`.
2021-02-23 14:30:20 +11:00
Thomas Eizinger
2a3db9bd80
Remove unnecessary derivative dependency 2021-02-23 14:30:19 +11:00
Thomas Eizinger
f0ba80794c
Remove unnecessary serde_derive dependency declaration
We already express the same thing through the serde `derive` feature.
2021-02-23 14:30:19 +11:00
Thomas Eizinger
d54fac6fd9
Remove unnecessary tempfile prod dependency 2021-02-23 14:30:19 +11:00
Thomas Eizinger
729f4f09a8
Remove unnecessary tracing_core dependency 2021-02-23 14:30:19 +11:00
Thomas Eizinger
418aa02191
Remove unnecessary ed25519-dalek dependency 2021-02-23 14:30:14 +11:00
rishflab
8280072400 Fix/improve comment explaining TxRefund encsigning 2021-02-23 12:18:22 +11:00
Daniel Karzel
151f33ba10 Rename variables to add to understanding the code 2021-02-22 15:38:14 +11:00
bors[bot]
61a8282be1
Merge #203
203: Introduce dynamic rates r=da-kami a=D4nte



Co-authored-by: Franck Royer <franck@coblox.tech>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-02-22 04:36:49 +00:00
bors[bot]
12c67bee3d
Merge #210
210: Change monitoring to default wallet r=da-kami a=da-kami

The automated swap backend (asb) requires Monero funds, because Alice is selling Monero.
We use a hardcoded default wallet named asb-wallet. This wallet is opened upon startup.
If the default wallet does not exist it will be created.

Additionally there is a check for the balance - if the balance is zero an address is printed for depositing funds.

Co-authored-by: Daniel Karzel <daniel@comit.network>
2021-02-22 04:03:35 +00:00
Daniel Karzel
b4ceee49df Change monitoring to default wallet
The automated swap backend (asb) requires Monero funds, because Alice is selling Monero.
We use a hardcoded default wallet named asb-wallet. This wallet is opened upon startup.
If the default wallet does not exist it will be created.
2021-02-22 15:00:06 +11:00
Daniel Karzel
9496dce917 Skip heartbeat messages 2021-02-22 14:51:22 +11:00