Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ pub fn cli_create_wallet(
validate_wallet_availability(Some(&label), None, WalletValidationMode::Label)?;

let passphrase = prompt_passphrase(true)?;
let (address, mnemonic) = create_encrypted_wallet(network, label, purpose, passphrase)?;
let (address, mnemonic, wallet_file_path) =
create_encrypted_wallet(network, label, purpose, passphrase)?;

let _ = crossterm::terminal::enable_raw_mode();
print!("\r\n");
Expand All @@ -73,6 +74,13 @@ pub fn cli_create_wallet(
"SUCCESS".bold(),
address.address_with_prefix()
);

print!(
"{} Wallet file saved to: {}\r\n",
"INFO".bold(),
wallet_file_path.display()
);

if purpose == Purpose::Deposit {
print!(
"{} Please do not send funds directly to this address!\r\n",
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn create_encrypted_wallet(
label: String,
purpose: Purpose,
passphrase: SecureString,
) -> Result<(TaprootAddressWithPrefix<NetworkChecked>, Mnemonic), BridgeCliError> {
) -> Result<(TaprootAddressWithPrefix<NetworkChecked>, Mnemonic, PathBuf), BridgeCliError> {
// Generate mnemonic
let mnemonic = generate_mnemonic()?;

Expand All @@ -97,7 +97,7 @@ pub fn create_encrypted_wallet(
let encrypted_private_key = aes_encrypt_secure(&master_private_key_secure, &passphrase)?;

// Store encrypted wallet with separate encrypted fields
wallet_storage::store_wallet_data(
let wallet_file_path = wallet_storage::store_wallet_data(
&address,
network,
&encrypted_mnemonic,
Expand All @@ -107,7 +107,7 @@ pub fn create_encrypted_wallet(
&label,
)?;

Ok((address, mnemonic))
Ok((address, mnemonic, wallet_file_path))
}

/// Backup a wallet file to a specified destination
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/wallet_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub(crate) fn store_wallet_data(
imported: bool,
import_method: Option<&str>,
label: &str,
) -> Result<(), BridgeCliError> {
) -> Result<PathBuf, BridgeCliError> {
validate_wallet_availability(Some(label), Some(address), WalletValidationMode::Both)?;

let wallet_data = GenericWalletData {
Expand Down Expand Up @@ -125,7 +125,7 @@ pub(crate) fn store_wallet_data(
// Update wallets registry
update_wallets_registry(label, address, network, imported, import_method)?;

Ok(())
Ok(wallet_file)
}

/// Update the wallets.json registry
Expand Down
Loading