Skip to content

Commit

Permalink
Fix #116 with consistent --fee-rate arg
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Nov 21, 2023
1 parent 2c31a0d commit 4dd5cc0
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions payjoin-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{Context, Result};
use clap::{value_parser, Arg, ArgMatches, Command};
use clap::{arg, value_parser, Arg, ArgMatches, Command};

mod app;
use app::{App, AppConfig};
Expand All @@ -13,18 +13,14 @@ fn main() -> Result<()> {

match matches.subcommand() {
Some(("send", sub_matches)) => {
let bip21 = sub_matches
.get_one::<String>("BIP21")
.context("Missing BIP21 argument")?;
let fee_rate_sat_per_vb = sub_matches
.get_one::<f32>("fee-rate")
.context("Missing fee_rate argument")?;
let bip21 = sub_matches.get_one::<String>("BIP21").context("Missing BIP21 argument")?;
let fee_rate_sat_per_vb =
sub_matches.get_one::<f32>("fee_rate").context("Missing --fee-rate argument")?;
app.send_payjoin(bip21, fee_rate_sat_per_vb)?;
}
Some(("receive", sub_matches)) => {
let amount = sub_matches
.get_one::<String>("AMOUNT")
.context("Missing AMOUNT argument")?;
let amount =
sub_matches.get_one::<String>("AMOUNT").context("Missing AMOUNT argument")?;
app.receive_payjoin(amount)?;
}
_ => unreachable!(), // If all subcommands are defined above, anything else is unreachabe!()
Expand Down Expand Up @@ -54,13 +50,11 @@ fn cli() -> ArgMatches {
.subcommand(
Command::new("send")
.arg_required_else_help(true)
.arg(
Arg::new("BIP21")
.help("The `bitcoin:...` payjoin uri to send to"))
.arg(arg!(<BIP21> "The `bitcoin:...` payjoin uri to send to"))
.arg_required_else_help(true)
.arg(
Arg::new("fee-rate")
.arg(Arg::new("fee_rate")
.long("fee-rate")
.value_name("FEE_SAT_PER_VB")
.help("Fee rate in sat/vB")
.value_parser(value_parser!(f32)),
)
Expand All @@ -71,9 +65,7 @@ fn cli() -> ArgMatches {
.subcommand(
Command::new("receive")
.arg_required_else_help(true)
.arg(
Arg::new("AMOUNT")
.help("The ammount to receive in satoshis"))
.arg(arg!(<AMOUNT> "The amount to receive in satoshis"))
.arg_required_else_help(true)
.arg(Arg::new("port")
.long("host-port")
Expand Down

0 comments on commit 4dd5cc0

Please sign in to comment.