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

BIP353 address parser #619

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 16 additions & 5 deletions cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ pub(crate) enum Command {
#[arg(long)]
address: Option<String>,

/// BIP353 address that contains a BOLT12 offer. If specified, amount_sat must also be set.
#[arg(long)]
pay_code: Option<String>,
lorenzoronzani marked this conversation as resolved.
Show resolved Hide resolved

/// The amount in satoshi to pay, in case of a direct Liquid address
/// or amount-less BIP21
#[arg(short, long)]
Expand Down Expand Up @@ -326,20 +330,27 @@ pub(crate) async fn handle_command(
invoice,
offer,
address,
pay_code,
amount_sat,
drain,
delay,
} => {
let destination = match (invoice, offer, address) {
(Some(invoice), None, None) => Ok(invoice),
(None, Some(offer), None) => match amount_sat {
let destination = match (invoice, offer, address, pay_code) {
(Some(invoice), None, None, None) => Ok(invoice),
(None, Some(offer), None, None) => match amount_sat {
Some(_) => Ok(offer),
None => Err(anyhow!(
"Must specify an amount for a BOLT12 offer."
))
},
(None, None, Some(address)) => Ok(address),
(Some(_), _, Some(_)) => {
(None, None, Some(address), None) => Ok(address),
(None, None, None, Some(pay_code)) => match amount_sat {
Some(_) => Ok(pay_code),
None => Err(anyhow!(
"Must specify an amount for a BOLT12 offer."
))
},
(Some(_), _, Some(_), _) => {
Err(anyhow::anyhow!(
"Cannot specify both invoice and address at the same time."
))
Expand Down
Loading