mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-08 06:22:39 -04:00
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.
This commit is contained in:
parent
32cb0eb896
commit
f472070546
3 changed files with 55 additions and 24 deletions
|
@ -1,5 +1,3 @@
|
|||
use crate::bitcoin;
|
||||
use anyhow::Result;
|
||||
use libp2p::{core::Multiaddr, PeerId};
|
||||
use std::path::PathBuf;
|
||||
use uuid::Uuid;
|
||||
|
@ -26,9 +24,6 @@ pub enum Command {
|
|||
|
||||
#[structopt(long = "connect-addr")]
|
||||
alice_addr: Multiaddr,
|
||||
|
||||
#[structopt(long = "send-btc", help = "Bitcoin amount as floating point nr without denomination (e.g. 1.25)", parse(try_from_str = parse_btc))]
|
||||
send_bitcoin: bitcoin::Amount,
|
||||
},
|
||||
History,
|
||||
Resume(Resume),
|
||||
|
@ -85,8 +80,3 @@ pub enum Refund {
|
|||
force: bool,
|
||||
},
|
||||
}
|
||||
|
||||
fn parse_btc(str: &str) -> Result<bitcoin::Amount> {
|
||||
let amount = bitcoin::Amount::from_str_in(str, ::bitcoin::Denomination::Bitcoin)?;
|
||||
Ok(amount)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue