Skip to content

Commit b42db7c

Browse files
Copilot0xrinegade
andcommitted
Update wallet storage to use ~/.config/svmai/ instead of home directory
Co-authored-by: 0xrinegade <[email protected]>
1 parent 8c5c1ec commit b42db7c

File tree

2 files changed

+71
-4
lines changed

2 files changed

+71
-4
lines changed

CONFIG_PATH_UPDATE.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Configuration Path Update
2+
3+
## Change Summary
4+
5+
Updated the wallet storage location to use `~/.config/svmai/` directory instead of storing directly in the home directory.
6+
7+
## Before
8+
9+
**Storage Location:** `~/.svmai_wallets.json`
10+
- Wallet data stored directly in home directory
11+
- Hidden file (prefixed with `.`)
12+
13+
## After
14+
15+
**Storage Location:** `~/.config/svmai/wallets.json`
16+
- Follows XDG Base Directory specification
17+
- Organized in dedicated config directory
18+
- Separate from Solana's config directory (`~/.config/solana/`)
19+
20+
## Changes Made
21+
22+
### File: `src/secure_storage.rs`
23+
24+
1. **Updated Constants:**
25+
```rust
26+
// Before
27+
pub const CONFIG_FILE_NAME: &str = ".svmai_wallets.json";
28+
29+
// After
30+
pub const CONFIG_FILE_NAME: &str = "wallets.json";
31+
pub const CONFIG_DIR_NAME: &str = "svmai";
32+
```
33+
34+
2. **Updated `get_config_path()` Function:**
35+
```rust
36+
// Before
37+
dirs::home_dir()
38+
.map(|home| home.join(CONFIG_FILE_NAME))
39+
40+
// After
41+
dirs::config_dir()
42+
.map(|config_dir| config_dir.join(CONFIG_DIR_NAME).join(CONFIG_FILE_NAME))
43+
```
44+
45+
## Benefits
46+
47+
1. **No Conflict with Solana:** Ensures svmai doesn't touch `~/.config/solana/` directory
48+
2. **Better Organization:** Follows standard config directory conventions
49+
3. **Platform Support:** Uses `dirs::config_dir()` which maps to:
50+
- Linux: `~/.config/svmai/`
51+
- macOS: `~/Library/Application Support/svmai/`
52+
- Windows: `%APPDATA%\svmai\`
53+
54+
## Migration Note
55+
56+
Existing users with wallets in `~/.svmai_wallets.json` will need to manually move their encrypted wallet data to the new location if they want to preserve their wallets. The application will create a fresh wallet store in the new location.
57+
58+
## Verification
59+
60+
Build and test completed successfully:
61+
- ✅ Application compiles without errors
62+
- ✅ Config path uses `~/.config/svmai/wallets.json`
63+
- ✅ No interaction with `~/.config/solana/` directory
64+
- ✅ Backward compatibility maintained through environment variable override for tests
65+

src/secure_storage.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use std::io::{self, Read, Write};
1616
use std::path::PathBuf;
1717
// --- Constants ---
1818
pub const KEYCHAIN_MASTER_KEY_ACCOUNT_NAME: &str = "svmai_master_encryption_key";
19-
pub const CONFIG_FILE_NAME: &str = ".svmai_wallets.json";
19+
pub const CONFIG_FILE_NAME: &str = "wallets.json";
20+
pub const CONFIG_DIR_NAME: &str = "svmai";
2021
const AES_KEY_SIZE: usize = 32; // 256 bits
2122
const NONCE_SIZE: usize = 12; // 96 bits
2223

@@ -224,14 +225,15 @@ pub fn get_config_path() -> Result<PathBuf, SecureStorageError> {
224225
return Ok(PathBuf::from(test_path));
225226
}
226227

227-
dirs::home_dir()
228+
// Use ~/.config/svmai/ directory for storing wallet data
229+
dirs::config_dir()
228230
.ok_or_else(|| {
229231
SecureStorageError::IoError(io::Error::new(
230232
io::ErrorKind::NotFound,
231-
"Home directory not found",
233+
"Config directory not found",
232234
))
233235
})
234-
.map(|home| home.join(CONFIG_FILE_NAME))
236+
.map(|config_dir| config_dir.join(CONFIG_DIR_NAME).join(CONFIG_FILE_NAME))
235237
}
236238

237239
// --- Core Secure Storage Functions (Now with Encryption) ---

0 commit comments

Comments
 (0)