Commit Graph

611 Commits (196557b37704ce5481847daacb96b07fbf0b660c)

Author SHA1 Message Date
Daniel Karzel 196557b377 Rename binary to swap 4 years ago
Daniel Karzel f8b61e2e0e Make monero daemon host configurable 4 years ago
Daniel Karzel f091402c7a Remove parameter duplication by introducing structs 4 years ago
Thomas Eizinger c826a28911
Add context if we fail to compute extended private key 4 years ago
Thomas Eizinger 1aa6d177bf
Improve error messages when determining BTC amount to be swapped 4 years ago
Thomas Eizinger 4138039ea0
Make sure all error messages start with an uppercase letter
These might potentially be shown to a user, let's make them all
consistent.
4 years ago
Thomas Eizinger 816e8b9b96
Add more context to fallible functions inside bitcoin::Wallet 4 years ago
Thomas Eizinger 5c24a46298
Improve error message if stuff fails directly in main 4 years ago
Thomas Eizinger 37f97ac471
Shorten function name
The variable will always be at least called `wallet`, hence we can
omit the `_wallet` postfix from the function name.
4 years ago
Thomas Eizinger 4f66269887
Move error message on sync _into_ the function
The bitcoin::Wallet::sync_wallet function doesn't do anything else
other than delegating. As such, we have just as much information
about what went wrong inside this function as we have outside.

By moving the .context call into the function, we can avoid repeating
us on every call-site.
4 years ago
Thomas Eizinger 5953037b81
Don't repeat the module name within the type 4 years ago
Thomas Eizinger 87f928f56c
Move const to function where it is used 4 years ago
Thomas Eizinger 4642e6c0e3
Simplify arguments to `init_XYZ_wallet` functions
This makes the function calls fit onto one line.
4 years ago
Thomas Eizinger d0db6cba10
Favour individual logs over one in main 4 years ago
bors[bot] 2041f367c6
Merge #288
288: Switch to public stagenet node that works r=rishflab a=rishflab

The xmr.to node has been unreliable lately. The exan.tech node seems to
working.

@da-kami is following up with making this configurable. Lets get this in so we can get a release on Friday.

Co-authored-by: rishflab <rishflab@hotmail.com>
4 years ago
rishflab 754159c9f8 Switch to public stagenet node that works
The xmr.to node has been unreliable lately. The exan.tech node seems to
working.
4 years ago
Thomas Eizinger b178e95f95
Redo layout of eventloop module
1. Move internal types to the bottom and make them private
2. Sort public types by their importance
4 years ago
Thomas Eizinger 1822886cd0
Provide stronger isolation of kraken module
Instead of leaking the tokio::sync::Receiver type in our
return value, we create a newtype that implements the desired
interface. This allows us to get rid of the `RateService` structs
and instead implement `LatestRate` directly on top of this struct.

Given that `LatestRate` is only used within the event_loop module,
we move the definition of this type into there.
4 years ago
Thomas Eizinger f6ed4d65b5
Properly deal with additional messages sent from kraken 4 years ago
Thomas Eizinger 7575d412b8
Add kraken_ticker CLI for local testing of the client 4 years ago
Thomas Eizinger 60d6d50246
Extract kraken websocket client into dedicated module 4 years ago
Thomas Eizinger 25c4639689
Prepare for next release 4 years ago
bors[bot] 20f2e56e2d
Merge #271
271: Bob can verify that the XMR lock tx was published r=da-kami a=da-kami

The Monero `txhash` log was removed. I feel the user should have the possibility to verify that the transaction was actually published so I added the tx-hash to the confirmation output. 

We could potentially print the tx-hash when receiving the transfer proof already, but that might not add much value compared to printing it with the confirmations. 

Additionally we should allow the user to at least know when the XMR can be expected in the user's wallet, otherwise the swap ends like this:

```
2021-03-04 13:49:19   INFO Monero lock tx received 5 out of 5 confirmations
```

This is just not very informative - yes, the final transaction is an implementation detail, but I don't think we should hide the transactions from the user. By printing the tx-hash for spending from the lock-tx into the user wallet we ensure the user knows that the XMR can now be expected in the user wallet. 

--- 

To add context, here the complete log (with debug enabled) **before** this change: 

```
2021-03-04 13:30:46  DEBUG Database and seed will be stored in /Users/dakami/Library/Application Support/xmr-btc-swap
2021-03-04 13:30:46  DEBUG Starting monero-wallet-rpc on port 56145
2021-03-04 13:30:51  DEBUG Requesting quote
2021-03-04 13:30:51   INFO Received quote: 1 XMR = 0.00433500 BTC
2021-03-04 13:30:51   INFO Still got 0.01018746 BTC left in wallet, swapping ...
2021-03-04 13:30:51   INFO Spot price for 0.00500000 BTC is 1.153402537485 XMR
2021-03-04 13:30:52  DEBUG Starting execution setup with 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-03-04 13:30:55   INFO Published Bitcoin 3a6690a962191529892318819fb20e7f1ac4625400e64ee734056a9b2a17ad8f transaction as lock
2021-03-04 13:41:13  DEBUG Received Transfer Proof from 12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi
2021-03-04 13:42:11   INFO Monero lock tx received 1 out of 5 confirmations
2021-03-04 13:45:33   INFO Monero lock tx received 2 out of 5 confirmations
2021-03-04 13:47:49   INFO Monero lock tx received 3 out of 5 confirmations
2021-03-04 13:48:56   INFO Monero lock tx received 4 out of 5 confirmations
2021-03-04 13:49:19   INFO Monero lock tx received 5 out of 5 confirmations
2021-03-04 13:49:19  DEBUG Encrypted signature sent
2021-03-04 13:49:19  DEBUG Alice acknowledged encrypted signature
2021-03-04 13:49:19  DEBUG watching for tx: e5569d3f0bcccac95252dffaebe74ead0360c09b76bc762de890aaa0e51afbcf
2021-03-04 13:49:20  DEBUG Received protocol error "missing transaction" from Electrum, retrying...
2021-03-04 13:49:22  DEBUG Received protocol error "missing transaction" from Electrum, retrying...
```



Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
Daniel Karzel 47a31760c0 Bob can verify the Monero txs by tx-hash
Print tx-hashes for monero transactions to allow Bob to look the transaction up in block explorer.

The story of Bab:
Our famous actor Bob has a brother named Bab.
In school they were often mixed up, because their names were so similar.
Eventually Bab renamed himself into Barbara, but that was even more confusing for now he
carried a female name even though he was not female. Bob wanted to help his brother and told him he
could just go for Bub. But that did not solve anything. Fun fact: Bub is actually married to Alice.
4 years ago
Thomas Eizinger 14dcd150af
Extract `determine_btc_to_swap` function and test it
We also instantiate tracing in to order to quickly validate, what
the output for the different scenarios looks like.
4 years ago
Thomas Eizinger 601bf07255
Introduce `quote` protocol and display it to the user before they fund
Previously, the user neither knew the price nor the maximum quantity
they could trade. We now request a quote from the user and display
it to them.

Fixes #255.
4 years ago
Thomas Eizinger 3da01ea44a
Rename local variables according to new protocol name 4 years ago
Thomas Eizinger ead5db3f45
Re-order fields to group them semantically 4 years ago
Thomas Eizinger bc176bc4fb
Minor import optimizations 4 years ago
Thomas Eizinger 6d9b21cb47
Change `imports_granularity` to module
This reduces the overall amount of LoC that imports take up in our
codebase by almost 100.
It also makes merge-conflicts less likely because there is less
grouping together of imports that may lead to layout changes which
in turn can cause merge conflicts.
4 years ago
Thomas Eizinger 2c8200621d
Move `pub use` into pub use block 4 years ago
bors[bot] d1363d130c
Merge #265
265: Replace quote with spot-price protocol r=thomaseizinger a=thomaseizinger

This is essentially functionally equivalent but includes some
cleanups by removing a layer of abstraction: `spot_price::Behaviour`
is now just a type-alias for a request-response behaviour.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
4 years ago
Daniel Karzel 7504c6ceee Context for monero address parsing errors
Most of the errors are not user friendly, thus added context to tell the user the given address is incorrect.
4 years ago
Daniel Karzel 35d0e246d8 Monero address network check
Add a network check to ensure the given monero address is on the configured network.
4 years ago
bors[bot] cba9f119b6
Merge #261
261: Sweep xmr funds from generated temp wallet r=da-kami a=da-kami

Fixes #252

Please review by commit :)
Did a few cleanups before actually doing the feature.

Please note the comment that influenced this solution: https://github.com/comit-network/xmr-btc-swap/issues/252#issuecomment-789387074



Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
Daniel Karzel 2e3c2d8edf Remove Arcs in favour of references 4 years ago
Daniel Karzel 5d807e9647 Reorder: Move utility functionality to bottom 4 years ago
Daniel Karzel 862c29f1a8 Reorder: Move sweep_all after transfer 4 years ago
Daniel Karzel 5a43b3453e Reorder: Move create after open 4 years ago
Daniel Karzel b17e6cbd94 Reorder: Move open to top 4 years ago
Daniel Karzel d63790c2a6 Remove unnecessary monero wallet trait abstractions 4 years ago
Daniel Karzel 1041212a60 Work in review comments 4 years ago
Daniel Karzel 66c8401c95 Sweep all from generated wallet to user wallet
The default implementation for the command was removed because it does not
add additional value if we have a mandatory parameter anyway.
4 years ago
Thomas Eizinger 7042ed9441
Replace quote with spot-price protocol
This is essentially functionally equivalent but includes some
cleanups by removing a layer of abstraction: `spot_price::Behaviour`
is now just a type-alias for a request-response behaviour.
4 years ago
Daniel Karzel 5111a12706 Wallet name constants for the e2e test setup
Container initialization and wallet initialization have to ensure to use the same wallet name.
In order to avoid problems constants are introduced to ensure we use the same wallet name.
4 years ago
Daniel Karzel 2bb1c1e177 No prefix for wallets in monero harness
Prefixing docker-containers and -networks is a necessity to be able to spin up multiple containers and networks.
However, there is no reason to prefix the wallet names that live inside a container. One cannot add a wallet with
the same name twice, so the prefixing of wallets does not bring any advantage. When re-opening a wallet by name
the wallet name prefix is cumbersome and was thus removed.
4 years ago
Daniel Karzel 9f53dab3c6 Harmonize names to make more sense
The wallet is an instance of a wallet that has a name.
When we use `CreateWalletForOutputThenReloadWallet` we actually unload the wallet.
It would be cleaner to create a new instance that does that swap, but I did not go that far.
4 years ago
Daniel Karzel 70494fcb4f Create means creating the current wallet 4 years ago
Daniel Karzel 5b798217bc Open means opening the current wallet 4 years ago
Thomas Eizinger 2440964385
Allow ASB to be configured with max BTC buy amount
This will make it easier to also configure the CLI to display an appropriate max amount the user has to deal with.
4 years ago