Skip to content

Commit 434460f

Browse files
refactor(key-wallet)!: remove MnemonicWithPassphrase wallet type
Drops the entire passphrase-as-callback feature: callers can no longer construct a wallet that retains a mnemonic and applies a BIP39 passphrase on-demand. Removed across the workspace: - `WalletType::MnemonicWithPassphrase` variant + Zeroize arm - `Wallet::from_mnemonic_with_passphrase` constructor - `add_account_with_passphrase`, `add_bls_account_with_passphrase`, `add_eddsa_account_with_passphrase` on `Wallet` - `derive_extended_private_key_with_passphrase`, `create_accounts_with_passphrase_from_options`, `create_special_purpose_accounts_with_passphrase`, `needs_passphrase`, and `root_extended_priv_key_with_callback` helpers - `add_managed_*_with_passphrase` on `ManagedAccountOperations` - `passphrase` parameter from `WalletManager::create_wallet_from_mnemonic` and `create_wallet_from_mnemonic_return_serialized_bytes` - `passphrase` parameter from FFI `wallet_create_from_mnemonic*`, `wallet_manager_add_wallet_from_mnemonic*`, `wallet_manager_add_wallet_from_mnemonic_return_serialized_bytes` - All passphrase-only tests (`test_wallet_with_passphrase`, `test_passphrase_edge_cases`, the `passphrase_test` module, FFI `test_passphrase_wallets.rs`, etc.) Breaking change: serialized wallets containing the `MnemonicWithPassphrase` variant can no longer be deserialized, and the FFI `passphrase` parameter is gone — callers must update their code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 49c8c6d commit 434460f

44 files changed

Lines changed: 57 additions & 1750 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dash-spv-ffi/src/bin/ffi_cli.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ fn main() {
537537
let success = wallet_manager_add_wallet_from_mnemonic(
538538
wallet_manager as *mut _,
539539
mnemonic_c.as_ptr(),
540-
ptr::null(), // no passphrase
541540
&mut error,
542541
);
543542

dash-spv-ffi/tests/dashd_sync/context.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,10 @@ impl FFITestContext {
169169
/// Calls FFI wallet functions through raw pointers held by the context.
170170
pub(super) unsafe fn add_wallet(&self, mnemonic: &str) -> Vec<u8> {
171171
let mnemonic_c = CString::new(mnemonic).unwrap();
172-
let passphrase = CString::new("").unwrap();
173172
let mut error = FFIError::default();
174173
let wm = self.session.wallet_manager as *mut FFIWalletManager;
175174

176-
let success = wallet_manager_add_wallet_from_mnemonic(
177-
wm,
178-
mnemonic_c.as_ptr(),
179-
passphrase.as_ptr(),
180-
&mut error,
181-
);
175+
let success = wallet_manager_add_wallet_from_mnemonic(wm, mnemonic_c.as_ptr(), &mut error);
182176
if !success {
183177
let error_msg = if !error.message.is_null() {
184178
CStr::from_ptr(error.message).to_str().unwrap_or("Unknown error")

dash-spv-ffi/tests/test_wallet_manager.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ mod tests {
7979
let (serialized_wallet, expected_wallet_id) = native_manager
8080
.create_wallet_from_mnemonic_return_serialized_bytes(
8181
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
82-
"",
8382
0,
8483
WalletAccountCreationOptions::Default,
8584
false,

dash-spv/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
292292
let mut wallet_manager = WalletManager::<ManagedWalletInfo>::new(config.network);
293293
wallet_manager.create_wallet_from_mnemonic(
294294
mnemonic_phrase.as_str(),
295-
"",
296295
0,
297296
key_wallet::wallet::initialization::WalletAccountCreationOptions::default(),
298297
)?;

dash-spv/tests/dashd_sync/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ pub(super) fn create_test_wallet(
372372
) -> (Arc<RwLock<WalletManager<ManagedWalletInfo>>>, WalletId) {
373373
let mut wallet_manager = WalletManager::<ManagedWalletInfo>::new(network);
374374
let wallet_id = wallet_manager
375-
.create_wallet_from_mnemonic(mnemonic, "", 0, test_account_options())
375+
.create_wallet_from_mnemonic(mnemonic, 0, test_account_options())
376376
.expect("Failed to create wallet from mnemonic");
377377
(Arc::new(RwLock::new(wallet_manager)), wallet_id)
378378
}

dash-spv/tests/dashd_sync/tests_multi_wallet.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async fn test_wallet_added_at_runtime_catches_up() {
8484
let w1_id = {
8585
let mut wallet_guard = client_handle.client.wallet().write().await;
8686
wallet_guard
87-
.create_wallet_from_mnemonic(&ctx.dashd.wallet.mnemonic, "", 0, test_account_options())
87+
.create_wallet_from_mnemonic(&ctx.dashd.wallet.mnemonic, 0, test_account_options())
8888
.expect("add pre-funded W1 at runtime")
8989
};
9090
wait_for_wallet_synced(client_handle.client.wallet(), &w1_id, initial_height).await;
@@ -115,7 +115,7 @@ async fn test_wallet_added_at_runtime_catches_up() {
115115
let w2_id = {
116116
let mut wallet_guard = client_handle.client.wallet().write().await;
117117
wallet_guard
118-
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, "", initial_height, test_account_options())
118+
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, initial_height, test_account_options())
119119
.expect("add W2 at runtime")
120120
};
121121

@@ -167,12 +167,7 @@ async fn test_wallet_added_at_runtime_catches_up() {
167167
let w3_id = {
168168
let mut wallet_guard = client_handle.client.wallet().write().await;
169169
wallet_guard
170-
.create_wallet_from_mnemonic(
171-
SECONDARY_MNEMONIC,
172-
"",
173-
future_height,
174-
test_account_options(),
175-
)
170+
.create_wallet_from_mnemonic(SECONDARY_MNEMONIC, future_height, test_account_options())
176171
.expect("add W3 at runtime")
177172
};
178173

@@ -278,18 +273,13 @@ async fn test_runtime_add_shared_block_two_wallets() {
278273
let w1_id = {
279274
let mut wallet_guard = client_handle.client.wallet().write().await;
280275
wallet_guard
281-
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, "", initial_height, test_account_options())
276+
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, initial_height, test_account_options())
282277
.expect("add W1 at runtime")
283278
};
284279
let w2_id = {
285280
let mut wallet_guard = client_handle.client.wallet().write().await;
286281
wallet_guard
287-
.create_wallet_from_mnemonic(
288-
SECONDARY_MNEMONIC,
289-
"",
290-
initial_height,
291-
test_account_options(),
292-
)
282+
.create_wallet_from_mnemonic(SECONDARY_MNEMONIC, initial_height, test_account_options())
293283
.expect("add W2 at runtime")
294284
};
295285

@@ -371,7 +361,7 @@ async fn test_runtime_add_during_initial_sync() {
371361
let w1_id = {
372362
let mut wallet_guard = wallet.write().await;
373363
wallet_guard
374-
.create_wallet_from_mnemonic(&ctx.dashd.wallet.mnemonic, "", 0, test_account_options())
364+
.create_wallet_from_mnemonic(&ctx.dashd.wallet.mnemonic, 0, test_account_options())
375365
.expect("add W1 before start")
376366
};
377367

@@ -423,7 +413,7 @@ async fn test_runtime_add_during_initial_sync() {
423413
let w2_id = {
424414
let mut wallet_guard = client_handle.client.wallet().write().await;
425415
wallet_guard
426-
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, "", 0, test_account_options())
416+
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, 0, test_account_options())
427417
.expect("add W2 mid-flight")
428418
};
429419

@@ -506,7 +496,7 @@ async fn test_runtime_add_with_tip_advance_during_rescan() {
506496
let w2_id = {
507497
let mut wallet_guard = client_handle.client.wallet().write().await;
508498
wallet_guard
509-
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, "", 0, test_account_options())
499+
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, 0, test_account_options())
510500
.expect("add W2 at runtime")
511501
};
512502

key-wallet-ffi/examples/check_transaction.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ typedef struct {
3535
// External function declarations
3636
extern void* wallet_create_from_mnemonic(
3737
const char* mnemonic,
38-
const char* passphrase,
3938
FFINetwork network,
4039
FFIError* error
4140
);
@@ -64,7 +63,7 @@ int main() {
6463
FFINetwork network = Testnet;
6564

6665
// Create wallet
67-
void* wallet = wallet_create_from_mnemonic(mnemonic, NULL, network, &error);
66+
void* wallet = wallet_create_from_mnemonic(mnemonic, network, &error);
6867
if (!wallet) {
6968
printf("Failed to create wallet: %s\n", error.message);
7069
return 1;

key-wallet-ffi/src/account_collection.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,6 @@ mod tests {
10701070
// Create wallet with default accounts
10711071
let wallet = wallet_create_from_mnemonic_with_options(
10721072
mnemonic.as_ptr(),
1073-
ptr::null(),
10741073
FFINetwork::Testnet,
10751074
ptr::null(),
10761075
error,
@@ -1125,7 +1124,6 @@ mod tests {
11251124

11261125
let wallet = wallet_create_from_mnemonic_with_options(
11271126
mnemonic.as_ptr(),
1128-
ptr::null(),
11291127
FFINetwork::Testnet,
11301128
&options,
11311129
error,
@@ -1172,7 +1170,6 @@ mod tests {
11721170

11731171
let wallet = wallet_create_from_mnemonic_with_options(
11741172
mnemonic.as_ptr(),
1175-
ptr::null(),
11761173
FFINetwork::Testnet,
11771174
&options,
11781175
error,
@@ -1243,7 +1240,6 @@ mod tests {
12431240

12441241
let wallet = wallet_create_from_mnemonic_with_options(
12451242
mnemonic.as_ptr(),
1246-
ptr::null(),
12471243
FFINetwork::Testnet,
12481244
&options,
12491245
error,
@@ -1296,7 +1292,6 @@ mod tests {
12961292

12971293
let wallet = wallet_create_from_mnemonic_with_options(
12981294
mnemonic.as_ptr(),
1299-
ptr::null(),
13001295
FFINetwork::Testnet,
13011296
&options,
13021297
error,
@@ -1381,7 +1376,6 @@ mod tests {
13811376

13821377
let wallet = wallet_create_from_mnemonic_with_options(
13831378
mnemonic.as_ptr(),
1384-
ptr::null(),
13851379
FFINetwork::Testnet,
13861380
&options,
13871381
error,
@@ -1468,7 +1462,6 @@ mod tests {
14681462

14691463
let wallet = wallet_create_from_mnemonic_with_options(
14701464
mnemonic.as_ptr(),
1471-
ptr::null(),
14721465
FFINetwork::Testnet,
14731466
&options,
14741467
error,
@@ -1539,7 +1532,6 @@ mod tests {
15391532
// Create wallet with default accounts (which should have at least BIP44 account 0)
15401533
let wallet = wallet_create_from_mnemonic_with_options(
15411534
mnemonic.as_ptr(),
1542-
ptr::null(),
15431535
FFINetwork::Testnet,
15441536
ptr::null(),
15451537
error,

key-wallet-ffi/src/account_derivation_tests.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ mod tests {
2323

2424
// Create wallet on testnet with default accounts
2525
let wallet = unsafe {
26-
wallet::wallet_create_from_mnemonic(
27-
mnemonic.as_ptr(),
28-
passphrase.as_ptr(),
29-
FFINetwork::Testnet,
30-
&mut error,
31-
)
26+
wallet::wallet_create_from_mnemonic(mnemonic.as_ptr(), FFINetwork::Testnet, &mut error)
3227
};
3328
assert!(!wallet.is_null());
3429
assert_eq!(error.code, FFIErrorCode::Success);
@@ -122,12 +117,7 @@ mod tests {
122117

123118
// Create wallet on testnet with default accounts
124119
let wallet = unsafe {
125-
wallet::wallet_create_from_mnemonic(
126-
mnemonic.as_ptr(),
127-
passphrase.as_ptr(),
128-
FFINetwork::Testnet,
129-
&mut error,
130-
)
120+
wallet::wallet_create_from_mnemonic(mnemonic.as_ptr(), FFINetwork::Testnet, &mut error)
131121
};
132122
assert!(!wallet.is_null());
133123

@@ -177,12 +167,7 @@ mod tests {
177167

178168
// Create wallet and get account 0
179169
let wallet = unsafe {
180-
wallet::wallet_create_from_mnemonic(
181-
mnemonic.as_ptr(),
182-
passphrase.as_ptr(),
183-
FFINetwork::Testnet,
184-
&mut error,
185-
)
170+
wallet::wallet_create_from_mnemonic(mnemonic.as_ptr(), FFINetwork::Testnet, &mut error)
186171
};
187172
assert!(!wallet.is_null());
188173
let account = unsafe {

key-wallet-ffi/src/account_tests.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,9 @@ mod tests {
3030

3131
// Create a wallet with default accounts
3232
let mnemonic = CString::new("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about").unwrap();
33-
let passphrase = CString::new("").unwrap();
3433

3534
let wallet = unsafe {
36-
wallet::wallet_create_from_mnemonic(
37-
mnemonic.as_ptr(),
38-
passphrase.as_ptr(),
39-
FFINetwork::Testnet,
40-
&mut error,
41-
)
35+
wallet::wallet_create_from_mnemonic(mnemonic.as_ptr(), FFINetwork::Testnet, &mut error)
4236
};
4337

4438
// Try to get the default account (should exist)
@@ -84,15 +78,9 @@ mod tests {
8478

8579
// Create a wallet
8680
let mnemonic = CString::new("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about").unwrap();
87-
let passphrase = CString::new("").unwrap();
8881

8982
let wallet = unsafe {
90-
wallet::wallet_create_from_mnemonic(
91-
mnemonic.as_ptr(),
92-
passphrase.as_ptr(),
93-
FFINetwork::Testnet,
94-
&mut error,
95-
)
83+
wallet::wallet_create_from_mnemonic(mnemonic.as_ptr(), FFINetwork::Testnet, &mut error)
9684
};
9785

9886
let count = unsafe { wallet_get_account_count(wallet, &mut error) };
@@ -129,15 +117,9 @@ mod tests {
129117

130118
// Create a wallet
131119
let mnemonic = CString::new("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about").unwrap();
132-
let passphrase = CString::new("").unwrap();
133120

134121
let wallet = unsafe {
135-
wallet::wallet_create_from_mnemonic(
136-
mnemonic.as_ptr(),
137-
passphrase.as_ptr(),
138-
FFINetwork::Testnet,
139-
&mut error,
140-
)
122+
wallet::wallet_create_from_mnemonic(mnemonic.as_ptr(), FFINetwork::Testnet, &mut error)
141123
};
142124

143125
assert!(!wallet.is_null());

0 commit comments

Comments
 (0)