Commit Graph

35 Commits

Author SHA1 Message Date
Thomas Eizinger
c2329b19a2
Tell the user more about the monero lock transaction
First, we tell the user that we are now waiting for Alice to lock
the monero. Additionally, we tell them once we received the
transfer proof which will lead directly into the
"waiting for confirmations" function.
2021-03-05 16:56:47 +11:00
Thomas Eizinger
13c4d29d40
Tell the user immediately how many confirmations we expect
Without this, the user doesn't see a message before the first
confirmation.
2021-03-05 16:56:47 +11:00
Thomas Eizinger
5d4cf40831
Fix comparison of Monero confirmations 2021-03-05 16:56:46 +11:00
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>
2021-03-04 06:24:59 +00:00
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.
2021-03-04 16:51:55 +11:00
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.
2021-03-04 14:48:13 +11:00
Daniel Karzel
5d807e9647 Reorder: Move utility functionality to bottom 2021-03-03 17:15:37 +11:00
Daniel Karzel
862c29f1a8 Reorder: Move sweep_all after transfer 2021-03-03 17:15:37 +11:00
Daniel Karzel
5a43b3453e Reorder: Move create after open 2021-03-03 17:15:37 +11:00
Daniel Karzel
b17e6cbd94 Reorder: Move open to top 2021-03-03 17:15:37 +11:00
Daniel Karzel
d63790c2a6 Remove unnecessary monero wallet trait abstractions 2021-03-03 17:15:37 +11:00
Daniel Karzel
1041212a60 Work in review comments 2021-03-03 17:15:37 +11:00
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.
2021-03-03 17:15:37 +11:00
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.
2021-03-03 17:03:34 +11:00
Daniel Karzel
70494fcb4f Create means creating the current wallet 2021-03-03 17:03:34 +11:00
Daniel Karzel
5b798217bc Open means opening the current wallet 2021-03-03 17:03:33 +11:00
Thomas Eizinger
bbbe5f7ae8
Demote / promote log messages to their appropriate level 2021-03-02 09:49:53 +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
Daniel Karzel
cad6a1c3a7 ABS only sends quote response if sufficient XMR balance 2021-02-26 11:12:32 +11: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
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
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
2d8ede80e1
Use released version of backoff 2021-02-19 15:18:40 +11:00
Daniel Karzel
dac4443bbd Add functionality to open monero wallet through rpc 2021-02-09 16:34:50 +11:00
Daniel Karzel
62605a318a Add CreateWallet trait to expose create_wallet 2021-02-09 16:34:50 +11:00
rishflab
77fc5743a2
Upgrade tokio to 1.0
Upgrade bitcoin harness dependency to latest commit

Upgrade backoff to fix failing tests. The previous version of backoff had a broken version of the retry function. Upgraded to a newer comit which fixes this problem.

Upgrade hyper to 0.14 as the 0.13 was bringing in tokio 0.2.24

Upgraded bitcoin harness to version that uses tokio 1.0 and reqwest 0.11

Upgrade reqwest to 0.11. Reqwest 0.11 uses tokio 1.0

Upgrade libp2p to 0.34 in preparation for tokio 1.0 upgrade
2021-01-29 11:36:10 +11:00
Daniel Karzel
44c4b5dcea Remove newlines from import statements to avoid problems
Rust fmt automatically groups the imports (from top to bottom) as `pub use` `use crate` and `use`.
There is no need to introduce sections which cause annoyance when auto importing using the IDE.
2021-01-21 19:10:51 +11:00
Daniel Karzel
d4316f0cfe Print each monero confirmation for Bob
This is to provide more context to the user.
2021-01-18 14:50:59 +11:00
Daniel Karzel
af45206fde Remember the block-height before XMR lock for generated monero wallet restore height
Speeds up wallet creation, because only the blocks after the recorded height will be scanned.
2021-01-12 13:18:49 +11:00
rishflab
e7c00d742e Re-export bitcoin and monero types 2021-01-08 12:34:36 +11:00
rishflab
c900d12593 Merge xmr_btc crate
Created network, storage and protocol modules. Organised
files into the modules where the belong.

xmr_btc crate moved into isolated modulein swap crate.

Remove the xmr_btc module and integrate into swap crate.

Consolidate message related code

Reorganise imports

Remove unused parent Message enum

Remove unused parent State enum

Remove unused dependencies from Cargo.toml
2021-01-08 12:34:33 +11:00