Skip to content
Merged
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
1 change: 0 additions & 1 deletion dash-spv-ffi/src/bin/ffi_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ fn main() {
let success = wallet_manager_add_wallet_from_mnemonic(
wallet_manager as *mut _,
mnemonic_c.as_ptr(),
ptr::null(), // no passphrase
&mut error,
);

Expand Down
8 changes: 1 addition & 7 deletions dash-spv-ffi/tests/dashd_sync/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,10 @@ impl FFITestContext {
/// Calls FFI wallet functions through raw pointers held by the context.
pub(super) unsafe fn add_wallet(&self, mnemonic: &str) -> Vec<u8> {
let mnemonic_c = CString::new(mnemonic).unwrap();
let passphrase = CString::new("").unwrap();
let mut error = FFIError::default();
let wm = self.session.wallet_manager as *mut FFIWalletManager;

let success = wallet_manager_add_wallet_from_mnemonic(
wm,
mnemonic_c.as_ptr(),
passphrase.as_ptr(),
&mut error,
);
let success = wallet_manager_add_wallet_from_mnemonic(wm, mnemonic_c.as_ptr(), &mut error);
if !success {
let error_msg = if !error.message.is_null() {
CStr::from_ptr(error.message).to_str().unwrap_or("Unknown error")
Expand Down
1 change: 0 additions & 1 deletion dash-spv-ffi/tests/test_wallet_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ mod tests {
let (serialized_wallet, expected_wallet_id) = native_manager
.create_wallet_from_mnemonic_return_serialized_bytes(
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
"",
0,
WalletAccountCreationOptions::Default,
false,
Expand Down
1 change: 0 additions & 1 deletion dash-spv/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
let mut wallet_manager = WalletManager::<ManagedWalletInfo>::new(config.network);
wallet_manager.create_wallet_from_mnemonic(
mnemonic_phrase.as_str(),
"",
0,
key_wallet::wallet::initialization::WalletAccountCreationOptions::default(),
)?;
Expand Down
2 changes: 1 addition & 1 deletion dash-spv/tests/dashd_sync/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ pub(super) fn create_test_wallet(
) -> (Arc<RwLock<WalletManager<ManagedWalletInfo>>>, WalletId) {
let mut wallet_manager = WalletManager::<ManagedWalletInfo>::new(network);
let wallet_id = wallet_manager
.create_wallet_from_mnemonic(mnemonic, "", 0, test_account_options())
.create_wallet_from_mnemonic(mnemonic, 0, test_account_options())
.expect("Failed to create wallet from mnemonic");
(Arc::new(RwLock::new(wallet_manager)), wallet_id)
}
Expand Down
26 changes: 8 additions & 18 deletions dash-spv/tests/dashd_sync/tests_multi_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn test_wallet_added_at_runtime_catches_up() {
let w1_id = {
let mut wallet_guard = client_handle.client.wallet().write().await;
wallet_guard
.create_wallet_from_mnemonic(&ctx.dashd.wallet.mnemonic, "", 0, test_account_options())
.create_wallet_from_mnemonic(&ctx.dashd.wallet.mnemonic, 0, test_account_options())
.expect("add pre-funded W1 at runtime")
};
wait_for_wallet_synced(client_handle.client.wallet(), &w1_id, initial_height).await;
Expand Down Expand Up @@ -115,7 +115,7 @@ async fn test_wallet_added_at_runtime_catches_up() {
let w2_id = {
let mut wallet_guard = client_handle.client.wallet().write().await;
wallet_guard
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, "", initial_height, test_account_options())
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, initial_height, test_account_options())
.expect("add W2 at runtime")
};

Expand Down Expand Up @@ -167,12 +167,7 @@ async fn test_wallet_added_at_runtime_catches_up() {
let w3_id = {
let mut wallet_guard = client_handle.client.wallet().write().await;
wallet_guard
.create_wallet_from_mnemonic(
SECONDARY_MNEMONIC,
"",
future_height,
test_account_options(),
)
.create_wallet_from_mnemonic(SECONDARY_MNEMONIC, future_height, test_account_options())
.expect("add W3 at runtime")
};

Expand Down Expand Up @@ -278,18 +273,13 @@ async fn test_runtime_add_shared_block_two_wallets() {
let w1_id = {
let mut wallet_guard = client_handle.client.wallet().write().await;
wallet_guard
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, "", initial_height, test_account_options())
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, initial_height, test_account_options())
.expect("add W1 at runtime")
};
let w2_id = {
let mut wallet_guard = client_handle.client.wallet().write().await;
wallet_guard
.create_wallet_from_mnemonic(
SECONDARY_MNEMONIC,
"",
initial_height,
test_account_options(),
)
.create_wallet_from_mnemonic(SECONDARY_MNEMONIC, initial_height, test_account_options())
.expect("add W2 at runtime")
};

Expand Down Expand Up @@ -371,7 +361,7 @@ async fn test_runtime_add_during_initial_sync() {
let w1_id = {
let mut wallet_guard = wallet.write().await;
wallet_guard
.create_wallet_from_mnemonic(&ctx.dashd.wallet.mnemonic, "", 0, test_account_options())
.create_wallet_from_mnemonic(&ctx.dashd.wallet.mnemonic, 0, test_account_options())
.expect("add W1 before start")
};

Expand Down Expand Up @@ -423,7 +413,7 @@ async fn test_runtime_add_during_initial_sync() {
let w2_id = {
let mut wallet_guard = client_handle.client.wallet().write().await;
wallet_guard
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, "", 0, test_account_options())
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, 0, test_account_options())
.expect("add W2 mid-flight")
};

Expand Down Expand Up @@ -506,7 +496,7 @@ async fn test_runtime_add_with_tip_advance_during_rescan() {
let w2_id = {
let mut wallet_guard = client_handle.client.wallet().write().await;
wallet_guard
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, "", 0, test_account_options())
.create_wallet_from_mnemonic(EMPTY_MNEMONIC, 0, test_account_options())
.expect("add W2 at runtime")
};

Expand Down
26 changes: 13 additions & 13 deletions key-wallet-ffi/FFI_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,14 @@ Free a managed platform account result's error message (if any) Note: This does
#### `wallet_manager_add_wallet_from_mnemonic`

```c
wallet_manager_add_wallet_from_mnemonic(manager: *mut FFIWalletManager, mnemonic: *const c_char, passphrase: *const c_char, error: *mut FFIError,) -> bool
wallet_manager_add_wallet_from_mnemonic(manager: *mut FFIWalletManager, mnemonic: *const c_char, error: *mut FFIError,) -> bool
```

**Description:**
Add a wallet from mnemonic to the manager (backward compatibility) # Safety - `manager` must be a valid pointer to an FFIWalletManager instance - `mnemonic` must be a valid pointer to a null-terminated C string - `passphrase` must be a valid pointer to a null-terminated C string or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call
Add a wallet from mnemonic to the manager (backward compatibility) # Safety - `manager` must be a valid pointer to an FFIWalletManager instance - `mnemonic` must be a valid pointer to a null-terminated C string - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call

**Safety:**
- `manager` must be a valid pointer to an FFIWalletManager instance - `mnemonic` must be a valid pointer to a null-terminated C string - `passphrase` must be a valid pointer to a null-terminated C string or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call
- `manager` must be a valid pointer to an FFIWalletManager instance - `mnemonic` must be a valid pointer to a null-terminated C string - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call

**Module:** `wallet_manager`

Expand All @@ -465,7 +465,7 @@ Add a wallet from mnemonic to the manager (backward compatibility) # Safety -
#### `wallet_manager_add_wallet_from_mnemonic_return_serialized_bytes`

```c
wallet_manager_add_wallet_from_mnemonic_return_serialized_bytes(manager: *mut FFIWalletManager, mnemonic: *const c_char, passphrase: *const c_char, birth_height: c_uint, account_options: *const crate::types::FFIWalletAccountCreationOptions, downgrade_to_pubkey_wallet: bool, allow_external_signing: bool, wallet_bytes_out: *mut *mut u8, wallet_bytes_len_out: *mut usize, wallet_id_out: *mut u8, error: *mut FFIError,) -> bool
wallet_manager_add_wallet_from_mnemonic_return_serialized_bytes(manager: *mut FFIWalletManager, mnemonic: *const c_char, birth_height: c_uint, account_options: *const crate::types::FFIWalletAccountCreationOptions, downgrade_to_pubkey_wallet: bool, allow_external_signing: bool, wallet_bytes_out: *mut *mut u8, wallet_bytes_len_out: *mut usize, wallet_id_out: *mut u8, error: *mut FFIError,) -> bool
```

**Module:** `wallet_manager`
Expand All @@ -475,14 +475,14 @@ wallet_manager_add_wallet_from_mnemonic_return_serialized_bytes(manager: *mut FF
#### `wallet_manager_add_wallet_from_mnemonic_with_options`

```c
wallet_manager_add_wallet_from_mnemonic_with_options(manager: *mut FFIWalletManager, mnemonic: *const c_char, passphrase: *const c_char, account_options: *const crate::types::FFIWalletAccountCreationOptions, error: *mut FFIError,) -> bool
wallet_manager_add_wallet_from_mnemonic_with_options(manager: *mut FFIWalletManager, mnemonic: *const c_char, account_options: *const crate::types::FFIWalletAccountCreationOptions, error: *mut FFIError,) -> bool
```

**Description:**
Add a wallet from mnemonic to the manager with options # Safety - `manager` must be a valid pointer to an FFIWalletManager instance - `mnemonic` must be a valid pointer to a null-terminated C string - `passphrase` must be a valid pointer to a null-terminated C string or null - `account_options` must be a valid pointer to FFIWalletAccountCreationOptions or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call
Add a wallet from mnemonic to the manager with options # Safety - `manager` must be a valid pointer to an FFIWalletManager instance - `mnemonic` must be a valid pointer to a null-terminated C string - `account_options` must be a valid pointer to FFIWalletAccountCreationOptions or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call

**Safety:**
- `manager` must be a valid pointer to an FFIWalletManager instance - `mnemonic` must be a valid pointer to a null-terminated C string - `passphrase` must be a valid pointer to a null-terminated C string or null - `account_options` must be a valid pointer to FFIWalletAccountCreationOptions or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call
- `manager` must be a valid pointer to an FFIWalletManager instance - `mnemonic` must be a valid pointer to a null-terminated C string - `account_options` must be a valid pointer to FFIWalletAccountCreationOptions or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call

**Module:** `wallet_manager`

Expand Down Expand Up @@ -1333,14 +1333,14 @@ Check if a transaction belongs to the wallet using ManagedWalletInfo # Safety
#### `wallet_create_from_mnemonic`

```c
wallet_create_from_mnemonic(mnemonic: *const c_char, passphrase: *const c_char, network: FFINetwork, error: *mut FFIError,) -> *mut FFIWallet
wallet_create_from_mnemonic(mnemonic: *const c_char, network: FFINetwork, error: *mut FFIError,) -> *mut FFIWallet
```

**Description:**
Create a new wallet from mnemonic (backward compatibility - single network) # Safety - `mnemonic` must be a valid pointer to a null-terminated C string - `passphrase` must be a valid pointer to a null-terminated C string or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call - The returned pointer must be freed with `wallet_free` when no longer needed
Create a new wallet from mnemonic (backward compatibility - single network) # Safety - `mnemonic` must be a valid pointer to a null-terminated C string - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call - The returned pointer must be freed with `wallet_free` when no longer needed

**Safety:**
- `mnemonic` must be a valid pointer to a null-terminated C string - `passphrase` must be a valid pointer to a null-terminated C string or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call - The returned pointer must be freed with `wallet_free` when no longer needed
- `mnemonic` must be a valid pointer to a null-terminated C string - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call - The returned pointer must be freed with `wallet_free` when no longer needed

**Module:** `wallet`

Expand All @@ -1349,14 +1349,14 @@ Create a new wallet from mnemonic (backward compatibility - single network) # S
#### `wallet_create_from_mnemonic_with_options`

```c
wallet_create_from_mnemonic_with_options(mnemonic: *const c_char, passphrase: *const c_char, network: FFINetwork, account_options: *const FFIWalletAccountCreationOptions, error: *mut FFIError,) -> *mut FFIWallet
wallet_create_from_mnemonic_with_options(mnemonic: *const c_char, network: FFINetwork, account_options: *const FFIWalletAccountCreationOptions, error: *mut FFIError,) -> *mut FFIWallet
```

**Description:**
Create a new wallet from mnemonic with options # Safety - `mnemonic` must be a valid pointer to a null-terminated C string - `passphrase` must be a valid pointer to a null-terminated C string or null - `account_options` must be a valid pointer to FFIWalletAccountCreationOptions or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call - The returned pointer must be freed with `wallet_free` when no longer needed
Create a new wallet from mnemonic with options # Safety - `mnemonic` must be a valid pointer to a null-terminated C string - `account_options` must be a valid pointer to FFIWalletAccountCreationOptions or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call - The returned pointer must be freed with `wallet_free` when no longer needed

**Safety:**
- `mnemonic` must be a valid pointer to a null-terminated C string - `passphrase` must be a valid pointer to a null-terminated C string or null - `account_options` must be a valid pointer to FFIWalletAccountCreationOptions or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call - The returned pointer must be freed with `wallet_free` when no longer needed
- `mnemonic` must be a valid pointer to a null-terminated C string - `account_options` must be a valid pointer to FFIWalletAccountCreationOptions or null - `error` must be a valid pointer to an FFIError structure - The caller must ensure all pointers remain valid for the duration of this call - The returned pointer must be freed with `wallet_free` when no longer needed

**Module:** `wallet`

Expand Down
3 changes: 1 addition & 2 deletions key-wallet-ffi/examples/check_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ typedef struct {
// External function declarations
extern void* wallet_create_from_mnemonic(
const char* mnemonic,
const char* passphrase,
FFINetwork network,
FFIError* error
);
Expand Down Expand Up @@ -64,7 +63,7 @@ int main() {
FFINetwork network = Testnet;

// Create wallet
void* wallet = wallet_create_from_mnemonic(mnemonic, NULL, network, &error);
void* wallet = wallet_create_from_mnemonic(mnemonic, network, &error);
if (!wallet) {
printf("Failed to create wallet: %s\n", error.message);
return 1;
Expand Down
8 changes: 0 additions & 8 deletions key-wallet-ffi/src/account_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,6 @@ mod tests {
// Create wallet with default accounts
let wallet = wallet_create_from_mnemonic_with_options(
mnemonic.as_ptr(),
ptr::null(),
FFINetwork::Testnet,
ptr::null(),
error,
Expand Down Expand Up @@ -1125,7 +1124,6 @@ mod tests {

let wallet = wallet_create_from_mnemonic_with_options(
mnemonic.as_ptr(),
ptr::null(),
FFINetwork::Testnet,
&options,
error,
Expand Down Expand Up @@ -1172,7 +1170,6 @@ mod tests {

let wallet = wallet_create_from_mnemonic_with_options(
mnemonic.as_ptr(),
ptr::null(),
FFINetwork::Testnet,
&options,
error,
Expand Down Expand Up @@ -1243,7 +1240,6 @@ mod tests {

let wallet = wallet_create_from_mnemonic_with_options(
mnemonic.as_ptr(),
ptr::null(),
FFINetwork::Testnet,
&options,
error,
Expand Down Expand Up @@ -1296,7 +1292,6 @@ mod tests {

let wallet = wallet_create_from_mnemonic_with_options(
mnemonic.as_ptr(),
ptr::null(),
FFINetwork::Testnet,
&options,
error,
Expand Down Expand Up @@ -1381,7 +1376,6 @@ mod tests {

let wallet = wallet_create_from_mnemonic_with_options(
mnemonic.as_ptr(),
ptr::null(),
FFINetwork::Testnet,
&options,
error,
Expand Down Expand Up @@ -1468,7 +1462,6 @@ mod tests {

let wallet = wallet_create_from_mnemonic_with_options(
mnemonic.as_ptr(),
ptr::null(),
FFINetwork::Testnet,
&options,
error,
Expand Down Expand Up @@ -1539,7 +1532,6 @@ mod tests {
// Create wallet with default accounts (which should have at least BIP44 account 0)
let wallet = wallet_create_from_mnemonic_with_options(
mnemonic.as_ptr(),
ptr::null(),
FFINetwork::Testnet,
ptr::null(),
error,
Expand Down
21 changes: 3 additions & 18 deletions key-wallet-ffi/src/account_derivation_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ mod tests {

// Create wallet on testnet with default accounts
let wallet = unsafe {
wallet::wallet_create_from_mnemonic(
mnemonic.as_ptr(),
passphrase.as_ptr(),
FFINetwork::Testnet,
&mut error,
)
wallet::wallet_create_from_mnemonic(mnemonic.as_ptr(), FFINetwork::Testnet, &mut error)
};
assert!(!wallet.is_null());
assert_eq!(error.code, FFIErrorCode::Success);
Expand Down Expand Up @@ -122,12 +117,7 @@ mod tests {

// Create wallet on testnet with default accounts
let wallet = unsafe {
wallet::wallet_create_from_mnemonic(
mnemonic.as_ptr(),
passphrase.as_ptr(),
FFINetwork::Testnet,
&mut error,
)
wallet::wallet_create_from_mnemonic(mnemonic.as_ptr(), FFINetwork::Testnet, &mut error)
};
assert!(!wallet.is_null());

Expand Down Expand Up @@ -177,12 +167,7 @@ mod tests {

// Create wallet and get account 0
let wallet = unsafe {
wallet::wallet_create_from_mnemonic(
mnemonic.as_ptr(),
passphrase.as_ptr(),
FFINetwork::Testnet,
&mut error,
)
wallet::wallet_create_from_mnemonic(mnemonic.as_ptr(), FFINetwork::Testnet, &mut error)
};
assert!(!wallet.is_null());
let account = unsafe {
Expand Down
Loading
Loading