feat: Add support for sqlcipher

This commit is contained in:
benthecarman
2025-03-08 21:58:29 -06:00
parent b787951dbc
commit 40c53e83df
12 changed files with 93 additions and 1 deletions

View File

@@ -31,6 +31,10 @@ struct Cli {
/// Database engine to use (sqlite/redb)
#[arg(short, long, default_value = "sqlite")]
engine: String,
/// Database password for sqlcipher
#[cfg(feature = "sqlcipher")]
#[arg(long)]
password: Option<String>,
/// Path to working dir
#[arg(short, long)]
work_dir: Option<PathBuf>,
@@ -106,7 +110,15 @@ async fn main() -> Result<()> {
match args.engine.as_str() {
"sqlite" => {
let sql_path = work_dir.join("cdk-cli.sqlite");
#[cfg(not(feature = "sqlcipher"))]
let sql = WalletSqliteDatabase::new(&sql_path).await?;
#[cfg(feature = "sqlcipher")]
let sql = {
match args.password {
Some(pass) => WalletSqliteDatabase::new(&sql_path, pass).await?,
None => bail!("Missing database password"),
}
};
sql.migrate().await;