/**
 * Synor Wallet SDK Types
 */

/** Wallet SDK configuration */
export interface WalletConfig {
  /** API key for authentication */
  apiKey: string;
  /** API endpoint (defaults to production) */
  endpoint?: string;
  /** Network type */
  network?: 'mainnet' | 'testnet';
  /** Request timeout in milliseconds */
  timeout?: number;
  /** Enable debug logging */
  debug?: boolean;
  /** BIP44 derivation path */
  derivationPath?: string;
}

/** Wallet type */
export type WalletType = 'standard' | 'multisig' | 'stealth' | 'hardware';

/** Wallet instance */
export interface Wallet {
  /** Unique wallet ID */
  id: string;
  /** Primary address */
  address: string;
  /** Compressed public key (hex) */
  publicKey: string;
  /** Wallet type */
  type: WalletType;
  /** Creation timestamp */
  createdAt: number;
}

/** Wallet creation result */
export interface CreateWalletResult {
  /** Created wallet */
  wallet: Wallet;
  /** BIP39 mnemonic phrase (24 words) - SENSITIVE */
  mnemonic: string;
}

/** Stealth address */
export interface StealthAddress {
  /** One-time address */
  address: string;
  /** View public key */
  viewKey: string;
  /** Spend public key */
  spendKey: string;
  /** Ephemeral public key */
  ephemeralKey?: string;
}

/** Transaction input */
export interface TransactionInput {
  /** Previous transaction hash */
  txid: string;
  /** Output index */
  vout: number;
  /** Amount */
  amount: string;
  /** Script signature (for signed inputs) */
  scriptSig?: string;
}

/** Transaction output */
export interface TransactionOutput {
  /** Recipient address */
  address: string;
  /** Amount */
  amount: string;
  /** Script pubkey */
  scriptPubKey?: string;
}

/** Unsigned transaction */
export interface Transaction {
  /** Version */
  version: number;
  /** Inputs */
  inputs: TransactionInput[];
  /** Outputs */
  outputs: TransactionOutput[];
  /** Lock time */
  lockTime?: number;
  /** Transaction fee */
  fee?: string;
}

/** Signed transaction */
export interface SignedTransaction {
  /** Raw hex-encoded transaction */
  raw: string;
  /** Transaction hash */
  txid: string;
  /** Transaction size in bytes */
  size: number;
  /** Transaction weight */
  weight?: number;
}

/** Message signing options */
export interface SignMessageOptions {
  /** Message to sign */
  message: string;
  /** Message format */
  format?: 'text' | 'hex' | 'base64';
}

/** Signed message result */
export interface SignedMessage {
  /** Signature (hex) */
  signature: string;
  /** Public key used for signing */
  publicKey: string;
  /** Address that signed */
  address: string;
}

/** UTXO (Unspent Transaction Output) */
export interface UTXO {
  /** Transaction hash */
  txid: string;
  /** Output index */
  vout: number;
  /** Amount */
  amount: string;
  /** Address */
  address: string;
  /** Number of confirmations */
  confirmations: number;
  /** Script pubkey */
  scriptPubKey?: string;
}

/** Balance information */
export interface Balance {
  /** Confirmed balance */
  confirmed: string;
  /** Unconfirmed balance */
  unconfirmed: string;
  /** Total balance */
  total: string;
}

/** Token balance */
export interface TokenBalance {
  /** Token contract address */
  token: string;
  /** Token symbol */
  symbol: string;
  /** Token decimals */
  decimals: number;
  /** Balance */
  balance: string;
}

/** Full balance response */
export interface BalanceResponse {
  /** Native token balance */
  native: Balance;
  /** Token balances */
  tokens?: TokenBalance[];
}

/** UTXO query options */
export interface GetUtxosOptions {
  /** Minimum confirmations */
  minConfirmations?: number;
  /** Minimum amount */
  minAmount?: string;
}

/** Import wallet options */
export interface ImportWalletOptions {
  /** BIP39 mnemonic phrase */
  mnemonic: string;
  /** Optional passphrase */
  passphrase?: string;
  /** Wallet type */
  type?: WalletType;
}

/** Transaction building options */
export interface BuildTransactionOptions {
  /** Recipient address */
  to: string;
  /** Amount to send */
  amount: string;
  /** Fee rate (satoshis per byte) */
  feeRate?: number;
  /** Specific UTXOs to use */
  utxos?: UTXO[];
  /** Change address (defaults to sender) */
  changeAddress?: string;
}

/** Transaction priority */
export type Priority = 'low' | 'medium' | 'high' | 'urgent';

/** Fee estimation result */
export interface FeeEstimate {
  /** Priority level */
  priority: Priority;
  /** Fee rate */
  feeRate: string;
  /** Estimated blocks until confirmation */
  estimatedBlocks: number;
}
