Skip to content

Commit 1a26acc

Browse files
committed
refactor: Drop FFINetworks and use FFINetwork only
This drops the `FFINetworks` enum which was supposed to be used by the FFI layer to provide multiple networks via bitflag combinations. Since im working away from having multi network support in the wallet this PR removes it and uses `FFINetwork` instead.
1 parent 0cbb078 commit 1a26acc

31 files changed

+387
-393
lines changed

dash-spv-ffi/examples/wallet_manager_usage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn main() {
5151
let affected = wallet_manager_process_transaction(
5252
wallet_manager,
5353
tx_hex.as_ptr() as *const i8,
54-
FFINetworks::TestnetFlag,
54+
FFINetwork::Testnet,
5555
100000, // block height
5656
&mut error
5757
);

key-wallet-ffi/FFI_API.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ Free a managed account result's error message (if any) Note: This does NOT free
418418
#### `wallet_manager_add_wallet_from_mnemonic`
419419

420420
```c
421-
wallet_manager_add_wallet_from_mnemonic(manager: *mut FFIWalletManager, mnemonic: *const c_char, passphrase: *const c_char, network: FFINetworks, error: *mut FFIError,) -> bool
421+
wallet_manager_add_wallet_from_mnemonic(manager: *mut FFIWalletManager, mnemonic: *const c_char, passphrase: *const c_char, network: FFINetwork, error: *mut FFIError,) -> bool
422422
```
423423

424424
**Description:**
@@ -434,7 +434,7 @@ Add a wallet from mnemonic to the manager (backward compatibility) # Safety -
434434
#### `wallet_manager_add_wallet_from_mnemonic_return_serialized_bytes`
435435

436436
```c
437-
wallet_manager_add_wallet_from_mnemonic_return_serialized_bytes(manager: *mut FFIWalletManager, mnemonic: *const c_char, passphrase: *const c_char, network: FFINetworks, 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
437+
wallet_manager_add_wallet_from_mnemonic_return_serialized_bytes(manager: *mut FFIWalletManager, mnemonic: *const c_char, passphrase: *const c_char, network: FFINetwork, 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
438438
```
439439

440440
**Module:** `wallet_manager`
@@ -444,7 +444,7 @@ wallet_manager_add_wallet_from_mnemonic_return_serialized_bytes(manager: *mut FF
444444
#### `wallet_manager_add_wallet_from_mnemonic_with_options`
445445

446446
```c
447-
wallet_manager_add_wallet_from_mnemonic_with_options(manager: *mut FFIWalletManager, mnemonic: *const c_char, passphrase: *const c_char, network: FFINetworks, account_options: *const crate::types::FFIWalletAccountCreationOptions, error: *mut FFIError,) -> bool
447+
wallet_manager_add_wallet_from_mnemonic_with_options(manager: *mut FFIWalletManager, mnemonic: *const c_char, passphrase: *const c_char, network: FFINetwork, account_options: *const crate::types::FFIWalletAccountCreationOptions, error: *mut FFIError,) -> bool
448448
```
449449

450450
**Description:**
@@ -1219,7 +1219,7 @@ Build and sign a transaction using the wallet's managed info This is the recomm
12191219
#### `wallet_build_transaction`
12201220

12211221
```c
1222-
wallet_build_transaction(wallet: *mut FFIWallet, _network: FFINetworks, account_index: c_uint, outputs: *const FFITxOutput, outputs_count: usize, fee_per_kb: u64, tx_bytes_out: *mut *mut u8, tx_len_out: *mut usize, error: *mut FFIError,) -> bool
1222+
wallet_build_transaction(wallet: *mut FFIWallet, _network: FFINetwork, account_index: c_uint, outputs: *const FFITxOutput, outputs_count: usize, fee_per_kb: u64, tx_bytes_out: *mut *mut u8, tx_len_out: *mut usize, error: *mut FFIError,) -> bool
12231223
```
12241224

12251225
**Description:**
@@ -1251,7 +1251,7 @@ Check if a transaction belongs to the wallet using ManagedWalletInfo # Safety
12511251
#### `wallet_create_from_mnemonic`
12521252

12531253
```c
1254-
wallet_create_from_mnemonic(mnemonic: *const c_char, passphrase: *const c_char, network: FFINetworks, error: *mut FFIError,) -> *mut FFIWallet
1254+
wallet_create_from_mnemonic(mnemonic: *const c_char, passphrase: *const c_char, network: FFINetwork, error: *mut FFIError,) -> *mut FFIWallet
12551255
```
12561256

12571257
**Description:**
@@ -1267,7 +1267,7 @@ Create a new wallet from mnemonic (backward compatibility - single network) # S
12671267
#### `wallet_create_from_mnemonic_with_options`
12681268

12691269
```c
1270-
wallet_create_from_mnemonic_with_options(mnemonic: *const c_char, passphrase: *const c_char, networks: FFINetworks, account_options: *const FFIWalletAccountCreationOptions, error: *mut FFIError,) -> *mut FFIWallet
1270+
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
12711271
```
12721272

12731273
**Description:**
@@ -1283,7 +1283,7 @@ Create a new wallet from mnemonic with options # Safety - `mnemonic` must be a
12831283
#### `wallet_create_from_seed`
12841284

12851285
```c
1286-
wallet_create_from_seed(seed: *const u8, seed_len: usize, network: FFINetworks, error: *mut FFIError,) -> *mut FFIWallet
1286+
wallet_create_from_seed(seed: *const u8, seed_len: usize, network: FFINetwork, error: *mut FFIError,) -> *mut FFIWallet
12871287
```
12881288

12891289
**Description:**
@@ -1299,7 +1299,7 @@ Create a new wallet from seed (backward compatibility) # Safety - `seed` must
12991299
#### `wallet_create_from_seed_with_options`
13001300

13011301
```c
1302-
wallet_create_from_seed_with_options(seed: *const u8, seed_len: usize, networks: FFINetworks, account_options: *const FFIWalletAccountCreationOptions, error: *mut FFIError,) -> *mut FFIWallet
1302+
wallet_create_from_seed_with_options(seed: *const u8, seed_len: usize, network: FFINetwork, account_options: *const FFIWalletAccountCreationOptions, error: *mut FFIError,) -> *mut FFIWallet
13031303
```
13041304

13051305
**Description:**
@@ -1331,7 +1331,7 @@ Create a managed wallet from a regular wallet This creates a ManagedWalletInfo
13311331
#### `wallet_create_random`
13321332

13331333
```c
1334-
wallet_create_random(network: FFINetworks, error: *mut FFIError,) -> *mut FFIWallet
1334+
wallet_create_random(network: FFINetwork, error: *mut FFIError,) -> *mut FFIWallet
13351335
```
13361336

13371337
**Description:**
@@ -1347,7 +1347,7 @@ Create a new random wallet (backward compatibility) # Safety - `error` must be
13471347
#### `wallet_create_random_with_options`
13481348

13491349
```c
1350-
wallet_create_random_with_options(networks: FFINetworks, account_options: *const FFIWalletAccountCreationOptions, error: *mut FFIError,) -> *mut FFIWallet
1350+
wallet_create_random_with_options(network: FFINetwork, account_options: *const FFIWalletAccountCreationOptions, error: *mut FFIError,) -> *mut FFIWallet
13511351
```
13521352

13531353
**Description:**
@@ -1603,7 +1603,7 @@ Get an IdentityTopUp account handle with a specific registration index This is u
16031603
#### `wallet_get_utxos`
16041604

16051605
```c
1606-
wallet_get_utxos(_wallet: *const crate::types::FFIWallet, _network: FFINetworks, utxos_out: *mut *mut FFIUTXO, count_out: *mut usize, error: *mut FFIError,) -> bool
1606+
wallet_get_utxos(_wallet: *const crate::types::FFIWallet, _network: FFINetwork, utxos_out: *mut *mut FFIUTXO, count_out: *mut usize, error: *mut FFIError,) -> bool
16071607
```
16081608

16091609
**Description:**
@@ -1667,7 +1667,7 @@ Check if wallet is watch-only # Safety - `wallet` must be a valid pointer to a
16671667
#### `wallet_sign_transaction`
16681668

16691669
```c
1670-
wallet_sign_transaction(wallet: *const FFIWallet, _network: FFINetworks, tx_bytes: *const u8, tx_len: usize, signed_tx_out: *mut *mut u8, signed_len_out: *mut usize, error: *mut FFIError,) -> bool
1670+
wallet_sign_transaction(wallet: *const FFIWallet, _network: FFINetwork, tx_bytes: *const u8, tx_len: usize, signed_tx_out: *mut *mut u8, signed_len_out: *mut usize, error: *mut FFIError,) -> bool
16711671
```
16721672

16731673
**Description:**
@@ -2293,14 +2293,14 @@ Check if an account is watch-only # Safety - `account` must be a valid pointer
22932293
#### `account_get_network`
22942294

22952295
```c
2296-
account_get_network(account: *const FFIAccount) -> FFINetworks
2296+
account_get_network(account: *const FFIAccount, out_network: *mut crate::FFINetwork, error: *mut crate::error::FFIError,) -> bool
22972297
```
22982298

22992299
**Description:**
2300-
Get the network of an account # Safety - `account` must be a valid pointer to an FFIAccount instance - Returns FFINetwork::NoNetworks if the account is null
2300+
Get the network of an account # Safety - `account` must be a valid pointer to an FFIAccount instance - `out_network` must be a valid pointer to an FFINetwork where the result will be written - `error` must be a valid pointer to an FFIError structure or null # Returns Returns `true` on success (network written to `out_network`), `false` on error. On error, `out_network` is not modified.
23012301

23022302
**Safety:**
2303-
- `account` must be a valid pointer to an FFIAccount instance - Returns FFINetwork::NoNetworks if the account is null
2303+
- `account` must be a valid pointer to an FFIAccount instance - `out_network` must be a valid pointer to an FFINetwork where the result will be written - `error` must be a valid pointer to an FFIError structure or null
23042304

23052305
**Module:** `account`
23062306

@@ -2369,7 +2369,7 @@ bls_account_get_is_watch_only(account: *const FFIBLSAccount) -> bool
23692369
#### `bls_account_get_network`
23702370

23712371
```c
2372-
bls_account_get_network(account: *const FFIBLSAccount) -> FFINetworks
2372+
bls_account_get_network(account: *const FFIBLSAccount, out_network: *mut crate::FFINetwork, error: *mut crate::error::FFIError,) -> bool
23732373
```
23742374

23752375
**Module:** `account`
@@ -2452,7 +2452,7 @@ eddsa_account_get_is_watch_only(account: *const FFIEdDSAAccount) -> bool
24522452
#### `eddsa_account_get_network`
24532453

24542454
```c
2455-
eddsa_account_get_network(account: *const FFIEdDSAAccount) -> FFINetworks
2455+
eddsa_account_get_network(account: *const FFIEdDSAAccount, out_network: *mut crate::FFINetwork, error: *mut crate::error::FFIError,) -> bool
24562456
```
24572457

24582458
**Module:** `account`
@@ -3038,14 +3038,14 @@ Check if a managed account is watch-only # Safety - `account` must be a valid
30383038
#### `managed_account_get_network`
30393039

30403040
```c
3041-
managed_account_get_network(account: *const FFIManagedAccount,) -> FFINetwork
3041+
managed_account_get_network(account: *const FFIManagedAccount, out_network: *mut FFINetwork, error: *mut crate::error::FFIError,) -> bool
30423042
```
30433043

30443044
**Description:**
3045-
Get the network of a managed account # Safety - `account` must be a valid pointer to an FFIManagedAccount instance
3045+
Get the network of a managed account # Safety - `account` must be a valid pointer to an FFIManagedAccount instance - `out_network` must be a valid pointer to an FFINetwork where the result will be written - `error` must be a valid pointer to an FFIError structure or null # Returns Returns `true` on success (network written to `out_network`), `false` on error. On error, `out_network` is not modified.
30463046

30473047
**Safety:**
3048-
- `account` must be a valid pointer to an FFIManagedAccount instance
3048+
- `account` must be a valid pointer to an FFIManagedAccount instance - `out_network` must be a valid pointer to an FFINetwork where the result will be written - `error` must be a valid pointer to an FFIError structure or null
30493049

30503050
**Module:** `managed_account`
30513051

@@ -3505,7 +3505,7 @@ This function is unsafe because it dereferences raw pointers: - `encrypted_key`
35053505
#### `bip38_encrypt_private_key`
35063506

35073507
```c
3508-
bip38_encrypt_private_key(private_key: *const c_char, passphrase: *const c_char, _network: FFINetworks, error: *mut FFIError,) -> *mut c_char
3508+
bip38_encrypt_private_key(private_key: *const c_char, passphrase: *const c_char, _network: FFINetwork, error: *mut FFIError,) -> *mut c_char
35093509
```
35103510

35113511
**Description:**
@@ -4080,7 +4080,7 @@ Free a string # Safety - `s` must be a valid pointer created by C string creat
40804080
- `FFIWalletManager` - Wallet manager handle
40814081
- `FFIBalance` - Balance information
40824082
- `FFIUTXO` - Unspent transaction output
4083-
- `FFINetworks` - Network enumeration
4083+
- `FFINetwork` - Network enumeration
40844084

40854085
## Memory Management
40864086

0 commit comments

Comments
 (0)