Skip to content

Commit

Permalink
lock issue on wallet creation
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder83singh committed Aug 10, 2024
1 parent 37f11d0 commit 752489c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli/src/modules/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Wallet {

let wallet_name = wallet_name.as_deref();
let import_with_mnemonic = op.as_str() == "import";
wizards::wallet::create(&ctx, wallet_name, import_with_mnemonic).await?;
wizards::wallet::create(&ctx, guard.into(), wallet_name, import_with_mnemonic).await?;
}
"open" => {
let name = if let Some(name) = argv.first().cloned() {
Expand Down
22 changes: 16 additions & 6 deletions cli/src/wizards/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@ use crate::cli::KaspaCli;
use crate::imports::*;
use crate::result::Result;
use kaspa_bip32::{Language, Mnemonic, WordCount};
use kaspa_wallet_core::storage::{make_filename, Hint};

pub(crate) async fn create(ctx: &Arc<KaspaCli>, name: Option<&str>, import_with_mnemonic: bool) -> Result<()> {
use kaspa_wallet_core::{
storage::{make_filename, Hint},
wallet::WalletGuard,
};

pub(crate) async fn create(
ctx: &Arc<KaspaCli>,
wallet_guard: Option<WalletGuard<'_>>,
name: Option<&str>,
import_with_mnemonic: bool,
) -> Result<()> {
let term = ctx.term();
let wallet = ctx.wallet();
let local_guard = ctx.wallet().guard();

let guard = ctx.wallet().guard();
let guard = guard.lock().await;

let guard = match wallet_guard {
Some(locked_guard) => locked_guard,
None => local_guard.lock().await,
};
// TODO @aspect
let word_count = WordCount::Words12;

Expand Down

0 comments on commit 752489c

Please sign in to comment.