Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch For Deposit #196

Closed
rishflab opened this issue Feb 16, 2021 · 1 comment · Fixed by #236
Closed

Watch For Deposit #196

rishflab opened this issue Feb 16, 2021 · 1 comment · Fixed by #236
Assignees

Comments

@rishflab
Copy link
Member

rishflab commented Feb 16, 2021

Problem

The buy-xmr tool generates and displays a bitcoin address for the user to fund. These funds are used to buy Monero. Currently we are manually checking that these funds have arrived before commencing the swap. This does not fit with the goal of providing a streamlined UX.

Potential Solution

Assumption: We do not really care how the buy-xmr tool is funded. All that matters is that is has enough funds to execute the swap.

The buy-xmr tool should watch for the funds and automatically commence the swap when they are confirmed.

Loop on bdk_wallet.get_balance() until the balance is sufficient for the swap.

Potential Issues

  1. get_balance() requires the wallet to be synced. Syncing could take a while.
  2. The get_balance API doesn't mention anything about UTXO confirmations. The swap could begin execution but fail when it comes to building/publishing/ waiting for TxLock to confirm.
@da-kami

This comment has been minimized.

@thomaseizinger thomaseizinger self-assigned this Feb 24, 2021
thomaseizinger added a commit that referenced this issue Feb 25, 2021
We are using BDK with an electrum backend. Electrum includes mempool
transactions in the response of unspent UTXOs. As such, picking up
the balance by simply syncing is extremely fast after the transaction
has been broadcasted to the network.

Fixes #196.
@thomaseizinger thomaseizinger linked a pull request Feb 26, 2021 that will close this issue
rishflab pushed a commit that referenced this issue Feb 26, 2021
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.
@bors bors bot closed this as completed in f472070 Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants