mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-20 14:14:49 +01:00
Mintd lib (#914)
* feat(cdk-integration-tests): refactor regtest setup and mintd integration - Replace shell-based regtest setup with Rust binary (start_regtest_mints) - Add cdk-mintd crate to workspace and integration tests - Improve environment variable handling for test configurations - Update integration tests to use proper temp directory management - Remove deprecated start_regtest.rs binary - Enhance CLN client connection with retry logic - Simplify regtest shell script (itests.sh) to use new binary - Fix tracing filters and improve error handling in setup - Update dependencies and configurations for integration tests fix: killing chore: comment tests for ci debugging chore: compile Revert "chore: comment tests for ci debugging" This reverts commit bfc594c11cf37caeaa6445cb854ae5567d2da6bd. * chore: sql cipher * fix: removal of sqlite cipher * fix: auth password * refactor(cdk-mintd): improve database password handling and function signatures - Pass database password as parameter instead of parsing CLI args in setup_database - Update function signatures for run_mintd and run_mintd_with_shutdown to accept db_password - Remove direct CLI parsing from database setup logic - Fix auth database initialization to use correct type when sqlcipher feature enabled
This commit is contained in:
@@ -14,11 +14,47 @@ use cdk_common::payment::{self, MintPayment};
|
||||
use cdk_common::Amount;
|
||||
#[cfg(feature = "fake")]
|
||||
use cdk_fake_wallet::FakeWallet;
|
||||
use clap::Parser;
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(any(feature = "cln", feature = "lnd", feature = "fake"))]
|
||||
use tokio::signal;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
/// Common CLI arguments for CDK binaries
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct CommonArgs {
|
||||
/// Enable logging (default is false)
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub enable_logging: bool,
|
||||
|
||||
/// Logging level when enabled (default is debug)
|
||||
#[arg(long, default_value = "debug")]
|
||||
pub log_level: tracing::Level,
|
||||
}
|
||||
|
||||
/// Initialize logging based on CLI arguments
|
||||
pub fn init_logging(enable_logging: bool, log_level: tracing::Level) {
|
||||
if enable_logging {
|
||||
let default_filter = log_level.to_string();
|
||||
|
||||
// Common filters to reduce noise
|
||||
let sqlx_filter = "sqlx=warn";
|
||||
let hyper_filter = "hyper=warn";
|
||||
let h2_filter = "h2=warn";
|
||||
let rustls_filter = "rustls=warn";
|
||||
let reqwest_filter = "reqwest=warn";
|
||||
|
||||
let env_filter = EnvFilter::new(format!(
|
||||
"{default_filter},{sqlx_filter},{hyper_filter},{h2_filter},{rustls_filter},{reqwest_filter}"
|
||||
));
|
||||
|
||||
// Ok if successful, Err if already initialized
|
||||
let _ = tracing_subscriber::fmt()
|
||||
.with_env_filter(env_filter)
|
||||
.try_init();
|
||||
}
|
||||
}
|
||||
|
||||
pub const ENV_LN_BACKEND: &str = "CDK_PAYMENT_PROCESSOR_LN_BACKEND";
|
||||
pub const ENV_LISTEN_HOST: &str = "CDK_PAYMENT_PROCESSOR_LISTEN_HOST";
|
||||
pub const ENV_LISTEN_PORT: &str = "CDK_PAYMENT_PROCESSOR_LISTEN_PORT";
|
||||
@@ -36,20 +72,20 @@ pub const ENV_LND_ADDRESS: &str = "CDK_PAYMENT_PROCESSOR_LND_ADDRESS";
|
||||
pub const ENV_LND_CERT_FILE: &str = "CDK_PAYMENT_PROCESSOR_LND_CERT_FILE";
|
||||
pub const ENV_LND_MACAROON_FILE: &str = "CDK_PAYMENT_PROCESSOR_LND_MACAROON_FILE";
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "payment-processor")]
|
||||
#[command(about = "CDK Payment Processor", long_about = None)]
|
||||
struct Args {
|
||||
#[command(flatten)]
|
||||
common: CommonArgs,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let default_filter = "debug";
|
||||
let args = Args::parse();
|
||||
|
||||
let sqlx_filter = "sqlx=warn";
|
||||
let hyper_filter = "hyper=warn";
|
||||
let h2_filter = "h2=warn";
|
||||
let rustls_filter = "rustls=warn";
|
||||
|
||||
let env_filter = EnvFilter::new(format!(
|
||||
"{default_filter},{sqlx_filter},{hyper_filter},{h2_filter},{rustls_filter}"
|
||||
));
|
||||
|
||||
tracing_subscriber::fmt().with_env_filter(env_filter).init();
|
||||
// Initialize logging based on CLI arguments
|
||||
init_logging(args.common.enable_logging, args.common.log_level);
|
||||
|
||||
#[cfg(any(feature = "cln", feature = "lnd", feature = "fake"))]
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user