feat: Add optional redb feature flag for database support

This commit is contained in:
thesimplekid (aider)
2025-03-24 22:28:54 +00:00
committed by thesimplekid
parent 9b87a65940
commit 7a9faec984
3 changed files with 15 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ use bip39::Mnemonic;
use cdk::cdk_database;
use cdk::cdk_database::WalletDatabase;
use cdk::wallet::{HttpClient, MultiMintWallet, Wallet, WalletBuilder};
#[cfg(feature = "redb")]
use cdk_redb::WalletRedbDatabase;
use cdk_sqlite::WalletSqliteDatabase;
use clap::{Parser, Subcommand};
@@ -132,9 +133,15 @@ async fn main() -> Result<()> {
Arc::new(sql)
}
"redb" => {
let redb_path = work_dir.join("cdk-cli.redb");
Arc::new(WalletRedbDatabase::new(&redb_path)?)
#[cfg(feature = "redb")]
{
let redb_path = work_dir.join("cdk-cli.redb");
Arc::new(WalletRedbDatabase::new(&redb_path)?)
}
#[cfg(not(feature = "redb"))]
{
bail!("redb feature not enabled");
}
}
_ => bail!("Unknown DB engine"),
};