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