mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Separate Buy/Sell for resume command
To avoid confusing the user on whether person should enter a listen addr or a connect peer id and address
This commit is contained in:
parent
672377b216
commit
1fa812b727
@ -23,7 +23,7 @@ use swap::{
|
||||
alice::swap::AliceState,
|
||||
bitcoin, bob,
|
||||
bob::swap::BobState,
|
||||
cli::{Command, Options},
|
||||
cli::{Command, Options, Resume},
|
||||
monero,
|
||||
network::transport::build,
|
||||
storage::Database,
|
||||
@ -173,18 +173,16 @@ async fn main() -> Result<()> {
|
||||
// Print the table to stdout
|
||||
table.printstd();
|
||||
}
|
||||
Command::Resume {
|
||||
Command::Resume(Resume::SellXmr {
|
||||
swap_id,
|
||||
bitcoind_url,
|
||||
bitcoin_wallet_name,
|
||||
monero_wallet_rpc_url,
|
||||
listen_addr,
|
||||
alice_peer_id,
|
||||
alice_addr,
|
||||
} => {
|
||||
}) => {
|
||||
let db_swap = db.get_state(swap_id)?;
|
||||
|
||||
if let Ok(alice_state) = AliceState::try_from(db_swap.clone()) {
|
||||
let alice_state = AliceState::try_from(db_swap.clone())?;
|
||||
let (bitcoin_wallet, monero_wallet) = setup_wallets(
|
||||
bitcoind_url,
|
||||
bitcoin_wallet_name.as_str(),
|
||||
@ -202,7 +200,19 @@ async fn main() -> Result<()> {
|
||||
db,
|
||||
)
|
||||
.await?;
|
||||
} else if let Ok(bob_state) = BobState::try_from(db_swap) {
|
||||
}
|
||||
Command::Resume(Resume::BuyXmr {
|
||||
swap_id,
|
||||
bitcoind_url,
|
||||
bitcoin_wallet_name,
|
||||
monero_wallet_rpc_url,
|
||||
alice_peer_id,
|
||||
alice_addr,
|
||||
}) => {
|
||||
let db_swap = db.get_state(swap_id)?;
|
||||
|
||||
let bob_state = BobState::try_from(db_swap)?;
|
||||
|
||||
let (bitcoin_wallet, monero_wallet) = setup_wallets(
|
||||
bitcoind_url,
|
||||
bitcoin_wallet_name.as_str(),
|
||||
@ -220,11 +230,8 @@ async fn main() -> Result<()> {
|
||||
alice_addr,
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
anyhow::bail!("Unable to construct swap state for swap with id {}")
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -60,16 +60,15 @@ pub enum Command {
|
||||
receive_monero: xmr_btc::monero::Amount,
|
||||
},
|
||||
History,
|
||||
Resume {
|
||||
Resume(Resume),
|
||||
}
|
||||
|
||||
#[derive(structopt::StructOpt, Debug)]
|
||||
pub enum Resume {
|
||||
SellXmr {
|
||||
#[structopt(long = "swap-id")]
|
||||
swap_id: Uuid,
|
||||
|
||||
#[structopt(long = "connect-peer-id")]
|
||||
alice_peer_id: PeerId,
|
||||
|
||||
#[structopt(long = "connect-addr")]
|
||||
alice_addr: Multiaddr,
|
||||
|
||||
#[structopt(long = "bitcoind-rpc", default_value = "http://127.0.0.1:8332")]
|
||||
bitcoind_url: Url,
|
||||
|
||||
@ -82,11 +81,31 @@ pub enum Command {
|
||||
)]
|
||||
monero_wallet_rpc_url: Url,
|
||||
|
||||
// TODO: The listen address is only relevant for Alice, but should be role independent
|
||||
// see: https://github.com/comit-network/xmr-btc-swap/issues/77
|
||||
#[structopt(long = "p2p-address", default_value = "/ip4/127.0.0.1/tcp/9876")]
|
||||
#[structopt(long = "listen-address", default_value = "/ip4/127.0.0.1/tcp/9876")]
|
||||
listen_addr: Multiaddr,
|
||||
},
|
||||
BuyXmr {
|
||||
#[structopt(long = "swap-id")]
|
||||
swap_id: Uuid,
|
||||
|
||||
#[structopt(long = "counterpart-peer-id")]
|
||||
alice_peer_id: PeerId,
|
||||
|
||||
#[structopt(long = "counterpart-addr")]
|
||||
alice_addr: Multiaddr,
|
||||
|
||||
#[structopt(long = "bitcoind-rpc", default_value = "http://127.0.0.1:8332")]
|
||||
bitcoind_url: Url,
|
||||
|
||||
#[structopt(long = "bitcoin-wallet-name")]
|
||||
bitcoin_wallet_name: String,
|
||||
|
||||
#[structopt(
|
||||
long = "monero-wallet-rpc",
|
||||
default_value = "http://127.0.0.1:18083/json_rpc"
|
||||
)]
|
||||
monero_wallet_rpc_url: Url,
|
||||
},
|
||||
}
|
||||
|
||||
fn parse_btc(str: &str) -> anyhow::Result<bitcoin::Amount> {
|
||||
|
Loading…
Reference in New Issue
Block a user