@uswap/toolboxes 4.3.6 → 4.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/src/cardano/index.cjs +2 -2
  2. package/dist/src/cardano/index.cjs.map +3 -3
  3. package/dist/src/cardano/index.js +2 -2
  4. package/dist/src/cardano/index.js.map +3 -3
  5. package/dist/src/cosmos/index.cjs +2 -2
  6. package/dist/src/cosmos/index.cjs.map +8 -8
  7. package/dist/src/cosmos/index.js +2 -2
  8. package/dist/src/cosmos/index.js.map +8 -8
  9. package/dist/src/evm/index.cjs +2 -2
  10. package/dist/src/evm/index.cjs.map +7 -7
  11. package/dist/src/evm/index.js +2 -2
  12. package/dist/src/evm/index.js.map +7 -7
  13. package/dist/src/index.cjs +3 -3
  14. package/dist/src/index.cjs.map +34 -34
  15. package/dist/src/index.js +3 -3
  16. package/dist/src/index.js.map +34 -34
  17. package/dist/src/near/index.cjs +2 -2
  18. package/dist/src/near/index.cjs.map +5 -5
  19. package/dist/src/near/index.js +2 -2
  20. package/dist/src/near/index.js.map +5 -5
  21. package/dist/src/radix/index.cjs +2 -2
  22. package/dist/src/radix/index.cjs.map +3 -3
  23. package/dist/src/radix/index.js +2 -2
  24. package/dist/src/radix/index.js.map +3 -3
  25. package/dist/src/ripple/index.cjs +2 -2
  26. package/dist/src/ripple/index.cjs.map +3 -3
  27. package/dist/src/ripple/index.js +2 -2
  28. package/dist/src/ripple/index.js.map +3 -3
  29. package/dist/src/solana/index.cjs +2 -2
  30. package/dist/src/solana/index.cjs.map +3 -3
  31. package/dist/src/solana/index.js +2 -2
  32. package/dist/src/solana/index.js.map +3 -3
  33. package/dist/src/substrate/index.cjs +2 -2
  34. package/dist/src/substrate/index.cjs.map +4 -4
  35. package/dist/src/substrate/index.js +2 -2
  36. package/dist/src/substrate/index.js.map +4 -4
  37. package/dist/src/sui/index.cjs +2 -2
  38. package/dist/src/sui/index.cjs.map +3 -3
  39. package/dist/src/sui/index.js +2 -2
  40. package/dist/src/sui/index.js.map +3 -3
  41. package/dist/src/ton/index.cjs +2 -2
  42. package/dist/src/ton/index.cjs.map +3 -3
  43. package/dist/src/ton/index.js +2 -2
  44. package/dist/src/ton/index.js.map +3 -3
  45. package/dist/src/tron/index.cjs +2 -2
  46. package/dist/src/tron/index.cjs.map +4 -4
  47. package/dist/src/tron/index.js +2 -2
  48. package/dist/src/tron/index.js.map +4 -4
  49. package/dist/src/utxo/index.cjs +3 -3
  50. package/dist/src/utxo/index.cjs.map +11 -11
  51. package/dist/src/utxo/index.js +3 -3
  52. package/dist/src/utxo/index.js.map +11 -11
  53. package/dist/types/cardano/toolbox.d.ts +5 -0
  54. package/dist/types/cardano/toolbox.d.ts.map +1 -1
  55. package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts +5 -0
  56. package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts.map +1 -1
  57. package/dist/types/cosmos/thorchainUtils/messages.d.ts +5 -0
  58. package/dist/types/cosmos/thorchainUtils/messages.d.ts.map +1 -1
  59. package/dist/types/cosmos/toolbox/cosmos.d.ts +5 -0
  60. package/dist/types/cosmos/toolbox/cosmos.d.ts.map +1 -1
  61. package/dist/types/cosmos/toolbox/index.d.ts +5 -0
  62. package/dist/types/cosmos/toolbox/index.d.ts.map +1 -1
  63. package/dist/types/cosmos/toolbox/thorchain.d.ts +5 -0
  64. package/dist/types/cosmos/toolbox/thorchain.d.ts.map +1 -1
  65. package/dist/types/cosmos/util.d.ts +5 -0
  66. package/dist/types/cosmos/util.d.ts.map +1 -1
  67. package/dist/types/evm/helpers.d.ts +1 -1
  68. package/dist/types/evm/helpers.d.ts.map +1 -1
  69. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +7 -0
  70. package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -1
  71. package/dist/types/evm/toolbox/evm.d.ts +38 -38
  72. package/dist/types/evm/toolbox/evm.d.ts.map +1 -1
  73. package/dist/types/evm/toolbox/op.d.ts +7 -14
  74. package/dist/types/evm/toolbox/op.d.ts.map +1 -1
  75. package/dist/types/index.d.ts +5 -0
  76. package/dist/types/index.d.ts.map +1 -1
  77. package/dist/types/near/helpers/core.d.ts +5 -0
  78. package/dist/types/near/helpers/core.d.ts.map +1 -1
  79. package/dist/types/near/toolbox.d.ts +5 -0
  80. package/dist/types/near/toolbox.d.ts.map +1 -1
  81. package/dist/types/radix/index.d.ts +5 -0
  82. package/dist/types/radix/index.d.ts.map +1 -1
  83. package/dist/types/ripple/index.d.ts +5 -0
  84. package/dist/types/ripple/index.d.ts.map +1 -1
  85. package/dist/types/solana/toolbox.d.ts +5 -0
  86. package/dist/types/solana/toolbox.d.ts.map +1 -1
  87. package/dist/types/substrate/substrate.d.ts +5 -0
  88. package/dist/types/substrate/substrate.d.ts.map +1 -1
  89. package/dist/types/sui/toolbox.d.ts +5 -0
  90. package/dist/types/sui/toolbox.d.ts.map +1 -1
  91. package/dist/types/ton/toolbox.d.ts +5 -0
  92. package/dist/types/ton/toolbox.d.ts.map +1 -1
  93. package/dist/types/tron/helpers/trongrid.d.ts +5 -0
  94. package/dist/types/tron/helpers/trongrid.d.ts.map +1 -1
  95. package/dist/types/tron/toolbox.d.ts +5 -0
  96. package/dist/types/tron/toolbox.d.ts.map +1 -1
  97. package/dist/types/utils.d.ts.map +1 -1
  98. package/dist/types/utxo/helpers/api.d.ts +5 -0
  99. package/dist/types/utxo/helpers/api.d.ts.map +1 -1
  100. package/dist/types/utxo/helpers/bchaddrjs.d.ts +5 -0
  101. package/dist/types/utxo/helpers/bchaddrjs.d.ts.map +1 -1
  102. package/dist/types/utxo/helpers/coinselect.d.ts +5 -0
  103. package/dist/types/utxo/helpers/coinselect.d.ts.map +1 -1
  104. package/dist/types/utxo/helpers/txSize.d.ts +5 -0
  105. package/dist/types/utxo/helpers/txSize.d.ts.map +1 -1
  106. package/dist/types/utxo/toolbox/bitcoinCash.d.ts +5 -0
  107. package/dist/types/utxo/toolbox/bitcoinCash.d.ts.map +1 -1
  108. package/dist/types/utxo/toolbox/index.d.ts +5 -0
  109. package/dist/types/utxo/toolbox/index.d.ts.map +1 -1
  110. package/dist/types/utxo/toolbox/utxo.d.ts +5 -0
  111. package/dist/types/utxo/toolbox/utxo.d.ts.map +1 -1
  112. package/dist/types/utxo/toolbox/zcash.d.ts +6 -1
  113. package/dist/types/utxo/toolbox/zcash.d.ts.map +1 -1
  114. package/package.json +4 -4
  115. package/src/cardano/toolbox.ts +12 -6
  116. package/src/cosmos/__tests__/toolbox.test.ts +8 -4
  117. package/src/cosmos/thorchainUtils/addressFormat.ts +8 -2
  118. package/src/cosmos/thorchainUtils/messages.ts +8 -2
  119. package/src/cosmos/toolbox/cosmos.ts +11 -5
  120. package/src/cosmos/toolbox/index.ts +8 -2
  121. package/src/cosmos/toolbox/thorchain.ts +9 -3
  122. package/src/cosmos/util.ts +9 -3
  123. package/src/evm/helpers.ts +7 -9
  124. package/src/evm/toolbox/baseEVMToolbox.ts +34 -26
  125. package/src/evm/toolbox/evm.ts +2 -3
  126. package/src/evm/toolbox/op.ts +10 -17
  127. package/src/index.ts +8 -2
  128. package/src/near/helpers/core.ts +8 -2
  129. package/src/near/toolbox.ts +21 -15
  130. package/src/radix/index.ts +15 -3
  131. package/src/ripple/index.ts +15 -12
  132. package/src/solana/toolbox.ts +16 -16
  133. package/src/substrate/balance.ts +2 -2
  134. package/src/substrate/substrate.ts +17 -11
  135. package/src/sui/__tests__/toolbox.test.ts +9 -5
  136. package/src/sui/toolbox.ts +18 -11
  137. package/src/ton/__tests__/toolbox.test.ts +9 -5
  138. package/src/ton/toolbox.ts +14 -8
  139. package/src/tron/helpers/trongrid.ts +8 -2
  140. package/src/tron/toolbox.ts +21 -15
  141. package/src/utils.ts +8 -1
  142. package/src/utxo/helpers/api.ts +15 -9
  143. package/src/utxo/helpers/bchaddrjs.ts +9 -3
  144. package/src/utxo/helpers/coinselect.ts +8 -2
  145. package/src/utxo/helpers/txSize.ts +8 -2
  146. package/src/utxo/toolbox/bitcoinCash.ts +13 -7
  147. package/src/utxo/toolbox/index.ts +8 -2
  148. package/src/utxo/toolbox/utxo.ts +16 -10
  149. package/src/utxo/toolbox/zcash.ts +24 -21
@@ -2,20 +2,20 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/utils.ts", "../src/utxo/helpers/api.ts", "../src/utxo/helpers/bchaddrjs.ts", "../src/utxo/helpers/txSize.ts", "../src/utxo/helpers/coinselect.ts", "../src/utxo/helpers/index.ts", "../src/utxo/toolbox/validators.ts", "../src/utxo/toolbox/utxo.ts", "../src/utxo/toolbox/bitcoinCash.ts", "../src/utxo/toolbox/zcash.ts", "../src/utxo/toolbox/index.ts", "../src/utxo/index.ts"],
4
4
  "sourcesContent": [
5
- "import { AssetValue, type Chain, getChainConfig } from \"@uswap/helpers\";\nimport { SwapKitApi } from \"@uswap/helpers/api\";\n\nconst pid = typeof process !== \"undefined\" && process.pid ? process.pid.toString(36) : \"\";\n\nlet last = 0;\nexport function uniqid() {\n function now() {\n const time = Date.now();\n const lastTime = last || time;\n last = lastTime;\n\n return time > last ? time : lastTime + 1;\n }\n\n return pid + now().toString(36);\n}\n\nexport function getBalance<T extends Chain>(chain: T) {\n return async function getBalance(address: string, scamFilter = true) {\n const balances = await SwapKitApi.getChainBalance({ address, chain, scamFilter });\n const { baseDecimal } = getChainConfig(chain);\n return balances.map(({ identifier, value, decimal }) => {\n return new AssetValue({ decimal: decimal || baseDecimal, identifier, value });\n });\n };\n}\n",
6
- "import { networks as zcashNetworks } from \"@bitgo/utxo-lib\";\nimport { Chain, getRPCUrl, RequestClient, SKConfig, SwapKitError, type UTXOChain, warnOnce } from \"@uswap/helpers\";\nimport { networks } from \"bitcoinjs-lib\";\n// @ts-expect-error\nimport coininfo from \"coininfo\";\nimport { uniqid } from \"../../utils\";\n\ntype BlockchairParams<T> = T & { chain: Chain; apiKey?: string };\ntype BlockchairFetchUnspentUtxoParams = BlockchairParams<{\n offset?: number;\n limit?: number;\n address: string;\n targetValue?: number;\n accumulativeValue?: number;\n}>;\n\nasync function broadcastUTXOTx({ chain, txHash }: { chain: Chain; txHash: string }) {\n // Use Blockchair's push transaction endpoint (no API key needed)\n const url = `${baseUrl(chain)}/push/transaction`;\n const body = JSON.stringify({ data: txHash });\n\n try {\n const response = await RequestClient.post<{\n data: { transaction_hash: string } | null;\n context: { code: number; error?: string };\n }>(url, { body, headers: { \"Content-Type\": \"application/json\" } });\n\n if (response.context.code !== 200) {\n throw new SwapKitError(\"toolbox_utxo_broadcast_failed\", {\n error: response.context.error || \"Transaction broadcast failed\",\n });\n }\n\n return response.data?.transaction_hash || txHash;\n } catch (error) {\n // Fallback to RPC if Blockchair fails\n const rpcUrl = await getRPCUrl(chain);\n if (rpcUrl) {\n const rpcBody = JSON.stringify({ id: uniqid(), jsonrpc: \"2.0\", method: \"sendrawtransaction\", params: [txHash] });\n\n const rpcResponse = await RequestClient.post<{\n id: string;\n result: string;\n error: { message: string; code?: number } | null;\n }>(rpcUrl, { body: rpcBody, headers: { \"Content-Type\": \"application/json\" } });\n\n if (rpcResponse.error) {\n throw new SwapKitError(\"toolbox_utxo_broadcast_failed\", { error: rpcResponse.error?.message });\n }\n\n if (rpcResponse.result.includes('\"code\":-26')) {\n throw new SwapKitError(\"toolbox_utxo_invalid_transaction\", { error: \"Transaction amount was too low\" });\n }\n\n return rpcResponse.result;\n }\n\n throw error;\n }\n}\n\nfunction baseUrl(chain: Chain) {\n return `https://api.blockchair.com/${mapChainToBlockchairChain(chain)}`;\n}\n\nfunction getDefaultTxFeeByChain(chain: Chain) {\n switch (chain) {\n case Chain.Bitcoin:\n return 5;\n case Chain.Dogecoin:\n return 10000;\n case Chain.Litecoin:\n return 1;\n case Chain.Zcash:\n return 1;\n default:\n return 2;\n }\n}\n\nfunction mapChainToBlockchairChain(chain: Chain) {\n switch (chain) {\n case Chain.BitcoinCash:\n return \"bitcoin-cash\";\n case Chain.Litecoin:\n return \"litecoin\";\n case Chain.Dash:\n return \"dash\";\n case Chain.Dogecoin:\n return \"dogecoin\";\n case Chain.Zcash:\n return \"zcash\";\n case Chain.Polkadot:\n return \"polkadot\";\n default:\n return \"bitcoin\";\n }\n}\n\nasync function getSuggestedTxFee(chain: Chain) {\n try {\n //Use Bitgo API for fee estimation\n //Refer: https://app.bitgo.com/docs/#operation/v2.tx.getfeeestimate\n const { feePerKb } = await RequestClient.get<{\n feePerKb: number;\n cpfpFeePerKb: number;\n numBlocks: number;\n feeByBlockTarget: { 1: number; 3: number };\n }>(`https://app.bitgo.com/api/v2/${chain.toLowerCase()}/tx/fee`);\n const suggestedFee = feePerKb / 1000;\n\n return Math.max(suggestedFee, getDefaultTxFeeByChain(chain));\n } catch {\n return getDefaultTxFeeByChain(chain);\n }\n}\n\nasync function blockchairRequest<T>(url: string, apiKey?: string): Promise<T> {\n const response = await RequestClient.get<BlockchairResponse<T>>(\n `${url}${apiKey ? `${url.includes(\"?\") ? \"&\" : \"?\"}key=${apiKey}` : \"\"}`,\n );\n\n if (!response || response.context.code !== 200)\n throw new SwapKitError(\"toolbox_utxo_api_error\", { error: `Failed to query ${url}` });\n\n return response.data as T;\n}\n\nasync function getAddressData({ address, chain, apiKey }: BlockchairParams<{ address?: string }>) {\n if (!address) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Address is required\" });\n\n try {\n const response = await blockchairRequest<BlockchairAddressResponse>(\n `${baseUrl(chain)}/dashboards/address/${address}?transaction_details=true`,\n apiKey,\n );\n\n return response[address];\n } catch {\n return { address: { balance: 0, transaction_count: 0 }, utxo: [] };\n }\n}\n\nasync function getUnconfirmedBalance({ address, chain, apiKey }: BlockchairParams<{ address?: string }>) {\n const response = await getAddressData({ address, apiKey, chain });\n\n return response?.address.balance || 0;\n}\n\nasync function getRawTx({ chain, apiKey, txHash }: BlockchairParams<{ txHash?: string }>) {\n if (!txHash) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"TxHash is required\" });\n\n try {\n const rawTxResponse = await blockchairRequest<BlockchairRawTransactionResponse>(\n `${baseUrl(chain)}/raw/transaction/${txHash}`,\n apiKey,\n );\n return rawTxResponse?.[txHash]?.raw_transaction || \"\";\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Failed to fetch raw transaction: ${errorMessage}`);\n return \"\";\n }\n}\n\nasync function fetchUtxosBatch({ chain, address, apiKey, offset = 0, limit = 30 }: BlockchairFetchUnspentUtxoParams) {\n // Only fetch the fields we need to reduce payload size\n const fields = \"is_spent,transaction_hash,index,value,script_hex,block_id,spending_signature_hex\";\n\n const response = await blockchairRequest<BlockchairOutputsResponse[]>(\n // TODO - remove max value limit once we updated bitcoinjs-lib to support larger values\n `${baseUrl(chain)}/outputs?q=recipient(${address}),is_spent(false),value(..2000000000000000)&s=value(desc)&fields=${fields}&limit=${limit}&offset=${offset}`,\n apiKey,\n );\n\n const txs = response.map(\n ({ is_spent, script_hex, block_id, transaction_hash, index, value, spending_signature_hex }) => ({\n hash: transaction_hash,\n index,\n is_confirmed: block_id !== -1,\n is_spent,\n script_hex,\n txHex: spending_signature_hex,\n value,\n }),\n );\n\n return txs;\n}\n\nfunction getTxsValue(txs: Awaited<ReturnType<typeof fetchUtxosBatch>>) {\n return txs.reduce((total, tx) => total + tx.value, 0);\n}\n\nfunction pickMostValuableTxs(\n txs: Awaited<ReturnType<typeof fetchUtxosBatch>>,\n targetValue?: number,\n): Awaited<ReturnType<typeof fetchUtxosBatch>> {\n const sortedTxs = [...txs].sort((a, b) => b.value - a.value);\n\n if (targetValue) {\n const result = [];\n let accumulated = 0;\n\n for (const utxo of sortedTxs) {\n result.push(utxo);\n accumulated += utxo.value;\n if (accumulated >= targetValue) break;\n }\n\n return result;\n }\n\n return sortedTxs;\n}\n\nasync function getUnspentUtxos({\n chain,\n address,\n apiKey,\n targetValue,\n accumulativeValue = 0,\n offset = 0,\n limit = 30,\n}: BlockchairFetchUnspentUtxoParams): Promise<Awaited<ReturnType<typeof fetchUtxosBatch>>> {\n if (!address) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Address is required\" });\n\n try {\n const utxos = await fetchUtxosBatch({ address, apiKey, chain, limit, offset, targetValue });\n const utxosCount = utxos.length;\n const isComplete = utxosCount < limit;\n\n const unspentUtxos = utxos.filter(({ is_spent }) => !is_spent);\n\n const unspentUtxosValue = getTxsValue(unspentUtxos);\n const totalCurrentValue = accumulativeValue + unspentUtxosValue;\n\n const limitReached = targetValue && totalCurrentValue >= targetValue;\n\n if (isComplete || limitReached) {\n return pickMostValuableTxs(unspentUtxos, targetValue);\n }\n\n const nextBatch = await getUnspentUtxos({\n accumulativeValue: totalCurrentValue,\n address,\n apiKey,\n chain,\n limit,\n offset: offset + limit,\n targetValue,\n });\n\n const allUtxos = [...unspentUtxos, ...nextBatch];\n\n return pickMostValuableTxs(allUtxos, targetValue);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Failed to fetch unspent UTXOs: ${errorMessage}`);\n return [];\n }\n}\n\nasync function getUtxos({\n address,\n chain,\n apiKey,\n fetchTxHex = true,\n targetValue,\n}: BlockchairParams<{ address: string; fetchTxHex?: boolean; targetValue?: number }>) {\n const utxos = await getUnspentUtxos({ address, apiKey, chain, targetValue });\n\n const results = [];\n\n for (const { hash, index, script_hex, value } of utxos) {\n let txHex: string | undefined;\n if (fetchTxHex) {\n txHex = await getRawTx({ apiKey, chain, txHash: hash });\n }\n results.push({\n address,\n hash,\n index,\n txHex,\n value,\n witnessUtxo: { script: Buffer.from(script_hex, \"hex\"), value },\n });\n }\n return results;\n}\n\nexport function getUtxoApi(chain: UTXOChain) {\n const apiKey = SKConfig.get(\"apiKeys\").blockchair || \"\";\n\n warnOnce({\n condition: !apiKey,\n id: \"no_blockchair_api_key_warning\",\n warning: \"No Blockchair API key found. Functionality will be limited.\",\n });\n\n return {\n broadcastTx: (txHash: string) => broadcastUTXOTx({ chain, txHash }),\n getAddressData: (address: string) => getAddressData({ address, apiKey, chain }),\n getBalance: (address: string) => getUnconfirmedBalance({ address, apiKey, chain }),\n getRawTx: (txHash: string) => getRawTx({ apiKey, chain, txHash }),\n getSuggestedTxFee: () => getSuggestedTxFee(chain),\n getUtxos: (params: { address: string; fetchTxHex?: boolean; targetValue?: number }) =>\n getUtxos({ ...params, apiKey, chain }),\n };\n}\n\n/**\n * \"Factory\" to ensure typing for custom UTXO APIs\n */\nexport function createCustomUtxoApi(methods: ReturnType<typeof getUtxoApi>) {\n return methods;\n}\n\nexport function getUtxoNetwork() {\n return function getNetwork(chain: Chain) {\n switch (chain) {\n case Chain.Bitcoin:\n return networks.bitcoin;\n case Chain.BitcoinCash:\n return coininfo.bitcoincash.main.toBitcoinJS();\n case Chain.Dash:\n return coininfo.dash.main.toBitcoinJS();\n case Chain.Litecoin:\n return coininfo.litecoin.main.toBitcoinJS();\n\n case Chain.Dogecoin: {\n const bip32 = { private: 0x04358394, public: 0x043587cf };\n const test = coininfo.dogecoin.test;\n test.versions.bip32 = bip32;\n return coininfo.dogecoin.main.toBitcoinJS();\n }\n\n case Chain.Zcash: {\n return zcashNetworks.zcash;\n }\n\n default:\n throw new SwapKitError(\"toolbox_utxo_not_supported\", { chain });\n }\n };\n}\n\ninterface BlockchairVin {\n txid: string;\n vout: number;\n scriptSig: { asm: string; hex: string };\n sequence: number;\n}\n\ninterface BlockchairVout {\n value: number;\n n: number;\n scriptPubKey: { asm: string; hex: string; address: string; type: string; addresses: string[]; reqSigs: number };\n}\n\ninterface BlockchairTransaction {\n block_id: number;\n hash: string;\n time: string;\n balance_change: number;\n}\n\ninterface BlockchairUtxo {\n block_id: number;\n transaction_hash: string;\n index: number;\n value: number;\n}\n\ninterface BlockchairAddressCoreData {\n type: string;\n script_hex: string;\n balance: number;\n balance_usd: number;\n received: number;\n received_usd: number;\n spent: number;\n spent_usd: number;\n output_count: number;\n unspent_output_count: number;\n first_seen_receiving: string;\n last_seen_receiving: string;\n first_seen_spending: null | string;\n last_seen_spending: null | string;\n transaction_count: number;\n scripthash_type: null | string;\n}\n\ninterface BlockchairInputOutputCommonData {\n block_id: number;\n transaction_id: number;\n index: number;\n transaction_hash: string;\n date: string;\n time: string;\n value: number;\n value_usd: number;\n recipient: string;\n type: string;\n script_hex: string;\n is_from_coinbase: boolean;\n is_spendable: boolean | null;\n is_spent: boolean;\n lifespan: number | null;\n cdd: number | null;\n}\n\ninterface BlockchairSpendingBlockData {\n spending_block_id: number | null;\n spending_transaction_id: number | null;\n spending_index: number | null;\n spending_transaction_hash: string | null;\n spending_date: string | null;\n spending_time: string | null;\n spending_value_usd: number | null;\n spending_sequence: number | null;\n spending_signature_hex: string | null;\n spending_witness: string | null;\n}\n\ninterface BlockchairAddressResponse {\n [key: string]: { address: BlockchairAddressCoreData; transactions: BlockchairTransaction[]; utxo: BlockchairUtxo[] };\n}\n\ninterface BlockchairOutputsResponse extends BlockchairSpendingBlockData, BlockchairInputOutputCommonData {}\n\ninterface BlockchairRawTransactionResponse {\n [key: string]: {\n raw_transaction: string;\n decoded_raw_transaction: {\n txid: string;\n hash: string;\n version: number;\n size: number;\n vsize: number;\n weight: number;\n locktime: number;\n vin: BlockchairVin[];\n vout: BlockchairVout[];\n };\n };\n}\n\ninterface BlockchairResponse<T> {\n data: T;\n context: {\n code: number;\n source: string;\n results: number;\n state: number;\n market_price_usd: number;\n cache: { live: boolean; duration: number; since: string; until: string; time: any };\n api: {\n version: string;\n last_major_update: string;\n next_major_update: null | string;\n documentation: string;\n notice: string;\n };\n servers: string;\n time: number;\n render_time: number;\n full_time: number;\n request_cost: number;\n };\n}\n",
7
- "import { SwapKitError } from \"@uswap/helpers\";\nimport base58check from \"bs58check\";\n// @ts-expect-error\nimport cashaddr from \"cashaddrjs\";\n\nenum Format {\n Legacy = \"legacy\",\n Bitpay = \"bitpay\",\n Cashaddr = \"cashaddr\",\n}\nenum UtxoNetwork {\n Mainnet = \"mainnet\",\n Testnet = \"testnet\",\n}\nenum Type {\n P2PKH = \"p2pkh\",\n P2SH = \"p2sh\",\n}\n\nconst VERSION_BYTE = {\n [Format.Legacy]: {\n [UtxoNetwork.Mainnet]: { [Type.P2PKH]: 0, [Type.P2SH]: 5 },\n [UtxoNetwork.Testnet]: { [Type.P2PKH]: 111, [Type.P2SH]: 196 },\n },\n [Format.Bitpay]: {\n [UtxoNetwork.Mainnet]: { [Type.P2PKH]: 28, [Type.P2SH]: 40 },\n [UtxoNetwork.Testnet]: { [Type.P2PKH]: 111, [Type.P2SH]: 196 },\n },\n};\n\ntype DecodedType = { format: Format; network: UtxoNetwork; type: Type; hash: any };\n\nfunction isValidAddress(input: any) {\n try {\n decodeAddress(input);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction detectAddressNetwork(address: string) {\n return decodeAddress(address)?.network;\n}\n\nfunction toLegacyAddress(address: string): string {\n const decoded = decodeAddress(address);\n if (decoded?.format === Format.Legacy) {\n return address;\n }\n return encodeAsLegacy(decoded);\n}\n\nfunction toCashAddress(address: string): string {\n const decoded = decodeAddress(address);\n return encodeAsCashaddr(decoded);\n}\n\nfunction decodeAddress(address: string) {\n try {\n const decoded = decodeBase58Address(address);\n if (decoded) {\n return decoded;\n }\n } catch {\n // Try to decode as cashaddr if base58 decoding fails.\n }\n try {\n const decoded = decodeCashAddress(address);\n if (decoded) {\n return decoded;\n }\n } catch {\n // Try to decode as bitpay if cashaddr decoding fails.\n }\n throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address });\n}\n\nfunction decodeBase58Address(address: string) {\n try {\n const payload = base58check.decode(address);\n\n // BASE_58_CHECK_PAYLOAD_LENGTH\n if (payload.length !== 21) throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address });\n const versionByte = payload[0];\n const hash = Array.prototype.slice.call(payload, 1);\n\n switch (versionByte) {\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Mainnet][Type.P2PKH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Mainnet, type: Type.P2PKH };\n\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Mainnet][Type.P2SH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Mainnet, type: Type.P2SH };\n\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Testnet][Type.P2PKH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Testnet, type: Type.P2PKH };\n\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Testnet][Type.P2SH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Testnet, type: Type.P2SH };\n\n case VERSION_BYTE[Format.Bitpay][UtxoNetwork.Mainnet][Type.P2PKH]:\n return { format: Format.Bitpay, hash, network: UtxoNetwork.Mainnet, type: Type.P2PKH };\n\n case VERSION_BYTE[Format.Bitpay][UtxoNetwork.Mainnet][Type.P2SH]:\n return { format: Format.Bitpay, hash, network: UtxoNetwork.Mainnet, type: Type.P2SH };\n\n default:\n return;\n }\n } catch {\n return;\n }\n}\n\nfunction decodeCashAddress(address: string) {\n if (address.indexOf(\":\") !== -1) {\n try {\n return decodeCashAddressWithPrefix(address);\n } catch {\n // Try to decode as legacy if cashaddr decoding fails.\n }\n } else {\n const prefixes = [\"bitcoincash\", \"bchtest\", \"bchreg\"];\n for (const prefix of prefixes) {\n try {\n return decodeCashAddressWithPrefix(`${prefix}:${address}`);\n } catch {\n // Try next prefix if decoding fails.\n }\n }\n }\n\n return;\n}\n\nfunction decodeCashAddressWithPrefix(address: string) {\n try {\n const { hash, prefix, type } = cashaddr.decode(address);\n\n return {\n format: Format.Cashaddr,\n hash: Array.prototype.slice.call(hash, 0),\n network: prefix === \"bitcoincash\" ? UtxoNetwork.Mainnet : UtxoNetwork.Testnet,\n type: type === \"P2PKH\" ? Type.P2PKH : Type.P2SH,\n };\n } catch {\n return;\n }\n}\n\nfunction encodeAsLegacy(decoded: DecodedType) {\n const versionByte = VERSION_BYTE[Format.Legacy][decoded.network][decoded.type];\n const buffer = Buffer.alloc(1 + decoded.hash.length);\n buffer[0] = versionByte;\n buffer.set(decoded.hash, 1);\n return base58check.encode(buffer);\n}\n\nfunction encodeAsCashaddr(decoded: DecodedType) {\n const prefix = decoded.network === UtxoNetwork.Mainnet ? \"bitcoincash\" : \"bchtest\";\n const type = decoded.type === Type.P2PKH ? \"P2PKH\" : \"P2SH\";\n const hash = new Uint8Array(decoded.hash);\n return cashaddr.encode(prefix, type, hash);\n}\n\nexport { detectAddressNetwork, isValidAddress, UtxoNetwork, toCashAddress, toLegacyAddress };\n",
8
- "import { SwapKitError } from \"@uswap/helpers\";\nimport { opcodes, script } from \"bitcoinjs-lib\";\nimport type { TargetOutput, UTXOCalculateTxSizeParams, UTXOInputWithScriptType, UTXOType } from \"../types\";\n\n/**\n * Minimum transaction fee\n * 1000 satoshi/kB (similar to current `minrelaytxfee`)\n * @see https://github.com/bitcoin/bitcoin/blob/db88db47278d2e7208c50d16ab10cb355067d071/src/validation.h#L56\n */\nexport const MIN_TX_FEE = 1000;\nexport const TX_OVERHEAD = 4 + 1 + 1 + 4; //10\nexport const OP_RETURN_OVERHEAD = 1 + 8 + 1; //10\nconst TX_INPUT_BASE = 32 + 4 + 1 + 4; // 41\nconst TX_INPUT_PUBKEYHASH = 107;\n\nexport function compileMemo(memo: string) {\n const data = Buffer.from(memo, \"utf8\"); // converts MEMO to buffer\n return script.compile([opcodes.OP_RETURN as number, data]); // Compile OP_RETURN script\n}\n\nexport enum UTXOScriptType {\n P2PKH = \"P2PKH\", // legacy\n // P2SH = 'P2SH', // multisig\n P2WPKH = \"P2WPKH\", // bech32 - native segwit\n // P2TR = \"P2TR\", // taproot\n}\n\nexport const InputSizes: Record<UTXOScriptType, number> = {\n [UTXOScriptType.P2PKH]: 148,\n // [UTXOScriptType.P2SH]: 91,\n [UTXOScriptType.P2WPKH]: 68,\n};\n\nexport const OutputSizes: Record<UTXOScriptType, number> = {\n [UTXOScriptType.P2PKH]: 34,\n // [UTXOScriptType.P2SH]: 91,\n [UTXOScriptType.P2WPKH]: 31,\n};\n\nexport const getScriptTypeForAddress = (address: string) => {\n // Native SegWit (Bech32) addresses - P2WPKH\n // Bitcoin: bc1 (mainnet), tb1 (testnet)\n // Litecoin: ltc1 (mainnet), tltc1 (testnet)\n if (\n address.startsWith(\"bc1\") ||\n address.startsWith(\"tb1\") ||\n address.startsWith(\"ltc1\") ||\n address.startsWith(\"tltc1\")\n ) {\n // Note: bc1p/tb1p are Taproot (P2TR) addresses, but we're treating them as P2WPKH for now\n // since P2TR is not yet implemented\n return UTXOScriptType.P2WPKH;\n }\n\n // P2SH addresses (Pay-to-Script-Hash) - Currently commented out but kept for future use\n // Bitcoin: 3 (mainnet), 2 (testnet)\n // Litecoin: M or 2 (mainnet), Q (testnet)\n // Dash: 7 (mainnet)\n // if (address.startsWith('3') || address.startsWith('2') ||\n // address.startsWith('M') || address.startsWith('Q') ||\n // address.startsWith('7')) {\n // return UTXOScriptType.P2SH;\n // }\n\n // Legacy P2PKH addresses\n // Bitcoin: 1 (mainnet), m/n (testnet)\n // Bitcoin Cash: bitcoincash:q (CashAddr format), q (legacy), 1 (legacy)\n // Litecoin: L (mainnet), m/n (testnet)\n // Dogecoin: D (mainnet), n (testnet)\n // Dash: X (mainnet), y (testnet)\n // Zcash: t1 (transparent mainnet), tm (testnet)\n if (\n // Bitcoin legacy\n address.startsWith(\"1\") ||\n address.startsWith(\"m\") ||\n address.startsWith(\"n\") ||\n // Bitcoin Cash\n address.startsWith(\"bitcoincash:q\") ||\n address.startsWith(\"bitcoincash:p\") ||\n address.startsWith(\"q\") ||\n address.startsWith(\"p\") ||\n // Litecoin legacy (also uses 3 for P2SH but treating as P2PKH for now)\n address.startsWith(\"L\") ||\n address.startsWith(\"M\") ||\n address.startsWith(\"3\") ||\n // Dogecoin\n address.startsWith(\"D\") ||\n address.startsWith(\"A\") ||\n address.startsWith(\"9\") ||\n // Dash\n address.startsWith(\"X\") ||\n address.startsWith(\"7\") ||\n address.startsWith(\"y\") ||\n // Zcash transparent addresses\n address.startsWith(\"t1\") ||\n address.startsWith(\"t3\") ||\n address.startsWith(\"tm\")\n ) {\n return UTXOScriptType.P2PKH;\n }\n\n throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address });\n};\n\nexport const calculateTxSize = ({ inputs, outputs, feeRate }: UTXOCalculateTxSizeParams) => {\n const newTxType =\n inputs[0] && \"address\" in inputs[0] && inputs[0].address\n ? getScriptTypeForAddress(inputs[0].address)\n : UTXOScriptType.P2PKH;\n const inputSize = inputs\n .filter((utxo) => utxo.value >= InputSizes[\"type\" in utxo ? utxo.type : UTXOScriptType.P2PKH] * Math.ceil(feeRate))\n .reduce((total, utxo) => total + getInputSize(utxo), 0);\n\n const outputSize = outputs?.reduce((total, output) => total + getOutputSize(output), 0) || OutputSizes[newTxType];\n\n return TX_OVERHEAD + inputSize + outputSize;\n};\n\nexport const getInputSize = (input: UTXOInputWithScriptType | UTXOType) => {\n if (\"type\" in input) {\n return InputSizes[input.type];\n }\n if (\"address\" in input && input.address) {\n return InputSizes[getScriptTypeForAddress(input.address as string)];\n }\n return TX_INPUT_BASE + TX_INPUT_PUBKEYHASH;\n};\n\nexport const getOutputSize = (output: TargetOutput, scriptType?: UTXOScriptType) => {\n if (output?.script) {\n return OP_RETURN_OVERHEAD + output.script.length + (output.script.length >= 74 ? 2 : 1);\n }\n if (scriptType) {\n return OutputSizes[scriptType];\n }\n return OutputSizes[UTXOScriptType.P2PKH];\n};\n",
9
- "import { Chain, SwapKitError, type UTXOChain } from \"@uswap/helpers\";\n\nimport {\n calculateTxSize,\n getInputSize,\n getOutputSize,\n getScriptTypeForAddress,\n TX_OVERHEAD,\n UTXOScriptType,\n} from \"../helpers/txSize\";\nimport type { TargetOutput, UTXOCalculateTxSizeParams, UTXOType } from \"../types\";\n\nexport function getDustThreshold(chain: UTXOChain) {\n switch (chain) {\n case Chain.Bitcoin:\n case Chain.BitcoinCash:\n return 550;\n case Chain.Dash:\n case Chain.Litecoin:\n return 5500;\n case Chain.Dogecoin:\n return 100000;\n case Chain.Zcash:\n return 546;\n default:\n throw new SwapKitError(\"toolbox_utxo_not_supported\", { chain });\n }\n}\n\nexport function accumulative({\n inputs,\n outputs,\n feeRate: initialFeeRate = 1,\n chain = Chain.Bitcoin,\n changeAddress = \"\",\n}: UTXOCalculateTxSizeParams & { outputs: TargetOutput[]; chain: UTXOChain; changeAddress?: string }) {\n const feeRate = Math.ceil(initialFeeRate);\n\n const newTxType =\n inputs[0] && \"address\" in inputs[0] && inputs[0].address\n ? getScriptTypeForAddress(inputs[0].address)\n : UTXOScriptType.P2PKH;\n // skip input if adding it would cost more than input is worth\n const filteredInputs = inputs.filter((input) => getInputSize(input) * feeRate <= input.value);\n\n const txSizeWithoutInputs =\n TX_OVERHEAD + outputs.reduce((total, output) => total + getOutputSize(output, newTxType), 0);\n\n const amountToSend = outputs.reduce((total, output) => total + output.value, 0);\n\n let fees = txSizeWithoutInputs * feeRate;\n let inputsValue = 0;\n const inputsToUse: typeof inputs = [];\n\n for (const input of filteredInputs) {\n const inputSize = getInputSize(input);\n const inputFee = feeRate * inputSize;\n\n fees += inputFee;\n inputsValue += input.value;\n\n inputsToUse.push(input);\n\n const totalCost = fees + amountToSend;\n\n // we need more inputs\n if (inputsValue < totalCost) continue;\n\n const remainder = inputsValue - totalCost;\n\n const feeForExtraOutput = feeRate * getOutputSize({ address: \"\", value: 0 }, newTxType);\n\n // potential change address\n if (remainder > feeForExtraOutput) {\n const feeAfterExtraOutput = feeForExtraOutput + fees;\n const remainderAfterExtraOutput = inputsValue - (amountToSend + feeAfterExtraOutput);\n\n // is it worth a change output aka can we send it in the future?\n if (remainderAfterExtraOutput > Math.max(getInputSize({} as UTXOType) * feeRate, getDustThreshold(chain))) {\n return {\n fee: feeAfterExtraOutput,\n inputs: inputsToUse,\n outputs: outputs.concat({ address: changeAddress, value: remainderAfterExtraOutput }),\n };\n }\n }\n return { fee: fees, inputs: inputsToUse, outputs };\n }\n\n // We don't have enough inputs, let's calculate transaction fee accrude to the last input\n return { fee: feeRate * calculateTxSize({ feeRate, inputs, outputs }) };\n}\n",
5
+ "import { AssetValue, type Chain, getChainConfig } from \"@uswap/helpers\";\nimport { SwapKitApi } from \"@uswap/helpers/api\";\n\nconst pid = typeof process !== \"undefined\" && process.pid ? process.pid.toString(36) : \"\";\n\nlet last = 0;\nexport function uniqid() {\n function now() {\n const time = Date.now();\n const lastTime = last || time;\n last = lastTime;\n\n return time > last ? time : lastTime + 1;\n }\n\n return pid + now().toString(36);\n}\n\nexport function getBalance<T extends Chain>(chain: T) {\n return async function getBalance(address: string, scamFilter = true) {\n const balances = await SwapKitApi.getChainBalance({ address, chain, scamFilter });\n const { baseDecimal } = getChainConfig(chain);\n const assetValues = balances.map(({ identifier, value, decimal }) => {\n return new AssetValue({ decimal: decimal || baseDecimal, identifier, value });\n });\n\n const hasNativeAsset = assetValues.some((asset) => asset.isGasAsset);\n if (!hasNativeAsset) {\n return [AssetValue.from({ chain }), ...assetValues];\n }\n\n return assetValues;\n };\n}\n",
6
+ "/**\n * Based on code from SwapKit (https://github.com/swapkit/SwapKit),\n * licensed under the Apache License 2.0.\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { networks as zcashNetworks } from \"@bitgo/utxo-lib\";\nimport { Chain, getRPCUrl, RequestClient, SKConfig, USwapError, type UTXOChain, warnOnce } from \"@uswap/helpers\";\nimport { networks } from \"bitcoinjs-lib\";\n// @ts-expect-error\nimport coininfo from \"coininfo\";\nimport { uniqid } from \"../../utils\";\n\ntype BlockchairParams<T> = T & { chain: Chain; apiKey?: string };\ntype BlockchairFetchUnspentUtxoParams = BlockchairParams<{\n offset?: number;\n limit?: number;\n address: string;\n targetValue?: number;\n accumulativeValue?: number;\n}>;\n\nasync function broadcastUTXOTx({ chain, txHash }: { chain: Chain; txHash: string }) {\n // Use Blockchair's push transaction endpoint (no API key needed)\n const url = `${baseUrl(chain)}/push/transaction`;\n const body = JSON.stringify({ data: txHash });\n\n try {\n const response = await RequestClient.post<{\n data: { transaction_hash: string } | null;\n context: { code: number; error?: string };\n }>(url, { body, headers: { \"Content-Type\": \"application/json\" } });\n\n if (response.context.code !== 200) {\n throw new USwapError(\"toolbox_utxo_broadcast_failed\", {\n error: response.context.error || \"Transaction broadcast failed\",\n });\n }\n\n return response.data?.transaction_hash || txHash;\n } catch (error) {\n // Fallback to RPC if Blockchair fails\n const rpcUrl = await getRPCUrl(chain);\n if (rpcUrl) {\n const rpcBody = JSON.stringify({ id: uniqid(), jsonrpc: \"2.0\", method: \"sendrawtransaction\", params: [txHash] });\n\n const rpcResponse = await RequestClient.post<{\n id: string;\n result: string;\n error: { message: string; code?: number } | null;\n }>(rpcUrl, { body: rpcBody, headers: { \"Content-Type\": \"application/json\" } });\n\n if (rpcResponse.error) {\n throw new USwapError(\"toolbox_utxo_broadcast_failed\", { error: rpcResponse.error?.message });\n }\n\n if (rpcResponse.result.includes('\"code\":-26')) {\n throw new USwapError(\"toolbox_utxo_invalid_transaction\", { error: \"Transaction amount was too low\" });\n }\n\n return rpcResponse.result;\n }\n\n throw error;\n }\n}\n\nfunction baseUrl(chain: Chain) {\n return `https://api.blockchair.com/${mapChainToBlockchairChain(chain)}`;\n}\n\nfunction getDefaultTxFeeByChain(chain: Chain) {\n switch (chain) {\n case Chain.Bitcoin:\n return 5;\n case Chain.Dogecoin:\n return 10000;\n case Chain.Litecoin:\n return 1;\n case Chain.Zcash:\n return 1;\n default:\n return 2;\n }\n}\n\nfunction mapChainToBlockchairChain(chain: Chain) {\n switch (chain) {\n case Chain.BitcoinCash:\n return \"bitcoin-cash\";\n case Chain.Litecoin:\n return \"litecoin\";\n case Chain.Dash:\n return \"dash\";\n case Chain.Dogecoin:\n return \"dogecoin\";\n case Chain.Zcash:\n return \"zcash\";\n case Chain.Polkadot:\n return \"polkadot\";\n default:\n return \"bitcoin\";\n }\n}\n\nasync function getSuggestedTxFee(chain: Chain) {\n try {\n //Use Bitgo API for fee estimation\n //Refer: https://app.bitgo.com/docs/#operation/v2.tx.getfeeestimate\n const { feePerKb } = await RequestClient.get<{\n feePerKb: number;\n cpfpFeePerKb: number;\n numBlocks: number;\n feeByBlockTarget: { 1: number; 3: number };\n }>(`https://app.bitgo.com/api/v2/${chain.toLowerCase()}/tx/fee`);\n const suggestedFee = feePerKb / 1000;\n\n return Math.max(suggestedFee, getDefaultTxFeeByChain(chain));\n } catch {\n return getDefaultTxFeeByChain(chain);\n }\n}\n\nasync function blockchairRequest<T>(url: string, apiKey?: string): Promise<T> {\n const response = await RequestClient.get<BlockchairResponse<T>>(\n `${url}${apiKey ? `${url.includes(\"?\") ? \"&\" : \"?\"}key=${apiKey}` : \"\"}`,\n );\n\n if (!response || response.context.code !== 200)\n throw new USwapError(\"toolbox_utxo_api_error\", { error: `Failed to query ${url}` });\n\n return response.data as T;\n}\n\nasync function getAddressData({ address, chain, apiKey }: BlockchairParams<{ address?: string }>) {\n if (!address) throw new USwapError(\"toolbox_utxo_invalid_params\", { error: \"Address is required\" });\n\n try {\n const response = await blockchairRequest<BlockchairAddressResponse>(\n `${baseUrl(chain)}/dashboards/address/${address}?transaction_details=true`,\n apiKey,\n );\n\n return response[address];\n } catch {\n return { address: { balance: 0, transaction_count: 0 }, utxo: [] };\n }\n}\n\nasync function getUnconfirmedBalance({ address, chain, apiKey }: BlockchairParams<{ address?: string }>) {\n const response = await getAddressData({ address, apiKey, chain });\n\n return response?.address.balance || 0;\n}\n\nasync function getRawTx({ chain, apiKey, txHash }: BlockchairParams<{ txHash?: string }>) {\n if (!txHash) throw new USwapError(\"toolbox_utxo_invalid_params\", { error: \"TxHash is required\" });\n\n try {\n const rawTxResponse = await blockchairRequest<BlockchairRawTransactionResponse>(\n `${baseUrl(chain)}/raw/transaction/${txHash}`,\n apiKey,\n );\n return rawTxResponse?.[txHash]?.raw_transaction || \"\";\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Failed to fetch raw transaction: ${errorMessage}`);\n return \"\";\n }\n}\n\nasync function fetchUtxosBatch({ chain, address, apiKey, offset = 0, limit = 30 }: BlockchairFetchUnspentUtxoParams) {\n // Only fetch the fields we need to reduce payload size\n const fields = \"is_spent,transaction_hash,index,value,script_hex,block_id,spending_signature_hex\";\n\n const response = await blockchairRequest<BlockchairOutputsResponse[]>(\n // TODO - remove max value limit once we updated bitcoinjs-lib to support larger values\n `${baseUrl(chain)}/outputs?q=recipient(${address}),is_spent(false),value(..2000000000000000)&s=value(desc)&fields=${fields}&limit=${limit}&offset=${offset}`,\n apiKey,\n );\n\n const txs = response.map(\n ({ is_spent, script_hex, block_id, transaction_hash, index, value, spending_signature_hex }) => ({\n hash: transaction_hash,\n index,\n is_confirmed: block_id !== -1,\n is_spent,\n script_hex,\n txHex: spending_signature_hex,\n value,\n }),\n );\n\n return txs;\n}\n\nfunction getTxsValue(txs: Awaited<ReturnType<typeof fetchUtxosBatch>>) {\n return txs.reduce((total, tx) => total + tx.value, 0);\n}\n\nfunction pickMostValuableTxs(\n txs: Awaited<ReturnType<typeof fetchUtxosBatch>>,\n targetValue?: number,\n): Awaited<ReturnType<typeof fetchUtxosBatch>> {\n const sortedTxs = [...txs].sort((a, b) => b.value - a.value);\n\n if (targetValue) {\n const result = [];\n let accumulated = 0;\n\n for (const utxo of sortedTxs) {\n result.push(utxo);\n accumulated += utxo.value;\n if (accumulated >= targetValue) break;\n }\n\n return result;\n }\n\n return sortedTxs;\n}\n\nasync function getUnspentUtxos({\n chain,\n address,\n apiKey,\n targetValue,\n accumulativeValue = 0,\n offset = 0,\n limit = 30,\n}: BlockchairFetchUnspentUtxoParams): Promise<Awaited<ReturnType<typeof fetchUtxosBatch>>> {\n if (!address) throw new USwapError(\"toolbox_utxo_invalid_params\", { error: \"Address is required\" });\n\n try {\n const utxos = await fetchUtxosBatch({ address, apiKey, chain, limit, offset, targetValue });\n const utxosCount = utxos.length;\n const isComplete = utxosCount < limit;\n\n const unspentUtxos = utxos.filter(({ is_spent }) => !is_spent);\n\n const unspentUtxosValue = getTxsValue(unspentUtxos);\n const totalCurrentValue = accumulativeValue + unspentUtxosValue;\n\n const limitReached = targetValue && totalCurrentValue >= targetValue;\n\n if (isComplete || limitReached) {\n return pickMostValuableTxs(unspentUtxos, targetValue);\n }\n\n const nextBatch = await getUnspentUtxos({\n accumulativeValue: totalCurrentValue,\n address,\n apiKey,\n chain,\n limit,\n offset: offset + limit,\n targetValue,\n });\n\n const allUtxos = [...unspentUtxos, ...nextBatch];\n\n return pickMostValuableTxs(allUtxos, targetValue);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Failed to fetch unspent UTXOs: ${errorMessage}`);\n return [];\n }\n}\n\nasync function getUtxos({\n address,\n chain,\n apiKey,\n fetchTxHex = true,\n targetValue,\n}: BlockchairParams<{ address: string; fetchTxHex?: boolean; targetValue?: number }>) {\n const utxos = await getUnspentUtxos({ address, apiKey, chain, targetValue });\n\n const results = [];\n\n for (const { hash, index, script_hex, value } of utxos) {\n let txHex: string | undefined;\n if (fetchTxHex) {\n txHex = await getRawTx({ apiKey, chain, txHash: hash });\n }\n results.push({\n address,\n hash,\n index,\n txHex,\n value,\n witnessUtxo: { script: Buffer.from(script_hex, \"hex\"), value },\n });\n }\n return results;\n}\n\nexport function getUtxoApi(chain: UTXOChain) {\n const apiKey = SKConfig.get(\"apiKeys\").blockchair || \"\";\n\n warnOnce({\n condition: !apiKey,\n id: \"no_blockchair_api_key_warning\",\n warning: \"No Blockchair API key found. Functionality will be limited.\",\n });\n\n return {\n broadcastTx: (txHash: string) => broadcastUTXOTx({ chain, txHash }),\n getAddressData: (address: string) => getAddressData({ address, apiKey, chain }),\n getBalance: (address: string) => getUnconfirmedBalance({ address, apiKey, chain }),\n getRawTx: (txHash: string) => getRawTx({ apiKey, chain, txHash }),\n getSuggestedTxFee: () => getSuggestedTxFee(chain),\n getUtxos: (params: { address: string; fetchTxHex?: boolean; targetValue?: number }) =>\n getUtxos({ ...params, apiKey, chain }),\n };\n}\n\n/**\n * \"Factory\" to ensure typing for custom UTXO APIs\n */\nexport function createCustomUtxoApi(methods: ReturnType<typeof getUtxoApi>) {\n return methods;\n}\n\nexport function getUtxoNetwork() {\n return function getNetwork(chain: Chain) {\n switch (chain) {\n case Chain.Bitcoin:\n return networks.bitcoin;\n case Chain.BitcoinCash:\n return coininfo.bitcoincash.main.toBitcoinJS();\n case Chain.Dash:\n return coininfo.dash.main.toBitcoinJS();\n case Chain.Litecoin:\n return coininfo.litecoin.main.toBitcoinJS();\n\n case Chain.Dogecoin: {\n const bip32 = { private: 0x04358394, public: 0x043587cf };\n const test = coininfo.dogecoin.test;\n test.versions.bip32 = bip32;\n return coininfo.dogecoin.main.toBitcoinJS();\n }\n\n case Chain.Zcash: {\n return zcashNetworks.zcash;\n }\n\n default:\n throw new USwapError(\"toolbox_utxo_not_supported\", { chain });\n }\n };\n}\n\ninterface BlockchairVin {\n txid: string;\n vout: number;\n scriptSig: { asm: string; hex: string };\n sequence: number;\n}\n\ninterface BlockchairVout {\n value: number;\n n: number;\n scriptPubKey: { asm: string; hex: string; address: string; type: string; addresses: string[]; reqSigs: number };\n}\n\ninterface BlockchairTransaction {\n block_id: number;\n hash: string;\n time: string;\n balance_change: number;\n}\n\ninterface BlockchairUtxo {\n block_id: number;\n transaction_hash: string;\n index: number;\n value: number;\n}\n\ninterface BlockchairAddressCoreData {\n type: string;\n script_hex: string;\n balance: number;\n balance_usd: number;\n received: number;\n received_usd: number;\n spent: number;\n spent_usd: number;\n output_count: number;\n unspent_output_count: number;\n first_seen_receiving: string;\n last_seen_receiving: string;\n first_seen_spending: null | string;\n last_seen_spending: null | string;\n transaction_count: number;\n scripthash_type: null | string;\n}\n\ninterface BlockchairInputOutputCommonData {\n block_id: number;\n transaction_id: number;\n index: number;\n transaction_hash: string;\n date: string;\n time: string;\n value: number;\n value_usd: number;\n recipient: string;\n type: string;\n script_hex: string;\n is_from_coinbase: boolean;\n is_spendable: boolean | null;\n is_spent: boolean;\n lifespan: number | null;\n cdd: number | null;\n}\n\ninterface BlockchairSpendingBlockData {\n spending_block_id: number | null;\n spending_transaction_id: number | null;\n spending_index: number | null;\n spending_transaction_hash: string | null;\n spending_date: string | null;\n spending_time: string | null;\n spending_value_usd: number | null;\n spending_sequence: number | null;\n spending_signature_hex: string | null;\n spending_witness: string | null;\n}\n\ninterface BlockchairAddressResponse {\n [key: string]: { address: BlockchairAddressCoreData; transactions: BlockchairTransaction[]; utxo: BlockchairUtxo[] };\n}\n\ninterface BlockchairOutputsResponse extends BlockchairSpendingBlockData, BlockchairInputOutputCommonData {}\n\ninterface BlockchairRawTransactionResponse {\n [key: string]: {\n raw_transaction: string;\n decoded_raw_transaction: {\n txid: string;\n hash: string;\n version: number;\n size: number;\n vsize: number;\n weight: number;\n locktime: number;\n vin: BlockchairVin[];\n vout: BlockchairVout[];\n };\n };\n}\n\ninterface BlockchairResponse<T> {\n data: T;\n context: {\n code: number;\n source: string;\n results: number;\n state: number;\n market_price_usd: number;\n cache: { live: boolean; duration: number; since: string; until: string; time: any };\n api: {\n version: string;\n last_major_update: string;\n next_major_update: null | string;\n documentation: string;\n notice: string;\n };\n servers: string;\n time: number;\n render_time: number;\n full_time: number;\n request_cost: number;\n };\n}\n",
7
+ "/**\n * Based on code from SwapKit (https://github.com/swapkit/SwapKit),\n * licensed under the Apache License 2.0.\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { USwapError } from \"@uswap/helpers\";\nimport base58check from \"bs58check\";\n// @ts-expect-error\nimport cashaddr from \"cashaddrjs\";\n\nenum Format {\n Legacy = \"legacy\",\n Bitpay = \"bitpay\",\n Cashaddr = \"cashaddr\",\n}\nenum UtxoNetwork {\n Mainnet = \"mainnet\",\n Testnet = \"testnet\",\n}\nenum Type {\n P2PKH = \"p2pkh\",\n P2SH = \"p2sh\",\n}\n\nconst VERSION_BYTE = {\n [Format.Legacy]: {\n [UtxoNetwork.Mainnet]: { [Type.P2PKH]: 0, [Type.P2SH]: 5 },\n [UtxoNetwork.Testnet]: { [Type.P2PKH]: 111, [Type.P2SH]: 196 },\n },\n [Format.Bitpay]: {\n [UtxoNetwork.Mainnet]: { [Type.P2PKH]: 28, [Type.P2SH]: 40 },\n [UtxoNetwork.Testnet]: { [Type.P2PKH]: 111, [Type.P2SH]: 196 },\n },\n};\n\ntype DecodedType = { format: Format; network: UtxoNetwork; type: Type; hash: any };\n\nfunction isValidAddress(input: any) {\n try {\n decodeAddress(input);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction detectAddressNetwork(address: string) {\n return decodeAddress(address)?.network;\n}\n\nfunction toLegacyAddress(address: string): string {\n const decoded = decodeAddress(address);\n if (decoded?.format === Format.Legacy) {\n return address;\n }\n return encodeAsLegacy(decoded);\n}\n\nfunction toCashAddress(address: string): string {\n const decoded = decodeAddress(address);\n return encodeAsCashaddr(decoded);\n}\n\nfunction decodeAddress(address: string) {\n try {\n const decoded = decodeBase58Address(address);\n if (decoded) {\n return decoded;\n }\n } catch {\n // Try to decode as cashaddr if base58 decoding fails.\n }\n try {\n const decoded = decodeCashAddress(address);\n if (decoded) {\n return decoded;\n }\n } catch {\n // Try to decode as bitpay if cashaddr decoding fails.\n }\n throw new USwapError(\"toolbox_utxo_invalid_address\", { address });\n}\n\nfunction decodeBase58Address(address: string) {\n try {\n const payload = base58check.decode(address);\n\n // BASE_58_CHECK_PAYLOAD_LENGTH\n if (payload.length !== 21) throw new USwapError(\"toolbox_utxo_invalid_address\", { address });\n const versionByte = payload[0];\n const hash = Array.prototype.slice.call(payload, 1);\n\n switch (versionByte) {\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Mainnet][Type.P2PKH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Mainnet, type: Type.P2PKH };\n\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Mainnet][Type.P2SH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Mainnet, type: Type.P2SH };\n\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Testnet][Type.P2PKH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Testnet, type: Type.P2PKH };\n\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Testnet][Type.P2SH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Testnet, type: Type.P2SH };\n\n case VERSION_BYTE[Format.Bitpay][UtxoNetwork.Mainnet][Type.P2PKH]:\n return { format: Format.Bitpay, hash, network: UtxoNetwork.Mainnet, type: Type.P2PKH };\n\n case VERSION_BYTE[Format.Bitpay][UtxoNetwork.Mainnet][Type.P2SH]:\n return { format: Format.Bitpay, hash, network: UtxoNetwork.Mainnet, type: Type.P2SH };\n\n default:\n return;\n }\n } catch {\n return;\n }\n}\n\nfunction decodeCashAddress(address: string) {\n if (address.indexOf(\":\") !== -1) {\n try {\n return decodeCashAddressWithPrefix(address);\n } catch {\n // Try to decode as legacy if cashaddr decoding fails.\n }\n } else {\n const prefixes = [\"bitcoincash\", \"bchtest\", \"bchreg\"];\n for (const prefix of prefixes) {\n try {\n return decodeCashAddressWithPrefix(`${prefix}:${address}`);\n } catch {\n // Try next prefix if decoding fails.\n }\n }\n }\n\n return;\n}\n\nfunction decodeCashAddressWithPrefix(address: string) {\n try {\n const { hash, prefix, type } = cashaddr.decode(address);\n\n return {\n format: Format.Cashaddr,\n hash: Array.prototype.slice.call(hash, 0),\n network: prefix === \"bitcoincash\" ? UtxoNetwork.Mainnet : UtxoNetwork.Testnet,\n type: type === \"P2PKH\" ? Type.P2PKH : Type.P2SH,\n };\n } catch {\n return;\n }\n}\n\nfunction encodeAsLegacy(decoded: DecodedType) {\n const versionByte = VERSION_BYTE[Format.Legacy][decoded.network][decoded.type];\n const buffer = Buffer.alloc(1 + decoded.hash.length);\n buffer[0] = versionByte;\n buffer.set(decoded.hash, 1);\n return base58check.encode(buffer);\n}\n\nfunction encodeAsCashaddr(decoded: DecodedType) {\n const prefix = decoded.network === UtxoNetwork.Mainnet ? \"bitcoincash\" : \"bchtest\";\n const type = decoded.type === Type.P2PKH ? \"P2PKH\" : \"P2SH\";\n const hash = new Uint8Array(decoded.hash);\n return cashaddr.encode(prefix, type, hash);\n}\n\nexport { detectAddressNetwork, isValidAddress, UtxoNetwork, toCashAddress, toLegacyAddress };\n",
8
+ "/**\n * Based on code from SwapKit (https://github.com/swapkit/SwapKit),\n * licensed under the Apache License 2.0.\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { USwapError } from \"@uswap/helpers\";\nimport { opcodes, script } from \"bitcoinjs-lib\";\nimport type { TargetOutput, UTXOCalculateTxSizeParams, UTXOInputWithScriptType, UTXOType } from \"../types\";\n\n/**\n * Minimum transaction fee\n * 1000 satoshi/kB (similar to current `minrelaytxfee`)\n * @see https://github.com/bitcoin/bitcoin/blob/db88db47278d2e7208c50d16ab10cb355067d071/src/validation.h#L56\n */\nexport const MIN_TX_FEE = 1000;\nexport const TX_OVERHEAD = 4 + 1 + 1 + 4; //10\nexport const OP_RETURN_OVERHEAD = 1 + 8 + 1; //10\nconst TX_INPUT_BASE = 32 + 4 + 1 + 4; // 41\nconst TX_INPUT_PUBKEYHASH = 107;\n\nexport function compileMemo(memo: string) {\n const data = Buffer.from(memo, \"utf8\"); // converts MEMO to buffer\n return script.compile([opcodes.OP_RETURN as number, data]); // Compile OP_RETURN script\n}\n\nexport enum UTXOScriptType {\n P2PKH = \"P2PKH\", // legacy\n // P2SH = 'P2SH', // multisig\n P2WPKH = \"P2WPKH\", // bech32 - native segwit\n // P2TR = \"P2TR\", // taproot\n}\n\nexport const InputSizes: Record<UTXOScriptType, number> = {\n [UTXOScriptType.P2PKH]: 148,\n // [UTXOScriptType.P2SH]: 91,\n [UTXOScriptType.P2WPKH]: 68,\n};\n\nexport const OutputSizes: Record<UTXOScriptType, number> = {\n [UTXOScriptType.P2PKH]: 34,\n // [UTXOScriptType.P2SH]: 91,\n [UTXOScriptType.P2WPKH]: 31,\n};\n\nexport const getScriptTypeForAddress = (address: string) => {\n // Native SegWit (Bech32) addresses - P2WPKH\n // Bitcoin: bc1 (mainnet), tb1 (testnet)\n // Litecoin: ltc1 (mainnet), tltc1 (testnet)\n if (\n address.startsWith(\"bc1\") ||\n address.startsWith(\"tb1\") ||\n address.startsWith(\"ltc1\") ||\n address.startsWith(\"tltc1\")\n ) {\n // Note: bc1p/tb1p are Taproot (P2TR) addresses, but we're treating them as P2WPKH for now\n // since P2TR is not yet implemented\n return UTXOScriptType.P2WPKH;\n }\n\n // P2SH addresses (Pay-to-Script-Hash) - Currently commented out but kept for future use\n // Bitcoin: 3 (mainnet), 2 (testnet)\n // Litecoin: M or 2 (mainnet), Q (testnet)\n // Dash: 7 (mainnet)\n // if (address.startsWith('3') || address.startsWith('2') ||\n // address.startsWith('M') || address.startsWith('Q') ||\n // address.startsWith('7')) {\n // return UTXOScriptType.P2SH;\n // }\n\n // Legacy P2PKH addresses\n // Bitcoin: 1 (mainnet), m/n (testnet)\n // Bitcoin Cash: bitcoincash:q (CashAddr format), q (legacy), 1 (legacy)\n // Litecoin: L (mainnet), m/n (testnet)\n // Dogecoin: D (mainnet), n (testnet)\n // Dash: X (mainnet), y (testnet)\n // Zcash: t1 (transparent mainnet), tm (testnet)\n if (\n // Bitcoin legacy\n address.startsWith(\"1\") ||\n address.startsWith(\"m\") ||\n address.startsWith(\"n\") ||\n // Bitcoin Cash\n address.startsWith(\"bitcoincash:q\") ||\n address.startsWith(\"bitcoincash:p\") ||\n address.startsWith(\"q\") ||\n address.startsWith(\"p\") ||\n // Litecoin legacy (also uses 3 for P2SH but treating as P2PKH for now)\n address.startsWith(\"L\") ||\n address.startsWith(\"M\") ||\n address.startsWith(\"3\") ||\n // Dogecoin\n address.startsWith(\"D\") ||\n address.startsWith(\"A\") ||\n address.startsWith(\"9\") ||\n // Dash\n address.startsWith(\"X\") ||\n address.startsWith(\"7\") ||\n address.startsWith(\"y\") ||\n // Zcash transparent addresses\n address.startsWith(\"t1\") ||\n address.startsWith(\"t3\") ||\n address.startsWith(\"tm\")\n ) {\n return UTXOScriptType.P2PKH;\n }\n\n throw new USwapError(\"toolbox_utxo_invalid_address\", { address });\n};\n\nexport const calculateTxSize = ({ inputs, outputs, feeRate }: UTXOCalculateTxSizeParams) => {\n const newTxType =\n inputs[0] && \"address\" in inputs[0] && inputs[0].address\n ? getScriptTypeForAddress(inputs[0].address)\n : UTXOScriptType.P2PKH;\n const inputSize = inputs\n .filter((utxo) => utxo.value >= InputSizes[\"type\" in utxo ? utxo.type : UTXOScriptType.P2PKH] * Math.ceil(feeRate))\n .reduce((total, utxo) => total + getInputSize(utxo), 0);\n\n const outputSize = outputs?.reduce((total, output) => total + getOutputSize(output), 0) || OutputSizes[newTxType];\n\n return TX_OVERHEAD + inputSize + outputSize;\n};\n\nexport const getInputSize = (input: UTXOInputWithScriptType | UTXOType) => {\n if (\"type\" in input) {\n return InputSizes[input.type];\n }\n if (\"address\" in input && input.address) {\n return InputSizes[getScriptTypeForAddress(input.address as string)];\n }\n return TX_INPUT_BASE + TX_INPUT_PUBKEYHASH;\n};\n\nexport const getOutputSize = (output: TargetOutput, scriptType?: UTXOScriptType) => {\n if (output?.script) {\n return OP_RETURN_OVERHEAD + output.script.length + (output.script.length >= 74 ? 2 : 1);\n }\n if (scriptType) {\n return OutputSizes[scriptType];\n }\n return OutputSizes[UTXOScriptType.P2PKH];\n};\n",
9
+ "/**\n * Based on code from SwapKit (https://github.com/swapkit/SwapKit),\n * licensed under the Apache License 2.0.\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { Chain, USwapError, type UTXOChain } from \"@uswap/helpers\";\n\nimport {\n calculateTxSize,\n getInputSize,\n getOutputSize,\n getScriptTypeForAddress,\n TX_OVERHEAD,\n UTXOScriptType,\n} from \"../helpers/txSize\";\nimport type { TargetOutput, UTXOCalculateTxSizeParams, UTXOType } from \"../types\";\n\nexport function getDustThreshold(chain: UTXOChain) {\n switch (chain) {\n case Chain.Bitcoin:\n case Chain.BitcoinCash:\n return 550;\n case Chain.Dash:\n case Chain.Litecoin:\n return 5500;\n case Chain.Dogecoin:\n return 100000;\n case Chain.Zcash:\n return 546;\n default:\n throw new USwapError(\"toolbox_utxo_not_supported\", { chain });\n }\n}\n\nexport function accumulative({\n inputs,\n outputs,\n feeRate: initialFeeRate = 1,\n chain = Chain.Bitcoin,\n changeAddress = \"\",\n}: UTXOCalculateTxSizeParams & { outputs: TargetOutput[]; chain: UTXOChain; changeAddress?: string }) {\n const feeRate = Math.ceil(initialFeeRate);\n\n const newTxType =\n inputs[0] && \"address\" in inputs[0] && inputs[0].address\n ? getScriptTypeForAddress(inputs[0].address)\n : UTXOScriptType.P2PKH;\n // skip input if adding it would cost more than input is worth\n const filteredInputs = inputs.filter((input) => getInputSize(input) * feeRate <= input.value);\n\n const txSizeWithoutInputs =\n TX_OVERHEAD + outputs.reduce((total, output) => total + getOutputSize(output, newTxType), 0);\n\n const amountToSend = outputs.reduce((total, output) => total + output.value, 0);\n\n let fees = txSizeWithoutInputs * feeRate;\n let inputsValue = 0;\n const inputsToUse: typeof inputs = [];\n\n for (const input of filteredInputs) {\n const inputSize = getInputSize(input);\n const inputFee = feeRate * inputSize;\n\n fees += inputFee;\n inputsValue += input.value;\n\n inputsToUse.push(input);\n\n const totalCost = fees + amountToSend;\n\n // we need more inputs\n if (inputsValue < totalCost) continue;\n\n const remainder = inputsValue - totalCost;\n\n const feeForExtraOutput = feeRate * getOutputSize({ address: \"\", value: 0 }, newTxType);\n\n // potential change address\n if (remainder > feeForExtraOutput) {\n const feeAfterExtraOutput = feeForExtraOutput + fees;\n const remainderAfterExtraOutput = inputsValue - (amountToSend + feeAfterExtraOutput);\n\n // is it worth a change output aka can we send it in the future?\n if (remainderAfterExtraOutput > Math.max(getInputSize({} as UTXOType) * feeRate, getDustThreshold(chain))) {\n return {\n fee: feeAfterExtraOutput,\n inputs: inputsToUse,\n outputs: outputs.concat({ address: changeAddress, value: remainderAfterExtraOutput }),\n };\n }\n }\n return { fee: fees, inputs: inputsToUse, outputs };\n }\n\n // We don't have enough inputs, let's calculate transaction fee accrude to the last input\n return { fee: feeRate * calculateTxSize({ feeRate, inputs, outputs }) };\n}\n",
10
10
  "export * from \"./api\";\nexport * from \"./bchaddrjs\";\nexport * from \"./coinselect\";\nexport * from \"./txSize\";\n",
11
11
  "import { networks, address as zcashAddress } from \"@bitgo/utxo-lib\";\nimport bs58check from \"bs58check\";\nimport { UtxoNetwork as bchNetwork, detectAddressNetwork, isValidAddress } from \"../helpers\";\n\nexport function stripPrefix(address: string) {\n return address.replace(/(bchtest:|bitcoincash:)/, \"\");\n}\n\nexport function bchValidateAddress(address: string) {\n const strippedAddress = stripPrefix(address);\n return isValidAddress(strippedAddress) && detectAddressNetwork(strippedAddress) === bchNetwork.Mainnet;\n}\n\nexport function validateZcashAddress(address: string): boolean {\n try {\n if (address.startsWith(\"z\")) {\n console.warn(\"Shielded Zcash addresses (z-addresses) are not supported. Use transparent addresses (t1/t3) only.\");\n return false;\n }\n\n const network = networks.zcash;\n\n try {\n zcashAddress.toOutputScript(address, network);\n return true;\n } catch {\n const decoded = bs58check.decode(address);\n if (decoded.length < 21) return false;\n\n const version = decoded[0];\n return version === network.pubKeyHash || version === network.scriptHash;\n }\n } catch {\n return false;\n }\n}\n",
12
- "import secp256k1 from \"@bitcoinerlab/secp256k1\";\n// @ts-expect-error\nimport { ECPair, HDNode } from \"@psf/bitcoincashjs-lib\";\nimport { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport {\n AssetValue,\n applyFeeMultiplier,\n Chain,\n type ChainSigner,\n DerivationPath,\n type DerivationPathArray,\n derivationPathToString,\n FeeOption,\n NetworkDerivationPath,\n SwapKitError,\n SwapKitNumber,\n type UTXOChain,\n updateDerivationPath,\n} from \"@uswap/helpers\";\nimport { address as btcLibAddress, initEccLib, Psbt, payments } from \"bitcoinjs-lib\";\nimport type { ECPairInterface } from \"ecpair\";\nimport { ECPairFactory } from \"ecpair\";\nimport { getBalance } from \"../../utils\";\nimport {\n accumulative,\n calculateTxSize,\n compileMemo,\n getDustThreshold,\n getInputSize,\n getUtxoApi,\n getUtxoNetwork,\n UTXOScriptType,\n} from \"../helpers\";\nimport type { BchECPair, TargetOutput, UTXOBuildTxParams, UTXOTransferParams, UTXOType } from \"../types\";\nimport type { UtxoToolboxParams } from \"./params\";\nimport { bchValidateAddress, validateZcashAddress } from \"./validators\";\n\nexport const nonSegwitChains: UTXOChain[] = [Chain.Dash, Chain.Dogecoin, Chain.Zcash, Chain.BitcoinCash];\n\nexport function addInputsAndOutputs({\n inputs,\n outputs,\n chain,\n psbt,\n sender,\n compiledMemo,\n}: {\n inputs: UTXOType[];\n outputs: TargetOutput[];\n chain: UTXOChain;\n psbt: Psbt;\n sender: string;\n compiledMemo: Buffer<ArrayBufferLike> | null;\n}) {\n for (const utxo of inputs) {\n const witnessInfo = !!utxo.witnessUtxo && !nonSegwitChains.includes(chain) && { witnessUtxo: utxo.witnessUtxo };\n\n const nonWitnessInfo = nonSegwitChains.includes(chain) && {\n nonWitnessUtxo: utxo.txHex ? Buffer.from(utxo.txHex, \"hex\") : undefined,\n };\n\n psbt.addInput({ hash: utxo.hash, index: utxo.index, ...witnessInfo, ...nonWitnessInfo });\n }\n\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : sender;\n const hasOutputScript = output.script;\n\n if (hasOutputScript && !compiledMemo) {\n continue;\n }\n\n const mappedOutput = hasOutputScript\n ? { script: compiledMemo as Buffer<ArrayBufferLike>, value: 0 }\n : { address, value: output.value };\n\n initEccLib(secp256k1);\n psbt.addOutput(mappedOutput);\n }\n\n return { inputs, psbt };\n}\n\nasync function createTransaction({\n assetValue,\n recipient,\n memo,\n feeRate,\n sender,\n fetchTxHex = false,\n}: UTXOBuildTxParams): Promise<{ psbt: Psbt; utxos: UTXOType[]; inputs: UTXOType[] }> {\n const chain = assetValue.chain as UTXOChain;\n const compiledMemo = memo ? await compileMemo(memo) : null;\n\n const inputsAndOutputs = await getInputsAndTargetOutputs({ assetValue, fetchTxHex, memo, recipient, sender });\n\n const { inputs, outputs } = accumulative({ ...inputsAndOutputs, chain, feeRate });\n\n // .inputs and .outputs will be undefined if no solution was found\n if (!(inputs && outputs)) throw new SwapKitError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n const getNetwork = await getUtxoNetwork();\n const psbt = new Psbt({ network: getNetwork(chain) });\n\n if (chain === Chain.Dogecoin) psbt.setMaximumFeeRate(650000000);\n\n const { psbt: mappedPsbt, inputs: mappedInputs } = await addInputsAndOutputs({\n chain,\n compiledMemo,\n inputs,\n outputs,\n psbt,\n sender,\n });\n\n return { inputs: mappedInputs, psbt: mappedPsbt, utxos: inputsAndOutputs.inputs };\n}\n\nexport async function getUTXOAddressValidator() {\n const getNetwork = await getUtxoNetwork();\n\n return function validateAddress({ address, chain }: { address: string; chain: UTXOChain }) {\n if (chain === Chain.BitcoinCash) {\n return bchValidateAddress(address);\n }\n\n if (chain === Chain.Zcash) {\n return validateZcashAddress(address);\n }\n\n try {\n initEccLib(secp256k1);\n btcLibAddress.toOutputScript(address, getNetwork(chain));\n return true;\n } catch {\n return false;\n }\n };\n}\n\nasync function createSignerWithKeys({\n chain,\n phrase,\n derivationPath,\n}: {\n chain: UTXOChain;\n phrase: string;\n derivationPath: string;\n}) {\n const keyPair = (await getCreateKeysForPath(chain as typeof Chain.Bitcoin))({ derivationPath, phrase });\n\n async function signTransaction(psbt: Psbt) {\n await psbt.signAllInputs(keyPair);\n return psbt;\n }\n\n function getAddress() {\n const addressGetter = addressFromKeysGetter(chain);\n return addressGetter(keyPair);\n }\n\n return { getAddress, signTransaction };\n}\n\nexport async function createUTXOToolbox<T extends UTXOChain>({\n chain,\n ...toolboxParams\n}: (UtxoToolboxParams[T] | { phrase?: string; derivationPath?: DerivationPathArray; index?: number }) & { chain: T }) {\n const phrase = \"phrase\" in toolboxParams ? toolboxParams.phrase : undefined;\n\n const index = \"index\" in toolboxParams ? toolboxParams.index || 0 : 0;\n\n const derivationPath = derivationPathToString(\n \"derivationPath\" in toolboxParams && toolboxParams.derivationPath\n ? toolboxParams.derivationPath\n : updateDerivationPath(NetworkDerivationPath[chain], { index }),\n );\n\n const signer = phrase\n ? await createSignerWithKeys({ chain, derivationPath, phrase })\n : \"signer\" in toolboxParams\n ? toolboxParams.signer\n : undefined;\n\n function getAddress() {\n return Promise.resolve(signer?.getAddress());\n }\n\n // const { signer } = params || {};\n const validateAddress = await getUTXOAddressValidator();\n const createKeysForPath = await getCreateKeysForPath(chain);\n\n return {\n accumulative,\n broadcastTx: (txHash: string) => getUtxoApi(chain).broadcastTx(txHash),\n calculateTxSize,\n createKeysForPath,\n createTransaction,\n estimateMaxSendableAmount: estimateMaxSendableAmount(chain),\n estimateTransactionFee: estimateTransactionFee(chain),\n getAddress,\n getAddressFromKeys: addressFromKeysGetter(chain),\n\n getBalance: getBalance(chain),\n getFeeRates: () => getFeeRates(chain),\n getInputsOutputsFee,\n getPrivateKeyFromMnemonic: (params: { phrase: string; derivationPath: string }) => {\n const keys = createKeysForPath(params);\n return keys.toWIF();\n },\n transfer: transfer(signer as UtxoToolboxParams[\"BTC\"][\"signer\"]),\n validateAddress: (address: string) => validateAddress({ address, chain }),\n };\n}\n\nasync function getInputsOutputsFee({\n assetValue,\n feeOptionKey = FeeOption.Fast,\n feeRate,\n memo,\n sender,\n recipient,\n}: Omit<UTXOBuildTxParams, \"feeRate\"> & { feeOptionKey?: FeeOption; feeRate?: number }) {\n const chain = assetValue.chain as UTXOChain;\n\n const inputsAndOutputs = await getInputsAndTargetOutputs({ assetValue, memo, recipient, sender });\n\n const feeRateWhole = feeRate ? Math.floor(feeRate) : (await getFeeRates(chain))[feeOptionKey];\n\n return accumulative({ ...inputsAndOutputs, chain, feeRate: feeRateWhole });\n}\n\nfunction estimateMaxSendableAmount(chain: UTXOChain) {\n return async function estimateMaxSendableAmount({\n from,\n memo,\n feeRate,\n feeOptionKey = FeeOption.Fast,\n recipients = 1,\n }: {\n from: string;\n memo?: string;\n feeRate?: number;\n feeOptionKey?: FeeOption;\n recipients?: number | TargetOutput[];\n }) {\n const addressData = await getUtxoApi(chain).getAddressData(from);\n const feeRateWhole = feeRate ? Math.ceil(feeRate) : (await getFeeRates(chain))[feeOptionKey];\n\n const inputs = addressData?.utxo\n .map((utxo) => ({\n ...utxo,\n hash: \"\",\n // type: utxo.witnessUtxo ? UTXOScriptType.P2WPKH : UTXOScriptType.P2PKH,\n type: UTXOScriptType.P2PKH,\n }))\n .filter((utxo) => utxo.value > Math.max(getDustThreshold(chain), getInputSize(utxo) * feeRateWhole));\n\n if (!inputs?.length) return AssetValue.from({ chain });\n\n const balance = AssetValue.from({ chain, value: inputs.reduce((sum, utxo) => sum + utxo.value, 0) });\n\n const outputs =\n typeof recipients === \"number\"\n ? (Array.from({ length: recipients }, () => ({ address: from, value: 0 })) as TargetOutput[])\n : recipients;\n\n if (memo) {\n const script = await compileMemo(memo);\n outputs.push({ address: from, script, value: 0 });\n }\n\n const txSize = calculateTxSize({ feeRate: feeRateWhole, inputs, outputs });\n\n const fee = txSize * feeRateWhole;\n\n return balance.sub(fee);\n };\n}\n\nfunction estimateTransactionFee(chain: UTXOChain) {\n return async (params: {\n assetValue: AssetValue;\n recipient: string;\n sender: string;\n memo?: string;\n feeOptionKey?: FeeOption;\n feeRate?: number;\n fetchTxHex?: boolean;\n }) => {\n const inputFees = await getInputsOutputsFee(params);\n\n return AssetValue.from({ chain, value: SwapKitNumber.fromBigInt(BigInt(inputFees.fee), 8).getValue(\"string\") });\n };\n}\n\ntype CreateKeysForPathReturnType = {\n [Chain.BitcoinCash]: BchECPair;\n [Chain.Bitcoin]: ECPairInterface;\n [Chain.Dash]: ECPairInterface;\n [Chain.Dogecoin]: ECPairInterface;\n [Chain.Litecoin]: ECPairInterface;\n [Chain.Zcash]: ECPairInterface;\n};\n\nexport async function getCreateKeysForPath<T extends keyof CreateKeysForPathReturnType>(\n chain: T,\n): Promise<(params: { wif?: string; phrase?: string; derivationPath?: string }) => CreateKeysForPathReturnType[T]> {\n const getNetwork = await getUtxoNetwork();\n\n switch (chain) {\n case Chain.BitcoinCash: {\n return function createKeysForPath({\n phrase,\n derivationPath = `${DerivationPath.BCH}/0`,\n wif,\n }: {\n wif?: string;\n phrase?: string;\n derivationPath?: string;\n }) {\n const network = getNetwork(chain);\n\n if (wif) {\n return ECPair.fromWIF(wif, network) as BchECPair;\n }\n if (!phrase) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"No phrase provided\" });\n\n const masterHDNode = HDNode.fromSeedBuffer(Buffer.from(mnemonicToSeedSync(phrase)), network);\n const keyPair = masterHDNode.derivePath(derivationPath).keyPair;\n\n return keyPair as BchECPair;\n } as (params: { wif?: string; phrase?: string; derivationPath?: string }) => CreateKeysForPathReturnType[T];\n }\n case Chain.Bitcoin:\n case Chain.Dogecoin:\n case Chain.Litecoin:\n case Chain.Zcash:\n case Chain.Dash: {\n return function createKeysForPath({\n phrase,\n wif,\n derivationPath,\n }: {\n phrase?: string;\n wif?: string;\n derivationPath: string;\n }) {\n if (!(wif || phrase))\n throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Either phrase or wif must be provided\" });\n\n const factory = ECPairFactory(secp256k1);\n const network = getNetwork(chain);\n\n if (wif) return factory.fromWIF(wif, network);\n\n const seed = mnemonicToSeedSync(phrase as string);\n const master = HDKey.fromMasterSeed(seed, network).derive(derivationPath);\n if (!master.privateKey)\n throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Could not get private key from phrase\" });\n\n return factory.fromPrivateKey(Buffer.from(master.privateKey), { network });\n } as (params: { wif?: string; phrase?: string; derivationPath?: string }) => CreateKeysForPathReturnType[T];\n }\n default:\n throw new SwapKitError(\"toolbox_utxo_not_supported\", { chain });\n }\n}\n\nexport function addressFromKeysGetter(chain: UTXOChain) {\n const getNetwork = getUtxoNetwork();\n\n return function getAddressFromKeys(keys: ECPairInterface | BchECPair) {\n if (!keys) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Keys must be provided\" });\n\n const method = nonSegwitChains.includes(chain) ? payments.p2pkh : payments.p2wpkh;\n const { address } = method({ network: getNetwork(chain), pubkey: keys.publicKey as Buffer });\n if (!address) throw new SwapKitError(\"toolbox_utxo_invalid_address\", { error: \"Address not defined\" });\n\n return address;\n };\n}\n\nfunction transfer(signer?: ChainSigner<Psbt, Psbt>) {\n return async function transfer({ memo, recipient, feeOptionKey, feeRate, assetValue }: UTXOTransferParams) {\n const from = await signer?.getAddress();\n\n const chain = assetValue.chain as UTXOChain;\n\n if (!(signer && from)) throw new SwapKitError(\"toolbox_utxo_no_signer\");\n if (!recipient)\n throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Recipient address must be provided\" });\n const txFeeRate = feeRate || (await getFeeRates(chain))[feeOptionKey || FeeOption.Fast];\n\n const { psbt } = await createTransaction({ assetValue, feeRate: txFeeRate, memo, recipient, sender: from });\n const signedPsbt = await signer.signTransaction(psbt);\n signedPsbt.finalizeAllInputs(); // Finalise inputs\n // TX extracted and formatted to hex\n return getUtxoApi(chain).broadcastTx(signedPsbt.extractTransaction().toHex());\n };\n}\n\nasync function getFeeRates(chain: UTXOChain) {\n const suggestedFeeRate = await getUtxoApi(chain).getSuggestedTxFee();\n\n return {\n [FeeOption.Average]: suggestedFeeRate,\n [FeeOption.Fast]: applyFeeMultiplier(suggestedFeeRate, FeeOption.Fast),\n [FeeOption.Fastest]: applyFeeMultiplier(suggestedFeeRate, FeeOption.Fastest),\n };\n}\n\nasync function getInputsAndTargetOutputs({\n assetValue,\n recipient,\n memo,\n sender,\n fetchTxHex: fetchTxOverwrite = false,\n}: Omit<UTXOBuildTxParams, \"feeRate\">) {\n const chain = assetValue.chain as UTXOChain;\n const feeRate = (await getFeeRates(chain))[FeeOption.Fastest];\n\n const fetchTxHex = fetchTxOverwrite || nonSegwitChains.includes(chain);\n\n const amountToSend = assetValue.getBaseValue(\"number\");\n\n // Overestimate by 5000 byte * highest feeRate to ensure we have enough UTXOs for fees and change\n const targetValue = Math.ceil(amountToSend + feeRate * 5000);\n\n const inputs = await getUtxoApi(chain).getUtxos({ address: sender, fetchTxHex, targetValue });\n\n return {\n inputs,\n outputs: [\n { address: recipient, value: amountToSend },\n ...(memo ? [{ address: \"\", script: await compileMemo(memo), value: 0 }] : []),\n ],\n };\n}\n",
13
- "import {\n address as bchAddress,\n Transaction,\n TransactionBuilder,\n // @ts-expect-error\n} from \"@psf/bitcoincashjs-lib\";\nimport {\n Chain,\n type ChainSigner,\n type DerivationPathArray,\n derivationPathToString,\n FeeOption,\n NetworkDerivationPath,\n SwapKitError,\n updateDerivationPath,\n} from \"@uswap/helpers\";\nimport { Psbt } from \"bitcoinjs-lib\";\nimport { accumulative, compileMemo, getUtxoApi, getUtxoNetwork, toCashAddress, toLegacyAddress } from \"../helpers\";\nimport type {\n BchECPair,\n TargetOutput,\n TransactionBuilderType,\n TransactionType,\n UTXOBuildTxParams,\n UTXOTransferParams,\n UTXOType,\n} from \"../types\";\nimport type { UtxoToolboxParams } from \"./params\";\nimport { createUTXOToolbox, getCreateKeysForPath } from \"./utxo\";\nimport { bchValidateAddress, stripPrefix } from \"./validators\";\n\nconst chain = Chain.BitcoinCash;\n\nexport function stripToCashAddress(address: string) {\n return stripPrefix(toCashAddress(address));\n}\n\nfunction createSignerWithKeys(keys: BchECPair) {\n function signTransaction({ builder, utxos }: { builder: TransactionBuilderType; utxos: UTXOType[] }) {\n utxos.forEach((utxo, index) => {\n builder.sign(index, keys, undefined, 0x41, utxo.witnessUtxo?.value);\n });\n\n return builder.build();\n }\n\n const getAddress = () => {\n const address = keys.getAddress(0);\n return Promise.resolve(stripToCashAddress(address));\n };\n\n return { getAddress, signTransaction };\n}\n\nexport async function createBCHToolbox<T extends typeof Chain.BitcoinCash>(\n toolboxParams: UtxoToolboxParams[T] | { phrase?: string; derivationPath?: DerivationPathArray; index?: number },\n) {\n const phrase = \"phrase\" in toolboxParams ? toolboxParams.phrase : undefined;\n\n const index = \"index\" in toolboxParams ? toolboxParams.index || 0 : 0;\n\n const derivationPath = derivationPathToString(\n \"derivationPath\" in toolboxParams && toolboxParams.derivationPath\n ? toolboxParams.derivationPath\n : updateDerivationPath(NetworkDerivationPath[chain], { index }),\n );\n\n const keys = phrase ? (await getCreateKeysForPath(chain))({ derivationPath, phrase }) : undefined;\n\n const signer = keys ? createSignerWithKeys(keys) : \"signer\" in toolboxParams ? toolboxParams.signer : undefined;\n\n function getAddress() {\n return Promise.resolve(signer?.getAddress());\n }\n\n const { getBalance, getFeeRates, broadcastTx, ...toolbox } = await createUTXOToolbox({ chain });\n\n function handleGetBalance(address: string, _scamFilter = true) {\n return getBalance(stripPrefix(toCashAddress(address)));\n }\n\n return {\n ...toolbox,\n broadcastTx,\n buildTx,\n createTransaction,\n getAddress,\n getAddressFromKeys,\n getBalance: handleGetBalance,\n getFeeRates,\n stripPrefix,\n stripToCashAddress,\n transfer: transfer({ broadcastTx, getFeeRates, signer }),\n validateAddress: bchValidateAddress,\n };\n}\n\nasync function createTransaction({ assetValue, recipient, memo, feeRate, sender }: UTXOBuildTxParams) {\n if (!bchValidateAddress(recipient)) throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address: recipient });\n\n // Overestimate by 7500 byte * feeRate to ensure we have enough UTXOs for fees and change\n const targetValue = Math.ceil(assetValue.getBaseValue(\"number\") + feeRate * 7500);\n\n const utxos = await getUtxoApi(chain).getUtxos({\n address: stripToCashAddress(sender),\n fetchTxHex: true,\n targetValue,\n });\n\n const compiledMemo = memo ? await compileMemo(memo) : null;\n\n const targetOutputs: TargetOutput[] = [];\n // output to recipient\n targetOutputs.push({ address: recipient, value: assetValue.getBaseValue(\"number\") });\n const { inputs, outputs } = accumulative({ chain, feeRate, inputs: utxos, outputs: targetOutputs });\n\n // .inputs and .outputs will be undefined if no solution was found\n if (!(inputs && outputs)) throw new SwapKitError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n const getNetwork = await getUtxoNetwork();\n const builder = new TransactionBuilder(getNetwork(chain)) as TransactionBuilderType;\n\n await Promise.all(\n inputs.map(async (utxo: UTXOType) => {\n const txHex = await getUtxoApi(chain).getRawTx(utxo.hash);\n\n builder.addInput(Transaction.fromBuffer(Buffer.from(txHex, \"hex\")), utxo.index);\n }),\n );\n\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : toLegacyAddress(sender);\n const getNetwork = await getUtxoNetwork();\n const outputScript = bchAddress.toOutputScript(toLegacyAddress(address), getNetwork(chain));\n\n builder.addOutput(outputScript, output.value);\n }\n\n // add output for memo\n if (compiledMemo) {\n builder.addOutput(compiledMemo, 0); // Add OP_RETURN {script, value}\n }\n\n return { builder, utxos: inputs };\n}\n\nfunction transfer({\n broadcastTx,\n getFeeRates,\n signer,\n}: {\n broadcastTx: (txHash: string) => Promise<string>;\n getFeeRates: () => Promise<Record<FeeOption, number>>;\n signer?: ChainSigner<{ builder: TransactionBuilderType; utxos: UTXOType[] }, TransactionType>;\n}) {\n return async function transfer({\n recipient,\n assetValue,\n feeOptionKey = FeeOption.Fast,\n ...rest\n }: UTXOTransferParams) {\n const from = await signer?.getAddress();\n if (!(signer && from)) throw new SwapKitError(\"toolbox_utxo_no_signer\");\n if (!recipient)\n throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Recipient address must be provided\" });\n\n const feeRate = rest.feeRate || (await getFeeRates())[feeOptionKey];\n\n // try out if psbt tx is faster/better/nicer\n const { builder, utxos } = await createTransaction({ ...rest, assetValue, feeRate, recipient, sender: from });\n\n const tx = await signer.signTransaction({ builder, utxos });\n const txHex = tx.toHex();\n\n return broadcastTx(txHex);\n };\n}\n\nasync function buildTx({\n assetValue,\n recipient,\n memo,\n feeRate,\n sender,\n setSigHashType,\n}: UTXOBuildTxParams & { setSigHashType?: boolean }) {\n const recipientCashAddress = toCashAddress(recipient);\n if (!bchValidateAddress(recipientCashAddress))\n throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address: recipientCashAddress });\n\n // Overestimate by 7500 byte * feeRate to ensure we have enough UTXOs for fees and change\n const targetValue = Math.ceil(assetValue.getBaseValue(\"number\") + feeRate * 7500);\n\n const utxos = await getUtxoApi(chain).getUtxos({\n address: stripToCashAddress(sender),\n fetchTxHex: false,\n targetValue,\n });\n\n const feeRateWhole = Number(feeRate.toFixed(0));\n const compiledMemo = memo ? await compileMemo(memo) : null;\n\n const targetOutputs = [] as TargetOutput[];\n\n // output to recipient\n targetOutputs.push({ address: toLegacyAddress(recipient), value: assetValue.getBaseValue(\"number\") });\n\n //2. add output memo to targets (optional)\n if (compiledMemo) {\n targetOutputs.push({ script: compiledMemo, value: 0 });\n }\n\n const { inputs, outputs } = accumulative({ chain, feeRate: feeRateWhole, inputs: utxos, outputs: targetOutputs });\n\n // .inputs and .outputs will be undefined if no solution was found\n if (!(inputs && outputs)) throw new SwapKitError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n const getNetwork = await getUtxoNetwork();\n const psbt = new Psbt({ network: getNetwork(chain) }); // Network-specific\n\n for (const { hash, index, witnessUtxo } of inputs) {\n psbt.addInput({ hash, index, sighashType: setSigHashType ? 0x41 : undefined, witnessUtxo });\n }\n\n // Outputs\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : toLegacyAddress(sender);\n const params = output.script\n ? compiledMemo\n ? { script: compiledMemo, value: 0 }\n : undefined\n : { address, value: output.value };\n\n if (params) {\n psbt.addOutput(params);\n }\n }\n\n return { inputs: inputs as UTXOType[], psbt, utxos };\n}\n\nfunction getAddressFromKeys(keys: { getAddress: (index?: number) => string }) {\n const address = keys.getAddress(0);\n return stripToCashAddress(address);\n}\n",
14
- "import { bitgo, crypto, ECPair, networks, address as zcashAddress } from \"@bitgo/utxo-lib\";\nimport type { ZcashPsbt } from \"@bitgo/utxo-lib/dist/src/bitgo\";\nimport { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport {\n Chain,\n type ChainSigner,\n type DerivationPathArray,\n derivationPathToString,\n FeeOption,\n NetworkDerivationPath,\n SKConfig,\n SwapKitError,\n updateDerivationPath,\n} from \"@uswap/helpers\";\nimport bs58check from \"bs58check\";\nimport { match, P } from \"ts-pattern\";\nimport { accumulative, compileMemo, getUtxoApi } from \"../helpers\";\nimport type { TargetOutput, UTXOBuildTxParams, UTXOTransferParams, UTXOType } from \"../types\";\nimport { createUTXOToolbox } from \"./utxo\";\nimport { validateZcashAddress } from \"./validators\";\n\nfunction getZcashNetwork() {\n return networks.zcash;\n}\n\nfunction getECPairNetwork() {\n return {\n bech32: undefined,\n bip32: { private: 0x0488ade4, public: 0x0488b21e },\n messagePrefix: \"\\x18ZCash Signed Message:\\n\",\n pubKeyHash: 0x1c,\n scriptHash: 0x1c,\n wif: 0x80,\n };\n}\n\ntype ZcashSigner = ChainSigner<ZcashPsbt, ZcashPsbt>;\n\nfunction createZcashSignerFromPhrase({\n phrase,\n derivationPath,\n}: {\n phrase: string;\n derivationPath: string;\n}): ZcashSigner {\n const seed = mnemonicToSeedSync(phrase);\n const root = HDKey.fromMasterSeed(seed);\n const node = root.derive(derivationPath);\n\n if (!node.privateKey) {\n throw new SwapKitError(\"toolbox_utxo_invalid_params\");\n }\n\n // Create key pair using BitGo's ECPair with ECPair-compatible network\n const ecpairNetwork = getECPairNetwork();\n const keyPair = ECPair.fromPrivateKey(Buffer.from(node.privateKey), { network: ecpairNetwork });\n\n const pubKeyHash = crypto.hash160(keyPair.publicKey);\n const { isStagenet } = SKConfig.get(\"envs\");\n\n const prefix = isStagenet\n ? Buffer.from([0x1d, 0x25]) // testnet prefix (results in tm... addresses)\n : Buffer.from([0x1c, 0xb8]); // mainnet prefix (results in t1... addresses)\n\n const payload = Buffer.concat([prefix, pubKeyHash]);\n\n const address = bs58check.encode(payload);\n\n return {\n getAddress: () => Promise.resolve(address),\n\n signTransaction: (psbt) => {\n const signedPsbt = psbt.signAllInputs(keyPair);\n\n return Promise.resolve(signedPsbt);\n },\n };\n}\n\nfunction addInputsAndOutputs({\n inputs,\n outputs,\n psbt,\n sender,\n compiledMemo,\n}: {\n inputs: UTXOType[];\n outputs: TargetOutput[];\n psbt: ZcashPsbt;\n sender: string;\n compiledMemo: Buffer<ArrayBufferLike> | null;\n}) {\n for (const utxo of inputs) {\n const witnessInfo = !!utxo.witnessUtxo && { witnessUtxo: { ...utxo.witnessUtxo, value: BigInt(utxo.value) } };\n\n const nonWitnessInfo = !utxo.witnessUtxo && {\n nonWitnessUtxo: utxo.txHex ? Buffer.from(utxo.txHex, \"hex\") : undefined,\n };\n\n psbt.addInput({ hash: utxo.hash, index: utxo.index, ...witnessInfo, ...nonWitnessInfo });\n }\n\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : sender;\n const hasOutputScript = output.script;\n\n if (hasOutputScript && !compiledMemo) {\n continue;\n }\n\n const mappedOutput = hasOutputScript\n ? { script: compiledMemo as Buffer<ArrayBufferLike>, value: 0n }\n : { script: zcashAddress.toOutputScript(address, getZcashNetwork()), value: BigInt(output.value) };\n\n psbt.addOutput(mappedOutput);\n }\n\n return { inputs, psbt };\n}\n\nasync function createTransaction(buildTxParams: UTXOBuildTxParams) {\n const { assetValue, recipient, memo, feeRate, sender, fetchTxHex } = buildTxParams;\n\n const compiledMemo = memo ? compileMemo(memo) : null;\n\n const utxos = await getUtxoApi(Chain.Zcash).getUtxos({ address: sender, fetchTxHex: fetchTxHex !== false });\n\n const targetOutputs = [\n { address: recipient, value: Number(assetValue.getBaseValue(\"string\")) },\n ...(compiledMemo ? [{ script: compiledMemo, value: 0 }] : []),\n ];\n\n const { inputs, outputs } = accumulative({\n chain: Chain.Zcash,\n changeAddress: sender, // Overwrite change address to sender\n feeRate,\n inputs: utxos,\n outputs: targetOutputs,\n });\n\n if (!(inputs && outputs)) {\n throw new SwapKitError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n }\n\n const psbt = bitgo.createPsbtForNetwork({ network: getZcashNetwork() }, { version: 455 }) as ZcashPsbt;\n\n // const NU6 = 0xc8e71055;\n const NU5 = 0xc2d6d0b4;\n // const branchId = tipHeight >= 2726400 ? NU6 : tipHeight >= 1687104 ? NU5 : NU5;\n const branchId = NU5;\n\n const CONSENSUS_BRANCH_ID_KEY = Buffer.concat([Buffer.of(0xfc), Buffer.of(0x05), Buffer.from(\"BITGO\"), Buffer.of(0)]);\n\n // PSBT value must be 4-byte little-endian\n const value = Buffer.allocUnsafe(4);\n value.writeUInt32LE(branchId >>> 0, 0);\n\n psbt.addUnknownKeyValToGlobal({ key: CONSENSUS_BRANCH_ID_KEY, value });\n\n const { psbt: mappedPsbt, inputs: mappedInputs } = await addInputsAndOutputs({\n compiledMemo,\n inputs,\n outputs,\n psbt,\n sender,\n });\n\n return { inputs: mappedInputs, outputs, psbt: mappedPsbt };\n}\n\nexport async function createZcashToolbox(\n toolboxParams: { signer?: ZcashSigner } | { phrase?: string; derivationPath?: DerivationPathArray; index?: number },\n) {\n const signer = await match(toolboxParams)\n .with({ signer: P.not(P.nullish) }, ({ signer }) => Promise.resolve(signer))\n .with({ phrase: P.string }, ({ phrase, derivationPath, index = 0 }) => {\n const baseDerivationPath = derivationPath || NetworkDerivationPath[Chain.Zcash] || [44, 133, 0, 0, 0];\n const updatedPath = updateDerivationPath(baseDerivationPath, { index });\n const pathString = derivationPathToString(updatedPath);\n\n return createZcashSignerFromPhrase({ derivationPath: pathString, phrase });\n })\n .otherwise(() => Promise.resolve(undefined));\n\n const baseToolbox = await createUTXOToolbox({ chain: Chain.Zcash, signer });\n\n async function transfer({ recipient, assetValue, feeOptionKey = FeeOption.Fast, ...rest }: UTXOTransferParams) {\n const from = await signer?.getAddress();\n if (!(signer && from)) {\n throw new SwapKitError(\"toolbox_utxo_no_signer\");\n }\n\n const feeRate = rest.feeRate || (await baseToolbox.getFeeRates())[feeOptionKey];\n\n const { psbt } = await createTransaction({ ...rest, assetValue, feeRate, recipient, sender: from });\n\n const signedPsbt = await signer.signTransaction(psbt);\n\n signedPsbt.finalizeAllInputs();\n\n return baseToolbox.broadcastTx(signedPsbt.extractTransaction().toHex());\n }\n\n function createKeysForPath({\n phrase,\n derivationPath = \"m/44'/133'/0'/0/0\",\n }: {\n phrase: string;\n derivationPath?: string;\n }) {\n const seed = mnemonicToSeedSync(phrase);\n const root = HDKey.fromMasterSeed(seed);\n const node = root.derive(derivationPath);\n\n if (!node.privateKey) {\n throw new SwapKitError(\"toolbox_utxo_invalid_params\");\n }\n\n const ecpairNetwork = getECPairNetwork();\n const keyPair = ECPair.fromPrivateKey(Buffer.from(node.privateKey), { network: ecpairNetwork });\n\n return keyPair;\n }\n\n function getPrivateKeyFromMnemonic({\n phrase,\n derivationPath = \"m/44'/133'/0'/0/0\",\n }: {\n phrase: string;\n derivationPath: string;\n }) {\n const keys = createKeysForPath({ derivationPath, phrase });\n return keys.toWIF();\n }\n\n return {\n ...baseToolbox,\n createKeysForPath,\n createTransaction,\n getPrivateKeyFromMnemonic,\n transfer,\n validateAddress: validateZcashAddress,\n };\n}\n",
15
- "import { Chain, type DerivationPathArray, SwapKitError, type UTXOChain } from \"@uswap/helpers\";\nimport { createBCHToolbox } from \"./bitcoinCash\";\nimport type { UtxoToolboxParams } from \"./params\";\nimport { createUTXOToolbox } from \"./utxo\";\nimport { createZcashToolbox } from \"./zcash\";\n\ntype BCHToolbox = Awaited<ReturnType<typeof createBCHToolbox>>;\ntype CommonUTXOToolbox = Awaited<\n ReturnType<typeof createUTXOToolbox<Exclude<UTXOChain, typeof Chain.BitcoinCash | typeof Chain.Zcash>>>\n>;\ntype ZcashToolbox = Awaited<ReturnType<typeof createZcashToolbox>>;\n\nexport type UTXOToolboxes = {\n [Chain.BitcoinCash]: BCHToolbox;\n [Chain.Bitcoin]: CommonUTXOToolbox;\n [Chain.Dogecoin]: CommonUTXOToolbox;\n [Chain.Litecoin]: CommonUTXOToolbox;\n [Chain.Dash]: CommonUTXOToolbox;\n [Chain.Zcash]: ZcashToolbox;\n};\n\nexport type UTXOWallets = {\n [key in keyof UTXOToolboxes]: UTXOToolboxes[key];\n};\n\nexport async function getUtxoToolbox<T extends keyof UTXOToolboxes>(\n chain: T,\n params?: UtxoToolboxParams[T] | { phrase?: string; derivationPath?: DerivationPathArray; index?: number },\n): Promise<UTXOToolboxes[T]> {\n switch (chain) {\n case Chain.BitcoinCash: {\n const toolbox = await createBCHToolbox((params as UtxoToolboxParams[typeof Chain.BitcoinCash]) || {});\n return toolbox as UTXOToolboxes[T];\n }\n\n case Chain.Zcash: {\n const toolbox = await createZcashToolbox(params as UtxoToolboxParams[typeof Chain.Zcash]);\n return toolbox as UTXOToolboxes[T];\n }\n\n case Chain.Bitcoin:\n case Chain.Dogecoin:\n case Chain.Litecoin:\n case Chain.Dash: {\n const toolbox = await createUTXOToolbox({\n chain,\n ...(params as UtxoToolboxParams[Exclude<T, typeof Chain.BitcoinCash | typeof Chain.Zcash>]),\n });\n return toolbox as UTXOToolboxes[Exclude<T, typeof Chain.BitcoinCash | typeof Chain.Zcash>];\n }\n\n default:\n throw new SwapKitError(\"toolbox_utxo_not_supported\", { chain });\n }\n}\n\nexport { stripToCashAddress } from \"./bitcoinCash\";\nexport * from \"./params\";\nexport { bchValidateAddress, stripPrefix, validateZcashAddress } from \"./validators\";\n",
12
+ "/**\n * Based on code from SwapKit (https://github.com/swapkit/SwapKit),\n * licensed under the Apache License 2.0.\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport secp256k1 from \"@bitcoinerlab/secp256k1\";\n// @ts-expect-error\nimport { ECPair, HDNode } from \"@psf/bitcoincashjs-lib\";\nimport { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport {\n AssetValue,\n applyFeeMultiplier,\n Chain,\n type ChainSigner,\n DerivationPath,\n type DerivationPathArray,\n derivationPathToString,\n FeeOption,\n NetworkDerivationPath,\n SwapKitNumber,\n USwapError,\n type UTXOChain,\n updateDerivationPath,\n} from \"@uswap/helpers\";\nimport { address as btcLibAddress, initEccLib, Psbt, payments } from \"bitcoinjs-lib\";\nimport type { ECPairInterface } from \"ecpair\";\nimport { ECPairFactory } from \"ecpair\";\nimport { getBalance } from \"../../utils\";\nimport {\n accumulative,\n calculateTxSize,\n compileMemo,\n getDustThreshold,\n getInputSize,\n getUtxoApi,\n getUtxoNetwork,\n UTXOScriptType,\n} from \"../helpers\";\nimport type { BchECPair, TargetOutput, UTXOBuildTxParams, UTXOTransferParams, UTXOType } from \"../types\";\nimport type { UtxoToolboxParams } from \"./params\";\nimport { bchValidateAddress, validateZcashAddress } from \"./validators\";\n\nexport const nonSegwitChains: UTXOChain[] = [Chain.Dash, Chain.Dogecoin, Chain.Zcash, Chain.BitcoinCash];\n\nexport function addInputsAndOutputs({\n inputs,\n outputs,\n chain,\n psbt,\n sender,\n compiledMemo,\n}: {\n inputs: UTXOType[];\n outputs: TargetOutput[];\n chain: UTXOChain;\n psbt: Psbt;\n sender: string;\n compiledMemo: Buffer<ArrayBufferLike> | null;\n}) {\n for (const utxo of inputs) {\n const witnessInfo = !!utxo.witnessUtxo && !nonSegwitChains.includes(chain) && { witnessUtxo: utxo.witnessUtxo };\n\n const nonWitnessInfo = nonSegwitChains.includes(chain) && {\n nonWitnessUtxo: utxo.txHex ? Buffer.from(utxo.txHex, \"hex\") : undefined,\n };\n\n psbt.addInput({ hash: utxo.hash, index: utxo.index, ...witnessInfo, ...nonWitnessInfo });\n }\n\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : sender;\n const hasOutputScript = output.script;\n\n if (hasOutputScript && !compiledMemo) {\n continue;\n }\n\n const mappedOutput = hasOutputScript\n ? { script: compiledMemo as Buffer<ArrayBufferLike>, value: 0 }\n : { address, value: output.value };\n\n initEccLib(secp256k1);\n psbt.addOutput(mappedOutput);\n }\n\n return { inputs, psbt };\n}\n\nasync function createTransaction({\n assetValue,\n recipient,\n memo,\n feeRate,\n sender,\n fetchTxHex = false,\n}: UTXOBuildTxParams): Promise<{ psbt: Psbt; utxos: UTXOType[]; inputs: UTXOType[] }> {\n const chain = assetValue.chain as UTXOChain;\n const compiledMemo = memo ? await compileMemo(memo) : null;\n\n const inputsAndOutputs = await getInputsAndTargetOutputs({ assetValue, fetchTxHex, memo, recipient, sender });\n\n const { inputs, outputs } = accumulative({ ...inputsAndOutputs, chain, feeRate });\n\n // .inputs and .outputs will be undefined if no solution was found\n if (!(inputs && outputs)) throw new USwapError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n const getNetwork = await getUtxoNetwork();\n const psbt = new Psbt({ network: getNetwork(chain) });\n\n if (chain === Chain.Dogecoin) psbt.setMaximumFeeRate(650000000);\n\n const { psbt: mappedPsbt, inputs: mappedInputs } = await addInputsAndOutputs({\n chain,\n compiledMemo,\n inputs,\n outputs,\n psbt,\n sender,\n });\n\n return { inputs: mappedInputs, psbt: mappedPsbt, utxos: inputsAndOutputs.inputs };\n}\n\nexport async function getUTXOAddressValidator() {\n const getNetwork = await getUtxoNetwork();\n\n return function validateAddress({ address, chain }: { address: string; chain: UTXOChain }) {\n if (chain === Chain.BitcoinCash) {\n return bchValidateAddress(address);\n }\n\n if (chain === Chain.Zcash) {\n return validateZcashAddress(address);\n }\n\n try {\n initEccLib(secp256k1);\n btcLibAddress.toOutputScript(address, getNetwork(chain));\n return true;\n } catch {\n return false;\n }\n };\n}\n\nasync function createSignerWithKeys({\n chain,\n phrase,\n derivationPath,\n}: {\n chain: UTXOChain;\n phrase: string;\n derivationPath: string;\n}) {\n const keyPair = (await getCreateKeysForPath(chain as typeof Chain.Bitcoin))({ derivationPath, phrase });\n\n async function signTransaction(psbt: Psbt) {\n await psbt.signAllInputs(keyPair);\n return psbt;\n }\n\n function getAddress() {\n const addressGetter = addressFromKeysGetter(chain);\n return addressGetter(keyPair);\n }\n\n return { getAddress, signTransaction };\n}\n\nexport async function createUTXOToolbox<T extends UTXOChain>({\n chain,\n ...toolboxParams\n}: (UtxoToolboxParams[T] | { phrase?: string; derivationPath?: DerivationPathArray; index?: number }) & { chain: T }) {\n const phrase = \"phrase\" in toolboxParams ? toolboxParams.phrase : undefined;\n\n const index = \"index\" in toolboxParams ? toolboxParams.index || 0 : 0;\n\n const derivationPath = derivationPathToString(\n \"derivationPath\" in toolboxParams && toolboxParams.derivationPath\n ? toolboxParams.derivationPath\n : updateDerivationPath(NetworkDerivationPath[chain], { index }),\n );\n\n const signer = phrase\n ? await createSignerWithKeys({ chain, derivationPath, phrase })\n : \"signer\" in toolboxParams\n ? toolboxParams.signer\n : undefined;\n\n function getAddress() {\n return Promise.resolve(signer?.getAddress());\n }\n\n // const { signer } = params || {};\n const validateAddress = await getUTXOAddressValidator();\n const createKeysForPath = await getCreateKeysForPath(chain);\n\n return {\n accumulative,\n broadcastTx: (txHash: string) => getUtxoApi(chain).broadcastTx(txHash),\n calculateTxSize,\n createKeysForPath,\n createTransaction,\n estimateMaxSendableAmount: estimateMaxSendableAmount(chain),\n estimateTransactionFee: estimateTransactionFee(chain),\n getAddress,\n getAddressFromKeys: addressFromKeysGetter(chain),\n\n getBalance: getBalance(chain),\n getFeeRates: () => getFeeRates(chain),\n getInputsOutputsFee,\n getPrivateKeyFromMnemonic: (params: { phrase: string; derivationPath: string }) => {\n const keys = createKeysForPath(params);\n return keys.toWIF();\n },\n transfer: transfer(signer as UtxoToolboxParams[\"BTC\"][\"signer\"]),\n validateAddress: (address: string) => validateAddress({ address, chain }),\n };\n}\n\nasync function getInputsOutputsFee({\n assetValue,\n feeOptionKey = FeeOption.Fast,\n feeRate,\n memo,\n sender,\n recipient,\n}: Omit<UTXOBuildTxParams, \"feeRate\"> & { feeOptionKey?: FeeOption; feeRate?: number }) {\n const chain = assetValue.chain as UTXOChain;\n\n const inputsAndOutputs = await getInputsAndTargetOutputs({ assetValue, memo, recipient, sender });\n\n const feeRateWhole = feeRate ? Math.floor(feeRate) : (await getFeeRates(chain))[feeOptionKey];\n\n return accumulative({ ...inputsAndOutputs, chain, feeRate: feeRateWhole });\n}\n\nfunction estimateMaxSendableAmount(chain: UTXOChain) {\n return async function estimateMaxSendableAmount({\n from,\n memo,\n feeRate,\n feeOptionKey = FeeOption.Fast,\n recipients = 1,\n }: {\n from: string;\n memo?: string;\n feeRate?: number;\n feeOptionKey?: FeeOption;\n recipients?: number | TargetOutput[];\n }) {\n const addressData = await getUtxoApi(chain).getAddressData(from);\n const feeRateWhole = feeRate ? Math.ceil(feeRate) : (await getFeeRates(chain))[feeOptionKey];\n\n const inputs = addressData?.utxo\n .map((utxo) => ({\n ...utxo,\n hash: \"\",\n // type: utxo.witnessUtxo ? UTXOScriptType.P2WPKH : UTXOScriptType.P2PKH,\n type: UTXOScriptType.P2PKH,\n }))\n .filter((utxo) => utxo.value > Math.max(getDustThreshold(chain), getInputSize(utxo) * feeRateWhole));\n\n if (!inputs?.length) return AssetValue.from({ chain });\n\n const balance = AssetValue.from({ chain, value: inputs.reduce((sum, utxo) => sum + utxo.value, 0) });\n\n const outputs =\n typeof recipients === \"number\"\n ? (Array.from({ length: recipients }, () => ({ address: from, value: 0 })) as TargetOutput[])\n : recipients;\n\n if (memo) {\n const script = await compileMemo(memo);\n outputs.push({ address: from, script, value: 0 });\n }\n\n const txSize = calculateTxSize({ feeRate: feeRateWhole, inputs, outputs });\n\n const fee = txSize * feeRateWhole;\n\n return balance.sub(fee);\n };\n}\n\nfunction estimateTransactionFee(chain: UTXOChain) {\n return async (params: {\n assetValue: AssetValue;\n recipient: string;\n sender: string;\n memo?: string;\n feeOptionKey?: FeeOption;\n feeRate?: number;\n fetchTxHex?: boolean;\n }) => {\n const inputFees = await getInputsOutputsFee(params);\n\n return AssetValue.from({ chain, value: SwapKitNumber.fromBigInt(BigInt(inputFees.fee), 8).getValue(\"string\") });\n };\n}\n\ntype CreateKeysForPathReturnType = {\n [Chain.BitcoinCash]: BchECPair;\n [Chain.Bitcoin]: ECPairInterface;\n [Chain.Dash]: ECPairInterface;\n [Chain.Dogecoin]: ECPairInterface;\n [Chain.Litecoin]: ECPairInterface;\n [Chain.Zcash]: ECPairInterface;\n};\n\nexport async function getCreateKeysForPath<T extends keyof CreateKeysForPathReturnType>(\n chain: T,\n): Promise<(params: { wif?: string; phrase?: string; derivationPath?: string }) => CreateKeysForPathReturnType[T]> {\n const getNetwork = await getUtxoNetwork();\n\n switch (chain) {\n case Chain.BitcoinCash: {\n return function createKeysForPath({\n phrase,\n derivationPath = `${DerivationPath.BCH}/0`,\n wif,\n }: {\n wif?: string;\n phrase?: string;\n derivationPath?: string;\n }) {\n const network = getNetwork(chain);\n\n if (wif) {\n return ECPair.fromWIF(wif, network) as BchECPair;\n }\n if (!phrase) throw new USwapError(\"toolbox_utxo_invalid_params\", { error: \"No phrase provided\" });\n\n const masterHDNode = HDNode.fromSeedBuffer(Buffer.from(mnemonicToSeedSync(phrase)), network);\n const keyPair = masterHDNode.derivePath(derivationPath).keyPair;\n\n return keyPair as BchECPair;\n } as (params: { wif?: string; phrase?: string; derivationPath?: string }) => CreateKeysForPathReturnType[T];\n }\n case Chain.Bitcoin:\n case Chain.Dogecoin:\n case Chain.Litecoin:\n case Chain.Zcash:\n case Chain.Dash: {\n return function createKeysForPath({\n phrase,\n wif,\n derivationPath,\n }: {\n phrase?: string;\n wif?: string;\n derivationPath: string;\n }) {\n if (!(wif || phrase))\n throw new USwapError(\"toolbox_utxo_invalid_params\", { error: \"Either phrase or wif must be provided\" });\n\n const factory = ECPairFactory(secp256k1);\n const network = getNetwork(chain);\n\n if (wif) return factory.fromWIF(wif, network);\n\n const seed = mnemonicToSeedSync(phrase as string);\n const master = HDKey.fromMasterSeed(seed, network).derive(derivationPath);\n if (!master.privateKey)\n throw new USwapError(\"toolbox_utxo_invalid_params\", { error: \"Could not get private key from phrase\" });\n\n return factory.fromPrivateKey(Buffer.from(master.privateKey), { network });\n } as (params: { wif?: string; phrase?: string; derivationPath?: string }) => CreateKeysForPathReturnType[T];\n }\n default:\n throw new USwapError(\"toolbox_utxo_not_supported\", { chain });\n }\n}\n\nexport function addressFromKeysGetter(chain: UTXOChain) {\n const getNetwork = getUtxoNetwork();\n\n return function getAddressFromKeys(keys: ECPairInterface | BchECPair) {\n if (!keys) throw new USwapError(\"toolbox_utxo_invalid_params\", { error: \"Keys must be provided\" });\n\n const method = nonSegwitChains.includes(chain) ? payments.p2pkh : payments.p2wpkh;\n const { address } = method({ network: getNetwork(chain), pubkey: keys.publicKey as Buffer });\n if (!address) throw new USwapError(\"toolbox_utxo_invalid_address\", { error: \"Address not defined\" });\n\n return address;\n };\n}\n\nfunction transfer(signer?: ChainSigner<Psbt, Psbt>) {\n return async function transfer({ memo, recipient, feeOptionKey, feeRate, assetValue }: UTXOTransferParams) {\n const from = await signer?.getAddress();\n\n const chain = assetValue.chain as UTXOChain;\n\n if (!(signer && from)) throw new USwapError(\"toolbox_utxo_no_signer\");\n if (!recipient)\n throw new USwapError(\"toolbox_utxo_invalid_params\", { error: \"Recipient address must be provided\" });\n const txFeeRate = feeRate || (await getFeeRates(chain))[feeOptionKey || FeeOption.Fast];\n\n const { psbt } = await createTransaction({ assetValue, feeRate: txFeeRate, memo, recipient, sender: from });\n const signedPsbt = await signer.signTransaction(psbt);\n signedPsbt.finalizeAllInputs(); // Finalise inputs\n // TX extracted and formatted to hex\n return getUtxoApi(chain).broadcastTx(signedPsbt.extractTransaction().toHex());\n };\n}\n\nasync function getFeeRates(chain: UTXOChain) {\n const suggestedFeeRate = await getUtxoApi(chain).getSuggestedTxFee();\n\n return {\n [FeeOption.Average]: suggestedFeeRate,\n [FeeOption.Fast]: applyFeeMultiplier(suggestedFeeRate, FeeOption.Fast),\n [FeeOption.Fastest]: applyFeeMultiplier(suggestedFeeRate, FeeOption.Fastest),\n };\n}\n\nasync function getInputsAndTargetOutputs({\n assetValue,\n recipient,\n memo,\n sender,\n fetchTxHex: fetchTxOverwrite = false,\n}: Omit<UTXOBuildTxParams, \"feeRate\">) {\n const chain = assetValue.chain as UTXOChain;\n const feeRate = (await getFeeRates(chain))[FeeOption.Fastest];\n\n const fetchTxHex = fetchTxOverwrite || nonSegwitChains.includes(chain);\n\n const amountToSend = assetValue.getBaseValue(\"number\");\n\n // Overestimate by 5000 byte * highest feeRate to ensure we have enough UTXOs for fees and change\n const targetValue = Math.ceil(amountToSend + feeRate * 5000);\n\n const inputs = await getUtxoApi(chain).getUtxos({ address: sender, fetchTxHex, targetValue });\n\n return {\n inputs,\n outputs: [\n { address: recipient, value: amountToSend },\n ...(memo ? [{ address: \"\", script: await compileMemo(memo), value: 0 }] : []),\n ],\n };\n}\n",
13
+ "/**\n * Based on code from SwapKit (https://github.com/swapkit/SwapKit),\n * licensed under the Apache License 2.0.\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport {\n address as bchAddress,\n Transaction,\n TransactionBuilder,\n // @ts-expect-error\n} from \"@psf/bitcoincashjs-lib\";\nimport {\n Chain,\n type ChainSigner,\n type DerivationPathArray,\n derivationPathToString,\n FeeOption,\n NetworkDerivationPath,\n USwapError,\n updateDerivationPath,\n} from \"@uswap/helpers\";\nimport { Psbt } from \"bitcoinjs-lib\";\nimport { accumulative, compileMemo, getUtxoApi, getUtxoNetwork, toCashAddress, toLegacyAddress } from \"../helpers\";\nimport type {\n BchECPair,\n TargetOutput,\n TransactionBuilderType,\n TransactionType,\n UTXOBuildTxParams,\n UTXOTransferParams,\n UTXOType,\n} from \"../types\";\nimport type { UtxoToolboxParams } from \"./params\";\nimport { createUTXOToolbox, getCreateKeysForPath } from \"./utxo\";\nimport { bchValidateAddress, stripPrefix } from \"./validators\";\n\nconst chain = Chain.BitcoinCash;\n\nexport function stripToCashAddress(address: string) {\n return stripPrefix(toCashAddress(address));\n}\n\nfunction createSignerWithKeys(keys: BchECPair) {\n function signTransaction({ builder, utxos }: { builder: TransactionBuilderType; utxos: UTXOType[] }) {\n utxos.forEach((utxo, index) => {\n builder.sign(index, keys, undefined, 0x41, utxo.witnessUtxo?.value);\n });\n\n return builder.build();\n }\n\n const getAddress = () => {\n const address = keys.getAddress(0);\n return Promise.resolve(stripToCashAddress(address));\n };\n\n return { getAddress, signTransaction };\n}\n\nexport async function createBCHToolbox<T extends typeof Chain.BitcoinCash>(\n toolboxParams: UtxoToolboxParams[T] | { phrase?: string; derivationPath?: DerivationPathArray; index?: number },\n) {\n const phrase = \"phrase\" in toolboxParams ? toolboxParams.phrase : undefined;\n\n const index = \"index\" in toolboxParams ? toolboxParams.index || 0 : 0;\n\n const derivationPath = derivationPathToString(\n \"derivationPath\" in toolboxParams && toolboxParams.derivationPath\n ? toolboxParams.derivationPath\n : updateDerivationPath(NetworkDerivationPath[chain], { index }),\n );\n\n const keys = phrase ? (await getCreateKeysForPath(chain))({ derivationPath, phrase }) : undefined;\n\n const signer = keys ? createSignerWithKeys(keys) : \"signer\" in toolboxParams ? toolboxParams.signer : undefined;\n\n function getAddress() {\n return Promise.resolve(signer?.getAddress());\n }\n\n const { getBalance, getFeeRates, broadcastTx, ...toolbox } = await createUTXOToolbox({ chain });\n\n function handleGetBalance(address: string, _scamFilter = true) {\n return getBalance(stripPrefix(toCashAddress(address)));\n }\n\n return {\n ...toolbox,\n broadcastTx,\n buildTx,\n createTransaction,\n getAddress,\n getAddressFromKeys,\n getBalance: handleGetBalance,\n getFeeRates,\n stripPrefix,\n stripToCashAddress,\n transfer: transfer({ broadcastTx, getFeeRates, signer }),\n validateAddress: bchValidateAddress,\n };\n}\n\nasync function createTransaction({ assetValue, recipient, memo, feeRate, sender }: UTXOBuildTxParams) {\n if (!bchValidateAddress(recipient)) throw new USwapError(\"toolbox_utxo_invalid_address\", { address: recipient });\n\n // Overestimate by 7500 byte * feeRate to ensure we have enough UTXOs for fees and change\n const targetValue = Math.ceil(assetValue.getBaseValue(\"number\") + feeRate * 7500);\n\n const utxos = await getUtxoApi(chain).getUtxos({\n address: stripToCashAddress(sender),\n fetchTxHex: true,\n targetValue,\n });\n\n const compiledMemo = memo ? await compileMemo(memo) : null;\n\n const targetOutputs: TargetOutput[] = [];\n // output to recipient\n targetOutputs.push({ address: recipient, value: assetValue.getBaseValue(\"number\") });\n const { inputs, outputs } = accumulative({ chain, feeRate, inputs: utxos, outputs: targetOutputs });\n\n // .inputs and .outputs will be undefined if no solution was found\n if (!(inputs && outputs)) throw new USwapError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n const getNetwork = await getUtxoNetwork();\n const builder = new TransactionBuilder(getNetwork(chain)) as TransactionBuilderType;\n\n await Promise.all(\n inputs.map(async (utxo: UTXOType) => {\n const txHex = await getUtxoApi(chain).getRawTx(utxo.hash);\n\n builder.addInput(Transaction.fromBuffer(Buffer.from(txHex, \"hex\")), utxo.index);\n }),\n );\n\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : toLegacyAddress(sender);\n const getNetwork = await getUtxoNetwork();\n const outputScript = bchAddress.toOutputScript(toLegacyAddress(address), getNetwork(chain));\n\n builder.addOutput(outputScript, output.value);\n }\n\n // add output for memo\n if (compiledMemo) {\n builder.addOutput(compiledMemo, 0); // Add OP_RETURN {script, value}\n }\n\n return { builder, utxos: inputs };\n}\n\nfunction transfer({\n broadcastTx,\n getFeeRates,\n signer,\n}: {\n broadcastTx: (txHash: string) => Promise<string>;\n getFeeRates: () => Promise<Record<FeeOption, number>>;\n signer?: ChainSigner<{ builder: TransactionBuilderType; utxos: UTXOType[] }, TransactionType>;\n}) {\n return async function transfer({\n recipient,\n assetValue,\n feeOptionKey = FeeOption.Fast,\n ...rest\n }: UTXOTransferParams) {\n const from = await signer?.getAddress();\n if (!(signer && from)) throw new USwapError(\"toolbox_utxo_no_signer\");\n if (!recipient)\n throw new USwapError(\"toolbox_utxo_invalid_params\", { error: \"Recipient address must be provided\" });\n\n const feeRate = rest.feeRate || (await getFeeRates())[feeOptionKey];\n\n // try out if psbt tx is faster/better/nicer\n const { builder, utxos } = await createTransaction({ ...rest, assetValue, feeRate, recipient, sender: from });\n\n const tx = await signer.signTransaction({ builder, utxos });\n const txHex = tx.toHex();\n\n return broadcastTx(txHex);\n };\n}\n\nasync function buildTx({\n assetValue,\n recipient,\n memo,\n feeRate,\n sender,\n setSigHashType,\n}: UTXOBuildTxParams & { setSigHashType?: boolean }) {\n const recipientCashAddress = toCashAddress(recipient);\n if (!bchValidateAddress(recipientCashAddress))\n throw new USwapError(\"toolbox_utxo_invalid_address\", { address: recipientCashAddress });\n\n // Overestimate by 7500 byte * feeRate to ensure we have enough UTXOs for fees and change\n const targetValue = Math.ceil(assetValue.getBaseValue(\"number\") + feeRate * 7500);\n\n const utxos = await getUtxoApi(chain).getUtxos({\n address: stripToCashAddress(sender),\n fetchTxHex: false,\n targetValue,\n });\n\n const feeRateWhole = Number(feeRate.toFixed(0));\n const compiledMemo = memo ? await compileMemo(memo) : null;\n\n const targetOutputs = [] as TargetOutput[];\n\n // output to recipient\n targetOutputs.push({ address: toLegacyAddress(recipient), value: assetValue.getBaseValue(\"number\") });\n\n //2. add output memo to targets (optional)\n if (compiledMemo) {\n targetOutputs.push({ script: compiledMemo, value: 0 });\n }\n\n const { inputs, outputs } = accumulative({ chain, feeRate: feeRateWhole, inputs: utxos, outputs: targetOutputs });\n\n // .inputs and .outputs will be undefined if no solution was found\n if (!(inputs && outputs)) throw new USwapError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n const getNetwork = await getUtxoNetwork();\n const psbt = new Psbt({ network: getNetwork(chain) }); // Network-specific\n\n for (const { hash, index, witnessUtxo } of inputs) {\n psbt.addInput({ hash, index, sighashType: setSigHashType ? 0x41 : undefined, witnessUtxo });\n }\n\n // Outputs\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : toLegacyAddress(sender);\n const params = output.script\n ? compiledMemo\n ? { script: compiledMemo, value: 0 }\n : undefined\n : { address, value: output.value };\n\n if (params) {\n psbt.addOutput(params);\n }\n }\n\n return { inputs: inputs as UTXOType[], psbt, utxos };\n}\n\nfunction getAddressFromKeys(keys: { getAddress: (index?: number) => string }) {\n const address = keys.getAddress(0);\n return stripToCashAddress(address);\n}\n",
14
+ "/**\n * Based on code from SwapKit (https://github.com/swapkit/SwapKit),\n * licensed under the Apache License 2.0.\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { bitgo, crypto, ECPair, networks, address as zcashAddress } from \"@bitgo/utxo-lib\";\nimport { type ZcashPsbt, ZcashTransaction } from \"@bitgo/utxo-lib/dist/src/bitgo\";\nimport { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport {\n Chain,\n type ChainSigner,\n type DerivationPathArray,\n derivationPathToString,\n FeeOption,\n NetworkDerivationPath,\n SKConfig,\n USwapError,\n updateDerivationPath,\n} from \"@uswap/helpers\";\nimport bs58check from \"bs58check\";\nimport { match, P } from \"ts-pattern\";\nimport { accumulative, compileMemo, getUtxoApi } from \"../helpers\";\nimport type { TargetOutput, UTXOBuildTxParams, UTXOTransferParams, UTXOType } from \"../types\";\nimport { createUTXOToolbox } from \"./utxo\";\nimport { validateZcashAddress } from \"./validators\";\n\nfunction getZcashNetwork() {\n return networks.zcash;\n}\n\nfunction getECPairNetwork() {\n return {\n bech32: undefined,\n bip32: { private: 0x0488ade4, public: 0x0488b21e },\n messagePrefix: \"\\x18ZCash Signed Message:\\n\",\n pubKeyHash: 0x1c,\n scriptHash: 0x1c,\n wif: 0x80,\n };\n}\n\ntype ZcashSigner = ChainSigner<ZcashPsbt, ZcashPsbt>;\n\nfunction createZcashSignerFromPhrase({\n phrase,\n derivationPath,\n}: {\n phrase: string;\n derivationPath: string;\n}): ZcashSigner {\n const seed = mnemonicToSeedSync(phrase);\n const root = HDKey.fromMasterSeed(seed);\n const node = root.derive(derivationPath);\n\n if (!node.privateKey) {\n throw new USwapError(\"toolbox_utxo_invalid_params\");\n }\n\n // Create key pair using BitGo's ECPair with ECPair-compatible network\n const ecpairNetwork = getECPairNetwork();\n const keyPair = ECPair.fromPrivateKey(Buffer.from(node.privateKey), { network: ecpairNetwork });\n\n const pubKeyHash = crypto.hash160(keyPair.publicKey);\n const { isStagenet } = SKConfig.get(\"envs\");\n\n const prefix = isStagenet\n ? Buffer.from([0x1d, 0x25]) // testnet prefix (results in tm... addresses)\n : Buffer.from([0x1c, 0xb8]); // mainnet prefix (results in t1... addresses)\n\n const payload = Buffer.concat([prefix, pubKeyHash]);\n\n const address = bs58check.encode(payload);\n\n return {\n getAddress: () => Promise.resolve(address),\n\n signTransaction: (psbt) => {\n const signedPsbt = psbt.signAllInputs(keyPair);\n\n return Promise.resolve(signedPsbt);\n },\n };\n}\n\nfunction addInputsAndOutputs({\n inputs,\n outputs,\n psbt,\n sender,\n compiledMemo,\n}: {\n inputs: UTXOType[];\n outputs: TargetOutput[];\n psbt: ZcashPsbt;\n sender: string;\n compiledMemo: Buffer<ArrayBufferLike> | null;\n}) {\n for (const utxo of inputs) {\n const witnessInfo = !!utxo.witnessUtxo && { witnessUtxo: { ...utxo.witnessUtxo, value: BigInt(utxo.value) } };\n\n const nonWitnessInfo = !utxo.witnessUtxo && {\n nonWitnessUtxo: utxo.txHex ? Buffer.from(utxo.txHex, \"hex\") : undefined,\n };\n\n psbt.addInput({ hash: utxo.hash, index: utxo.index, ...witnessInfo, ...nonWitnessInfo });\n }\n\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : sender;\n const hasOutputScript = output.script;\n\n if (hasOutputScript && !compiledMemo) {\n continue;\n }\n\n const mappedOutput = hasOutputScript\n ? { script: compiledMemo as Buffer<ArrayBufferLike>, value: 0n }\n : { script: zcashAddress.toOutputScript(address, getZcashNetwork()), value: BigInt(output.value) };\n\n psbt.addOutput(mappedOutput);\n }\n\n return { inputs, psbt };\n}\n\nasync function createTransaction(buildTxParams: UTXOBuildTxParams) {\n const { assetValue, recipient, memo, feeRate, sender, fetchTxHex } = buildTxParams;\n\n const compiledMemo = memo ? compileMemo(memo) : null;\n\n const utxos = await getUtxoApi(Chain.Zcash).getUtxos({ address: sender, fetchTxHex: fetchTxHex !== false });\n\n const targetOutputs = [\n { address: recipient, value: Number(assetValue.getBaseValue(\"string\")) },\n ...(compiledMemo ? [{ script: compiledMemo, value: 0 }] : []),\n ];\n\n const { inputs, outputs } = accumulative({\n chain: Chain.Zcash,\n changeAddress: sender, // Overwrite change address to sender\n feeRate,\n inputs: utxos,\n outputs: targetOutputs,\n });\n\n if (!(inputs && outputs)) {\n throw new USwapError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n }\n\n const psbt = bitgo.createPsbtForNetwork(\n { network: getZcashNetwork() },\n { version: ZcashTransaction.VERSION4_BRANCH_NU6_1 },\n ) as ZcashPsbt;\n\n const { psbt: mappedPsbt, inputs: mappedInputs } = await addInputsAndOutputs({\n compiledMemo,\n inputs,\n outputs,\n psbt,\n sender,\n });\n\n mappedPsbt.setDefaultsForVersion(getZcashNetwork(), ZcashTransaction.VERSION4_BRANCH_NU6_1);\n\n return { inputs: mappedInputs, outputs, psbt: mappedPsbt };\n}\n\nexport async function createZcashToolbox(\n toolboxParams: { signer?: ZcashSigner } | { phrase?: string; derivationPath?: DerivationPathArray; index?: number },\n) {\n const signer = await match(toolboxParams)\n .with({ signer: P.not(P.nullish) }, ({ signer }) => Promise.resolve(signer))\n .with({ phrase: P.string }, ({ phrase, derivationPath, index = 0 }) => {\n const baseDerivationPath = derivationPath || NetworkDerivationPath[Chain.Zcash] || [44, 133, 0, 0, 0];\n const updatedPath = updateDerivationPath(baseDerivationPath, { index });\n const pathString = derivationPathToString(updatedPath);\n\n return createZcashSignerFromPhrase({ derivationPath: pathString, phrase });\n })\n .otherwise(() => Promise.resolve(undefined));\n\n const baseToolbox = await createUTXOToolbox({ chain: Chain.Zcash, signer });\n\n async function transfer({ recipient, assetValue, feeOptionKey = FeeOption.Fast, ...rest }: UTXOTransferParams) {\n const from = await signer?.getAddress();\n if (!(signer && from)) {\n throw new USwapError(\"toolbox_utxo_no_signer\");\n }\n\n const feeRate = rest.feeRate || (await baseToolbox.getFeeRates())[feeOptionKey];\n\n const { psbt } = await createTransaction({ ...rest, assetValue, feeRate, recipient, sender: from });\n\n const signedPsbt = await signer.signTransaction(psbt);\n\n signedPsbt.validateSignaturesOfAllInputs();\n\n signedPsbt.finalizeAllInputs();\n\n const finalTx = signedPsbt.extractTransaction();\n const txHex = finalTx.toHex();\n\n return baseToolbox.broadcastTx(txHex);\n }\n\n function createKeysForPath({\n phrase,\n derivationPath = \"m/44'/133'/0'/0/0\",\n }: {\n phrase: string;\n derivationPath?: string;\n }) {\n const seed = mnemonicToSeedSync(phrase);\n const root = HDKey.fromMasterSeed(seed);\n const node = root.derive(derivationPath);\n\n if (!node.privateKey) {\n throw new USwapError(\"toolbox_utxo_invalid_params\");\n }\n\n const ecpairNetwork = getECPairNetwork();\n const keyPair = ECPair.fromPrivateKey(Buffer.from(node.privateKey), { network: ecpairNetwork });\n\n return keyPair;\n }\n\n function getPrivateKeyFromMnemonic({\n phrase,\n derivationPath = \"m/44'/133'/0'/0/0\",\n }: {\n phrase: string;\n derivationPath: string;\n }) {\n const keys = createKeysForPath({ derivationPath, phrase });\n return keys.toWIF();\n }\n\n return {\n ...baseToolbox,\n createKeysForPath,\n createTransaction,\n getPrivateKeyFromMnemonic,\n transfer,\n validateAddress: validateZcashAddress,\n };\n}\n",
15
+ "/**\n * Based on code from SwapKit (https://github.com/swapkit/SwapKit),\n * licensed under the Apache License 2.0.\n * Modifications © 2025 Horizontal Systems.\n */\n\nimport { Chain, type DerivationPathArray, USwapError, type UTXOChain } from \"@uswap/helpers\";\nimport { createBCHToolbox } from \"./bitcoinCash\";\nimport type { UtxoToolboxParams } from \"./params\";\nimport { createUTXOToolbox } from \"./utxo\";\nimport { createZcashToolbox } from \"./zcash\";\n\ntype BCHToolbox = Awaited<ReturnType<typeof createBCHToolbox>>;\ntype CommonUTXOToolbox = Awaited<\n ReturnType<typeof createUTXOToolbox<Exclude<UTXOChain, typeof Chain.BitcoinCash | typeof Chain.Zcash>>>\n>;\ntype ZcashToolbox = Awaited<ReturnType<typeof createZcashToolbox>>;\n\nexport type UTXOToolboxes = {\n [Chain.BitcoinCash]: BCHToolbox;\n [Chain.Bitcoin]: CommonUTXOToolbox;\n [Chain.Dogecoin]: CommonUTXOToolbox;\n [Chain.Litecoin]: CommonUTXOToolbox;\n [Chain.Dash]: CommonUTXOToolbox;\n [Chain.Zcash]: ZcashToolbox;\n};\n\nexport type UTXOWallets = {\n [key in keyof UTXOToolboxes]: UTXOToolboxes[key];\n};\n\nexport async function getUtxoToolbox<T extends keyof UTXOToolboxes>(\n chain: T,\n params?: UtxoToolboxParams[T] | { phrase?: string; derivationPath?: DerivationPathArray; index?: number },\n): Promise<UTXOToolboxes[T]> {\n switch (chain) {\n case Chain.BitcoinCash: {\n const toolbox = await createBCHToolbox((params as UtxoToolboxParams[typeof Chain.BitcoinCash]) || {});\n return toolbox as UTXOToolboxes[T];\n }\n\n case Chain.Zcash: {\n const toolbox = await createZcashToolbox(params as UtxoToolboxParams[typeof Chain.Zcash]);\n return toolbox as UTXOToolboxes[T];\n }\n\n case Chain.Bitcoin:\n case Chain.Dogecoin:\n case Chain.Litecoin:\n case Chain.Dash: {\n const toolbox = await createUTXOToolbox({\n chain,\n ...(params as UtxoToolboxParams[Exclude<T, typeof Chain.BitcoinCash | typeof Chain.Zcash>]),\n });\n return toolbox as UTXOToolboxes[Exclude<T, typeof Chain.BitcoinCash | typeof Chain.Zcash>];\n }\n\n default:\n throw new USwapError(\"toolbox_utxo_not_supported\", { chain });\n }\n}\n\nexport { stripToCashAddress } from \"./bitcoinCash\";\nexport * from \"./params\";\nexport { bchValidateAddress, stripPrefix, validateZcashAddress } from \"./validators\";\n",
16
16
  "export * from \"./helpers\";\nexport * from \"./toolbox\";\nexport * from \"./toolbox/bitcoinCash\";\nexport * from \"./toolbox/utxo\";\nexport * from \"./toolbox/zcash\";\nexport * from \"./types\";\n"
17
17
  ],
18
- "mappings": "ssBAAA,qBAAS,qBAAwB,wBACjC,qBAAS,4BAKF,SAAS,EAAM,EAAG,CACvB,SAAS,CAAG,EAAG,CACb,IAAM,EAAO,KAAK,IAAI,EAChB,EAAW,IAAQ,EAGzB,OAFA,GAAO,EAEA,EAAO,GAAO,EAAO,EAAW,EAGzC,OAAO,GAAM,EAAI,EAAE,SAAS,EAAE,EAGzB,SAAS,EAA2B,CAAC,EAAU,CACpD,OAAO,cAAyB,CAAC,EAAiB,EAAa,GAAM,CACnE,IAAM,EAAW,MAAM,GAAW,gBAAgB,CAAE,UAAS,QAAO,YAAW,CAAC,GACxE,eAAgB,GAAe,CAAK,EAC5C,OAAO,EA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,GAAmB,CAA+C,OAIrF,EAAM,aACN,EAAM,cACN,EAAM,cACN,EAAM,KAKT,OAJgB,MAAM,EAAkB,CACtC,WACI,CACN,CAAC,UAKD,MAAM,IAAI,GAAW,6BAA8B,CAAE,OAAM,CAAC,iBAnDlE,KAEA,IACA,KAoDA,KAEA,gzBChEA,IACA,KACA,KACA,IACA",
19
+ "debugId": "FFE15F310CC5C6C264756E2164756E21",
20
20
  "names": []
21
21
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Based on code from SwapKit (https://github.com/swapkit/SwapKit),
3
+ * licensed under the Apache License 2.0.
4
+ * Modifications © 2025 Horizontal Systems.
5
+ */
1
6
  import { AssetValue, type DerivationPathArray } from "@uswap/helpers";
2
7
  import type { CardanoProvider } from "./index";
3
8
  type CardanoSigner = CardanoProvider | {
@@ -1 +1 @@
1
- {"version":3,"file":"toolbox.d.ts","sourceRoot":"","sources":["../../../src/cardano/toolbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAS,KAAK,mBAAmB,EAAgC,MAAM,gBAAgB,CAAC;AAE3G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,KAAK,aAAa,GAAG,eAAe,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AA4C3D,wBAAsB,0BAA0B,sBAG7B,MAAM,cAQxB;AAED,wBAAsB,iBAAiB,CACrC,aAAa,CAAC,EACV;IAAE,MAAM,CAAC,EAAE,aAAa,CAAA;CAAE,GAC1B;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,mBAAmB,CAAA;CAAE;0DAyC1E;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,UAAU,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;;;;;;gCAlBkC,MAAM;gCAsCN,MAAM;iDAYtC;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,UAAU,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;+BA9FgB,MAAM;GAoHxB"}
1
+ {"version":3,"file":"toolbox.d.ts","sourceRoot":"","sources":["../../../src/cardano/toolbox.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAS,KAAK,mBAAmB,EAA8B,MAAM,gBAAgB,CAAC;AAEzG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,KAAK,aAAa,GAAG,eAAe,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AA4C3D,wBAAsB,0BAA0B,sBAG7B,MAAM,cAQxB;AAED,wBAAsB,iBAAiB,CACrC,aAAa,CAAC,EACV;IAAE,MAAM,CAAC,EAAE,aAAa,CAAA;CAAE,GAC1B;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,mBAAmB,CAAA;CAAE;0DAyC1E;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,UAAU,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;;;;;;gCAlBkC,MAAM;gCAsCN,MAAM;iDAYtC;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,UAAU,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;+BA9FgB,MAAM;GAoHxB"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Based on code from SwapKit (https://github.com/swapkit/SwapKit),
3
+ * licensed under the Apache License 2.0.
4
+ * Modifications © 2025 Horizontal Systems.
5
+ */
1
6
  export declare function bech32ToBase64(address: string): string;
2
7
  export declare function base64ToBech32(address: string, prefix?: string): `${Lowercase<string>}1${string}`;
3
8
  export declare function toBase64(data: Uint8Array): string;
@@ -1 +1 @@
1
- {"version":3,"file":"addressFormat.d.ts","sourceRoot":"","sources":["../../../../src/cosmos/thorchainUtils/addressFormat.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,UAE7C;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,oCAE9D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,UAExC;AAED,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,+BAK9C"}
1
+ {"version":3,"file":"addressFormat.d.ts","sourceRoot":"","sources":["../../../../src/cosmos/thorchainUtils/addressFormat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,UAE7C;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,oCAE9D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,UAExC;AAED,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,+BAK9C"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Based on code from SwapKit (https://github.com/swapkit/SwapKit),
3
+ * licensed under the Apache License 2.0.
4
+ * Modifications © 2025 Horizontal Systems.
5
+ */
1
6
  import { AssetValue, type TCLikeChain } from "@uswap/helpers";
2
7
  import type { ThorchainCreateTransactionParams } from "./types";
3
8
  type MsgSend = ReturnType<typeof transferMsgAmino>;
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/cosmos/thorchainUtils/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAuC,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKnG,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAEhE,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AACnD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AACr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AC;CACf;;;;;;;;;;CAUA,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,0CAK3B;IACD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;;;;;;;;;;;;;;;;;;;;CAOA,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAU,KAAK,OAAO,GAAG,UAAU,EAAE,OAAO,WAAW,0DAIpF,CAAC;AAaF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,IACf,QAAQ,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAS3E;AAED,eAAO,MAAM,eAAe,GACzB,QAAQ,MAAM,MACR,+FASJ,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;EAqBlC,CAAC;AAEJ,eAAO,MAAM,cAAc,GACxB,QAAQ,MAAM,MACR,oFAQJ,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;EAwBlC,CAAC;AAEJ,wBAAgB,iCAAiC,CAAC,CAAC,SAAS,UAAU,GAAG,OAAO,EAAE,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;oBAOP,MAAM;;;;;;;;;;;;oBAAN,MAAM;;;;;;;;;GAUtF;AAED,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,IAAI,EACJ,IAAI,GACL,EAAE;IACD,IAAI,EAAE,4BAA4B,EAAE,GAAG,yBAAyB,EAAE,CAAC;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,WAAW,CAAC;CACpB,wCAUA"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Based on code from SwapKit (https://github.com/swapkit/SwapKit),
3
+ * licensed under the Apache License 2.0.
4
+ * Modifications © 2025 Horizontal Systems.
5
+ */
1
6
  import type { Account } from "@cosmjs/stargate";
2
7
  import { AssetValue, Chain, type ChainId, type CosmosChain, type DerivationPathArray, type GenericTransferParams, SwapKitNumber } from "@uswap/helpers";
3
8
  import type { CosmosToolboxParams } from "../types";
@@ -1 +1 @@
1
- {"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["../../../../src/cosmos/toolbox/cosmos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EACL,UAAU,EAEV,KAAK,EACL,KAAK,OAAO,EACZ,KAAK,WAAW,EAGhB,KAAK,mBAAmB,EAGxB,KAAK,qBAAqB,EAK1B,aAAa,EAGd,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EACL,uBAAuB,EAMxB,MAAM,SAAS,CAAC;AAEjB,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBASlF;AAED,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EACN,MAAM,EACN,GAAG,gBAAgB,EACpB,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC,oEAavG;AAED,wBAAsB,uBAAuB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,kEAM/G;AAWD,wBAAgB,eAAe,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,IAChD,kCAInC;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,sBAWF;AA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EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,cAE3F;AA8BD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,WAAW,IAEzB,SAAS,MAAM,aAYhD"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Based on code from SwapKit (https://github.com/swapkit/SwapKit),
3
+ * licensed under the Apache License 2.0.
4
+ * Modifications © 2025 Horizontal Systems.
5
+ */
1
6
  import { Chain, type CosmosChain } from "@uswap/helpers";
2
7
  import type { CosmosToolboxParams } from "../types";
3
8
  import { createCosmosToolbox } from "./cosmos";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cosmos/toolbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAgB,MAAM,gBAAgB,CAAC;AAEvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IAC7C,IAAI,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IAC7C,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IAChD,KAAK,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IAC9C,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,EAC3E,OAAO,CAAC,EACR,SAAS,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,KAC1C,eAAe,CAAC,CAAC,CAcnB,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cosmos/toolbox/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IAC7C,IAAI,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IAC7C,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IAChD,KAAK,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;IAC9C,IAAI,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,EAC3E,OAAO,CAAC,EACR,SAAS,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,KAC1C,eAAe,CAAC,CAAC,CAcnB,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Based on code from SwapKit (https://github.com/swapkit/SwapKit),
3
+ * licensed under the Apache License 2.0.
4
+ * Modifications © 2025 Horizontal Systems.
5
+ */
1
6
  import type { Pubkey, Secp256k1HdWallet } from "@cosmjs/amino";
2
7
  import { type GenericTransferParams, SwapKitNumber, type TCLikeChain } from "@uswap/helpers";
3
8
  import { buildEncodedTxBody, createDefaultRegistry, parseAminoMessageForDirectSigning } from "../thorchainUtils";
@@ -1 +1 @@
1
- {"version":3,"file":"thorchain.d.ts","sourceRoot":"","sources":["../../../../src/cosmos/toolbox/thorchain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAKL,KAAK,qBAAqB,EAO1B,aAAa,EACb,KAAK,WAAW,EAEjB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAEL,kBAAkB,EAGlB,qBAAqB,EAErB,iCAAiC,EAClC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAoFhF,iBAAe,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,UAAO,4DAOvF;AAED,iBAAS,eAAe,CAAC,SAAS,EAAE,MAAM,+BAEzC;AAED,iBAAe,kBAAkB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,mBAKrG;AAED,wBAAsB,sBAAsB,CAAC,EAAE,KAAK,EAAE,GAAG,aAAa,EAAE,EAAE,mBAAmB,CAAC,WAAW,CAAC;8BArDlG,MAAM,WACD,cAAc,EAAE,kBACT,MAAM,EAAE,aACb,MAAM,aACN,UAAU;;;iBA7B6B,CAAC;;YAA0C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gDA+H7F,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;8BAqDlC,MAAM;8CApMsB,MAAM;qCAef;QAAE,MAAM,EAAE,iBAAi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F,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;8BAqDlC,MAAM;8CApMsB,MAAM;qCAef;QAAE,MAAM,EAAE,iBAAiB,CAAC;QAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE;;;;;iDAgIxG,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;GAiErE"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Based on code from SwapKit (https://github.com/swapkit/SwapKit),
3
+ * licensed under the Apache License 2.0.
4
+ * Modifications © 2025 Horizontal Systems.
5
+ */
1
6
  import type { OfflineSigner } from "@cosmjs/proto-signing";
2
7
  import type { SigningStargateClientOptions } from "@cosmjs/stargate";
3
8
  import { AssetValue, type CosmosChain } from "@uswap/helpers";
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/cosmos/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAS,KAAK,WAAW,EAA2C,MAAM,gBAAgB,CAAC;AAC9G,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAE7D,eAAO,MAAM,wBAAwB,mFAC6C,CAAC;AAEnF,eAAO,MAAM,wBAAwB,+DAA+D,CAAC;AAErG,eAAO,MAAM,0BAA0B;;;;;;CAAiE,CAAC;AAEzG,eAAO,MAAM,wBAAwB;;;;;;CAAkE,CAAC;AAExG,eAAO,MAAM,yBAAyB;;;;;;CAAkE,CAAC;AAEzG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW;;;;;;EAapD;AAED,eAAO,MAAM,eA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KAAK,EAAE,WAAW;;;;;;EAapD;AAED,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,qBAAmB,WAwBlE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,mBAAmB,UAAU,WAU9D,CAAC;AAEF,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,MAAM,sDAWrD;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,aAAa,EACrB,gBAAgB,GAAE,MAAM,GAAG,4BAAiC,6DAS7D;AAED,wBAAsB,2BAA2B,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,4BAA4B,6DAI/G;AAgBD;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,MAAM,EACN,SAAS,EACT,UAAU,EACV,IAAS,EACT,OAAO,EACP,QAAQ,EACR,aAAa,GACd,EAAE,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;GAkC/B;AAgCD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,EAAE,QAAQ,MAAM,eAc9D,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { Chain, type EVMChain, type NetworkParams } from "@uswap/helpers";
2
2
  export declare function getProvider(chain: EVMChain, customUrl?: string): Promise<import("ethers").JsonRpcProvider>;
3
3
  export declare function toHexString(value: bigint): string;
4
- export declare function getNetworkParams<C extends EVMChain>(chain: C): () => C extends typeof Chain.Ethereum ? undefined : NetworkParams;
4
+ export declare function getNetworkParams<C extends EVMChain>(chain: C): () => C extends Chain.Ethereum ? undefined : NetworkParams;
5
5
  export declare function getIsEIP1559Compatible<C extends EVMChain>(chain: C): boolean;
6
6
  //# sourceMappingURL=helpers.d.ts.map