import Foundation

// MARK: - Account

/// Represents a Rosetta user account.
/// Sensitive fields (private key, seed phrase) are stored encrypted.
/// The public key is the user's unique identity on the network.
struct Account: Codable, Equatable {

    /// Compressed secp256k1 public key (33 bytes, hex-encoded, 66 characters).
    /// This is the user's unique identifier on the Rosetta network.
    let publicKey: String

    /// AES-256-CBC encrypted private key (Base64(IV):Base64(ciphertext)).
    let privateKeyEncrypted: String

    /// AES-256-CBC encrypted BIP39 seed phrase joined by spaces.
    let seedPhraseEncrypted: String

    var displayName: String?
    var username: String?
}

// MARK: - System Accounts

extension Account {
    /// The "Safe" system account — sends security alerts.
    static let safePublicKey = "0x0000000000000000000000000000000000000000000000000000000000000002"

    /// The "Updates" system account — sends release notes.
    static let updatesPublicKey = "0x0000000000000000000000000000000000000000000000000000000000000001"
}

// MARK: - Keychain Keys

extension Account {
    enum KeychainKey {
        /// Legacy single-account Keychain key (kept for backward compatibility / migration).
        static let account = "currentAccount"
        /// Multi-account: array of all accounts stored in Keychain.
        static let allAccounts = "allAccounts"
        /// UserDefaults key tracking which account is currently active.
        static let activeAccountKey = "activeAccountPublicKey"
    }
}
