Use default alice peer id and multiaddr if not specified in cli args

This commit is contained in:
rishflab 2021-02-25 12:05:07 +11:00
parent f52567155a
commit abc9aaa327

View File

@ -4,6 +4,9 @@ use libp2p::{core::Multiaddr, PeerId};
use std::path::PathBuf; use std::path::PathBuf;
use uuid::Uuid; use uuid::Uuid;
const DEFAULT_ALICE_MULTIADDR: &str = "/dns4/xmr-btc-asb.coblox.tech/tcp/9876";
const DEFAULT_ALICE_PEER_ID: &str = "12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi";
#[derive(structopt::StructOpt, Debug)] #[derive(structopt::StructOpt, Debug)]
pub struct Arguments { pub struct Arguments {
#[structopt( #[structopt(
@ -21,10 +24,13 @@ pub struct Arguments {
#[structopt(name = "xmr_btc-swap", about = "XMR BTC atomic swap")] #[structopt(name = "xmr_btc-swap", about = "XMR BTC atomic swap")]
pub enum Command { pub enum Command {
BuyXmr { BuyXmr {
#[structopt(long = "connect-peer-id")] #[structopt(long = "connect-peer-id", default_value = DEFAULT_ALICE_PEER_ID)]
alice_peer_id: PeerId, alice_peer_id: PeerId,
#[structopt(long = "connect-addr")] #[structopt(
long = "connect-addr",
default_value = DEFAULT_ALICE_MULTIADDR
)]
alice_addr: Multiaddr, 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))] #[structopt(long = "send-btc", help = "Bitcoin amount as floating point nr without denomination (e.g. 1.25)", parse(try_from_str = parse_btc))]
@ -42,10 +48,13 @@ pub enum Resume {
#[structopt(long = "swap-id")] #[structopt(long = "swap-id")]
swap_id: Uuid, swap_id: Uuid,
#[structopt(long = "counterpart-peer-id")] #[structopt(long = "counterpart-peer-id", default_value = DEFAULT_ALICE_PEER_ID)]
alice_peer_id: PeerId, alice_peer_id: PeerId,
#[structopt(long = "counterpart-addr")] #[structopt(
long = "counterpart-addr",
default_value = DEFAULT_ALICE_MULTIADDR
)]
alice_addr: Multiaddr, alice_addr: Multiaddr,
}, },
} }
@ -58,9 +67,13 @@ pub enum Cancel {
// TODO: Remove Alice peer-id/address, it should be saved in the database when running swap // TODO: Remove Alice peer-id/address, it should be saved in the database when running swap
// and loaded from the database when running resume/cancel/refund // and loaded from the database when running resume/cancel/refund
#[structopt(long = "counterpart-peer-id")] #[structopt(long = "counterpart-peer-id", default_value = DEFAULT_ALICE_PEER_ID)]
alice_peer_id: PeerId, alice_peer_id: PeerId,
#[structopt(long = "counterpart-addr")]
#[structopt(
long = "counterpart-addr",
default_value = DEFAULT_ALICE_MULTIADDR
)]
alice_addr: Multiaddr, alice_addr: Multiaddr,
#[structopt(short, long)] #[structopt(short, long)]
@ -76,9 +89,13 @@ pub enum Refund {
// TODO: Remove Alice peer-id/address, it should be saved in the database when running swap // TODO: Remove Alice peer-id/address, it should be saved in the database when running swap
// and loaded from the database when running resume/cancel/refund // and loaded from the database when running resume/cancel/refund
#[structopt(long = "counterpart-peer-id")] #[structopt(long = "counterpart-peer-id", default_value = DEFAULT_ALICE_PEER_ID)]
alice_peer_id: PeerId, alice_peer_id: PeerId,
#[structopt(long = "counterpart-addr")]
#[structopt(
long = "counterpart-addr",
default_value = DEFAULT_ALICE_MULTIADDR
)]
alice_addr: Multiaddr, alice_addr: Multiaddr,
#[structopt(short, long)] #[structopt(short, long)]