{"version":3,"sources":["../src/index.ts","../src/core.ts","../src/multi-chain/maestro-unified.ts","../src/providers/blockstream.ts","../src/providers/common.ts","../src/providers/maestro.ts","../src/utils/address.ts","../src/wallets/browser/index.ts","../src/wallets/embedded/index.ts"],"sourcesContent":["export * from \"./core\";\nexport * from \"./interfaces\";\nexport * from \"./multi-chain\";\nexport * from \"./providers\";\nexport * from \"./utils\";\nexport * from \"./types\";\nexport * from \"./wallets\";\n","import * as bitcoin from \"bitcoinjs-lib\";\nimport * as ecc from \"@bitcoin-js/tiny-secp256k1-asmjs\";\nimport * as bip39 from \"bip39\";\nimport { BIP32Factory } from \"bip32\";\nimport { ECPairFactory } from \"ecpair\";\n\nconst bip32 = BIP32Factory(ecc);\nconst ECPair = ECPairFactory(ecc);\n\nbitcoin.initEccLib(ecc);\n\nexport { bitcoin, ECPair, bip32, bip39 };\n","import { MaestroProvider as CardanoMaestroProvider, type MaestroSupportedNetworks as CardanoMaestroNetworks } from \"@meshsdk/provider\";\nimport type { TransactionInfo as CardanoTransactionInfo, UTxO as CardanoUTxO, IFetcherOptions } from \"@meshsdk/common\";\nimport { MaestroProvider as BitcoinMaestroProvider } from \"../providers\";\nimport type {\n  MaestroSupportedNetworks as BitcoinMaestroNetworks,\n  TransactionsInfo as BitcoinTransactionInfo,\n  UTxO as BitcoinUTxO,\n  AddressInfo as BitcoinAddressInfo,\n  TransactionsStatus as BitcoinTransactionStatus\n} from \"../types\";\n\nexport type MaestroMultiChainConfig =\n  | { chain: \"cardano\"; apiKey: string; network: CardanoMaestroNetworks; turboSubmit?: boolean }\n  | { chain: \"bitcoin\"; apiKey: string; network: BitcoinMaestroNetworks };\n\n/**\n * Unified Maestro provider that supports both Cardano and Bitcoin operations.\n * Chain is specified in the constructor\n *\n * @example\n * ```typescript\n * // Cardano provider\n * const cardanoMaestro = new MaestroProvider({\n *   chain: \"cardano\",\n *   apiKey: \"your-maestro-api-key\",\n *   network: \"Mainnet\",\n *   turboSubmit: true\n * });\n *\n * // Bitcoin provider\n * const bitcoinMaestro = new MaestroProvider({\n *   chain: \"bitcoin\",\n *   apiKey: \"your-maestro-api-key\",\n *   network: \"mainnet\"\n * });\n *\n * // Clean unified API\n * const cardanoTxs = await cardanoMaestro.getAddressTxs(address);\n * const bitcoinUTxOs = await bitcoinMaestro.getAddressUTxOs(address);\n * ```\n */\nexport class MaestroMultiChainProvider {\n  private _cardanoProvider?: CardanoMaestroProvider;\n  private _bitcoinProvider?: BitcoinMaestroProvider;\n  private _chain: \"cardano\" | \"bitcoin\";\n\n  /**\n   * Create a Maestro provider for the specified chain.\n   * @param config - Chain-specific configuration object.\n   */\n  constructor(config: MaestroMultiChainConfig) {\n    this._chain = config.chain;\n\n    if (config.chain === \"cardano\") {\n      this._cardanoProvider = new CardanoMaestroProvider({\n        network: config.network,\n        apiKey: config.apiKey,\n        turboSubmit: config.turboSubmit\n      });\n    } else if (config.chain === \"bitcoin\") {\n      this._bitcoinProvider = new BitcoinMaestroProvider({\n        network: config.network,\n        apiKey: config.apiKey\n      });\n    }\n  }\n\n  /**\n   * Get address transactions.\n   * @param address - The address to query.\n   * @param options - For Cardano: IFetcherOptions, for Bitcoin: lastSeenTxId string.\n   * @returns Promise of transaction array (type depends on chain).\n   */\n  async getAddressTxs(address: string, options?: IFetcherOptions | string): Promise<CardanoTransactionInfo[] | BitcoinTransactionInfo[]> {\n    if (this._chain === \"cardano\") {\n      if (!this._cardanoProvider) {\n        throw new Error(\"Cardano provider not initialized.\");\n      }\n      // For Cardano, options should be IFetcherOptions or undefined\n      const cardanoOptions = typeof options === 'string' ? undefined : options;\n      return this._cardanoProvider.fetchAddressTxs(address, cardanoOptions);\n    }\n\n    if (this._chain === \"bitcoin\") {\n      if (!this._bitcoinProvider) {\n        throw new Error(\"Bitcoin provider not initialized.\");\n      }\n      // For Bitcoin, options should be the lastSeenTxId string\n      const lastSeenTxId = typeof options === 'string' ? options : undefined;\n      return await this._bitcoinProvider.fetchAddressTransactions(address, lastSeenTxId);\n    }\n\n    throw new Error(`Unsupported chain: ${this._chain}`);\n  }\n\n  /**\n   * Get address UTXOs.\n   * @param address - The address to query.\n   * @returns Promise of UTXO array (type depends on chain).\n   */\n  async getAddressUTxOs(address: string): Promise<CardanoUTxO[] | BitcoinUTxO[]> {\n    if (this._chain === \"cardano\") {\n      if (!this._cardanoProvider) {\n        throw new Error(\"Cardano provider not initialized.\");\n      }\n      return this._cardanoProvider.fetchAddressUTxOs(address);\n    }\n\n    if (this._chain === \"bitcoin\") {\n      if (!this._bitcoinProvider) {\n        throw new Error(\"Bitcoin provider not initialized.\");\n      }\n      return await this._bitcoinProvider.fetchAddressUTxOs(address);\n    }\n\n    throw new Error(`Unsupported chain: ${this._chain}`);\n  }\n\n  /**\n   * Get address information including balance, transaction count, and UTXO statistics.\n   * Available for Bitcoin only - Cardano doesn't have this endpoint.\n   * @param address - The Bitcoin address to query.\n   * @returns Promise of address info with chain_stats and mempool_stats.\n   */\n  async getAddressInfo(address: string): Promise<BitcoinAddressInfo> {\n    if (this._chain !== \"bitcoin\") {\n      throw new Error(\"Address info is only supported for Bitcoin chain. Cardano doesn't have this endpoint.\");\n    }\n\n    if (!this._bitcoinProvider) {\n      throw new Error(\"Bitcoin provider not initialized.\");\n    }\n\n    return await this._bitcoinProvider.fetchAddress(address);\n  }\n\n  /**\n   * Submit a transaction.\n   * @param txData - The transaction data (format depends on chain).\n   * @returns Promise of transaction ID.\n   */\n  async submitTx(txData: string): Promise<string> {\n    if (this._chain === \"cardano\") {\n      if (!this._cardanoProvider) {\n        throw new Error(\"Cardano provider not initialized.\");\n      }\n      return this._cardanoProvider.submitTx(txData);\n    }\n\n    if (this._chain === \"bitcoin\") {\n      if (!this._bitcoinProvider) {\n        throw new Error(\"Bitcoin provider not initialized.\");\n      }\n      return this._bitcoinProvider.submitTx(txData);\n    }\n\n    throw new Error(`Unsupported chain: ${this._chain}`);\n  }\n\n  /**\n   * Get the configured chain.\n   * @returns The chain this provider is configured for.\n   */\n  getChain(): \"cardano\" | \"bitcoin\" {\n    return this._chain;\n  }\n\n  /**\n   * Get transaction details by hash.\n   * @param txHash - The transaction hash.\n   * @returns Promise of transaction details (type depends on chain).\n   */\n  async getTxInfo(txHash: string): Promise<CardanoTransactionInfo | BitcoinTransactionInfo> {\n    if (this._chain === \"cardano\") {\n      if (!this._cardanoProvider) {\n        throw new Error(\"Cardano provider not initialized.\");\n      }\n      return this._cardanoProvider.fetchTxInfo(txHash);\n    }\n\n    if (this._chain === \"bitcoin\") {\n      if (!this._bitcoinProvider) {\n        throw new Error(\"Bitcoin provider not initialized.\");\n      }\n      return await this._bitcoinProvider.fetchTxInfo(txHash);\n    }\n\n    throw new Error(`Unsupported chain: ${this._chain}`);\n  }\n\n  /**\n   * Get transaction status/confirmation details.\n   * @param txHash - The transaction hash.\n   * @returns Promise of transaction status (type depends on chain).\n   */\n  async getTxStatus(txHash: string): Promise<{ confirmed: boolean; details: CardanoTransactionInfo } | BitcoinTransactionStatus> {\n    if (this._chain === \"cardano\") {\n      // Cardano uses fetchTxInfo which includes status in the response\n      if (!this._cardanoProvider) {\n        throw new Error(\"Cardano provider not initialized.\");\n      }\n      const txInfo = await this._cardanoProvider.fetchTxInfo(txHash);\n      return { confirmed: true, details: txInfo };\n    }\n\n    if (this._chain === \"bitcoin\") {\n      if (!this._bitcoinProvider) {\n        throw new Error(\"Bitcoin provider not initialized.\");\n      }\n      return await this._bitcoinProvider.fetchTransactionStatus(txHash);\n    }\n\n    throw new Error(`Unsupported chain: ${this._chain}`);\n  }\n\n  /**\n   * Get the configured network.\n   * @returns The network configuration.\n   */\n  async getNetwork(): Promise<string> {\n    if (this._chain === \"cardano\") {\n      // Cardano provider doesn't expose network publicly\n      return \"cardano-network\";\n    }\n\n    if (this._chain === \"bitcoin\") {\n      if (!this._bitcoinProvider) {\n        throw new Error(\"Bitcoin provider not initialized.\");\n      }\n      return this._bitcoinProvider.getNetwork();\n    }\n\n    throw new Error(`Unsupported chain: ${this._chain}`);\n  }\n\n  /**\n   * Generic GET request to chain-specific API endpoints.\n   * @param url - The API endpoint URL (relative to the chain's base URL).\n   * @returns The response data.\n   */\n  async get(url: string): Promise<any> {\n    if (this._chain === \"cardano\") {\n      if (!this._cardanoProvider) {\n        throw new Error(\"Cardano provider not initialized.\");\n      }\n      return this._cardanoProvider.get(url);\n    }\n\n    if (this._chain === \"bitcoin\") {\n      if (!this._bitcoinProvider) {\n        throw new Error(\"Bitcoin provider not initialized.\");\n      }\n      return this._bitcoinProvider.get(url);\n    }\n\n    throw new Error(`Unsupported chain: ${this._chain}`);\n  }\n\n  /**\n   * Generic POST request to chain-specific API endpoints.\n   * @param url - The API endpoint URL (relative to the chain's base URL).\n   * @param body - The request body data.\n   * @returns The response data.\n   */\n  async post(url: string, body: any): Promise<any> {\n    if (this._chain === \"cardano\") {\n      if (!this._cardanoProvider) {\n        throw new Error(\"Cardano provider not initialized.\");\n      }\n      return this._cardanoProvider.post(url, body);\n    }\n\n    if (this._chain === \"bitcoin\") {\n      if (!this._bitcoinProvider) {\n        throw new Error(\"Bitcoin provider not initialized.\");\n      }\n      return this._bitcoinProvider.post(url, body);\n    }\n\n    throw new Error(`Unsupported chain: ${this._chain}`);\n  }\n}\n","import axios, { AxiosInstance } from \"axios\";\nimport { IBitcoinProvider } from \"../interfaces/provider\";\nimport { UTxO } from \"../types\";\nimport { parseHttpError } from \"./common\";\nimport { AddressInfo } from \"../types/address-info\";\nimport { ScriptInfo } from \"../types/script-info\";\nimport { TransactionsInfo } from \"../types/transactions-info\";\nimport { TransactionsStatus } from \"../types/transactions-status\";\n\n/**\n * https://github.com/Blockstream/esplora/blob/master/API.md\n */\nexport class BlockstreamProvider implements IBitcoinProvider {\n  private readonly _axiosInstance: AxiosInstance;\n\n  constructor(network: \"mainnet\" | \"testnet\" = \"mainnet\") {\n    const baseURL =\n      network === \"testnet\"\n        ? \"https://blockstream.info/testnet/api\"\n        : \"https://blockstream.info/api\";\n\n    this._axiosInstance = axios.create({\n      baseURL,\n    });\n  }\n\n  /**\n   * Get information about an address.\n   * @param address - The address.\n   * @returns AddressInfo\n   */\n  async fetchAddress(address: string): Promise<AddressInfo> {\n    try {\n      const { data, status } = await this._axiosInstance.get(\n        `/address/${address}`\n      );\n\n      if (status === 200) return data as AddressInfo;\n      throw parseHttpError(data);\n    } catch (error) {\n      throw parseHttpError(error);\n    }\n  }\n\n  /**\n   * Get transaction history for the specified address, sorted with newest first.\n   * Returns up to 50 mempool transactions plus the first 25 confirmed transactions. You can request more confirmed transactions using `last_seen_txid`.\n   * @param address - The address.\n   * @param last_seen_txid - The last seen transaction ID (optional).\n   * @returns TransactionsInfo[]\n   */\n  async fetchAddressTransactions(\n    address: string,\n    last_seen_txid?: string\n  ): Promise<TransactionsInfo[]> {\n    try {\n      const url = last_seen_txid\n        ? `/address/${address}/txs/chain/${last_seen_txid}`\n        : `/address/${address}/txs`;\n      const { data, status } = await this._axiosInstance.get(url);\n\n      if (status === 200) return data as TransactionsInfo[];\n      throw parseHttpError(data);\n    } catch (error) {\n      throw parseHttpError(error);\n    }\n  }\n\n  /**\n   * Get the list of unspent transaction outputs associated with the address.\n   * @param address - The address.\n   * @returns UTxO[]\n   */\n  async fetchAddressUTxOs(address: string): Promise<UTxO[]> {\n    try {\n      const { data, status } = await this._axiosInstance.get(\n        `/address/${address}/utxo`\n      );\n\n      if (status === 200) return data as UTxO[];\n      throw parseHttpError(data);\n    } catch (error) {\n      throw parseHttpError(error);\n    }\n  }\n\n  /**\n   * Get information about a scripthash.\n   * @param hash - The hash of the script.\n   * @returns ScriptInfo\n   */\n  async fetchScript(hash: string): Promise<ScriptInfo> {\n    try {\n      const { data, status } = await this._axiosInstance.get(\n        `/scripthash/${hash}`\n      );\n\n      if (status === 200) return data as ScriptInfo;\n      throw parseHttpError(data);\n    } catch (error) {\n      throw parseHttpError(error);\n    }\n  }\n\n  /**\n   * Get transaction history for the specified scripthash, sorted with newest first.\n   * Returns up to 50 mempool transactions plus the first 25 confirmed transactions. You can request more confirmed transactions using `last_seen_txid`.\n   * @param hash - The hash of the script.\n   * @param last_seen_txid - The last seen transaction ID (optional).\n   * @returns TransactionsInfo[]\n   */\n  async fetchScriptTransactions(\n    hash: string,\n    last_seen_txid?: string\n  ): Promise<TransactionsInfo[]> {\n    try {\n      const url = last_seen_txid\n        ? `/scripthash/${hash}/txs/chain/${last_seen_txid}`\n        : `/scripthash/${hash}/txs`;\n      const { data, status } = await this._axiosInstance.get(url);\n\n      if (status === 200) return data as TransactionsInfo[];\n      throw parseHttpError(data);\n    } catch (error) {\n      throw parseHttpError(error);\n    }\n  }\n\n  /**\n   * Get the list of unspent transaction outputs associated with the scripthash.\n   * @param hash - The hash of the script.\n   * @returns UTxO[]\n   */\n  async fetchScriptUTxOs(hash: string): Promise<UTxO[]> {\n    try {\n      const { data, status } = await this._axiosInstance.get(\n        `/scripthash/${hash}/utxo`\n      );\n\n      if (status === 200) return data as UTxO[];\n      throw parseHttpError(data);\n    } catch (error) {\n      throw parseHttpError(error);\n    }\n  }\n\n  /**\n   * Fetches the status of a transaction\n   * @param txid - The transaction ID.\n   * @returns TransactionsStatus\n   */\n  async fetchTransactionStatus(txid: string): Promise<TransactionsStatus> {\n    try {\n      const { data, status } = await this._axiosInstance.get(\n        `/tx/${txid}/status`\n      );\n\n      if (status === 200) return data as TransactionsStatus;\n      throw parseHttpError(data);\n    } catch (error) {\n      throw parseHttpError(error);\n    }\n  }\n\n  /**\n   * Get fee estimates for confirmation within a specified number of blocks.\n   * Returns fee rate in sat/vB based on Blockstream's fee estimates API.\n   * @param blocks - Confirmation target in blocks (1-25, 144, 504, 1008)\n   * @returns Fee rate in sat/vB\n   */\n  async fetchFeeEstimates(blocks: number): Promise<number> {\n    try {\n      const { data, status } = await this._axiosInstance.get(\"/fee-estimates\");\n\n      if (status === 200) {\n        const feeEstimates = data as Record<string, number>;\n        \n        // Find the closest available confirmation target\n        const availableTargets = Object.keys(feeEstimates).map(Number).sort((a, b) => a - b);\n        const closestTarget = availableTargets.find(target => target >= blocks) || availableTargets[availableTargets.length - 1];\n        \n        return feeEstimates[closestTarget.toString()] || 10;\n      }\n      throw parseHttpError(data);\n    } catch (error) {\n      throw parseHttpError(error);\n    }\n  }\n\n  /**\n   * Broadcast a raw transaction to the network.\n   * The transaction should be provided as hex in the request body. The txid will be returned on success.\n   * @param tx - The transaction in hex format.\n   * @returns The transaction ID.\n   */\n  async submitTx(tx: string): Promise<string> {\n    try {\n      const { data, status } = await this._axiosInstance.post(\"/tx\", tx, {\n        headers: { \"Content-Type\": \"text/plain\" },\n      });\n\n      if (status === 200) return data as string;\n      throw parseHttpError(data);\n    } catch (error) {\n      throw parseHttpError(error);\n    }\n  }\n}\n","import axios from \"axios\";\n\nexport const parseHttpError = (error: unknown): string => {\n  if (!axios.isAxiosError(error)) {\n    return JSON.stringify(error);\n  }\n\n  if (error.response) {\n    return JSON.stringify({\n      data: error.response.data,\n      headers: error.response.headers,\n      status: error.response.status,\n    });\n  }\n\n  if (error.request) {\n    return JSON.stringify(error.request);\n  }\n\n  return JSON.stringify({ code: error.code, message: error.message });\n};\n","import axios, { AxiosInstance } from \"axios\";\nimport { IBitcoinProvider } from \"../interfaces/provider\";\nimport { UTxO, AddressInfo, ScriptInfo, TransactionsInfo, TransactionsStatus } from \"../types\";\nimport { MaestroSupportedNetworks, MaestroConfig, SatoshiActivityResponse, BalanceResponse } from \"../types/maestro\";\nimport { parseHttpError } from \"./common\";\n\n/**\n * Maestro provider for Bitcoin operations.\n */\nexport class MaestroProvider implements IBitcoinProvider {\n    private readonly _axiosInstance: AxiosInstance;\n    private readonly _network: MaestroSupportedNetworks;\n\n    /**\n     * Create provider with custom base URL (for proxy endpoints).\n     * @param baseUrl - The base URL of the proxy endpoint.\n     * @param apiKey - The API key for the proxy.\n     */\n    constructor(baseUrl: string, apiKey: string);\n\n    /**\n     * Create provider with Maestro configuration.\n     * @param config - The Maestro configuration object.\n     */\n    constructor(config: MaestroConfig);\n\n    constructor(...args: unknown[]) {\n        if (\n            typeof args[0] === \"string\" &&\n            (args[0].startsWith(\"http\") || args[0].startsWith(\"/\"))\n        ) {\n            this._axiosInstance = axios.create({\n                baseURL: args[0],\n                headers: { \"api-key\": args[1] as string },\n            });\n            this._network = args[0].includes(\"testnet\") ? \"testnet\" : \"mainnet\";\n        } else {\n            const { network, apiKey } = args[0] as MaestroConfig;\n            this._axiosInstance = axios.create({\n                baseURL: `https://xbt-${network}.gomaestro-api.org/v0`,\n                headers: { \"api-key\": apiKey },\n            });\n            this._network = network;\n        }\n    }\n\n    /**\n     * Get information about a script hash.\n     * @param hash - The script hash.\n     * @returns ScriptInfo\n     * @note Maestro does not have any endpoint available for this yet\n     */\n    async fetchScript(hash: string): Promise<ScriptInfo> {\n        throw new Error(\n            \"fetchScript is not implemented - Maestro does not have any endpoint available for this yet\",\n        );\n    }\n\n    /**\n     * Get transaction history for the specified script hash, sorted with newest first.\n     * @param hash - The script hash.\n     * @param last_seen_txid - The last seen transaction ID (optional).\n     * @returns TransactionsInfo[]\n     * @note Maestro does not have any endpoint available for this yet\n     */\n    async fetchScriptTransactions(\n        hash: string,\n        last_seen_txid?: string,\n    ): Promise<TransactionsInfo[]> {\n        throw new Error(\n            \"fetchScriptTransactions is not implemented - Maestro does not have any endpoint available for this yet\",\n        );\n    }\n\n    /**\n     * Get the list of unspent transaction outputs associated with the script hash.\n     * @param hash - The script hash.\n     * @returns UTxO[]\n     * @note Maestro does not have any endpoint available for this yet\n     */\n    async fetchScriptUTxOs(hash: string): Promise<UTxO[]> {\n        throw new Error(\n            \"fetchScriptUTxOs is not implemented - Maestro does not have any endpoint available for this yet\",\n        );\n    }\n\n    /**\n     * Get information about an address.\n     * @param address - The address.\n     * @returns AddressInfo\n     */\n    async fetchAddress(address: string): Promise<AddressInfo> {\n        try {\n            const { data, status } = await this._axiosInstance.get(\n                `/esplora/address/${address}`,\n            );\n\n            if (status === 200) return data as AddressInfo;\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Get transaction history for the specified address, sorted with newest first.\n     * Returns up to 50 mempool transactions plus the first 25 confirmed transactions. You can request more confirmed transactions using `last_seen_txid`.\n     * @param address - The address.\n     * @param last_seen_txid - The last seen transaction ID (optional).\n     * @returns TransactionsInfo[]\n     */\n    async fetchAddressTransactions(\n        address: string,\n        last_seen_txid?: string,\n    ): Promise<TransactionsInfo[]> {\n        try {\n            const url = last_seen_txid\n                ? `/esplora/address/${address}/txs/chain/${last_seen_txid}`\n                : `/esplora/address/${address}/txs`;\n            const { data, status } = await this._axiosInstance.get(url);\n\n            if (status === 200) return data as TransactionsInfo[];\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Get the list of unspent transaction outputs associated with the address.\n     * @param address - The address.\n     * @returns UTxO[]\n     */\n    async fetchAddressUTxOs(address: string): Promise<UTxO[]> {\n        try {\n            const { data, status } = await this._axiosInstance.get(\n                `/esplora/address/${address}/utxo`,\n            );\n\n            if (status === 200) return data as UTxO[];\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Get the spending status of a transaction output.\n     * @param txid - The transaction ID.\n     * @returns TransactionsStatus\n     */\n    async fetchTransactionStatus(txid: string): Promise<TransactionsStatus> {\n        try {\n            const { data, status } = await this._axiosInstance.get(\n                `/esplora/tx/${txid}/status`,\n            );\n\n            if (status === 200) return data as TransactionsStatus;\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Broadcast a raw transaction to the network.\n     * @param txHex - The raw transaction in hexadecimal format.\n     * @returns The transaction ID.\n     */\n    async submitTx(txHex: string): Promise<string> {\n        try {\n            const { data, status } = await this._axiosInstance.post(\n                \"/esplora/tx\",\n                txHex,\n            );\n\n            if (status === 200) return data.txid || data;\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Get fee estimates for Bitcoin transactions.\n     * @param blocks - The number of blocks to estimate fees for (default: 6).\n     * @returns The estimated fee rate in satoshis per vByte.\n     */\n    async fetchFeeEstimates(blocks: number = 6): Promise<number> {\n        try {\n            const { data, status } = await this._axiosInstance.get(\n                `/rpc/transaction/estimatefee/${blocks}`,\n            );\n\n            if (status === 200) {\n                const feeRateInBtc = data.data.feerate;\n                if (feeRateInBtc === 0) {\n                    if (this._network === \"testnet\") {\n                        return 1; // 1 sat/vByte fallback for testnet (low activity expected)\n                    } else {\n                        throw new Error(\"Fee estimation unavailable for mainnet\");\n                    }\n                }\n\n                return feeRateInBtc * 100_000_000;\n            }\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    // Additional Bitcoin-specific methods (beyond IBitcoinProvider)\n    /**\n     * Fetch satoshi activity for a Bitcoin address (transaction history).\n     * @param address - The Bitcoin address.\n     * @param options - Optional parameters for filtering and pagination.\n     * @param options.order - Sort order ('asc' or 'desc').\n     * @param options.count - Maximum number of results to return.\n     * @param options.from - Start block height.\n     * @param options.to - End block height.\n     * @param options.cursor - Pagination cursor.\n     * @returns SatoshiActivityResponse containing transaction activity data.\n     */\n    async fetchSatoshiActivity(\n        address: string,\n        options: {\n            order?: \"asc\" | \"desc\";\n            count?: number;\n            from?: number;\n            to?: number;\n            cursor?: string;\n        } = {},\n    ): Promise<SatoshiActivityResponse> {\n        const params = new URLSearchParams();\n\n        Object.entries(options).forEach(([key, value]) => {\n            if (value !== undefined && value !== null) {\n                params.append(key, value.toString());\n            }\n        });\n\n        const queryString = params.toString();\n        const url = `/addresses/${address}/activity${queryString ? `?${queryString}` : \"\"}`;\n\n        try {\n            const { data, status } = await this._axiosInstance.get(url);\n\n            if (status === 200) return data as SatoshiActivityResponse;\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Get transaction details by hash.\n     * @param hash - The transaction hash.\n     * @returns TransactionsInfo containing transaction details.\n     */\n    async fetchTxInfo(hash: string): Promise<TransactionsInfo> {\n        try {\n            const { data, status } = await this._axiosInstance.get(\n                `/esplora/tx/${hash}`,\n            );\n\n            if (status === 200) return data as TransactionsInfo;\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Get address balance (raw response).\n     * @param address - The Bitcoin address.\n     * @returns BalanceResponse containing the raw balance data.\n     */\n    async fetchAddressBalance(address: string): Promise<BalanceResponse> {\n        try {\n            const { data, status } = await this._axiosInstance.get(\n                `/addresses/${address}/balance`,\n            );\n\n            if (status === 200) return data as BalanceResponse;\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Get balance for a Bitcoin address (convenience method).\n     * @param address - The Bitcoin address.\n     * @returns The balance as a bigint in satoshis.\n     */\n    async getBalance(address: string): Promise<bigint> {\n        const balanceResponse = await this.fetchAddressBalance(address);\n        return BigInt(balanceResponse.data);\n    }\n\n    /**\n     * Generic GET request for Bitcoin API endpoints.\n     * @param url - The API endpoint URL.\n     * @returns The response data.\n     */\n    async get(url: string): Promise<any> {\n        try {\n            const { data, status } = await this._axiosInstance.get(url);\n\n            if (status === 200) return data;\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Generic POST request for Bitcoin API endpoints.\n     * @param url - The API endpoint URL.\n     * @param body - The request body data.\n     * @returns The response data.\n     */\n    async post(url: string, body: any): Promise<any> {\n        try {\n            const { data, status } = await this._axiosInstance.post(url, body, {\n                headers: {\n                    \"Content-Type\": \"application/json\",\n                },\n            });\n\n            if (status === 200) return data;\n            throw parseHttpError(data);\n        } catch (error) {\n            throw parseHttpError(error);\n        }\n    }\n\n    /**\n     * Get the network this provider is configured for.\n     * @returns The network configuration (mainnet or testnet).\n     */\n    getNetwork(): MaestroSupportedNetworks {\n        return this._network;\n    }\n}\n","import { bitcoin } from \"../core\";\nimport { Address } from \"../types\";\n\nexport function resolveAddress(\n  publicKey: string | Buffer,\n  network: \"mainnet\" | \"testnet\" | bitcoin.networks.Network\n): Address {\n  const p2wpkh = bitcoin.payments.p2wpkh({\n    pubkey:\n      typeof publicKey === \"string\" ? Buffer.from(publicKey, \"hex\") : publicKey,\n    network:\n      network === \"mainnet\"\n        ? bitcoin.networks.bitcoin\n        : network === \"testnet\"\n          ? bitcoin.networks.testnet\n          : network,\n  });\n\n  if (!p2wpkh?.address) {\n    throw new Error(\"Address is not initialized.\");\n  }\n\n  const pubKeyHex = Buffer.isBuffer(publicKey)\n    ? publicKey.toString(\"hex\")\n    : publicKey;\n\n  return {\n    address: p2wpkh.address,\n    publicKey: pubKeyHex,\n    purpose: \"payment\",\n    addressType: \"p2wpkh\",\n  };\n}\n","// https://developer.bitcoin.org/reference/rpc/index.html#wallet-rpcs\n\nimport { Address } from \"../../types/address\";\nimport { IBitcoinWallet } from \"../../interfaces/wallet\";\n\ndeclare const window: {\n  BitcoinProvider?: any;\n};\n\nexport class BrowserWallet implements IBitcoinWallet {\n  private readonly _purposes: string[];\n\n  constructor(purposes: string[]) {\n    this._purposes = purposes;\n  }\n\n  /**\n   * This is the entrypoint to start communication with the user's wallet. The wallet should request the user's permission to connect the web page to the user's wallet, and if permission has been granted, the wallet will be returned and exposing the full API for the dApp to use.\n   * @param message - A message to display to the user when requesting permission to connect the wallet.\n   * @param purposes - An array of purposes for which the wallet is being connected. Default is `[\"payment\"]`. Options are `[\"payment\", \"ordinals\", \"stacks\"]`.\n   * @returns\n   */\n  static async enable(\n    message: string,\n    purposes = [\"payment\"]\n  ): Promise<BrowserWallet> {\n    const response = await WalletStaticMethods.request(\"getAccounts\", {\n      purposes: purposes,\n      message: message,\n    });\n    if (response.status === \"success\") {\n      return new BrowserWallet(purposes);\n    }\n    throw new Error(\"Failed to enable wallet\");\n  }\n\n  async getAddresses(): Promise<Address[] | undefined> {\n    try {\n      const response = await this.request(\"getAddresses\", {\n        purposes: this._purposes,\n      });\n      if (response.status === \"success\") {\n        return response.result.addresses as Address[];\n      }\n    } catch (err) {\n      console.error(\"getAccounts ~ error:\", err);\n    }\n  }\n\n  async getChangeAddress() {\n    const addresses = await this.getAddresses();\n    const address = addresses?.find((address) => address.purpose === \"payment\");\n    if (address) return address.address;\n    throw new Error(\"No change address found\");\n  }\n\n  async getCollateral() {\n    console.log(\"Method getCollateral not implemented.\");\n    return [];\n  }\n\n  async getNetworkId(): Promise<0 | 1> {\n    return 1;\n  }\n\n  async request(method: string, params?: any) {\n    return WalletStaticMethods.request(method, params);\n  }\n\n  async signData(\n    payload: string,\n    address?: string,\n    addressType: \"p2wpkh\" | \"p2tr\" | \"stacks\" = \"p2wpkh\"\n  ): Promise<\n    | {\n        address: string;\n        signature: string;\n        messageHash: string;\n      }\n    | undefined\n  > {\n    try {\n      let _address = address;\n      if (!_address) {\n        _address = await this.getAddresses().then((addresses) => {\n          const address = addresses?.find(\n            (address) => address.addressType === addressType\n          );\n          return address?.address;\n        });\n      }\n\n      if (_address) {\n        const response = await this.request(\"signMessage\", {\n          message: payload,\n          address: _address,\n        });\n        if (response.status === \"success\") {\n          return response.result;\n        }\n      }\n    } catch (err) {\n      console.error(\"signMessage ~ error:\", err);\n    }\n  }\n\n  async signTx(signedTx: string): Promise<string> {\n    console.log(\"Method signTx not implemented.\");\n    return \"\";\n  }\n\n  async submitTx(signedTx: string): Promise<string> {\n    console.log(\"Method submitTx not implemented.\");\n    return \"\";\n  }\n}\n\nclass WalletStaticMethods {\n  static async request(\n    method: string, // todo define\n    params: any, // todo define\n    providerId?: string\n  ): Promise<any> {\n    let provider = window.BitcoinProvider;\n    // todo extend to all wallets based on providerId\n\n    if (!provider) {\n      throw new Error(\"No wallet provider was found\");\n    }\n    if (!method) {\n      throw new Error(\"A wallet method is required\");\n    }\n\n    const response = await provider.request(method, params);\n\n    if (response.result) {\n      return {\n        status: \"success\",\n        result: response.result,\n      };\n    }\n\n    return {\n      status: \"error\",\n      error: response.error,\n    };\n  }\n}\n","import type { Network } from \"bitcoinjs-lib\";\nimport { BIP32Interface } from \"bip32\";\nimport { mnemonicToSeedSync, validateMnemonic } from \"bip39\";\n\nimport { bip32, bip39, bitcoin, ECPair } from \"../../core\";\nimport { IBitcoinProvider } from \"../../interfaces/provider\";\nimport { UTxO } from \"../../types/utxo\";\nimport {\n  CreateWalletOptions,\n  GetAddressResult,\n  GetBalanceResult,\n  SendTransferParams,\n  SendTransferResult,\n  SignMessageParams,\n  SignMessageResult,\n  SignMultipleTransactionsParams,\n  SignPsbtParams,\n  SignPsbtResult,\n} from \"../../types/wallet\";\nimport { resolveAddress } from \"../../utils\";\n\n/**\n * EmbeddedWallet is a class that provides a simple interface to interact with Bitcoin wallets.\n */\nexport class EmbeddedWallet {\n  private readonly _network: Network;\n  private readonly _wallet?: BIP32Interface;\n  private readonly _provider?: IBitcoinProvider;\n  private readonly _isReadOnly: boolean;\n  private readonly _address?: string;\n\n  constructor(options: CreateWalletOptions) {\n    switch (options.network) {\n      case \"Testnet\":\n        this._network = bitcoin.networks.testnet;\n        break;\n      case \"Regtest\":\n        this._network = bitcoin.networks.regtest;\n        break;\n      case \"Mainnet\":\n      default:\n        this._network = bitcoin.networks.bitcoin;\n        break;\n    }\n\n    if (options.key.type === \"mnemonic\") {\n      // Use BIP84 standard: m/84'/coin_type'/0'/0/0\n      // coin_type: 0 for mainnet, 1 for testnet (including testnet4 and regtest)\n      const coinType = this._network === bitcoin.networks.bitcoin ? 0 : 1;\n      const defaultPath = `m/84'/${coinType}'/0'/0/0`;\n      \n      this._wallet = _derive(\n        options.key.words,\n        options.path ?? defaultPath,\n        this._network,\n      );\n      this._isReadOnly = false;\n    } else {\n      // Read-only wallet initialized with just an address\n      this._address = options.key.address;\n      this._isReadOnly = true;\n    }\n\n    this._provider = options.provider;\n  }\n\n  /**\n   * Apps can specify which wallet addresses they require: Bitcoin ordinals address or Bitcoin payment address,\n   * using the `purposes` request parameter. The `message` request param gives apps the option to display a\n   * message to the user when requesting their addresses. (note: ignored for embedded wallets)\n   *\n   * @param purposes Array of strings used to specify the purpose of the address(es) to request:\n   *   - `'ordinals'` is preferably used to manage the user's ordinals\n   *   - `'payment'` is preferably used to manage the user's bitcoin\n   *   Example: `['ordinals', 'payment']`\n   * @param message Optional - a message to be displayed to the user in the request prompt (ignored for embedded wallets)\n   * @returns {Promise<GetAddressResult[]>} Once resolved, returns an array of the user's wallet address objects:\n   *   - `address`: string - the user's connected wallet address\n   *   - `publicKey`: A hex string representing the bytes of the public key of the account. You can use this to construct partially signed Bitcoin transactions (PSBT)\n   *   - `purpose`: string - The purpose of the address ('ordinals' for managing ordinals, 'payment' for managing bitcoin)\n   *   - `addressType`: string - the address's format ('P2TR' for ordinals, 'P2SH' for payment, 'P2WPKH' for payment using Ledger)\n   *   - `network`: string - the network where the address is being used ('mainnet', 'testnet', 'signet')\n   *   - `walletType`: string - the type of wallet used for the account ('ledger' for Ledger devices, 'software' otherwise)\n   * @throws {Error} If wallet is not properly initialized.\n   */\n  async getAddresses(\n    purposes?: Array<\"payment\" | \"ordinals\">,\n    message?: string,\n  ): Promise<GetAddressResult[]> {\n    // TODO: Implement full Xverse API compliance\n    // - Default to both purposes if not specified: [\"payment\", \"ordinals\"]\n    // - Generate payment address (P2WPKH) when \"payment\" is requested\n    // - Generate ordinals address (P2TR - Taproot) when \"ordinals\" is requested\n    // - Filter addresses based on requested purposes\n    //\n    // Note: `message` parameter is used by Xverse to show custom prompts to users,\n    // but embedded wallets don't have UI prompts, so this parameter is ignored here\n\n    if (this._isReadOnly && this._address) {\n      return [\n        {\n          address: this._address,\n          publicKey: \"\", // Not available for read-only wallets\n          purpose: \"payment\",\n          addressType: \"p2wpkh\",\n          network: this._getNetworkString(),\n          walletType: \"software\",\n        },\n      ];\n    }\n\n    if (!this._wallet) {\n      throw new Error(\"Wallet not initialized properly.\");\n    }\n\n    const addressInfo = resolveAddress(this._wallet.publicKey, this._network);\n\n    return [\n      {\n        address: addressInfo.address,\n        publicKey:\n          addressInfo.publicKey || this._wallet.publicKey.toString(\"hex\"),\n        purpose: \"payment\",\n        addressType: addressInfo.addressType,\n        network: this._getNetworkString(),\n        walletType: \"software\",\n      },\n    ];\n  }\n\n  /**\n   * Returns the hex-encoded public key of the wallet.\n   *\n   * @returns {string} The public key in hexadecimal format.\n   * @throws {Error} If the wallet is read-only and public key is not available.\n   */\n  getPublicKey(): string {\n    if (this._isReadOnly) {\n      throw new Error(\"Public key is not available for read-only wallets.\");\n    }\n\n    if (!this._wallet) {\n      throw new Error(\"Wallet not initialized properly.\");\n    }\n\n    return this._wallet.publicKey.toString(\"hex\");\n  }\n\n  /**\n   * Returns the network identifier of the wallet.\n   * 0: Indicates the Bitcoin testnet.\n   * 1: Indicates the Bitcoin mainnet.\n   * 2: Indicates the Bitcoin regtest.\n   *\n   * @returns {0 | 1 | 2} The Bitcoin network ID.\n   */\n  getNetworkId(): 0 | 1 | 2 {\n    if (this._network === bitcoin.networks.testnet) return 0;\n    if (this._network === bitcoin.networks.regtest) return 2;\n    return 1; // mainnet\n  }\n\n  /**\n   * Returns the network type as a string for API responses.\n   */\n  private _getNetworkString(): \"mainnet\" | \"testnet\" | \"regtest\" {\n    if (this._network === bitcoin.networks.testnet) return \"testnet\";\n    if (this._network === bitcoin.networks.regtest) return \"regtest\";\n    return \"mainnet\";\n  }\n\n  /**\n   * Get UTXOs for the wallet address.\n   * @returns An array of UTXOs.\n   */\n  async getUTxOs(): Promise<UTxO[]> {\n    const address = await this.getAddresses();\n    if (this._provider === undefined) {\n      throw new Error(\"`provider` is not defined. Provide a BitcoinProvider.\");\n    }\n\n    return await this._provider.fetchAddressUTxOs(address[0].address);\n  }\n\n  /**\n   * You can request to sign a message with wallet's Bitcoin addresses, by invoking the `signMessage` method.\n   *\n   * @param params - Object containing the following parameters:\n   *   - `address`: a string representing the address to use to sign the message\n   *   - `message`: a string representing the message to be signed by the wallet\n   *   - `protocol` (optional): By default, signMessage will use two type of signatures depending on the Bitcoin address used for signing:\n   *     - ECDSA signatures over the secp256k1 curve when signing with the Bitcoin payment (`p2sh`) address\n   *     - BIP322 signatures when signing with the Bitcoin Ordinals (`p2tr`) address or a Ledger-based Bitcoin payment address (`p2wpkh`)\n   *\n   *     You have the option to specify your preferred signature type with the `protocol` parameter:\n   *     - `ECDSA` to request ECDSA signatures over the secp256k1 curve (available for payment addresses only: `p2sh` and `p2wpkh`)\n   *     - `BIP322` to request BIP322 signatures (available for all payment (`p2sh` and `p2wpkh`) & ordinals addresses (`p2tr`))\n   * @returns Promise that resolves to the `SignMessageResult` object containing:\n   *   - `signature`: a string representing the signed message\n   *   - `messageHash`: a string representing the hash of the message\n   *   - `address`: a string representing the address used for signing\n   * @throws {Error} If the wallet is read-only or private key is not available.\n   */\n  async signMessage(params: SignMessageParams): Promise<SignMessageResult> {\n    const { address, message, protocol = \"ECDSA\" } = params;\n\n    // TODO: Implement BIP322 support for message signing\n    if (protocol === \"BIP322\") {\n      throw new Error(\n        \"BIP322 protocol is not yet supported. Only ECDSA is currently available.\",\n      );\n    }\n\n    if (this._isReadOnly) {\n      throw new Error(\"Cannot sign data with a read-only wallet.\");\n    }\n\n    if (!this._wallet || !this._wallet.privateKey) {\n      throw new Error(\"Private key is not available for signing.\");\n    }\n\n    // TODO: This uses legacy message signing format which may not be appropriate for SegWit addresses\n    // Since we're using BIP84 derivation path (m/84'/0'/0'/0/0) for native SegWit (P2WPKH),\n    // we should implement BIP322 message signing for proper SegWit address ownership proof\n\n    // Create ECPair from private key\n    const keyPair = ECPair.fromPrivateKey(this._wallet.privateKey, {\n      compressed: true,\n    });\n    // Prepare message buffer\n    const messageBuffer = Buffer.from(message, \"utf8\");\n    // Prepare the buffer to sign (see bitcoinjs-message implementation)\n\n    const bufferToHash = Buffer.concat([\n      varIntBuffer(messageBuffer.length),\n      messageBuffer,\n    ]);\n    const hash = bitcoin.crypto.hash256(bufferToHash);\n    // Sign the hash\n    const signature = keyPair.sign(hash);\n\n    return {\n      signature: signature.toString(\"base64\"),\n      messageHash: hash.toString(\"hex\"),\n      address: address,\n    };\n  }\n\n  /**\n   * You can use the `signPsbt` method to request the signature of a Partially Signed Bitcoin Transaction (PSBT)\n   * from Bitcoin wallet addresses.\n   *\n   * The PSBT to be signed must be base64-encoded. You can use any Bitcoin library to construct this transaction.\n   *\n   * @param params - Object containing the following parameters:\n   *   - `psbt`: a string representing the psbt to sign, encoded in base64\n   *   - `signInputs`: A Record<string, number[]> where:\n   *     - the keys are the addresses to use for signing\n   *     - the values are the indexes of the inputs to sign with each address\n   *   - `broadcast`: a boolean flag that specifies whether to broadcast the signed transaction after signature\n   *\n   * Depending on your use case, you can request that the PSBT be finalized and broadcasted after signing,\n   * by setting the broadcast flag to true. Otherwise, the signed PSBT will be returned in the response without broadcasting.\n   *\n   * @returns Promise that resolves to the `SignPsbtResult` object containing:\n   *   - `psbt`: The base64 encoded signed PSBT\n   *   - `txid`: The transaction id as a hex-encoded string (only returned if the transaction was broadcasted)\n   * @throws {Error} If the wallet is read-only or private key is not available.\n   */\n  async signPsbt(params: SignPsbtParams): Promise<SignPsbtResult> {\n    const { psbt: psbtBase64, signInputs, broadcast = false } = params;\n    if (this._isReadOnly) {\n      throw new Error(\"Cannot sign transactions with a read-only wallet.\");\n    }\n\n    if (!this._wallet || !this._wallet.privateKey) {\n      throw new Error(\"Private key is not available for signing.\");\n    }\n\n    const psbt = bitcoin.Psbt.fromBase64(psbtBase64, {\n      network: this._network,\n    });\n\n    const ecPair = ECPair.fromPrivateKey(this._wallet.privateKey, {\n      network: this._network,\n    });\n\n    // Sign the specified inputs\n    const allInputIndexes = Object.values(signInputs).flat();\n    allInputIndexes.forEach((inputIndex) => {\n      psbt.signInput(inputIndex, this._wallet!);\n      psbt.validateSignaturesOfInput(\n        inputIndex,\n        (pubkey, hash, signature) =>\n          ecPair.publicKey.equals(pubkey) && ecPair.verify(hash, signature),\n      );\n    });\n\n    const signedPsbt = psbt.toBase64();\n\n    if (broadcast) {\n      if (!this._provider) {\n        throw new Error(\n          \"`provider` is not defined. Provide a BitcoinProvider for broadcasting.\",\n        );\n      }\n\n      psbt.finalizeAllInputs();\n      const txHex = psbt.extractTransaction().toHex();\n      const txid = await this._provider.submitTx(txHex);\n\n      return {\n        psbt: signedPsbt,\n        txid: txid,\n      };\n    }\n\n    return {\n      psbt: signedPsbt,\n    };\n  }\n\n  /**\n   * You can use the `sendTransfer` method to request a transfer of any amount of Bitcoin to one or more recipients from the wallet.\n   *\n   * @param params - Object containing the following parameters:\n   *   - `recipients`: an array of objects with <address, amount> properties:\n   *     - `address`: a string representing the recipient's address\n   *     - `amount`: a number representing the amount of Bitcoin to send, denominated in satoshis (Bitcoin base unit)\n   * @returns Promise that resolves to the `sendTransferResult` object containing:\n   *   - `txid`: The transaction id as a hex-encoded string\n   * @throws {Error} If the wallet is read-only or provider is not available.\n   */\n  async sendTransfer(params: SendTransferParams): Promise<SendTransferResult> {\n    if (this._isReadOnly) {\n      throw new Error(\"Cannot send transactions with a read-only wallet.\");\n    }\n\n    if (!this._provider) {\n      throw new Error(\n        \"`provider` is not defined. Provide a BitcoinProvider for sending.\",\n      );\n    }\n\n    if (!this._wallet) {\n      throw new Error(\"Wallet not initialized properly.\");\n    }\n\n    const { recipients } = params;\n\n    const [addresses, utxos] = await Promise.all([\n      this.getAddresses(),\n      this.getUTxOs(),\n    ]);\n\n    const walletAddress = addresses[0].address;\n    const psbt = await this._buildTransferPsbt(\n      utxos,\n      recipients,\n      walletAddress,\n    );\n\n    // Sign and broadcast using signPsbt\n    const inputCount = psbt.inputCount;\n    const signInputs: Record<string, number[]> = {\n      [walletAddress]: Array.from({ length: inputCount }, (_, i) => i),\n    };\n\n    const signResult = await this.signPsbt({\n      psbt: psbt.toBase64(),\n      signInputs,\n      broadcast: true,\n    });\n\n    return { txid: signResult.txid! };\n  }\n\n  /**\n   * You can use the `getBalance` method to retrieve Bitcoin balance.\n   *\n   * The `getBalance` method will return an object representing the connected wallet's payment address BTC holdings:\n   *\n   * @returns Promise that resolves to an object containing the following balance information:\n   *   - `confirmed`: a string representing the connected wallet's confirmed BTC balance, i.e. the amount of confirmed BTC which the payment address holds, in satoshis\n   *   - `unconfirmed`: a string representing the connected wallet's unconfirmed BTC balance, i.e. the amount of unconfirmed BTC which the payment address will send/receive as a result of pending mempool transactions, in satoshis (Note: this amount can be negative if the net result of pending mempool transaction decreases the address balance)\n   *   - `total`: a string representing the sum of confirmed and unconfirmed BTC balances\n   * @throws {Error} If provider is not available.\n   */\n  async getBalance(): Promise<GetBalanceResult> {\n    if (!this._provider) {\n      throw new Error(\n        \"`provider` is not defined. Provide a BitcoinProvider for balance.\",\n      );\n    }\n\n    const addresses = await this.getAddresses();\n    const address = addresses[0].address;\n\n    const addressInfo = await this._provider.fetchAddress(address);\n    const confirmed =\n      addressInfo.chain_stats.funded_txo_sum -\n      addressInfo.chain_stats.spent_txo_sum;\n    const unconfirmed =\n      addressInfo.mempool_stats.funded_txo_sum -\n      addressInfo.mempool_stats.spent_txo_sum;\n    const total = confirmed + unconfirmed;\n\n    return {\n      confirmed: confirmed.toString(),\n      unconfirmed: unconfirmed.toString(),\n      total: total.toString(),\n    };\n  }\n\n  /**\n   * To request signing of multiple PSBTs, you can use the `signMultipleTransactions` function.\n   *\n   * @param params - Object containing an array of PSBTs to sign, where each PSBT contains:\n   *   - `psbtBase64`: a valid psbt encoded in base64\n   *   - `inputsToSign`: an array of objects describing the address and index of input to sign\n   * @returns Promise resolving to signed PSBTs\n   * @throws {Error} If the wallet is read-only or private key is not available.\n   */\n  async signMultipleTransactions(\n    params: SignMultipleTransactionsParams,\n  ): Promise<SignPsbtResult[]> {\n    if (!this._wallet || !this._wallet.privateKey) {\n      throw new Error(\"Private key is not available for signing.\");\n    }\n\n    const { psbts } = params;\n    const results: SignPsbtResult[] = [];\n\n    for (const psbtInfo of psbts) {\n      const psbt = bitcoin.Psbt.fromBase64(psbtInfo.psbtBase64, {\n        network: this._network,\n      });\n\n      // Sign all specified input indexes\n      const inputIndexes = psbtInfo.inputsToSign.flatMap(\n        (input) => input.signingIndexes,\n      );\n      inputIndexes.forEach((index) => psbt.signInput(index, this._wallet!));\n\n      results.push({\n        psbt: psbt.toBase64(),\n      });\n    }\n\n    return results;\n  }\n\n  /**\n   * Simple largest-first coin selection algorithm.\n   * Selects UTXOs in descending order by value until target amount + fees is reached.\n   *\n   * @param utxos Available UTXOs\n   * @param targetAmount Amount needed in satoshis\n   * @param feeRate Fee rate in sat/vByte\n   * @returns Selected UTXOs and change amount\n   */\n  private _selectUtxosLargestFirst(\n    utxos: UTxO[],\n    targetAmount: number,\n    feeRate: number,\n  ): { selectedUtxos: UTxO[]; change: number } {\n    // Sort UTXOs by value (descending) - largest first\n    const sortedUtxos = [...utxos].sort((a, b) => b.value - a.value);\n\n    let selectedValue = 0;\n    const selectedUtxos: UTxO[] = [];\n\n    // Accumulate UTXOs until we have enough\n    for (const utxo of sortedUtxos) {\n      selectedUtxos.push(utxo);\n      selectedValue += utxo.value;\n\n      // Calculate fee with current selection (rough estimate)\n      const estimatedTxSize = selectedUtxos.length * 150 + 2 * 34 + 10; // inputs + outputs + overhead\n      const fee = Math.ceil(estimatedTxSize * feeRate);\n\n      // Check if we have enough\n      if (selectedValue >= targetAmount + fee) {\n        const finalFee = Math.ceil(\n          (selectedUtxos.length * 150 + 2 * 34 + 10) * feeRate,\n        );\n        const change = selectedValue - targetAmount - finalFee;\n        return { selectedUtxos, change };\n      }\n    }\n\n    throw new Error(\"Insufficient funds for transaction.\");\n  }\n\n  /**\n   * Build PSBT for transfer using optimal coin selection.\n   * @param utxos Available UTXOs\n   * @param recipients Transfer recipients\n   * @param walletAddress Wallet address for change\n   * @returns Built PSBT ready for signing\n   */\n  private async _buildTransferPsbt(\n    utxos: UTxO[],\n    recipients: any[],\n    walletAddress: string,\n  ): Promise<bitcoin.Psbt> {\n    let feeRate = 2; // Default fallback\n    if (this._provider) {\n      try {\n        feeRate = await this._provider.fetchFeeEstimates(6);\n      } catch (error) {\n        console.warn(\"Fee estimation failed, using default rate:\", error);\n      }\n    }\n\n    // Use largest-first coin selection\n    const targetAmount = recipients.reduce((sum, r) => sum + r.amount, 0);\n    const { selectedUtxos, change } = this._selectUtxosLargestFirst(\n      utxos,\n      targetAmount,\n      feeRate,\n    );\n    const psbt = new bitcoin.Psbt({ network: this._network });\n    const p2wpkh = bitcoin.payments.p2wpkh({\n      pubkey: this._wallet!.publicKey,\n      network: this._network,\n    });\n\n    selectedUtxos.forEach((utxo) => {\n      psbt.addInput({\n        hash: utxo.txid,\n        index: utxo.vout,\n        witnessUtxo: {\n          script: p2wpkh.output!,\n          value: utxo.value,\n        },\n      });\n    });\n\n    recipients.forEach((recipient) => {\n      psbt.addOutput({ address: recipient.address, value: recipient.amount });\n    });\n\n    if (change > 0) {\n      psbt.addOutput({ address: walletAddress, value: change });\n    }\n\n    return psbt;\n  }\n\n  /**\n   * Generates a mnemonic phrase and returns it as an array of words.\n   *\n   * @param {number} [strength=128] - The strength of the mnemonic in bits (must be a multiple of 32 between 128 and 256).\n   * @returns {string[]} An array of words representing the generated mnemonic.\n   * @throws {Error} If the strength is not valid.\n   */\n  static brew(strength: number = 128): string[] {\n    if (![128, 160, 192, 224, 256].includes(strength)) {\n      throw new Error(\n        \"Invalid strength. Must be one of: 128, 160, 192, 224, 256.\",\n      );\n    }\n\n    const mnemonic = bip39.generateMnemonic(strength);\n    return mnemonic.split(\" \");\n  }\n}\n\nfunction _derive(\n  words: string[],\n  path: string = \"m/84'/0'/0'/0/0\",\n  network?: Network,\n): BIP32Interface {\n  const mnemonic = words.join(\" \");\n\n  if (!validateMnemonic(mnemonic)) {\n    throw new Error(\"Invalid mnemonic provided.\");\n  }\n\n  const seed = mnemonicToSeedSync(mnemonic);\n  const root = bip32.fromSeed(seed, network);\n  const child = root.derivePath(path);\n\n  return child;\n}\n\nfunction varIntBuffer(n: number): Buffer {\n  if (n < 0xfd) return Buffer.from([n]);\n  if (n <= 0xffff) return Buffer.from([0xfd, n & 0xff, n >> 8]);\n  if (n <= 0xffffffff)\n    return Buffer.from([\n      0xfe,\n      n & 0xff,\n      (n >> 8) & 0xff,\n      (n >> 16) & 0xff,\n      (n >> 24) & 0xff,\n    ]);\n  throw new Error(\"Message too long\");\n}\n\n/**\n * Verifies if a signature is valid for a given message and public key.\n * @param message - The original message that was signed.\n * @param signatureBase64 - The base64-encoded signature to verify.\n * @param publicKeyHex - The hex-encoded public key to verify against.\n * @returns {boolean} True if the signature is valid and matches the public key.\n */\nexport function verifySignature(\n  message: string,\n  signatureBase64: string,\n  publicKeyHex: string,\n): boolean {\n  try {\n    const messageBuffer = Buffer.from(message, \"utf8\");\n    const bufferToHash = Buffer.concat([\n      varIntBuffer(messageBuffer.length),\n      messageBuffer,\n    ]);\n    const hash = bitcoin.crypto.hash256(bufferToHash);\n    const signature = Buffer.from(signatureBase64, \"base64\");\n    const publicKey = Buffer.from(publicKeyHex, \"hex\");\n\n    return ECPair.fromPublicKey(publicKey).verify(hash, signature);\n  } catch (e) {\n    return false;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,cAAyB;AACzB,UAAqB;AACrB,YAAuB;AACvB,mBAA6B;AAC7B,oBAA8B;AAE9B,IAAM,YAAQ,2BAAa,GAAG;AAC9B,IAAM,aAAS,6BAAc,GAAG;AAExB,mBAAW,GAAG;;;ACTtB,sBAAmH;;;ACAnH,IAAAA,gBAAqC;;;ACArC,mBAAkB;AAEX,IAAM,iBAAiB,CAAC,UAA2B;AACxD,MAAI,CAAC,aAAAC,QAAM,aAAa,KAAK,GAAG;AAC9B,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B;AAEA,MAAI,MAAM,UAAU;AAClB,WAAO,KAAK,UAAU;AAAA,MACpB,MAAM,MAAM,SAAS;AAAA,MACrB,SAAS,MAAM,SAAS;AAAA,MACxB,QAAQ,MAAM,SAAS;AAAA,IACzB,CAAC;AAAA,EACH;AAEA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