diff --git a/crates/cdk-cli/src/main.rs b/crates/cdk-cli/src/main.rs index ab4f0cbf..860bbd92 100644 --- a/crates/cdk-cli/src/main.rs +++ b/crates/cdk-cli/src/main.rs @@ -54,6 +54,8 @@ enum Commands { MintInfo(sub_commands::mint_info::MintInfoSubcommand), /// Mint proofs via bolt11 Mint(sub_commands::mint::MintSubCommand), + /// Burn Spent tokens + Burn(sub_commands::burn::BurnSubCommand), /// Restore proofs from seed Restore(sub_commands::restore::RestoreSubCommand), } @@ -113,6 +115,9 @@ async fn main() -> Result<()> { Commands::Mint(sub_command_args) => { sub_commands::mint::mint(wallet, sub_command_args).await } + Commands::Burn(sub_command_args) => { + sub_commands::burn::burn(wallet, sub_command_args).await + } Commands::Restore(sub_command_args) => { sub_commands::restore::restore(wallet, sub_command_args).await } diff --git a/crates/cdk-cli/src/sub_commands/burn.rs b/crates/cdk-cli/src/sub_commands/burn.rs new file mode 100644 index 00000000..04463920 --- /dev/null +++ b/crates/cdk-cli/src/sub_commands/burn.rs @@ -0,0 +1,19 @@ +use anyhow::Result; +use cdk::wallet::Wallet; +use clap::Args; + +#[derive(Args)] +pub struct BurnSubCommand { + /// Token Memo + #[arg(short, long)] + mint_url: Option, +} + +pub async fn burn(wallet: Wallet, sub_command_args: &BurnSubCommand) -> Result<()> { + let amount_burnt = wallet + .check_all_pending_proofs(sub_command_args.mint_url.clone().map(|u| u.into())) + .await?; + + println!("{amount_burnt} burned"); + Ok(()) +} diff --git a/crates/cdk-cli/src/sub_commands/mod.rs b/crates/cdk-cli/src/sub_commands/mod.rs index 6255c9ba..1d8ac28c 100644 --- a/crates/cdk-cli/src/sub_commands/mod.rs +++ b/crates/cdk-cli/src/sub_commands/mod.rs @@ -1,4 +1,5 @@ pub mod balance; +pub mod burn; pub mod check_spent; pub mod decode_token; pub mod melt;