mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-22 23:25:22 +01:00
@@ -7,6 +7,7 @@ use anyhow::{bail, Result};
|
||||
use bip39::Mnemonic;
|
||||
use cdk::cdk_database;
|
||||
use cdk::cdk_database::WalletDatabase;
|
||||
use cdk::wallet::client::HttpClient;
|
||||
use cdk::wallet::{MultiMintWallet, Wallet};
|
||||
use cdk_redb::WalletRedbDatabase;
|
||||
use cdk_sqlite::WalletSqliteDatabase;
|
||||
@@ -14,6 +15,7 @@ use clap::{Parser, Subcommand};
|
||||
use rand::Rng;
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use url::Url;
|
||||
|
||||
mod sub_commands;
|
||||
|
||||
@@ -35,6 +37,9 @@ struct Cli {
|
||||
/// Logging level
|
||||
#[arg(short, long, default_value = "error")]
|
||||
log_level: Level,
|
||||
/// NWS Proxy
|
||||
#[arg(short, long)]
|
||||
proxy: Option<Url>,
|
||||
#[command(subcommand)]
|
||||
command: Commands,
|
||||
}
|
||||
@@ -130,13 +135,16 @@ async fn main() -> Result<()> {
|
||||
let mints = localstore.get_mints().await?;
|
||||
|
||||
for (mint, _) in mints {
|
||||
let wallet = Wallet::new(
|
||||
let mut wallet = Wallet::new(
|
||||
&mint.to_string(),
|
||||
cdk::nuts::CurrencyUnit::Sat,
|
||||
localstore.clone(),
|
||||
&mnemonic.to_seed_normalized(""),
|
||||
None,
|
||||
);
|
||||
if let Some(proxy_url) = args.proxy.as_ref() {
|
||||
wallet.set_client(HttpClient::with_proxy(proxy_url.clone(), None, true)?);
|
||||
}
|
||||
|
||||
wallets.push(wallet);
|
||||
}
|
||||
@@ -167,7 +175,7 @@ async fn main() -> Result<()> {
|
||||
sub_commands::check_spent::check_spent(&multi_mint_wallet).await
|
||||
}
|
||||
Commands::MintInfo(sub_command_args) => {
|
||||
sub_commands::mint_info::mint_info(sub_command_args).await
|
||||
sub_commands::mint_info::mint_info(args.proxy, sub_command_args).await
|
||||
}
|
||||
Commands::Mint(sub_command_args) => {
|
||||
sub_commands::mint::mint(
|
||||
|
||||
@@ -2,6 +2,7 @@ use anyhow::Result;
|
||||
use cdk::url::UncheckedUrl;
|
||||
use cdk::HttpClient;
|
||||
use clap::Args;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct MintInfoSubcommand {
|
||||
@@ -9,8 +10,11 @@ pub struct MintInfoSubcommand {
|
||||
mint_url: UncheckedUrl,
|
||||
}
|
||||
|
||||
pub async fn mint_info(sub_command_args: &MintInfoSubcommand) -> Result<()> {
|
||||
let client = HttpClient::default();
|
||||
pub async fn mint_info(proxy: Option<Url>, sub_command_args: &MintInfoSubcommand) -> Result<()> {
|
||||
let client = match proxy {
|
||||
Some(proxy) => HttpClient::with_proxy(proxy, None, true)?,
|
||||
None => HttpClient::new(),
|
||||
};
|
||||
|
||||
let info = client
|
||||
.get_mint_info(sub_command_args.mint_url.clone().try_into()?)
|
||||
|
||||
Reference in New Issue
Block a user