mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-23 07:35:03 +01:00
refactor: rename melt to pay
This commit is contained in:
@@ -22,13 +22,13 @@ const DEFAULT_WORK_DIR: &str = ".cdk-cli";
|
|||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(name = "cashu-tool")]
|
#[command(name = "cashu-tool")]
|
||||||
#[command(author = "thesimplekid <tsk@thesimplekid.com>")]
|
#[command(author = "thesimplekid <tsk@thesimplekid.com>")]
|
||||||
#[command(version = "0.1")]
|
#[command(version = "0.1.0")]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Database engine to use (sqlite/redb)
|
/// Database engine to use (sqlite/redb)
|
||||||
#[arg(short, long, default_value = "sqlite")]
|
#[arg(short, long, default_value = "sqlite")]
|
||||||
engine: String,
|
engine: String,
|
||||||
/// Path to Seed
|
/// Path to working dir
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
work_dir: Option<PathBuf>,
|
work_dir: Option<PathBuf>,
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
@@ -42,9 +42,9 @@ enum Commands {
|
|||||||
/// Balance
|
/// Balance
|
||||||
Balance,
|
Balance,
|
||||||
/// Pay bolt11 invoice
|
/// Pay bolt11 invoice
|
||||||
Melt(sub_commands::melt::MeltSubCommand),
|
Pay,
|
||||||
/// Claim pending mints
|
/// Claim pending mint quotes that have been paid
|
||||||
PendingMint,
|
MintPending,
|
||||||
/// Receive token
|
/// Receive token
|
||||||
Receive(sub_commands::receive::ReceiveSubCommand),
|
Receive(sub_commands::receive::ReceiveSubCommand),
|
||||||
/// Send
|
/// Send
|
||||||
@@ -138,9 +138,7 @@ async fn main() -> Result<()> {
|
|||||||
sub_commands::decode_token::decode_token(sub_command_args)
|
sub_commands::decode_token::decode_token(sub_command_args)
|
||||||
}
|
}
|
||||||
Commands::Balance => sub_commands::balance::balance(wallets).await,
|
Commands::Balance => sub_commands::balance::balance(wallets).await,
|
||||||
Commands::Melt(sub_command_args) => {
|
Commands::Pay => sub_commands::melt::pay(wallets).await,
|
||||||
sub_commands::melt::melt(wallets, sub_command_args).await
|
|
||||||
}
|
|
||||||
Commands::Receive(sub_command_args) => {
|
Commands::Receive(sub_command_args) => {
|
||||||
sub_commands::receive::receive(
|
sub_commands::receive::receive(
|
||||||
wallets,
|
wallets,
|
||||||
@@ -166,7 +164,7 @@ async fn main() -> Result<()> {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
Commands::PendingMint => sub_commands::pending_mints::pending_mints(wallets).await,
|
Commands::MintPending => sub_commands::pending_mints::mint_pending(wallets).await,
|
||||||
Commands::Burn(sub_command_args) => {
|
Commands::Burn(sub_command_args) => {
|
||||||
sub_commands::burn::burn(wallets, sub_command_args).await
|
sub_commands::burn::burn(wallets, sub_command_args).await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,17 +7,10 @@ use anyhow::{bail, Result};
|
|||||||
use cdk::amount::SplitTarget;
|
use cdk::amount::SplitTarget;
|
||||||
use cdk::wallet::Wallet;
|
use cdk::wallet::Wallet;
|
||||||
use cdk::{Bolt11Invoice, UncheckedUrl};
|
use cdk::{Bolt11Invoice, UncheckedUrl};
|
||||||
use clap::Args;
|
|
||||||
|
|
||||||
use crate::sub_commands::balance::mint_balances;
|
use crate::sub_commands::balance::mint_balances;
|
||||||
|
|
||||||
#[derive(Args)]
|
pub async fn pay(wallets: HashMap<UncheckedUrl, Wallet>) -> Result<()> {
|
||||||
pub struct MeltSubCommand {}
|
|
||||||
|
|
||||||
pub async fn melt(
|
|
||||||
wallets: HashMap<UncheckedUrl, Wallet>,
|
|
||||||
_sub_command_args: &MeltSubCommand,
|
|
||||||
) -> Result<()> {
|
|
||||||
let mints_amounts = mint_balances(wallets).await?;
|
let mints_amounts = mint_balances(wallets).await?;
|
||||||
|
|
||||||
println!("Enter mint number to melt from");
|
println!("Enter mint number to melt from");
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ pub struct MintSubCommand {
|
|||||||
/// Amount
|
/// Amount
|
||||||
amount: u64,
|
amount: u64,
|
||||||
/// Currency unit e.g. sat
|
/// Currency unit e.g. sat
|
||||||
|
#[arg(default_value = "sat")]
|
||||||
unit: String,
|
unit: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use anyhow::Result;
|
|||||||
use cdk::wallet::Wallet;
|
use cdk::wallet::Wallet;
|
||||||
use cdk::{Amount, UncheckedUrl};
|
use cdk::{Amount, UncheckedUrl};
|
||||||
|
|
||||||
pub async fn pending_mints(wallets: HashMap<UncheckedUrl, Wallet>) -> Result<()> {
|
pub async fn mint_pending(wallets: HashMap<UncheckedUrl, Wallet>) -> Result<()> {
|
||||||
let mut amount_claimed = Amount::ZERO;
|
let mut amount_claimed = Amount::ZERO;
|
||||||
for wallet in wallets.values() {
|
for wallet in wallets.values() {
|
||||||
let claimed = wallet.check_all_mint_quotes().await?;
|
let claimed = wallet.check_all_mint_quotes().await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user