mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-23 07:35:03 +01:00
feat(cli): burn
This commit is contained in:
@@ -54,6 +54,8 @@ enum Commands {
|
|||||||
MintInfo(sub_commands::mint_info::MintInfoSubcommand),
|
MintInfo(sub_commands::mint_info::MintInfoSubcommand),
|
||||||
/// Mint proofs via bolt11
|
/// Mint proofs via bolt11
|
||||||
Mint(sub_commands::mint::MintSubCommand),
|
Mint(sub_commands::mint::MintSubCommand),
|
||||||
|
/// Burn Spent tokens
|
||||||
|
Burn(sub_commands::burn::BurnSubCommand),
|
||||||
/// Restore proofs from seed
|
/// Restore proofs from seed
|
||||||
Restore(sub_commands::restore::RestoreSubCommand),
|
Restore(sub_commands::restore::RestoreSubCommand),
|
||||||
}
|
}
|
||||||
@@ -113,6 +115,9 @@ async fn main() -> Result<()> {
|
|||||||
Commands::Mint(sub_command_args) => {
|
Commands::Mint(sub_command_args) => {
|
||||||
sub_commands::mint::mint(wallet, sub_command_args).await
|
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) => {
|
Commands::Restore(sub_command_args) => {
|
||||||
sub_commands::restore::restore(wallet, sub_command_args).await
|
sub_commands::restore::restore(wallet, sub_command_args).await
|
||||||
}
|
}
|
||||||
|
|||||||
19
crates/cdk-cli/src/sub_commands/burn.rs
Normal file
19
crates/cdk-cli/src/sub_commands/burn.rs
Normal file
@@ -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<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
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(())
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
pub mod balance;
|
pub mod balance;
|
||||||
|
pub mod burn;
|
||||||
pub mod check_spent;
|
pub mod check_spent;
|
||||||
pub mod decode_token;
|
pub mod decode_token;
|
||||||
pub mod melt;
|
pub mod melt;
|
||||||
|
|||||||
Reference in New Issue
Block a user