{"version":3,"file":"index.mjs","names":[],"sources":["../source/requests/utilities.ts","../source/requests/address.ts","../source/requests/headers.ts","../source/requests/scripthash.ts","../source/requests/transaction.ts","../source/network.ts"],"sourcesContent":["/**\n * Creates a token filter according to electrum protocol requirements.\n */\nexport const generateTokenFilter = async function(includeSatoshis: boolean, includeTokens: boolean): Promise<string>\n{\n\t// Don't include anything.\n\tif(!includeSatoshis && !includeTokens)\n\t{\n\t\tthrow(new Error('Cannot create token filter that excludes both satoshis and tokens.'));\n\t}\n\n\t// Only include satoshis.\n\tif(includeSatoshis && !includeTokens)\n\t{\n\t\treturn 'exclude_tokens';\n\t}\n\n\t// Only include tokens.\n\tif(!includeSatoshis && includeTokens)\n\t{\n\t\treturn 'tokens_only';\n\t}\n\n\t// Include both satoshis and tokens.\n\treturn 'include_tokens';\n};\n","// Import utility functions.\nimport { generateTokenFilter } from './utilities.ts';\n\n// Import typing for electrum clients.\nimport type { ElectrumClient } from '@electrum-cash/network';\n\n// ...\nimport type\n{\n\t// Primitives\n\tAddress,\n\tBlockHeight,\n\n\t// Address related requests.\n\tAddressGetBalanceResponse,\n\tAddressGetHistoryResponse,\n\tAddressGetMempoolResponse,\n\tAddressListUnspentResponse,\n\tAddressGetFirstUseResponse,\n\n\t// Electrum protocol events.\n\tElectrumProtocolEvents,\n} from '../interfaces/index.ts';\n\n/**\n * @module Address\n * @memberof Network\n */\n\n/**\n * Fetches a balance for a given address.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param address         - The address to fetch balance for.\n * @param includeSatoshis - If the balance should include outputs that does not have tokens on them.\n * @param includeTokens   - If the balance should include outputs that have tokens on them.\n *\n * @returns the number of confirmed and unconfirmed satoshis on the relevant outputs.\n */\nexport const fetchBalance = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, address: Address, includeSatoshis: boolean = true, includeTokens: boolean = false): Promise<AddressGetBalanceResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Construct the token filter to determine what balances to include.\n\tconst tokenFilter = await generateTokenFilter(includeSatoshis, includeTokens);\n\n\t// Fetch the transaction from the network.\n\tconst trustedAddressBalance = await electrumClient.request('blockchain.address.get_balance', address, tokenFilter) as AddressGetBalanceResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(trustedAddressBalance instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = trustedAddressBalance.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch trusted balance: ${errorMessage}`));\n\t}\n\n\treturn trustedAddressBalance;\n};\n\n/**\n * Fetches the first time an address was used on-chain or in mempool.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param address         - The address to fetch first on-chain presence for.\n *\n * @returns the block height, block hash and transaction hash relating to this address first usage on-chain.\n */\nexport const fetchAddressFirstUse = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, address: Address): Promise<AddressGetFirstUseResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the transaction from the network.\n\tconst trustedAddressCreationHeight = await electrumClient.request('blockchain.address.get_first_use', address) as AddressGetFirstUseResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(trustedAddressCreationHeight instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = trustedAddressCreationHeight.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch trusted address creation height: ${errorMessage}`));\n\t}\n\n\treturn trustedAddressCreationHeight;\n};\n\n/**\n * Fetches the transaction history for an address.\n * @group Requests\n *\n * @param electrumClient    - an Electrum Client used to connect to the network.\n * @param address           - The address to fetch transaction history for.\n * @param fromHeight        - Limit transactions to those included in this and later blocks, if provided.\n * @param toHeightExclusive - Limit transactions to those included before this block, if provided.\n *\n * @returns the transactions that make up the on-chain history requested.\n */\nexport const fetchHistory = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, address: Address, fromHeight: BlockHeight = 0, toHeightExclusive: BlockHeight = undefined): Promise<AddressGetHistoryResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the history from the network.\n\tconst addressHistory = await electrumClient.request('blockchain.address.get_history', address, fromHeight, toHeightExclusive ?? -1) as AddressGetHistoryResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(addressHistory instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = addressHistory.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch address history: ${errorMessage}`));\n\t}\n\n\treturn addressHistory;\n};\n\n/**\n * Fetches a list of transactions related to an address, that are currently unconfirmed in the mempool.\n * @group Requests\n *\n * @param electrumClient - an Electrum Client used to connect to the network.\n * @param address        - The address to fetch mempool transactions for.\n *\n * @returns the list of related transactions in the mempool.\n */\nexport const fetchPendingTransactions = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, address: Address): Promise<AddressGetMempoolResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the transactions from the network.\n\tconst pendingTransactions = await electrumClient.request('blockchain.address.get_mempool', address) as AddressGetMempoolResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(pendingTransactions instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = pendingTransactions.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch pending transactions: ${errorMessage}`));\n\t}\n\n\treturn pendingTransactions;\n};\n\n/**\n * Fetches a list of transaction outputs that are ready to be spent.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param address         - The address to fetch a list of unspent transaction outputs for.\n * @param includeSatoshis - If the list should include outputs that does not have tokens on them.\n * @param includeTokens   - If the list should include outputs that have tokens on them.\n *\n * @return a list of unspent transaction outputs.\n*/\nexport const fetchUnspentTransactionOutputs = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, address: Address, includeSatoshis: boolean = true, includeTokens: boolean = false): Promise<AddressListUnspentResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Construct the token filter to determine what outputs to include.\n\tconst tokenFilter = await generateTokenFilter(includeSatoshis, includeTokens);\n\n\t// Fetch the list of unspent outputs from the network.\n\tconst unspentOutputs = await electrumClient.request('blockchain.address.listunspent', address, tokenFilter) as AddressListUnspentResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(unspentOutputs instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = unspentOutputs.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch unspent outputs: ${errorMessage}`));\n\t}\n\n\treturn unspentOutputs;\n};\n\n/**\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n *\n * @note before calling a subscription related method, you should set up an event listener to handle the generated notifications.\n */\nexport const subscribeToAddressUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, address: Address): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Subscribe to status updates for the address.\n\tawait electrumClient.subscribe('blockchain.address.subscribe', address);\n};\n\n/**\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n */\nexport const unsubscribeFromAddressUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, address: Address): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Unsubscribe to status updates for the address.\n\tawait electrumClient.subscribe('blockchain.address.unsubscribe', address);\n};\n","// Import typing for electrum clients.\nimport type { ElectrumClient } from '@electrum-cash/network';\n\n// ...\nimport type\n{\n\t// Primitives\n\tBlockHeight,\n\tBlockHeaderHash,\n\tBlockHeaderHex,\n\n\t// Block related requests.\n\tBlockHeaderResponse,\n\tBlockHeaderWithProofResponse,\n\tBlockHeadersResponse,\n\n\t// Header related requests.\n\tHeaderGetResponse,\n\tHeadersGetTipResponse,\n\n\t// Electrum protocol events.\n\tElectrumProtocolEvents,\n} from '../interfaces/index.ts';\n\n/**\n * @module Blockchain\n * @memberof Network\n */\n\n/**\n * Fetches the current block header for a given block height from the network.\n * @group Requests\n *\n * @param electrumClient - an Electrum Client used to connect to the network.\n * @param blockHeight    - block height to get block header for.\n *\n * @returns the block header as a hex-encoded string.\n */\nexport const fetchBlockHeaderFromBlockHeight = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, blockHeight: BlockHeight): Promise<BlockHeaderHex>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the block header from the backend network servers.\n\tconst blockHeaderHex = await electrumClient.request('blockchain.block.header', blockHeight) as BlockHeaderResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(blockHeaderHex instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = blockHeaderHex.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch block header from block height: ${errorMessage}`));\n\t}\n\n\t// Return the block header.\n\treturn blockHeaderHex;\n};\n\n/**\n * Fetches the current block header with an inclusion proof for a given block height from the network.\n * @group Requests\n *\n * @param electrumClient   - an Electrum Client used to connect to the network.\n * @param blockHeight      - block height to get block header for.\n * @param checkpointHeight - block height of the checkpoint to use as the base of the inclusion proof.\n *\n * @returns the block header with inclusion proof.\n */\nexport const fetchBlockHeaderWithProofFromBlockHeight = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, blockHeight: BlockHeight, checkpointHeight: BlockHeight): Promise<BlockHeaderWithProofResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the block header with inclusion proof from the backend network servers.\n\tconst blockHeaderWithProof = await electrumClient.request('blockchain.block.header', blockHeight, checkpointHeight) as BlockHeaderWithProofResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(blockHeaderWithProof instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = blockHeaderWithProof.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch block header with proof from block height: ${errorMessage}`));\n\t}\n\n\t// Return the block header with the inclusion proof.\n\treturn blockHeaderWithProof;\n};\n\n/**\n * Fetches the one or more block headers starting at a given height.\n * @group Requests\n *\n * @param electrumClient      - an Electrum Client used to connect to the network.\n * @param startingBlockHeight - block height for the first block header to request.\n * @param count               - the maximum number of block headers to request.\n *\n * @returns a list of block headers.\n */\nexport const fetchBlockHeaders = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, startingBlockHeight: BlockHeight, count: number): Promise<Array<BlockHeaderHex>>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the block header with inclusion proof from the backend network servers.\n\tconst response = await electrumClient.request('blockchain.block.headers', startingBlockHeight, count) as BlockHeadersResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(response instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = response.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch up to ${count} block headers starting with #${startingBlockHeight}: ${errorMessage}`));\n\t}\n\n\t// Extract the concatenated block headers.\n\tconst concatenatedBlockHeaders = response.hex;\n\n\t// Initialize an empty list of block headers.\n\tconst blockHeaders: Array<BlockHeaderHex> = [];\n\n\t// TODO: Move this to a constant somewhere.\n\tconst blockHeaderLength = 80 * 2;\n\n\t// Extract each block header hash and push them into the list.\n\tfor(let index = 0; index < response.count; index += 1)\n\t{\n\t\tblockHeaders.push(concatenatedBlockHeaders.slice(index * blockHeaderLength, (index + 1) * blockHeaderLength));\n\t}\n\n\t// Return the list of block headers\n\treturn blockHeaders;\n};\n\n/**\n * Fetches a given header from the network.\n * @group Requests\n *\n * @param electrumClient          - an Electrum Client used to connect to the network.\n * @param blockheaderHashOrHeight - the hash of the header to fetch, or the block height of the headers inclusion in the current chain.\n *\n * @returns the header requested from the network.\n */\nexport const fetchBlockHeader = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, blockheaderHashOrHeight: BlockHeaderHash | BlockHeight): Promise<HeaderGetResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the current chain tip.\n\tconst requestedHeader = await electrumClient.request('blockchain.header.get', blockheaderHashOrHeight) as HeaderGetResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(requestedHeader instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = requestedHeader.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch the requested header: ${errorMessage}`));\n\t}\n\n\t// Return the requested header.\n\treturn requestedHeader;\n};\n\n/**\n * Fetches the current chain tip from the network.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n *\n * @returns the current block height and block hash of the current chain tip.\n */\nexport const fetchCurrentChainTip = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>): Promise<HeadersGetTipResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the current chain tip.\n\tconst currentChainTip = await electrumClient.request('blockchain.headers.get_tip') as HeadersGetTipResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(currentChainTip instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = currentChainTip.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch the current chain tip: ${errorMessage}`));\n\t}\n\n\t// Return the fetched chain tip.\n\treturn currentChainTip;\n};\n\n/**\n * Subscribes to new block headers.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n *\n * @note before calling a subscription related method, you should set up an event listener to handle the generated notifications.\n */\nexport const subscribeToBlockheaderUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Subscribe to new block headers.\n\tawait electrumClient.subscribe('blockchain.headers.subscribe');\n};\n\n/**\n * Unsubscribes from new block headers.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n */\nexport const unsubscribeFromBlockheaderUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Unsubscribe from new block headers.\n\tawait electrumClient.unsubscribe('blockchain.headers.subscribe');\n};\n","// Import utility functions.\nimport { generateTokenFilter } from './utilities.ts';\n\n// Import typing for electrum clients.\nimport type { ElectrumClient } from '@electrum-cash/network';\n\n// ...\nimport type\n{\n\t// Primitives\n\tScriptHash,\n\tBlockHeight,\n\n\t// Scripthash related requests.\n\tScriptHashGetBalanceResponse,\n\tScriptHashGetHistoryResponse,\n\tScriptHashGetFirstUseResponse,\n\tScriptHashGetMempoolResponse,\n\tScriptHashListUnspentResponse,\n\n\t// Electrum protocol events.\n\tElectrumProtocolEvents,\n} from '../interfaces/index.ts';\n\n/**\n * @module Scripthash\n * @memberof Network\n */\n\n/**\n * Fetches a balance for a given script hash.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param scriptHash      - The script hash to fetch balance for.\n * @param includeSatoshis - If the balance should include outputs that does not have tokens on them.\n * @param includeTokens   - If the balance should include outputs that have tokens on them.\n *\n * @returns the number of confirmed and unconfirmed satoshis on the relevant outputs.\n */\nexport const fetchScriptHashBalance = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, scriptHash: ScriptHash, includeSatoshis: boolean = true, includeTokens: boolean = false): Promise<ScriptHashGetBalanceResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Construct the token filter to determine what balances to include.\n\tconst tokenFilter = await generateTokenFilter(includeSatoshis, includeTokens);\n\n\t// Fetch the transaction from the network.\n\tconst trustedScriptHashBalance = await electrumClient.request('blockchain.scripthash.get_balance', scriptHash, tokenFilter) as ScriptHashGetBalanceResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(trustedScriptHashBalance instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = trustedScriptHashBalance.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch trusted balance: ${errorMessage}`));\n\t}\n\n\treturn trustedScriptHashBalance;\n};\n\n/**\n * Fetches the first time a script hash was used on-chain or in mempool.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param scriptHash      - The script hash to fetch first on-chain presence for.\n *\n * @returns the block height, block hash and transaction hash relating to this script hash first usage on-chain.\n */\nexport const fetchScriptHashFirstUse = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, scriptHash: ScriptHash): Promise<ScriptHashGetFirstUseResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the transaction from the network.\n\tconst trustedScriptHashCreationHeight = await electrumClient.request('blockchain.scripthash.get_first_use', scriptHash) as ScriptHashGetFirstUseResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(trustedScriptHashCreationHeight instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = trustedScriptHashCreationHeight.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch trusted script hash creation height: ${errorMessage}`));\n\t}\n\n\treturn trustedScriptHashCreationHeight;\n};\n\n/**\n * Fetches the transaction history for a script hash.\n * @group Requests\n *\n * @param electrumClient    - an Electrum Client used to connect to the network.\n * @param scriptHash        - The script hash to fetch transaction history for.\n * @param fromHeight        - Limit transactions to those included in this and later blocks, if provided.\n * @param toHeightExclusive - Limit transactions to those included before this block, if provided.\n *\n * @returns the transactions that make up the on-chain history requested.\n */\nexport const fetchScriptHashHistory = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, scriptHash: ScriptHash, fromHeight: BlockHeight = 0, toHeightExclusive: BlockHeight = undefined): Promise<ScriptHashGetHistoryResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the history from the network.\n\tconst scriptHashHistory = await electrumClient.request('blockchain.scripthash.get_history', scriptHash, fromHeight, toHeightExclusive ?? -1) as ScriptHashGetHistoryResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(scriptHashHistory instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = scriptHashHistory.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch script hash history: ${errorMessage}`));\n\t}\n\n\treturn scriptHashHistory;\n};\n\n/**\n * Fetches a list of transactions related to a script hash, that are currently unconfirmed in the mempool.\n * @group Requests\n *\n * @param electrumClient - an Electrum Client used to connect to the network.\n * @param scriptHash     - The script hash to fetch mempool transactions for.\n *\n * @returns the list of related transactions in the mempool.\n */\nexport const fetchScriptHashPendingTransactions = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, scriptHash: ScriptHash): Promise<ScriptHashGetMempoolResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the transactions from the network.\n\tconst pendingTransactions = await electrumClient.request('blockchain.scripthash.get_mempool', scriptHash) as ScriptHashGetMempoolResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(pendingTransactions instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = pendingTransactions.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch pending transactions: ${errorMessage}`));\n\t}\n\n\treturn pendingTransactions;\n};\n\n/**\n * Fetches a list of transaction outputs that are ready to be spent.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param scriptHash      - The script hash to fetch a list of unspent transaction outputs for.\n * @param includeSatoshis - If the list should include outputs that does not have tokens on them.\n * @param includeTokens   - If the list should include outputs that have tokens on them.\n *\n * @return a list of unspent transaction outputs.\n*/\nexport const fetchScriptHashUnspentTransactionOutputs = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, scriptHash: ScriptHash, includeSatoshis: boolean = true, includeTokens: boolean = false): Promise<ScriptHashListUnspentResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Construct the token filter to determine what outputs to include.\n\tconst tokenFilter = await generateTokenFilter(includeSatoshis, includeTokens);\n\n\t// Fetch the list of unspent outputs from the network.\n\tconst unspentOutputs = await electrumClient.request('blockchain.scripthash.listunspent', scriptHash, tokenFilter) as ScriptHashListUnspentResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(unspentOutputs instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = unspentOutputs.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch unspent outputs: ${errorMessage}`));\n\t}\n\n\treturn unspentOutputs;\n};\n\n/**\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param scriptHash      - the script hash to monitor for status updates.\n *\n * @note before calling a subscription related method, you should set up an event listener to handle the generated notifications.\n */\nexport const subscribeToScriptHashUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, scriptHash: ScriptHash): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Subscribe to status updates for the scripthash.\n\tawait electrumClient.subscribe('blockchain.scripthash.subscribe', scriptHash);\n};\n\n/**\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param scriptHash      - the script hash to stop monitoring for status updates.\n */\nexport const unsubscribeFromScriptHashUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, scriptHash: ScriptHash): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Unsubscribe to status updates for the scripthash.\n\tawait electrumClient.subscribe('blockchain.scripthash.unsubscribe', scriptHash);\n};\n","// Import utility functions used for validation.\nimport { hashTransaction, hexToBin } from '@bitauth/libauth';\n\n// Import typing for electrum clients.\nimport type { ElectrumClient } from '@electrum-cash/network';\n\n// ...\nimport type\n{\n\t// Primitives\n\tTransactionHex,\n\tTransactionHash,\n\tBlockHeight,\n\n\t// Transaction related requests.\n\tTransactionBroadcastResponse,\n\tTransactionGetResponse,\n\tTransactionGetMerkleResponse,\n\tTransactionGetHeightResponse,\n\tTransactionGetConfirmedBlockHashResponse,\n\tTransactionDoublespendProofGetResponse,\n\n\t// Electrum protocol events.\n\tElectrumProtocolEvents,\n} from '../interfaces/index.ts';\n\n/**\n * @module Transactions\n * @memberof Network\n */\n\n/**\n * TODO: (later/never?)\n * blockchain.transaction.id_from_pos\n * blockchain.transaction.dsproof.list\n */\n\n/**\n * Broadcasts a raw transaction to the network.\n * @group Requests\n *\n * @param electrumClient - an Electrum Client used to connect to the network.\n * @param transactionHex - the raw transaction to broadcast, as a hex-encoded string.\n *\n * @returns the transactionHash of the broadcasted transaction.\n */\nexport const broadcastTransaction = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHex: TransactionHex): Promise<TransactionHash>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Hash the transaction so that we can verify that the result of our Electrum Broadcast Call is correct.\n\tconst expectedTransactionHash = hashTransaction(hexToBin(transactionHex));\n\n\t// Fetch the transaction from the network.\n\tconst returnedTransactionHash = await electrumClient.request('blockchain.transaction.broadcast', transactionHex) as TransactionBroadcastResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(returnedTransactionHash instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = returnedTransactionHash.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to broadcast transaction '${transactionHex}': ${errorMessage}`));\n\t}\n\n\t// If the response does not match our expected transaction hash..\n\tif(returnedTransactionHash !== expectedTransactionHash)\n\t{\n\t\tthrow(new Error(`Failed to broadcast transaction '${transactionHex}': returned transaction hash (${returnedTransactionHash}) does not match broadcasted transaction (${expectedTransactionHash})`));\n\t}\n\n\treturn returnedTransactionHash;\n};\n\n/**\n * Fetches a transaction from the network.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param transactionHash - hash of the transaction to fetch, as a hex-encoded string.\n *\n * @returns the transaction as a hex-encoded string.\n */\nexport const fetchTransaction = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHash: TransactionHash): Promise<TransactionHex>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the transaction from the network.\n\tconst transactionHex = await electrumClient.request('blockchain.transaction.get', transactionHash) as TransactionGetResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(transactionHex instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = transactionHex.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch transaction '${transactionHash}': ${errorMessage}`));\n\t}\n\n\t// NOTE: We do not check the returned transaction hex as requests for unknown transaction returns errors above.\n\n\t// Return the transaction hex with a type assertion as we know we did not use the verbose version of call.\n\treturn transactionHex as TransactionHex;\n};\n\n/**\n * Fetches the block height that a given transaction was included in, or a number indicating it is present in the mempool\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param transactionHash - hash of the transaction to fetch a block height for.\n *\n * @returns the block height the transaction was included in, if available.\n */\nexport const fetchTransactionBlockHeight = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHash: TransactionHash): Promise<BlockHeight>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the block height of the transaction from the backend network servers.\n\tconst blockHeight = await electrumClient.request('blockchain.transaction.get_height', transactionHash) as TransactionGetHeightResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(blockHeight instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = blockHeight.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch transaction confirmation height: ${errorMessage}`));\n\t}\n\n\t// Return the block height the transaction was included in, or it's presence in the mempool.\n\treturn blockHeight;\n};\n\n/**\n * Fetches the block hash, height and optionally header that a given transaction was included in.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param transactionHash - hash of the transaction to fetch a block height for.\n * @param includeHeader   - if set to true, response includes the optional block header.\n *\n * @returns the block hash, height and header the transaction was included in, if available.\n */\nexport const fetchTransactionConfirmation = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHash: TransactionHash, includeHeader: boolean = false): Promise<TransactionGetConfirmedBlockHashResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the transaction confirmation from the backend network servers.\n\tconst transactionConfirmation = await electrumClient.request('blockchain.transaction.get_confirmed_blockhash', transactionHash, includeHeader) as TransactionGetConfirmedBlockHashResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(transactionConfirmation instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = transactionConfirmation.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch transaction confirmation: ${errorMessage}`));\n\t}\n\n\t// Return the transaction confirmation data.\n\treturn transactionConfirmation;\n};\n\n/**\n * Fetches the transaction's merkle proof from the network.\n * @group Requests\n *\n * @param electrumClient  - an Electrum Client used to connect to the network.\n * @param transactionHash - hex-encoded string of the transaction hash\n * @param blockHeight     - number for the blockheight that transaction was stored in\n *\n * @throws if the network returns an invalid merkle proof.\n * @returns the merkle proof for the transaction, or undefined if transaction is still unconfirmed.\n */\nexport const fetchTransactionProof = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHash: TransactionHash, blockHeight: BlockHeight): Promise<TransactionGetMerkleResponse | undefined>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the proof from the backend network servers.\n\tconst transactionInclusionProof = await electrumClient.request('blockchain.transaction.get_merkle', transactionHash, blockHeight) as TransactionGetMerkleResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(transactionInclusionProof instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = transactionInclusionProof.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch transaction inclusion proof: ${errorMessage}`));\n\t}\n\n\treturn transactionInclusionProof;\n};\n\n/**\n * TODO: Document me.\n * @group Requests\n *\n * @param electrumClient - an Electrum Client used to connect to the network.\n *\n * @note before calling a subscription related method, you should set up an event listener to handle the generated notifications.\n */\nexport const subscribeToTransactionUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHash: TransactionHash): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Subscribe to status updates for the transaction.\n\tawait electrumClient.subscribe('blockchain.transaction.subscribe', transactionHash);\n};\n\n/**\n * TODO: Document me.\n * @group Requests\n *\n * @param electrumClient - an Electrum Client used to connect to the network.\n */\nexport const unsubscribeFromTransactionUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHash: TransactionHash): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Unsubscribe to status updates for the transaction.\n\tawait electrumClient.subscribe('blockchain.transaction.unsubscribe', transactionHash);\n};\n\n/**\n * TODO: Document me.\n * @group Requests\n *\n * @param electrumClient - an Electrum Client used to connect to the network.\n */\nexport const fetchDoublespendProof = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHash: TransactionHash): Promise<TransactionDoublespendProofGetResponse>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Fetch the transaction doublespend proof from the network.\n\tconst doublespendProof = await electrumClient.request('blockchain.transaction.dsproof.get', transactionHash) as TransactionDoublespendProofGetResponse | Error;\n\n\t// Throw an error if the request failed.\n\tif(doublespendProof instanceof Error)\n\t{\n\t\t// Extract the error message from the error response.\n\t\tconst errorMessage = doublespendProof.message;\n\n\t\t// Throw an error with additional context.\n\t\tthrow(new Error(`Failed to fetch doublespend proof for '${transactionHash}': ${errorMessage}`));\n\t}\n\n\treturn doublespendProof;\n};\n\n/**\n * TODO: Document me.\n * @group Requests\n *\n * @param electrumClient - an Electrum Client used to connect to the network.\n *\n * @note before calling a subscription related method, you should set up an event listener to handle the generated notifications.\n */\nexport const subscribeToDoublespendUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHash: TransactionHash): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Subscribe to doublespend updates for the transaction.\n\tawait electrumClient.subscribe('blockchain.transaction.dsproof.subscribe', transactionHash);\n};\n\n/**\n * TODO: Document me.\n * @group Requests\n *\n * @param electrumClient - an Electrum Client used to connect to the network.\n */\nexport const unsubscribeFromDoublespendUpdates = async function(electrumClient: ElectrumClient<ElectrumProtocolEvents>, transactionHash: TransactionHash): Promise<void>\n{\n\t// Ensure the electrum client is connected.\n\tawait electrumClient.connect();\n\n\t// Unsubscribe to doublespend updates for the transaction.\n\tawait electrumClient.subscribe('blockchain.transaction.dsproof.unsubscribe', transactionHash);\n};\n","// Import the electrum client and related information.\nimport { ElectrumClient } from '@electrum-cash/network';\n\n// ...\nimport type { ElectrumSocket, ElectrumNetworkOptions } from '@electrum-cash/network';\n\n// Import electrum and blockchain related type information.\nimport type { ElectrumProtocolEvents, VersionNumbers, ElectrumNotification, AddressSubscribeNotification, TransactionSubscribeNotification, TransactionDsProofNotification, HeadersSubscribeNotification, ScriptHashSubscribeNotification } from './interfaces/index.ts';\n\n/**\n * Defines the required version of the electrum cash protocol\n * @group Setup\n */\nexport const requiredProtocolVersion = '1.5.2';\n\n/**\n * Extracts the major, minor and patch numbers from an electrum version string.\n * @ignore\n */\nexport const extractVersionNumbers = async function(versionString: string): Promise<VersionNumbers>\n{\n\t// Define a regexp to extract the version numbers.\n\tconst regexp = /(?<major>[0-9]+)(\\.(?<minor>[0-9]+))?(\\.(?<patch>[0-9]+))?/g;\n\n\t// Consume the iterator to get the single match.\n\tconst { value: match } = versionString.matchAll(regexp).next();\n\n\t// Throw an error if we couldn't parse the version numbers.\n\tif(!match || !match.groups.major)\n\t{\n\t\tthrow(new Error(`Could not extract version numbers from '${versionString}'.`));\n\t}\n\n\t// Return the extracted version numbers.\n\treturn match.groups as unknown as VersionNumbers;\n};\n\n/**\n * Utility function that verifies that a provided electrum version string is sufficient for usage in this library.\n * @group Setup\n * @internal\n */\nexport const sufficientProtocolVersion = async function(providedVersion: string): Promise<boolean>\n{\n\tconst providedVersionNumbers = await extractVersionNumbers(providedVersion);\n\tconst requiredVersionNumbers = await extractVersionNumbers(requiredProtocolVersion);\n\n\t// Return true if the provided major version exceeds required major version.\n\tif(providedVersionNumbers.major > requiredVersionNumbers.major)\n\t{\n\t\treturn true;\n\t}\n\n\t// Return false if the provided major version is insufficient.\n\tif(providedVersionNumbers.major < requiredVersionNumbers.major)\n\t{\n\t\treturn false;\n\t}\n\n\t// The major version is now the same.\n\n\t// Return true if the provided major version is the same, and the minor version exceeds required minor version.\n\tif(providedVersionNumbers.minor > requiredVersionNumbers.minor)\n\t{\n\t\treturn true;\n\t}\n\n\t// Return false if the provided major version is insufficient.\n\tif(providedVersionNumbers.minor < requiredVersionNumbers.minor)\n\t{\n\t\treturn false;\n\t}\n\n\t// The major and minor versions are now the same.\n\n\t// Return true if the provided major and minor versions are the same, and the patch version is sufficient.\n\tif(providedVersionNumbers.patch >= requiredVersionNumbers.patch)\n\t{\n\t\treturn true;\n\t}\n\n\t// Return false since the patch version was not sufficient.\n\treturn false;\n};\n\n/**\n * Handler function for all electrum notifications.\n *\n * This function determines what type of notification has been provided and emits the\n * same notification it received, but with added type information.\n * @ignore\n */\nexport const processElectrumNotifications = async function(notification: ElectrumNotification): Promise<void>\n{\n\t// If this is an address status update notification..\n\tif(notification.method === 'blockchain.address.subscribe')\n\t{\n\t\t// Re-emit the event with full typing.\n\t\tthis.emit(notification.method, notification as AddressSubscribeNotification);\n\t}\n\n\t// If this is a scripthash status update notification..\n\tif(notification.method === 'blockchain.scripthash.subscribe')\n\t{\n\t\t// Re-emit the event with full typing.\n\t\tthis.emit(notification.method, notification as ScriptHashSubscribeNotification);\n\t}\n\n\t// If this is a transaction status update notification..\n\tif(notification.method === 'blockchain.transaction.subscribe')\n\t{\n\t\t// Re-emit the event with full typing.\n\t\tthis.emit(notification.method, notification as TransactionSubscribeNotification);\n\t}\n\n\t// If this is a transaction double spend notification..\n\tif(notification.method === 'blockchain.transaction.dsproof.subscribe')\n\t{\n\t\t// Re-emit the event with full typing.\n\t\tthis.emit(notification.method, notification as TransactionDsProofNotification);\n\t}\n\n\t// If this is a block header notification..\n\tif(notification.method === 'blockchain.headers.subscribe')\n\t{\n\t\t// Re-emit the event with full typing.\n\t\tthis.emit(notification.method, notification as HeadersSubscribeNotification);\n\t}\n};\n\n/**\n * Creates and initializes an electrum client in order\n * to provide typed electrum notification events.\n *\n * @emits blockchain.address.subscribe\n * @emits blockchain.scripthash.subscribe\n * @emits blockchain.transaction.subscribe\n * @emits blockchain.transaction.dsproof.subscribe\n * @emits blockchain.headers.subscribe\n *\n * @group Setup\n *\n * @param application       - your application name, used to identify to the electrum host.\n * @param socketOrHostname  - pre-configured electrum socket or fully qualified domain name or IP number of the host\n * @param options           - optional settings that change the default behavior of the network connection.\n *\n * @returns an electrum client that provides fully typed electrum notifications.\n */\nexport const initializeElectrumClient = async function(application: string, socketOrHostname: ElectrumSocket | string, options?: ElectrumNetworkOptions): Promise<ElectrumClient<ElectrumProtocolEvents>>\n{\n\t// Store the electrum client as the initialized network provider.\n\tconst electrumClient = new ElectrumClient<ElectrumProtocolEvents>(application, requiredProtocolVersion, socketOrHostname, options);\n\n\t// Hook up the electrum notification parser to the client.\n\telectrumClient.on('notification', processElectrumNotifications.bind(electrumClient));\n\n\t// Connect the electrum client with the electrum server in the background.\n\telectrumCl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