mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
further simplfied path retrieval
This commit is contained in:
@@ -49,7 +49,7 @@ impl ProgramState for State {
|
||||
fn is_valid_cashier_public_key(&self, _public: &jubjub::SubgroupPoint) -> bool {
|
||||
// TODO
|
||||
// Still needs to be tested
|
||||
//let path = WalletDB::wallet_path();
|
||||
let path = WalletDB::path("cashier.db");
|
||||
//let connect = Connection::open(&path).expect("Failed to connect to database.");
|
||||
//connect.execute(
|
||||
// " SELECT key_public FROM cashier WHERE key_public IN (SELECT key_public)",
|
||||
|
||||
@@ -12,55 +12,37 @@ impl RpcAdapter {
|
||||
Arc::new(Self {})
|
||||
}
|
||||
|
||||
pub async fn get_path(wallet: &str) -> Result<PathBuf> {
|
||||
debug!(target: "adapter", "TEST PATH [START]");
|
||||
let mut path = WalletDB::path().await.expect("Failed to get path");
|
||||
debug!(target: "adapter", "TEST PATH {:?}", path);
|
||||
path.push(wallet);
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
pub async fn key_gen() -> Result<PathBuf> {
|
||||
debug!(target: "adapter", "key_gen() [START]");
|
||||
let path = Self::get_path("wallet.db")
|
||||
.await
|
||||
.expect("Failed to get path");
|
||||
let path = WalletDB::path("wallet.db").await.expect("Failed to get path");
|
||||
//WalletDB::key_gen(path).await?;
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
pub async fn new_wallet() -> Result<()> {
|
||||
debug!(target: "adapter", "new_wallet() [START]");
|
||||
let path = Self::get_path("wallet.db")
|
||||
.await
|
||||
.expect("Failed to get path");
|
||||
let path = WalletDB::path("wallet.db").await.expect("Failed to get path");
|
||||
WalletDB::new(path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn new_cashier_wallet() -> Result<()> {
|
||||
debug!(target: "adapter", "new_cashier_wallet() [START]");
|
||||
let path = Self::get_path("cashier.db")
|
||||
.await
|
||||
.expect("Failed to get path");
|
||||
let path = WalletDB::path("cashier.db").await.expect("Failed to get path");
|
||||
WalletDB::new(path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn save_cash_key(pubkey: Vec<u8>) -> Result<()> {
|
||||
debug!(target: "adapter", "save_cash_key() [START]");
|
||||
let path = Self::get_path("cashier.db")
|
||||
.await
|
||||
.expect("Failed to get path");
|
||||
let path = WalletDB::path("cashier.db").await.expect("Failed to get path");
|
||||
WalletDB::save(path, pubkey).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn save_key(pubkey: Vec<u8>) -> Result<()> {
|
||||
debug!(target: "adapter", "save_key() [START]");
|
||||
let path = Self::get_path("wallet.db")
|
||||
.await
|
||||
.expect("Failed to get path");
|
||||
let path = WalletDB::path("wallet.db").await.expect("Failed to get path");
|
||||
WalletDB::save(path, pubkey).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@ impl WalletDB {
|
||||
// let privkey = serial::serialize(&secret);
|
||||
// Ok(pubkey, privkey)
|
||||
// }
|
||||
pub async fn path() -> Result<PathBuf> {
|
||||
let path = dirs::home_dir()
|
||||
pub async fn path(wallet: &str) -> Result<PathBuf> {
|
||||
let mut path = dirs::home_dir()
|
||||
.expect("cannot find home directory.")
|
||||
.as_path()
|
||||
.join(".config/darkfi/");
|
||||
debug!(target: "walletdb", "CREATE PATH {:?}", path);
|
||||
path.push(wallet);
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user