diff --git a/key-wallet/src/account/mod.rs b/key-wallet/src/account/mod.rs index 177a42747..b75082a31 100644 --- a/key-wallet/src/account/mod.rs +++ b/key-wallet/src/account/mod.rs @@ -34,7 +34,6 @@ use crate::managed_account::address_pool::AddressPoolType; pub use crate::managed_account::managed_account_collection::ManagedAccountCollection; pub use crate::managed_account::managed_account_trait::ManagedAccountTrait; pub use crate::managed_account::managed_account_type::ManagedAccountType; -pub use crate::managed_account::metadata::AccountMetadata; pub use crate::managed_account::transaction_record::{ InputDetail, OutputDetail, OutputRole, TransactionDirection, TransactionRecord, }; diff --git a/key-wallet/src/managed_account/managed_account_trait.rs b/key-wallet/src/managed_account/managed_account_trait.rs index dfcf38e25..39ffb48fb 100644 --- a/key-wallet/src/managed_account/managed_account_trait.rs +++ b/key-wallet/src/managed_account/managed_account_trait.rs @@ -4,7 +4,6 @@ use std::collections::BTreeMap; -use crate::account::AccountMetadata; use crate::account::TransactionRecord; use crate::managed_account::managed_account_type::ManagedAccountType; use crate::utxo::Utxo; @@ -24,12 +23,6 @@ pub trait ManagedAccountTrait { /// Get the network fn network(&self) -> Network; - /// Get metadata - fn metadata(&self) -> &AccountMetadata; - - /// Get mutable metadata - fn metadata_mut(&mut self) -> &mut AccountMetadata; - /// Check if this is a watch-only account fn is_watch_only(&self) -> bool; diff --git a/key-wallet/src/managed_account/managed_platform_account.rs b/key-wallet/src/managed_account/managed_platform_account.rs index aa85ce5b1..6087d0f8d 100644 --- a/key-wallet/src/managed_account/managed_platform_account.rs +++ b/key-wallet/src/managed_account/managed_platform_account.rs @@ -12,7 +12,6 @@ use std::collections::BTreeMap; use super::address_pool::{AddressPool, KeySource}; -use super::metadata::AccountMetadata; use super::platform_address::PlatformP2PKHAddress; use crate::error::{Error, Result}; use crate::Network; @@ -48,8 +47,6 @@ pub struct ManagedPlatformAccount { pub address_balances: BTreeMap, /// Address pool for key derivation and address generation pub addresses: AddressPool, - /// Account metadata - pub metadata: AccountMetadata, /// Whether this is a watch-only account pub is_watch_only: bool, } @@ -67,7 +64,6 @@ impl ManagedPlatformAccount { credit_balance: 0, address_balances: BTreeMap::new(), addresses, - metadata: AccountMetadata::default(), is_watch_only, } } @@ -85,7 +81,6 @@ impl ManagedPlatformAccount { /// Set the total credit balance pub fn set_credit_balance(&mut self, credit_balance: u64) { self.credit_balance = credit_balance; - self.metadata.last_used = Some(Self::current_timestamp()); } /// Get the credit balance for a specific address @@ -113,7 +108,6 @@ impl ManagedPlatformAccount { // Apply delta to total: subtract old, add new self.credit_balance = self.credit_balance.saturating_sub(old_balance).saturating_add(credit_balance); - self.metadata.last_used = Some(Self::current_timestamp()); // If address became funded and we have a key source, update address pool if was_unfunded && is_now_funded { @@ -143,7 +137,6 @@ impl ManagedPlatformAccount { self.address_balances.insert(address, new_balance); // Add the amount to the total (saturating to handle overflow) self.credit_balance = self.credit_balance.saturating_add(amount); - self.metadata.last_used = Some(Self::current_timestamp()); // If address became funded and we have a key source, update address pool if was_unfunded && is_now_funded { @@ -171,7 +164,6 @@ impl ManagedPlatformAccount { self.address_balances.insert(address, new_balance); // Subtract only what was actually removed from the total self.credit_balance = self.credit_balance.saturating_sub(actual_removed); - self.metadata.last_used = Some(Self::current_timestamp()); new_balance } @@ -254,11 +246,7 @@ impl ManagedPlatformAccount { /// Mark an address as used pub fn mark_address_used(&mut self, address: &Address) -> bool { - let result = self.addresses.mark_used(address); - if result { - self.metadata.last_used = Some(Self::current_timestamp()); - } - result + self.addresses.mark_used(address) } /// Mark a platform address as used @@ -300,14 +288,6 @@ impl ManagedPlatformAccount { self.addresses.address_info(address).cloned() } - /// Get the current timestamp - fn current_timestamp() -> u64 { - std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .unwrap_or_default() - .as_secs() - } - /// Get pool statistics pub fn address_pool_stats(&self) -> super::address_pool::PoolStats { self.addresses.stats() @@ -347,7 +327,6 @@ impl bincode::Encode for ManagedPlatformAccount { bincode::Encode::encode(&address_balances_vec, encoder)?; bincode::Encode::encode(&self.addresses, encoder)?; - bincode::Encode::encode(&self.metadata, encoder)?; bincode::Encode::encode(&self.is_watch_only, encoder)?; Ok(()) } @@ -370,7 +349,6 @@ impl bincode::Decode for ManagedPlatformAccount { address_balances_vec.into_iter().collect(); let addresses = bincode::Decode::decode(decoder)?; - let metadata = bincode::Decode::decode(decoder)?; let is_watch_only = bincode::Decode::decode(decoder)?; Ok(Self { @@ -380,7 +358,6 @@ impl bincode::Decode for ManagedPlatformAccount { credit_balance, address_balances, addresses, - metadata, is_watch_only, }) } diff --git a/key-wallet/src/managed_account/metadata.rs b/key-wallet/src/managed_account/metadata.rs deleted file mode 100644 index b03c5ef14..000000000 --- a/key-wallet/src/managed_account/metadata.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! Account metadata for organization and tracking -//! -//! This module contains metadata structures for accounts. - -#[cfg(feature = "bincode")] -use bincode_derive::{Decode, Encode}; -#[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; - -/// Account metadata for organization and tracking -#[derive(Debug, Clone, Default)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "bincode", derive(Encode, Decode))] -pub struct AccountMetadata { - /// Human-readable account name - pub name: Option, - /// Account description - pub description: Option, - /// Account color for UI (hex format) - pub color: Option, - /// Custom tags for categorization - pub tags: Vec, - /// Account creation timestamp - pub created_at: u64, - /// Last activity timestamp - pub last_used: Option, - /// Total received amount - pub total_received: u64, - /// Total sent amount - pub total_sent: u64, - /// Transaction count - pub tx_count: u32, -} diff --git a/key-wallet/src/managed_account/mod.rs b/key-wallet/src/managed_account/mod.rs index b13808fc3..7d5c0147f 100644 --- a/key-wallet/src/managed_account/mod.rs +++ b/key-wallet/src/managed_account/mod.rs @@ -3,7 +3,6 @@ //! This module contains the mutable account state that changes during wallet operation, //! kept separate from the immutable Account structure. -use crate::account::AccountMetadata; #[cfg(feature = "bls")] use crate::account::BLSAccount; #[cfg(feature = "eddsa")] @@ -38,15 +37,14 @@ pub mod managed_account_collection; pub mod managed_account_trait; pub mod managed_account_type; pub mod managed_platform_account; -pub mod metadata; pub mod platform_address; pub mod transaction_record; /// Managed account with mutable state /// -/// This struct contains the mutable state of an account including address pools, -/// metadata, and balance information. It is managed separately from -/// the immutable Account structure. +/// This struct contains the mutable state of an account including address pools +/// and balance information. It is managed separately from the immutable Account +/// structure. #[derive(Debug, Clone)] #[cfg_attr(feature = "serde", derive(Serialize))] pub struct ManagedCoreAccount { @@ -54,8 +52,6 @@ pub struct ManagedCoreAccount { pub managed_account_type: ManagedAccountType, /// Network this account belongs to pub network: Network, - /// Account metadata - pub metadata: AccountMetadata, /// Whether this is a watch-only account pub is_watch_only: bool, /// Account balance information @@ -84,7 +80,6 @@ impl ManagedCoreAccount { Self { managed_account_type, network, - metadata: AccountMetadata::default(), is_watch_only, balance: WalletCoreBalance::default(), transactions: BTreeMap::new(), @@ -301,9 +296,6 @@ impl ManagedCoreAccount { /// Mark an address as used pub fn mark_address_used(&mut self, address: &Address) -> bool { - // Update metadata timestamp - self.metadata.last_used = Some(Self::current_timestamp()); - // Use the account type's mark_address_used method // The address pools already track gap limits internally self.managed_account_type.mark_address_used(address) @@ -615,7 +607,6 @@ impl ManagedCoreAccount { } } self.balance = WalletCoreBalance::new(confirmed, unconfirmed, immature, locked); - self.metadata.last_used = Some(Self::current_timestamp()); } /// Get all addresses from all pools @@ -1175,14 +1166,6 @@ impl ManagedCoreAccount { self.managed_account_type.get_address_derivation_path(address) } - /// Get the current timestamp (for metadata) - fn current_timestamp() -> u64 { - std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .unwrap_or_default() - .as_secs() - } - /// Get total address count across all pools pub fn total_address_count(&self) -> usize { self.managed_account_type @@ -1302,14 +1285,6 @@ impl ManagedAccountTrait for ManagedCoreAccount { self.network } - fn metadata(&self) -> &AccountMetadata { - &self.metadata - } - - fn metadata_mut(&mut self) -> &mut AccountMetadata { - &mut self.metadata - } - fn is_watch_only(&self) -> bool { self.is_watch_only } @@ -1349,7 +1324,6 @@ impl<'de> Deserialize<'de> for ManagedCoreAccount { struct Helper { managed_account_type: ManagedAccountType, network: Network, - metadata: AccountMetadata, is_watch_only: bool, balance: WalletCoreBalance, transactions: BTreeMap, @@ -1368,7 +1342,6 @@ impl<'de> Deserialize<'de> for ManagedCoreAccount { Ok(ManagedCoreAccount { managed_account_type: helper.managed_account_type, network: helper.network, - metadata: helper.metadata, is_watch_only: helper.is_watch_only, balance: helper.balance, transactions: helper.transactions,