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
21 changes: 2 additions & 19 deletions key-wallet-ffi/FFI_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This document provides a comprehensive reference for all FFI (Foreign Function I

**Auto-generated**: This documentation is automatically generated from the source code. Do not edit manually.

**Total Functions**: 259
**Total Functions**: 258

## Table of Contents

Expand Down Expand Up @@ -140,7 +140,7 @@ Functions: 64

### Account Management

Functions: 109
Functions: 108

| Function | Description | Module |
|----------|-------------|--------|
Expand Down Expand Up @@ -238,7 +238,6 @@ Functions: 109
| `managed_core_account_get_external_address_pool` | Get the external address pool from a managed account This function returns... | managed_account |
| `managed_core_account_get_index` | Get the account index from a managed account Returns the primary account... | managed_account |
| `managed_core_account_get_internal_address_pool` | Get the internal address pool from a managed account This function returns... | managed_account |
| `managed_core_account_get_is_watch_only` | Check if a managed account is watch-only # Safety - `account` must be a... | managed_account |
| `managed_core_account_get_network` | Get the network of a managed account # Safety - `account` must be a valid... | managed_account |
| `managed_core_account_get_transaction_count` | Get the number of transactions in a managed account # Safety - `account`... | managed_account |
| `managed_core_account_get_transactions` | Get all transactions from a managed account Returns an array of... | managed_account |
Expand Down Expand Up @@ -3170,22 +3169,6 @@ Get the internal address pool from a managed account This function returns the

---

#### `managed_core_account_get_is_watch_only`

```c
managed_core_account_get_is_watch_only(account: *const FFIManagedCoreAccount,) -> bool
```

**Description:**
Check if a managed account is watch-only # Safety - `account` must be a valid pointer to an FFIManagedCoreAccount instance

**Safety:**
- `account` must be a valid pointer to an FFIManagedCoreAccount instance

**Module:** `managed_account`

---

#### `managed_core_account_get_network`

```c
Expand Down
28 changes: 1 addition & 27 deletions key-wallet-ffi/src/managed_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,23 +585,6 @@ pub unsafe extern "C" fn managed_core_account_get_account_type(
}
}

/// Check if a managed account is watch-only
///
/// # Safety
///
/// - `account` must be a valid pointer to an FFIManagedCoreAccount instance
#[no_mangle]
pub unsafe extern "C" fn managed_core_account_get_is_watch_only(
account: *const FFIManagedCoreAccount,
) -> bool {
if account.is_null() {
return false;
}

let account = &*account;
account.inner().is_watch_only()
}

/// Get the balance of a managed account
///
/// # Safety
Expand Down Expand Up @@ -1630,9 +1613,7 @@ mod tests {
assert!(result.error_message.is_null());

// Verify the account was created successfully
let account = &*result.account;
// Account should exist and be valid
assert!(!account.inner().is_watch_only());
let _account = &*result.account;

// Clean up
managed_core_account_free(result.account);
Expand Down Expand Up @@ -1830,10 +1811,6 @@ mod tests {
assert_eq!(account_type, FFIAccountKind::StandardBIP44);
assert_eq!(index_out, 0);

// Test get_is_watch_only
let is_watch_only = managed_core_account_get_is_watch_only(account);
assert!(!is_watch_only);

// Test get_balance
let mut balance_out = crate::types::FFIBalance {
confirmed: 999,
Expand Down Expand Up @@ -1881,9 +1858,6 @@ mod tests {
let account_type = managed_core_account_get_account_type(ptr::null(), &mut index_out);
assert_eq!(account_type, FFIAccountKind::StandardBIP44); // Default type

let is_watch_only = managed_core_account_get_is_watch_only(ptr::null());
assert!(!is_watch_only);

let tx_count = managed_core_account_get_transaction_count(ptr::null());
assert_eq!(tx_count, 0);

Expand Down
1 change: 0 additions & 1 deletion key-wallet-ffi/src/managed_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ mod tests {
internal_addresses: internal_pool,
},
network,
false,
);

managed_collection.standard_bip44_accounts.insert(0, managed_account.clone());
Expand Down
5 changes: 0 additions & 5 deletions key-wallet-ffi/src/utxo_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ mod utxo_tests {
.unwrap(),
},
Network::Testnet,
false,
);

// Add multiple UTXOs
Expand Down Expand Up @@ -308,7 +307,6 @@ mod utxo_tests {
.unwrap(),
},
Network::Testnet,
false,
);

let utxos = Utxo::dummy_batch(0..2, 10000, 100, false, false);
Expand All @@ -334,7 +332,6 @@ mod utxo_tests {
.unwrap(),
},
Network::Testnet,
false,
);

let utxos = Utxo::dummy_batch(10..11, 20000, 200, false, false);
Expand All @@ -353,7 +350,6 @@ mod utxo_tests {
.unwrap(),
},
Network::Testnet,
false,
);

let utxos = Utxo::dummy_batch(20..22, 30000, 300, false, false);
Expand Down Expand Up @@ -412,7 +408,6 @@ mod utxo_tests {
.unwrap(),
},
Network::Testnet,
false,
);

let utxos = Utxo::dummy_batch(1..2, 10000, 100, false, false);
Expand Down
8 changes: 2 additions & 6 deletions key-wallet/src/managed_account/managed_account_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ impl ManagedAccountCollection {
Self::create_managed_account_from_account_type(
account.account_type,
account.network,
account.is_watch_only,
&key_source,
)
}
Expand All @@ -528,7 +527,6 @@ impl ManagedAccountCollection {
Self::create_managed_account_from_account_type(
account.account_type,
account.network,
account.is_watch_only,
&key_source,
)
}
Expand All @@ -547,16 +545,14 @@ impl ManagedAccountCollection {
Self::create_managed_account_from_account_type(
account.account_type,
account.network,
account.is_watch_only,
&key_source,
)
}

/// Create a ManagedAccount from an Account type with network and watch-only status
/// Create a ManagedAccount from an Account type with network
fn create_managed_account_from_account_type(
account_type: AccountType,
network: Network,
is_watch_only: bool,
key_source: &KeySource,
) -> Result<ManagedCoreFundsAccount, crate::error::Error> {
// Get the derivation path for this account type
Expand Down Expand Up @@ -786,7 +782,7 @@ impl ManagedAccountCollection {
}
};

Ok(ManagedCoreFundsAccount::new(managed_type, network, is_watch_only))
Ok(ManagedCoreFundsAccount::new(managed_type, network))
}

/// Create a ManagedPlatformAccount from an Account for Platform Payment accounts
Expand Down
3 changes: 0 additions & 3 deletions key-wallet/src/managed_account/managed_account_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ pub trait ManagedAccountTrait {
/// Get the network
fn network(&self) -> Network;

/// Check if this is a watch-only account
fn is_watch_only(&self) -> bool;

/// Get transactions
fn transactions(&self) -> &BTreeMap<Txid, TransactionRecord>;

Expand Down
14 changes: 3 additions & 11 deletions key-wallet/src/managed_account/managed_core_funds_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use std::collections::{BTreeSet, HashSet};
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct ManagedCoreFundsAccount {
/// Shared keys-account state (address pools, transactions, network,
/// is_watch_only, monitor revision).
/// monitor revision).
keys: ManagedCoreKeysAccount,
/// Account balance information
pub balance: WalletCoreBalance,
Expand All @@ -64,13 +64,9 @@ pub struct ManagedCoreFundsAccount {

impl ManagedCoreFundsAccount {
/// Create a new managed funds account
pub fn new(
managed_account_type: ManagedAccountType,
network: Network,
is_watch_only: bool,
) -> Self {
pub fn new(managed_account_type: ManagedAccountType, network: Network) -> Self {
Self {
keys: ManagedCoreKeysAccount::new(managed_account_type, network, is_watch_only),
keys: ManagedCoreKeysAccount::new(managed_account_type, network),
balance: WalletCoreBalance::default(),
utxos: BTreeMap::new(),
spent_outpoints: HashSet::new(),
Expand Down Expand Up @@ -604,10 +600,6 @@ impl ManagedAccountTrait for ManagedCoreFundsAccount {
self.keys.network()
}

fn is_watch_only(&self) -> bool {
self.keys.is_watch_only()
}

fn transactions(&self) -> &BTreeMap<Txid, TransactionRecord> {
self.keys.transactions()
}
Expand Down
19 changes: 4 additions & 15 deletions key-wallet/src/managed_account/managed_core_keys_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ pub struct ManagedCoreKeysAccount {
managed_account_type: ManagedAccountType,
/// Network this account belongs to
network: Network,
/// Whether this is a watch-only account
is_watch_only: bool,
/// Transaction history for this account
transactions: BTreeMap<Txid, TransactionRecord>,
/// Revision counter incremented when the monitored address set changes
Expand All @@ -49,15 +47,10 @@ pub struct ManagedCoreKeysAccount {

impl ManagedCoreKeysAccount {
/// Create a new managed keys account
pub fn new(
managed_account_type: ManagedAccountType,
network: Network,
is_watch_only: bool,
) -> Self {
pub fn new(managed_account_type: ManagedAccountType, network: Network) -> Self {
Self {
managed_account_type,
network,
is_watch_only,
transactions: BTreeMap::new(),
monitor_revision: 0,
}
Expand All @@ -81,7 +74,7 @@ impl ManagedCoreKeysAccount {
.expect("Should succeed with NoKeySource")
});

Self::new(managed_type, account.network, account.is_watch_only)
Self::new(managed_type, account.network)
}

/// Create a `ManagedCoreKeysAccount` from a [`BLSAccount`].
Expand All @@ -103,7 +96,7 @@ impl ManagedCoreKeysAccount {
.expect("Should succeed with NoKeySource")
});

Self::new(managed_type, account.network, account.is_watch_only)
Self::new(managed_type, account.network)
}

/// Create a `ManagedCoreKeysAccount` from an [`EdDSAAccount`].
Expand All @@ -118,7 +111,7 @@ impl ManagedCoreKeysAccount {
)
.expect("Should succeed with NoKeySource");

Self::new(managed_type, account.network, account.is_watch_only)
Self::new(managed_type, account.network)
}
}

Expand All @@ -135,10 +128,6 @@ impl ManagedAccountTrait for ManagedCoreKeysAccount {
self.network
}

fn is_watch_only(&self) -> bool {
self.is_watch_only
}

fn transactions(&self) -> &BTreeMap<Txid, TransactionRecord> {
&self.transactions
}
Expand Down
2 changes: 1 addition & 1 deletion key-wallet/src/test_utils/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ impl ManagedCoreFundsAccount {
internal_addresses: internal_pool,
};

ManagedCoreFundsAccount::new(account_type, Network::Regtest, false)
ManagedCoreFundsAccount::new(account_type, Network::Regtest)
}
}
Loading