crypto-aio 0.2.0 → 1.0.0-rc.1

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 (162) hide show
  1. package/CHANGELOG.md +70 -2
  2. package/README.md +16 -10
  3. package/dist/adapters/avalanche/driver.d.ts +4 -0
  4. package/dist/adapters/avalanche/driver.js.map +1 -1
  5. package/dist/adapters/avalanche/sdk.d.ts +15 -0
  6. package/dist/adapters/avalanche/sdk.js.map +1 -1
  7. package/dist/adapters/evm/plugin.d.ts +1 -0
  8. package/dist/adapters/evm/plugin.js.map +1 -1
  9. package/dist/adapters/ton/network.d.ts +1 -0
  10. package/dist/adapters/ton/network.js +1 -0
  11. package/dist/adapters/ton/network.js.map +1 -1
  12. package/dist/adapters/ton/types.d.ts +1 -0
  13. package/dist/adapters/ton/types.js.map +1 -1
  14. package/dist/adapters/tron/decode.js +3 -2
  15. package/dist/adapters/tron/decode.js.map +1 -1
  16. package/dist/adapters/tron/http.d.ts +6 -0
  17. package/dist/adapters/tron/http.js +9 -0
  18. package/dist/adapters/tron/http.js.map +1 -1
  19. package/dist/adapters/tron/network.d.ts +4 -0
  20. package/dist/adapters/tron/network.js +4 -0
  21. package/dist/adapters/tron/network.js.map +1 -1
  22. package/dist/adapters/tron/proofs.js +6 -2
  23. package/dist/adapters/tron/proofs.js.map +1 -1
  24. package/dist/adapters/tron/reader.js +1 -1
  25. package/dist/adapters/tron/reader.js.map +1 -1
  26. package/dist/adapters/utxo/driver.d.ts +4 -0
  27. package/dist/adapters/utxo/driver.js.map +1 -1
  28. package/dist/adapters/utxo/esplora.d.ts +6 -0
  29. package/dist/adapters/utxo/esplora.js +20 -3
  30. package/dist/adapters/utxo/esplora.js.map +1 -1
  31. package/dist/adapters/utxo/types.d.ts +1 -0
  32. package/dist/adapters/utxo/types.js.map +1 -1
  33. package/dist/core/blockchain/handle.d.ts +6 -1
  34. package/dist/core/blockchain/handle.js +1 -1
  35. package/dist/core/blockchain/handle.js.map +1 -1
  36. package/dist/core/config/types.d.ts +64 -0
  37. package/dist/core/config/types.js.map +1 -1
  38. package/dist/core/container/container.d.ts +3 -0
  39. package/dist/core/container/container.js.map +1 -1
  40. package/dist/core/container/pool.js +12 -0
  41. package/dist/core/container/pool.js.map +1 -1
  42. package/dist/core/driver/types.d.ts +124 -7
  43. package/dist/core/driver/types.js.map +1 -1
  44. package/dist/core/errors/codes.d.ts +3 -0
  45. package/dist/core/errors/codes.js.map +1 -1
  46. package/dist/core/errors/error.d.ts +26 -0
  47. package/dist/core/errors/error.js +20 -0
  48. package/dist/core/errors/error.js.map +1 -1
  49. package/dist/core/events/logger.d.ts +17 -1
  50. package/dist/core/events/logger.js +5 -1
  51. package/dist/core/events/logger.js.map +1 -1
  52. package/dist/core/events/types.d.ts +26 -1
  53. package/dist/core/events/types.js.map +1 -1
  54. package/dist/core/lifecycle/engine.d.ts +5 -0
  55. package/dist/core/lifecycle/engine.js.map +1 -1
  56. package/dist/core/lifecycle/monitor.d.ts +6 -0
  57. package/dist/core/lifecycle/monitor.js.map +1 -1
  58. package/dist/core/lifecycle/views.d.ts +5 -0
  59. package/dist/core/lifecycle/views.js.map +1 -1
  60. package/dist/core/lifecycle/workers.d.ts +1 -0
  61. package/dist/core/lifecycle/workers.js.map +1 -1
  62. package/dist/core/model/address.d.ts +4 -0
  63. package/dist/core/model/address.js.map +1 -1
  64. package/dist/core/model/amount.d.ts +5 -0
  65. package/dist/core/model/amount.js.map +1 -1
  66. package/dist/core/model/asset.d.ts +11 -0
  67. package/dist/core/model/asset.js +2 -0
  68. package/dist/core/model/asset.js.map +1 -1
  69. package/dist/core/model/capability.d.ts +6 -0
  70. package/dist/core/model/capability.js +4 -0
  71. package/dist/core/model/capability.js.map +1 -1
  72. package/dist/core/model/chain.d.ts +19 -0
  73. package/dist/core/model/chain.js +1 -0
  74. package/dist/core/model/chain.js.map +1 -1
  75. package/dist/core/model/fee.d.ts +24 -1
  76. package/dist/core/model/fee.js.map +1 -1
  77. package/dist/core/model/ids.d.ts +10 -7
  78. package/dist/core/model/ids.js +1 -0
  79. package/dist/core/model/ids.js.map +1 -1
  80. package/dist/core/model/intent.d.ts +13 -0
  81. package/dist/core/model/intent.js.map +1 -1
  82. package/dist/core/model/ordering.d.ts +5 -0
  83. package/dist/core/model/ordering.js.map +1 -1
  84. package/dist/core/model/transaction.d.ts +39 -0
  85. package/dist/core/model/transaction.js.map +1 -1
  86. package/dist/core/observe/scanner.d.ts +10 -1
  87. package/dist/core/observe/scanner.js +6 -0
  88. package/dist/core/observe/scanner.js.map +1 -1
  89. package/dist/core/registry/assets.d.ts +5 -0
  90. package/dist/core/registry/assets.js.map +1 -1
  91. package/dist/core/registry/plugin.d.ts +6 -1
  92. package/dist/core/registry/plugin.js.map +1 -1
  93. package/dist/core/registry/providers.d.ts +5 -0
  94. package/dist/core/registry/providers.js.map +1 -1
  95. package/dist/core/registry/schemes.d.ts +7 -0
  96. package/dist/core/registry/schemes.js.map +1 -1
  97. package/dist/core/secret/redact.d.ts +9 -0
  98. package/dist/core/secret/redact.js +9 -0
  99. package/dist/core/secret/redact.js.map +1 -1
  100. package/dist/core/secret/secret.d.ts +4 -0
  101. package/dist/core/secret/secret.js +4 -0
  102. package/dist/core/secret/secret.js.map +1 -1
  103. package/dist/core/signing/callback.d.ts +5 -0
  104. package/dist/core/signing/callback.js.map +1 -1
  105. package/dist/core/signing/hd.d.ts +4 -0
  106. package/dist/core/signing/hd.js.map +1 -1
  107. package/dist/core/signing/local.d.ts +17 -0
  108. package/dist/core/signing/local.js +5 -0
  109. package/dist/core/signing/local.js.map +1 -1
  110. package/dist/core/signing/types.d.ts +35 -1
  111. package/dist/core/signing/types.js.map +1 -1
  112. package/dist/core/store/format.d.ts +3 -3
  113. package/dist/core/store/format.js +18 -8
  114. package/dist/core/store/format.js.map +1 -1
  115. package/dist/core/store/memory.d.ts +11 -0
  116. package/dist/core/store/memory.js +11 -0
  117. package/dist/core/store/memory.js.map +1 -1
  118. package/dist/core/store/types.d.ts +164 -3
  119. package/dist/core/store/types.js +4 -0
  120. package/dist/core/store/types.js.map +1 -1
  121. package/dist/core/transport/http-transport.js +33 -13
  122. package/dist/core/transport/http-transport.js.map +1 -1
  123. package/dist/core/transport/types.d.ts +70 -0
  124. package/dist/core/transport/types.js.map +1 -1
  125. package/dist/core/util/clock.d.ts +6 -0
  126. package/dist/core/util/clock.js.map +1 -1
  127. package/dist/core/util/json.d.ts +6 -0
  128. package/dist/core/util/json.js +21 -8
  129. package/dist/core/util/json.js.map +1 -1
  130. package/dist/testing/contracts/api.d.ts +1 -0
  131. package/dist/testing/contracts/api.js +1 -0
  132. package/dist/testing/contracts/api.js.map +1 -1
  133. package/dist/testing/contracts/cursors.d.ts +5 -0
  134. package/dist/testing/contracts/cursors.js +4 -0
  135. package/dist/testing/contracts/cursors.js.map +1 -1
  136. package/dist/testing/contracts/locks.d.ts +6 -0
  137. package/dist/testing/contracts/locks.js +5 -0
  138. package/dist/testing/contracts/locks.js.map +1 -1
  139. package/dist/testing/contracts/operations.d.ts +11 -0
  140. package/dist/testing/contracts/operations.js +10 -0
  141. package/dist/testing/contracts/operations.js.map +1 -1
  142. package/dist/testing/contracts/sequences.d.ts +5 -0
  143. package/dist/testing/contracts/sequences.js +4 -0
  144. package/dist/testing/contracts/sequences.js.map +1 -1
  145. package/dist/testing/env.d.ts +11 -0
  146. package/dist/testing/env.js +1 -0
  147. package/dist/testing/env.js.map +1 -1
  148. package/dist/testing/fake-chain.d.ts +32 -0
  149. package/dist/testing/fake-chain.js +11 -0
  150. package/dist/testing/fake-chain.js.map +1 -1
  151. package/dist/testing/fake-driver.d.ts +2 -0
  152. package/dist/testing/fake-driver.js.map +1 -1
  153. package/dist/testing/fake-fetch.d.ts +6 -0
  154. package/dist/testing/fake-fetch.js +2 -0
  155. package/dist/testing/fake-fetch.js.map +1 -1
  156. package/dist/testing/fake-plugin.d.ts +2 -0
  157. package/dist/testing/fake-plugin.js +2 -0
  158. package/dist/testing/fake-plugin.js.map +1 -1
  159. package/dist/testing/faulty-store.d.ts +2 -0
  160. package/dist/testing/faulty-store.js +1 -0
  161. package/dist/testing/faulty-store.js.map +1 -1
  162. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"esplora.js","sourceRoot":"","sources":["../../../src/adapters/utxo/esplora.ts"],"names":[],"mappings":";;;AAkDA,8BAEC;AAGD,gCAMC;AA+CD,kCAKC;AAED,8BAEC;AAED,kCAYC;AAmCD,0BAcC;AAiBD,sCAUC;AAkBD,8CAWC;AA5OD;;;;;;;;;;GAUG;AACH,mDAIiC;AAEjC,mCAAmE;AACnE,yCAA6E;AAC7E,mCAAoC;AAepC,MAAM,KAAK,GAAG,gBAAgB,CAAC;AAC/B;;;GAGG;AACU,QAAA,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AACrF,wEAAwE;AAC3D,QAAA,SAAS,GAAG,iBAAsB,CAAC;AAEhD;;;GAGG;AACH,MAAM,KAAK,GAAG,CAAC,KAAa,EAAW,EAAE,CACvC,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAEtD,SAAgB,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,qBAAa,CAAC,sBAAsB,EAAE,6BAA6B,IAAI,EAAE,CAAC,CAAC;AACxF,CAAC;AAED,yFAAyF;AACzF,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,CACL,IAAA,wBAAgB,EAAC,KAAK,EAAE,WAAW,CAAC;QACpC,CAAC,KAAK,CAAC,SAAS;QAChB,KAAK,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,CAC9B,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,IAAY,EAAQ,EAAE;IACpD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,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CACjB,MAAM,IAAI,CAAC,IAAI,CACb,IAAI,CAAC,OAAO,EACZ,YAAY,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EACzC,mBAAmB,EACnB,IAAI,EACJ,MAAM,EACN,IAAI,CACL,EACD,SAAS,CACV,CAAC;QACF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;QAC7D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QAC1D,iFAAiF;QACjF,IAAI,KAAK,GAAG,MAAM,IAAI,MAAM,GAAG,KAAK,GAAG,iBAAS;YAAE,MAAM,SAAS,CAAC,iBAAiB,CAAC,CAAC;QACrF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED,iFAAiF;IACjF,KAAK,CAAC,UAAU,CACd,OAAe,EACf,QAA4B,EAC5B,IAAkB;QAElB,MAAM,IAAI,GAAG,YAAY,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,CAAC;QACjE,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACpE,MAAM,KAAK,GAAG,QAAQ;YACpB,CAAC,CAAC,6CAA6C;YAC/C,CAAC,CAAC,6BAA6B,CAAC;QAClC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IACxF,CAAC;CACF;AA9UD,sCA8UC","sourcesContent":["/**\n * The Esplora REST API, sent directly over the core transport. Every call carries the\n * calling driver method's tags and a `route` template with no identifiers in it, which\n * events and logs show instead of the path. Answers are validated strictly: a malformed\n * one is a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, a missing or ill-typed\n * field is malformed and never a default, an answer for another id than the one asked for is\n * refused, and a 404 is `null`. Chain data is read as the chain allows it, never bounded by\n * what this library builds (lenient readers). Chain reads use the `rpc` transport; address\n * reads use the `indexer`. Only raw transactions and blocks are decoded, by the strict\n * linear readers (`rawtx.ts`, `rawblock.ts`), to bind them to their txid or block hash.\n */\nimport {\n ProviderError,\n ValidationError,\n isCryptoAioError,\n} from '../../core/errors/error';\nimport type { HttpRequest, Transport } from '../../core/transport/types';\nimport { previousTxOf, txidOfHex, type PreviousTx } from './codec';\nimport { commitsToTransactions, readBlock, type RawBlock } from './rawblock';\nimport { readTxHex } from './rawtx';\nimport type {\n EsploraAddressStats,\n EsploraBlock,\n EsploraInput,\n EsploraOutput,\n EsploraOutspend,\n EsploraStatus,\n EsploraTx,\n EsploraUtxo,\n UtxoCallTags,\n} from './types';\n\ntype Json = Readonly<Record<string, unknown>>;\n\nconst HEX64 = /^[0-9a-f]{64}$/;\n/**\n * The previous transactions one client keeps, by count and by bytes without the\n * witness (a larger one is not kept). A typical one is a few hundred bytes.\n */\nexport const PREVIOUS_TX_CACHE = Object.freeze({ entries: 1_000, bytes: 8_000_000 });\n/** Bitcoin Core's `MAX_MONEY`: no output, and no balance, is larger. */\nexport const MAX_MONEY = 2_100_000_000_000_000n;\n\n/**\n * Lowercase hex of whole bytes. A flat character class, not `([0-9a-f]{2})+`: that pattern\n * overflows V8's regexp stack on the hex of a transaction of about 3.5 MB, which is valid.\n */\nconst isHex = (value: string): boolean =>\n value.length % 2 === 0 && /^[0-9a-f]*$/.test(value);\n\nexport function malformed(what: string): ProviderError {\n return new ProviderError('PROVIDER_UNAVAILABLE', `malformed Esplora answer: ${what}`);\n}\n\n/** A definitive 404 (not an ambiguous or retried failure): the resource is not there. */\nexport function isNotFound(error: unknown): boolean {\n return (\n isCryptoAioError(error, 'RPC_ERROR') &&\n !error.ambiguous &&\n error.details?.status === 404\n );\n}\n\nconst record = (value: unknown, what: string): Json => {\n if (value === null || typeof value !== 'object' || Array.isArray(value))\n throw malformed(what);\n return value as Json;\n};\nconst hash = (value: unknown, what: string): string => {\n if (typeof value !== 'string' || !HEX64.test(value)) throw malformed(what);\n return value;\n};\nconst integer = (value: unknown, what: string, max = Number.MAX_SAFE_INTEGER): number => {\n if (!Number.isSafeInteger(value) || (value as number) < 0 || (value as number) > max) {\n throw malformed(what);\n }\n return value as number;\n};\nconst sats = (value: unknown, what: string): bigint =>\n BigInt(integer(value, what, Number(MAX_MONEY)));\nconst u32 = (value: unknown, what: string): number => integer(value, what, 0xffffffff);\n/**\n * A transaction's 32-bit version, which Esplora servers print signed or unsigned, as one\n * signed value (`v | 0`), so both printings agree. Chain data: any version a block holds is\n * read, whatever this library builds (version 2).\n */\nconst txVersion = (value: unknown): number => {\n if (\n !Number.isSafeInteger(value) ||\n (value as number) < -0x80000000 ||\n (value as number) > 0xffffffff\n ) {\n throw malformed('tx.version');\n }\n return (value as number) | 0;\n};\n/**\n * A cumulative total of an address (every output it ever received or spent), read exactly\n * (`exactIntegers`): a busy address's totals exceed 21 million bitcoin, and may exceed 2^53.\n */\nconst total = (value: unknown, what: string): bigint => {\n if (typeof value === 'bigint') {\n if (value < 0n) throw malformed(what);\n return value;\n }\n return BigInt(integer(value, what));\n};\n\nexport function parseHeight(text: unknown): bigint {\n if (typeof text !== 'string' || !/^(0|[1-9][0-9]{0,9})$/.test(text.trim())) {\n throw malformed('block height');\n }\n return BigInt(text.trim());\n}\n\nexport function parseHash(text: unknown): string {\n return hash(typeof text === 'string' ? text.trim() : text, 'block hash');\n}\n\nexport function parseStatus(value: unknown): EsploraStatus {\n const status = record(value, 'status');\n if (typeof status.confirmed !== 'boolean') throw malformed('status.confirmed');\n if (!status.confirmed) return { confirmed: false };\n return {\n confirmed: true,\n blockHeight: BigInt(integer(status.block_height, 'status.block_height')),\n blockHash: hash(status.block_hash, 'status.block_hash'),\n ...(status.block_time !== undefined && status.block_time !== null\n ? { blockTime: integer(status.block_time, 'status.block_time') }\n : {}),\n };\n}\n\nfunction parseOutput(value: unknown): EsploraOutput {\n const output = record(value, 'vout');\n if (typeof output.scriptpubkey !== 'string' || !isHex(output.scriptpubkey)) {\n throw malformed('vout.scriptpubkey');\n }\n if (typeof output.scriptpubkey_type !== 'string')\n throw malformed('vout.scriptpubkey_type');\n const address = output.scriptpubkey_address;\n if (address !== undefined && address !== null && typeof address !== 'string') {\n throw malformed('vout.scriptpubkey_address');\n }\n return {\n script: output.scriptpubkey,\n type: output.scriptpubkey_type,\n ...(typeof address === 'string' ? { address } : {}),\n value: sats(output.value, 'vout.value'),\n };\n}\n\nfunction parseInput(value: unknown): EsploraInput {\n const input = record(value, 'vin');\n // It decides whether the input has a previous output and the transaction a fee.\n if (typeof input.is_coinbase !== 'boolean') throw malformed('vin.is_coinbase');\n const coinbase = input.is_coinbase;\n return {\n txid: hash(input.txid, 'vin.txid'),\n vout: u32(input.vout, 'vin.vout'),\n coinbase,\n sequence: u32(input.sequence, 'vin.sequence'),\n ...(coinbase ? {} : { prevout: parseOutput(input.prevout) }),\n };\n}\n\nexport function parseTx(value: unknown): EsploraTx {\n const tx = record(value, 'tx');\n if (!Array.isArray(tx.vin) || !Array.isArray(tx.vout)) throw malformed('tx.vin/vout');\n return {\n txid: hash(tx.txid, 'tx.txid'),\n version: txVersion(tx.version),\n locktime: u32(tx.locktime, 'tx.locktime'),\n weight: integer(tx.weight, 'tx.weight'),\n // Esplora answers `fee` for every transaction (0 for a coinbase): missing is malformed.\n fee: sats(tx.fee, 'tx.fee'),\n vin: tx.vin.map(parseInput),\n vout: tx.vout.map(parseOutput),\n status: parseStatus(tx.status),\n };\n}\n\nfunction parseBlock(value: unknown): EsploraBlock {\n const block = record(value, 'block');\n const height = BigInt(integer(block.height, 'block.height'));\n return {\n hash: hash(block.id, 'block.id'),\n height,\n parentHash:\n height === 0n && block.previousblockhash === null\n ? '0'.repeat(64)\n : hash(block.previousblockhash, 'block.previousblockhash'),\n timestamp: integer(block.timestamp, 'block.timestamp'),\n txCount: integer(block.tx_count, 'block.tx_count'),\n };\n}\n\nexport function parseOutspend(value: unknown): EsploraOutspend {\n const spend = record(value, 'outspend');\n if (typeof spend.spent !== 'boolean') throw malformed('outspend.spent');\n if (!spend.spent) return { spent: false };\n return {\n spent: true,\n txid: hash(spend.txid, 'outspend.txid'),\n vin: u32(spend.vin, 'outspend.vin'),\n status: parseStatus(spend.status),\n };\n}\n\nfunction parseUtxo(value: unknown): EsploraUtxo {\n const utxo = record(value, 'utxo');\n return {\n txid: hash(utxo.txid, 'utxo.txid'),\n vout: u32(utxo.vout, 'utxo.vout'),\n value: sats(utxo.value, 'utxo.value'),\n status: parseStatus(utxo.status),\n };\n}\n\nfunction list<T>(value: unknown, what: string, parse: (item: unknown) => T): T[] {\n if (!Array.isArray(value)) throw malformed(what);\n return value.map(parse);\n}\n\n/** Esplora's `/fee-estimates`: confirmation target (blocks) → sat/vB (a float). */\nexport function parseFeeEstimates(value: unknown): ReadonlyMap<number, number> {\n const estimates = record(value, 'fee-estimates');\n const out = new Map<number, number>();\n for (const [target, rate] of Object.entries(estimates)) {\n if (!/^[1-9][0-9]{0,3}$/.test(target)) throw malformed('fee-estimates target');\n if (typeof rate !== 'number' || !Number.isFinite(rate) || rate < 0 || rate > 1e7) {\n throw malformed('fee-estimates rate');\n }\n out.set(Number(target), rate);\n }\n return out;\n}\n\n/** Whether a caller's id is a txid or block hash (64 lowercase hex characters). */\nexport const isHash = (value: unknown): value is string =>\n typeof value === 'string' && HEX64.test(value);\n\n/**\n * A URL path segment from a caller must be exactly an id or an address, so no `..`, `/`\n * or query can reach another route. The reader maps a malformed id to \"not found\" first.\n */\nfunction segment(value: string, kind: 'id' | 'address'): string {\n if (kind === 'id' && !isHash(value)) {\n throw new ValidationError(\n 'INVALID_INTENT',\n 'a transaction or block id must be 64 lowercase hex digits',\n );\n }\n if (kind === 'address' && !/^[0-9A-Za-z]{1,90}$/.test(value)) {\n throw new ValidationError('INVALID_ADDRESS', 'invalid Bitcoin address');\n }\n return value;\n}\n\n/** The txid of strictly decoded transaction hex, or `undefined`. */\nfunction txidOf(hex: string): { readonly txid: string } | undefined {\n try {\n return { txid: txidOfHex(hex) };\n } catch {\n return undefined;\n }\n}\n\n/** An output as a transaction's bytes hold it: its value, signed as bitcoind reads it. */\nexport interface TxOutput {\n readonly value: bigint;\n readonly script: Uint8Array;\n}\n\n/** The txid and outputs (copied) of strictly decoded transaction hex, or `undefined`. */\nfunction outputsOfHex(\n hex: string,\n): { readonly txid: string; readonly outputs: readonly TxOutput[] } | undefined {\n const tx = readTxHex(hex);\n return (\n tx && {\n txid: tx.txid,\n outputs: tx.outputs.map(({ value, script }) => ({\n value,\n script: Uint8Array.from(script),\n })),\n }\n );\n}\n\n/** Transactions kept per txid, oldest out first, by count and by bytes without witness. */\nclass TxCache {\n readonly #txs = new Map<string, PreviousTx>();\n #bytes = 0;\n\n constructor(\n private readonly bounds: { readonly entries: number; readonly bytes: number },\n ) {}\n\n has(txid: string): boolean {\n return this.#txs.has(txid);\n }\n\n /** The transaction, now the most recently used, or `undefined`. */\n get(txid: string): PreviousTx | undefined {\n const tx = this.#txs.get(txid);\n if (tx) {\n this.#txs.delete(txid);\n this.#txs.set(txid, tx);\n }\n return tx;\n }\n\n set(tx: PreviousTx): void {\n if (tx.bytes.length > this.bounds.bytes) return;\n const old = this.#txs.get(tx.txid);\n if (old) {\n this.#txs.delete(tx.txid);\n this.#bytes -= old.bytes.length;\n }\n this.#txs.set(tx.txid, tx);\n this.#bytes += tx.bytes.length;\n // The oldest go first (a Map iterates in insertion order).\n for (const [id, entry] of this.#txs) {\n if (this.#txs.size <= this.bounds.entries && this.#bytes <= this.bounds.bytes)\n break;\n this.#txs.delete(id);\n this.#bytes -= entry.bytes.length;\n }\n }\n}\n\n/** One Esplora endpoint family (the `rpc` transport) and its address index (`indexer`). */\nexport class EsploraClient {\n readonly #previous: TxCache;\n readonly #own: TxCache;\n\n constructor(\n private readonly chain: Transport,\n private readonly indexer: Transport,\n private readonly cache: {\n readonly entries: number;\n readonly bytes: number;\n } = PREVIOUS_TX_CACHE,\n ) {\n this.#previous = new TxCache(cache);\n this.#own = new TxCache(cache);\n }\n\n #get<T>(\n transport: Transport,\n path: string,\n route: string,\n tags: UtxoCallTags,\n responseType: 'json' | 'text' | 'bytes' = 'json',\n exactIntegers = false,\n ): Promise<T> {\n const request: HttpRequest = { method: 'GET', path, route, responseType };\n return transport.http<T>(request, exactIntegers ? { ...tags, exactIntegers } : tags);\n }\n\n async #orNull<T>(work: () => Promise<T>): Promise<T | null> {\n try {\n return await work();\n } catch (error) {\n if (isNotFound(error)) return null;\n throw error;\n }\n }\n\n async tipHeight(tags: UtxoCallTags): Promise<bigint> {\n return parseHeight(\n await this.#get(\n this.chain,\n '/blocks/tip/height',\n '/blocks/tip/height',\n tags,\n 'text',\n ),\n );\n }\n\n /** The hash of the block at `height` on this endpoint's best chain, or `null` above its tip. */\n blockHashAt(height: bigint, tags: UtxoCallTags): Promise<string | null> {\n return this.#orNull(async () =>\n parseHash(\n await this.#get(\n this.chain,\n `/block-height/${height}`,\n '/block-height/:height',\n tags,\n 'text',\n ),\n ),\n );\n }\n\n block(blockHash: string, tags: UtxoCallTags): Promise<EsploraBlock | null> {\n return this.#orNull(async () => {\n const block = parseBlock(\n await this.#get(\n this.chain,\n `/block/${segment(blockHash, 'id')}`,\n '/block/:hash',\n tags,\n ),\n );\n // The answer must be the block asked for.\n if (block.hash !== blockHash) throw malformed('block.id');\n return block;\n });\n }\n\n /**\n * `/block/:hash/raw`, the block's own bytes, read strictly once (`rawblock.ts`) and bound to\n * `blockHash`: bytes that do not decode are malformed, and bytes whose header hashes to\n * another block, or whose transactions are not the ones that header commits to, are a\n * retryable `PROVIDER_INCONSISTENT`. So no endpoint can add, drop or alter a transaction of\n * a block whose hash is right. A 404 (a backend that does not have the block) is `null`.\n */\n rawBlock(blockHash: string, tags: UtxoCallTags): Promise<RawBlock | null> {\n return this.#orNull(async () => {\n const answer = await this.#get<unknown>(\n this.chain,\n `/block/${segment(blockHash, 'id')}/raw`,\n '/block/:hash/raw',\n tags,\n 'bytes',\n );\n const block = answer instanceof Uint8Array ? readBlock(answer) : undefined;\n if (!block) throw malformed('raw block');\n if (block.hash !== blockHash) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the block bytes do not hash to the block asked for',\n { retryable: true },\n );\n }\n if (!commitsToTransactions(block)) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n \"the block's transactions are not the ones its header commits to\",\n { retryable: true },\n );\n }\n return block;\n });\n }\n\n async blockTxids(blockHash: string, tags: UtxoCallTags): Promise<string[]> {\n const ids = await this.#get(\n this.chain,\n `/block/${segment(blockHash, 'id')}/txids`,\n '/block/:hash/txids',\n tags,\n );\n return list(ids, 'txids', (id) => hash(id, 'txid'));\n }\n\n /** Up to 25 transactions of a block from `start` (a multiple of 25). */\n async blockTxs(\n blockHash: string,\n start: number,\n tags: UtxoCallTags,\n ): Promise<EsploraTx[]> {\n const txs = await this.#get(\n this.chain,\n `/block/${segment(blockHash, 'id')}/txs/${start}`,\n '/block/:hash/txs/:start',\n tags,\n );\n return list(txs, 'block txs', parseTx);\n }\n\n tx(txid: string, tags: UtxoCallTags): Promise<EsploraTx | null> {\n return this.#orNull(async () => {\n const tx = parseTx(\n await this.#get(this.chain, `/tx/${segment(txid, 'id')}`, '/tx/:txid', tags),\n );\n // The answer must be the transaction asked for.\n if (tx.txid !== txid) throw malformed('tx.txid');\n return tx;\n });\n }\n\n /**\n * `/tx/:txid/hex`, decoded strictly once and bound to `txid`: bytes that do not decode are\n * malformed, and the bytes of another transaction are a retryable `PROVIDER_INCONSISTENT`,\n * so a garbled answer is never taken for the caller's error. The decoder's cap is the\n * largest transaction a block can hold, never what this library builds. Under\n * a quorum, each endpoint's answer is keyed on the txid its bytes hash to, and the answer\n * the quorum returns is not decoded again.\n */\n async #rawTx<T extends { readonly txid: string }>(\n txid: string,\n tags: UtxoCallTags,\n decode: (hex: string) => T | undefined,\n ): Promise<{ readonly hex: string; readonly tx: T }> {\n const decoded = new Map<string, T | undefined>();\n const read = (answer: unknown): { hex: string; tx: T | undefined } => {\n const hex = typeof answer === 'string' ? answer.trim() : '';\n if (!decoded.has(hex)) {\n decoded.set(hex, hex.length > 0 && isHex(hex) ? decode(hex) : undefined);\n }\n return { hex, tx: decoded.get(hex) };\n };\n const keyed: UtxoCallTags =\n tags.quorum === undefined\n ? tags\n : {\n ...tags,\n // A throwing key counts as a disagreement.\n quorumKey: (answer) => {\n const { tx } = read(answer);\n if (!tx) throw malformed('tx hex');\n return tx.txid;\n },\n };\n const answer = await this.#get(\n this.chain,\n `/tx/${segment(txid, 'id')}/hex`,\n '/tx/:txid/hex',\n keyed,\n 'text',\n );\n const { hex, tx } = read(answer);\n if (!tx) throw malformed('tx hex');\n if (tx.txid !== txid) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the transaction bytes do not hash to the id asked for',\n { retryable: true },\n );\n }\n return { hex, tx };\n }\n\n /** The raw transaction, as hex, bound to `txid` (see `#rawTx`). */\n txHex(txid: string, tags: UtxoCallTags): Promise<string | null> {\n return this.#orNull(async () => (await this.#rawTx(txid, tags, txidOf)).hex);\n }\n\n /**\n * An input's previous transaction, decoded once and bound to `txid` (see\n * `#rawTx`). Its bytes authenticate themselves, so it is kept per txid, whatever endpoint\n * served it, in a bounded cache: a replacement's inputs are read once per client.\n */\n async previousTx(txid: string, tags: UtxoCallTags): Promise<PreviousTx | null> {\n const known = this.#own.get(txid) ?? this.#previous.get(txid);\n if (known) return known;\n const found = await this.#orNull(\n async () => (await this.#rawTx(txid, tags, previousTxOf)).tx,\n );\n if (found) this.#previous.set(found);\n return found;\n }\n\n /**\n * The outputs of transaction `txid`, from its bytes, bound to `txid` (see `#rawTx`), or\n * `null` when the endpoint does not have it: what an input naming `txid:vout` spends. A\n * previous transaction this client keeps answers without a read; one read here is not kept,\n * since a block scan reads thousands, which would evict a build's.\n */\n async outputsOf(txid: string, tags: UtxoCallTags): Promise<readonly TxOutput[] | null> {\n const known = this.#own.get(txid) ?? this.#previous.get(txid);\n if (known) return known.outputs;\n return this.#orNull(\n async () => (await this.#rawTx(txid, tags, outputsOfHex)).tx.outputs,\n );\n }\n\n /**\n * A transaction this client sent for an Attempt and a node took. Its bytes are\n * known here, so its outputs are not an indexer's word even before a block holds it, and\n * under `minInputConfirmations: 0` they may be spent unconfirmed. Kept like the cache.\n */\n rememberOwn(tx: PreviousTx): void {\n this.#own.set(tx);\n }\n\n isOwn(txid: string): boolean {\n return this.#own.has(txid);\n }\n\n async outspend(\n txid: string,\n vout: number,\n tags: UtxoCallTags,\n ): Promise<EsploraOutspend> {\n return parseOutspend(\n await this.#get(\n this.chain,\n `/tx/${segment(txid, 'id')}/outspend/${vout}`,\n '/tx/:txid/outspend/:vout',\n tags,\n ),\n );\n }\n\n async feeEstimates(tags: UtxoCallTags): Promise<ReadonlyMap<number, number>> {\n return parseFeeEstimates(\n await this.#get(this.chain, '/fee-estimates', '/fee-estimates', tags),\n );\n }\n\n /** `POST /tx`: the node's txid on success; a node refusal is the transport's `RPC_ERROR`. */\n async broadcast(hex: string, tags: UtxoCallTags): Promise<string> {\n const answer = await this.chain.http<string>(\n { method: 'POST', path: '/tx', route: '/tx', body: hex, responseType: 'text' },\n tags,\n );\n if (typeof answer !== 'string' || !HEX64.test(answer.trim())) {\n // The node answered 2xx, so the bytes may have been accepted.\n throw new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n 'malformed Esplora answer: broadcast txid',\n {\n ambiguous: true,\n },\n );\n }\n return answer.trim();\n }\n\n async addressUtxos(address: string, tags: UtxoCallTags): Promise<EsploraUtxo[]> {\n const utxos = await this.#get(\n this.indexer,\n `/address/${segment(address, 'address')}/utxo`,\n '/address/:address/utxo',\n tags,\n );\n return list(utxos, 'utxo list', parseUtxo);\n }\n\n async addressStats(address: string, tags: UtxoCallTags): Promise<EsploraAddressStats> {\n const info = record(\n await this.#get(\n this.indexer,\n `/address/${segment(address, 'address')}`,\n '/address/:address',\n tags,\n 'json',\n true,\n ),\n 'address',\n );\n const chain = record(info.chain_stats, 'chain_stats');\n const funded = total(chain.funded_txo_sum, 'funded_txo_sum');\n const spent = total(chain.spent_txo_sum, 'spent_txo_sum');\n // The totals are unbounded; the balance is the chain's: 0 to 21 million bitcoin.\n if (spent > funded || funded - spent > MAX_MONEY) throw malformed('address balance');\n return { funded, spent };\n }\n\n /** Confirmed history, newest first, 25 per page, after `lastSeen` when given. */\n async addressTxs(\n address: string,\n lastSeen: string | undefined,\n tags: UtxoCallTags,\n ): Promise<EsploraTx[]> {\n const base = `/address/${segment(address, 'address')}/txs/chain`;\n const path = lastSeen ? `${base}/${segment(lastSeen, 'id')}` : base;\n const route = lastSeen\n ? '/address/:address/txs/chain/:last_seen_txid'\n : '/address/:address/txs/chain';\n return list(await this.#get(this.indexer, path, route, tags), 'address txs', parseTx);\n }\n}\n"]}
1
+ {"version":3,"file":"esplora.js","sourceRoot":"","sources":["../../../src/adapters/utxo/esplora.ts"],"names":[],"mappings":";;;AAkDA,8BAEC;AAOD,wCAKC;AAUD,gCAMC;AA+CD,kCAKC;AAED,8BAEC;AAED,kCAYC;AAmCD,0BAcC;AAiBD,sCAUC;AAkBD,8CAWC;AA/PD;;;;;;;;;;GAUG;AACH,mDAIiC;AAEjC,mCAAmE;AACnE,yCAA6E;AAC7E,mCAAoC;AAepC,MAAM,KAAK,GAAG,gBAAgB,CAAC;AAC/B;;;GAGG;AACU,QAAA,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AACrF,wEAAwE;AAC3D,QAAA,SAAS,GAAG,iBAAsB,CAAC;AAEhD;;;GAGG;AACH,MAAM,KAAK,GAAG,CAAC,KAAa,EAAW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C;QACF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;QAC7D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QAC1D,iFAAiF;QACjF,IAAI,KAAK,GAAG,MAAM,IAAI,MAAM,GAAG,KAAK,GAAG,iBAAS;YAAE,MAAM,SAAS,CAAC,iBAAiB,CAAC,CAAC;QACrF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED,iFAAiF;IACjF,KAAK,CAAC,UAAU,CACd,OAAe,EACf,QAA4B,EAC5B,IAAkB;QAElB,MAAM,IAAI,GAAG,YAAY,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,CAAC;QACjE,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACpE,MAAM,KAAK,GAAG,QAAQ;YACpB,CAAC,CAAC,6CAA6C;YAC/C,CAAC,CAAC,6BAA6B,CAAC;QAClC,OAAO,IAAI,CACT,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EAC7D,aAAa,EACb,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AAlVD,sCAkVC","sourcesContent":["/**\n * The Esplora REST API, sent directly over the core transport. Every call carries the\n * calling driver method's tags and a `route` template with no identifiers in it, which\n * events and logs show instead of the path. Answers are validated strictly: a malformed\n * one is a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, a missing or ill-typed\n * field is malformed and never a default, an answer for another id than the one asked for is\n * refused, and a 404 is `null`. Chain data is read as the chain allows it, never bounded by\n * what this library builds (lenient readers). Chain reads use the `rpc` transport; address\n * reads use the `indexer`. Only raw transactions and blocks are decoded, by the strict\n * linear readers (`rawtx.ts`, `rawblock.ts`), to bind them to their txid or block hash.\n */\nimport {\n ProviderError,\n ValidationError,\n isCryptoAioError,\n} from '../../core/errors/error';\nimport type { CallOptions, HttpRequest, Transport } from '../../core/transport/types';\nimport { previousTxOf, txidOfHex, type PreviousTx } from './codec';\nimport { commitsToTransactions, readBlock, type RawBlock } from './rawblock';\nimport { readTxHex } from './rawtx';\nimport type {\n EsploraAddressStats,\n EsploraBlock,\n EsploraInput,\n EsploraOutput,\n EsploraOutspend,\n EsploraStatus,\n EsploraTx,\n EsploraUtxo,\n UtxoCallTags,\n} from './types';\n\ntype Json = Readonly<Record<string, unknown>>;\n\nconst HEX64 = /^[0-9a-f]{64}$/;\n/**\n * The previous transactions one client keeps, by count and by bytes without the\n * witness (a larger one is not kept). A typical one is a few hundred bytes.\n */\nexport const PREVIOUS_TX_CACHE = Object.freeze({ entries: 1_000, bytes: 8_000_000 });\n/** Bitcoin Core's `MAX_MONEY`: no output, and no balance, is larger. */\nexport const MAX_MONEY = 2_100_000_000_000_000n;\n\n/**\n * Lowercase hex of whole bytes. A flat character class, not `([0-9a-f]{2})+`: that pattern\n * overflows V8's regexp stack on the hex of a transaction of about 3.5 MB, which is valid.\n */\nconst isHex = (value: string): boolean =>\n value.length % 2 === 0 && /^[0-9a-f]*$/.test(value);\n\nexport function malformed(what: string): ProviderError {\n return new ProviderError('PROVIDER_UNAVAILABLE', `malformed Esplora answer: ${what}`);\n}\n\n/**\n * An indexer's refusal to serve an address beyond its own limits, which another indexer\n * may serve: electrs answers HTTP 400 with \"Too many unspent transaction outputs\", \"Too many\n * history entries\" or \"Scripthash history too large to scan\" for a busy address.\n */\nexport function isAddressLimit(error: unknown): boolean {\n if (!isCryptoAioError(error, 'RPC_ERROR') || error.details?.status !== 400)\n return false;\n const body = error.details.body;\n return typeof body === 'string' && /\\btoo (?:many|large)\\b/i.test(body);\n}\n\n/** The tags of a read of an address route: another indexer is asked past one's limit. */\nconst addressRead = (tags: UtxoCallTags): AddressTags => ({\n ...tags,\n endpointLimit: isAddressLimit,\n});\ntype AddressTags = UtxoCallTags & Pick<CallOptions, 'endpointLimit'>;\n\n/** A definitive 404 (not an ambiguous or retried failure): the resource is not there. */\nexport function isNotFound(error: unknown): boolean {\n return (\n isCryptoAioError(error, 'RPC_ERROR') &&\n !error.ambiguous &&\n error.details?.status === 404\n );\n}\n\nconst record = (value: unknown, what: string): Json => {\n if (value === null || typeof value !== 'object' || Array.isArray(value))\n throw malformed(what);\n return value as Json;\n};\nconst hash = (value: unknown, what: string): string => {\n if (typeof value !== 'string' || !HEX64.test(value)) throw malformed(what);\n return value;\n};\nconst integer = (value: unknown, what: string, max = Number.MAX_SAFE_INTEGER): number => {\n if (!Number.isSafeInteger(value) || (value as number) < 0 || (value as number) > max) {\n throw malformed(what);\n }\n return value as number;\n};\nconst sats = (value: unknown, what: string): bigint =>\n BigInt(integer(value, what, Number(MAX_MONEY)));\nconst u32 = (value: unknown, what: string): number => integer(value, what, 0xffffffff);\n/**\n * A transaction's 32-bit version, which Esplora servers print signed or unsigned, as one\n * signed value (`v | 0`), so both printings agree. Chain data: any version a block holds is\n * read, whatever this library builds (version 2).\n */\nconst txVersion = (value: unknown): number => {\n if (\n !Number.isSafeInteger(value) ||\n (value as number) < -0x80000000 ||\n (value as number) > 0xffffffff\n ) {\n throw malformed('tx.version');\n }\n return (value as number) | 0;\n};\n/**\n * A cumulative total of an address (every output it ever received or spent), read exactly\n * (`exactIntegers`): a busy address's totals exceed 21 million bitcoin, and may exceed 2^53.\n */\nconst total = (value: unknown, what: string): bigint => {\n if (typeof value === 'bigint') {\n if (value < 0n) throw malformed(what);\n return value;\n }\n return BigInt(integer(value, what));\n};\n\nexport function parseHeight(text: unknown): bigint {\n if (typeof text !== 'string' || !/^(0|[1-9][0-9]{0,9})$/.test(text.trim())) {\n throw malformed('block height');\n }\n return BigInt(text.trim());\n}\n\nexport function parseHash(text: unknown): string {\n return hash(typeof text === 'string' ? text.trim() : text, 'block hash');\n}\n\nexport function parseStatus(value: unknown): EsploraStatus {\n const status = record(value, 'status');\n if (typeof status.confirmed !== 'boolean') throw malformed('status.confirmed');\n if (!status.confirmed) return { confirmed: false };\n return {\n confirmed: true,\n blockHeight: BigInt(integer(status.block_height, 'status.block_height')),\n blockHash: hash(status.block_hash, 'status.block_hash'),\n ...(status.block_time !== undefined && status.block_time !== null\n ? { blockTime: integer(status.block_time, 'status.block_time') }\n : {}),\n };\n}\n\nfunction parseOutput(value: unknown): EsploraOutput {\n const output = record(value, 'vout');\n if (typeof output.scriptpubkey !== 'string' || !isHex(output.scriptpubkey)) {\n throw malformed('vout.scriptpubkey');\n }\n if (typeof output.scriptpubkey_type !== 'string')\n throw malformed('vout.scriptpubkey_type');\n const address = output.scriptpubkey_address;\n if (address !== undefined && address !== null && typeof address !== 'string') {\n throw malformed('vout.scriptpubkey_address');\n }\n return {\n script: output.scriptpubkey,\n type: output.scriptpubkey_type,\n ...(typeof address === 'string' ? { address } : {}),\n value: sats(output.value, 'vout.value'),\n };\n}\n\nfunction parseInput(value: unknown): EsploraInput {\n const input = record(value, 'vin');\n // It decides whether the input has a previous output and the transaction a fee.\n if (typeof input.is_coinbase !== 'boolean') throw malformed('vin.is_coinbase');\n const coinbase = input.is_coinbase;\n return {\n txid: hash(input.txid, 'vin.txid'),\n vout: u32(input.vout, 'vin.vout'),\n coinbase,\n sequence: u32(input.sequence, 'vin.sequence'),\n ...(coinbase ? {} : { prevout: parseOutput(input.prevout) }),\n };\n}\n\nexport function parseTx(value: unknown): EsploraTx {\n const tx = record(value, 'tx');\n if (!Array.isArray(tx.vin) || !Array.isArray(tx.vout)) throw malformed('tx.vin/vout');\n return {\n txid: hash(tx.txid, 'tx.txid'),\n version: txVersion(tx.version),\n locktime: u32(tx.locktime, 'tx.locktime'),\n weight: integer(tx.weight, 'tx.weight'),\n // Esplora answers `fee` for every transaction (0 for a coinbase): missing is malformed.\n fee: sats(tx.fee, 'tx.fee'),\n vin: tx.vin.map(parseInput),\n vout: tx.vout.map(parseOutput),\n status: parseStatus(tx.status),\n };\n}\n\nfunction parseBlock(value: unknown): EsploraBlock {\n const block = record(value, 'block');\n const height = BigInt(integer(block.height, 'block.height'));\n return {\n hash: hash(block.id, 'block.id'),\n height,\n parentHash:\n height === 0n && block.previousblockhash === null\n ? '0'.repeat(64)\n : hash(block.previousblockhash, 'block.previousblockhash'),\n timestamp: integer(block.timestamp, 'block.timestamp'),\n txCount: integer(block.tx_count, 'block.tx_count'),\n };\n}\n\nexport function parseOutspend(value: unknown): EsploraOutspend {\n const spend = record(value, 'outspend');\n if (typeof spend.spent !== 'boolean') throw malformed('outspend.spent');\n if (!spend.spent) return { spent: false };\n return {\n spent: true,\n txid: hash(spend.txid, 'outspend.txid'),\n vin: u32(spend.vin, 'outspend.vin'),\n status: parseStatus(spend.status),\n };\n}\n\nfunction parseUtxo(value: unknown): EsploraUtxo {\n const utxo = record(value, 'utxo');\n return {\n txid: hash(utxo.txid, 'utxo.txid'),\n vout: u32(utxo.vout, 'utxo.vout'),\n value: sats(utxo.value, 'utxo.value'),\n status: parseStatus(utxo.status),\n };\n}\n\nfunction list<T>(value: unknown, what: string, parse: (item: unknown) => T): T[] {\n if (!Array.isArray(value)) throw malformed(what);\n return value.map(parse);\n}\n\n/** Esplora's `/fee-estimates`: confirmation target (blocks) → sat/vB (a float). */\nexport function parseFeeEstimates(value: unknown): ReadonlyMap<number, number> {\n const estimates = record(value, 'fee-estimates');\n const out = new Map<number, number>();\n for (const [target, rate] of Object.entries(estimates)) {\n if (!/^[1-9][0-9]{0,3}$/.test(target)) throw malformed('fee-estimates target');\n if (typeof rate !== 'number' || !Number.isFinite(rate) || rate < 0 || rate > 1e7) {\n throw malformed('fee-estimates rate');\n }\n out.set(Number(target), rate);\n }\n return out;\n}\n\n/** Whether a caller's id is a txid or block hash (64 lowercase hex characters). */\nexport const isHash = (value: unknown): value is string =>\n typeof value === 'string' && HEX64.test(value);\n\n/**\n * A URL path segment from a caller must be exactly an id or an address, so no `..`, `/`\n * or query can reach another route. The reader maps a malformed id to \"not found\" first.\n */\nfunction segment(value: string, kind: 'id' | 'address'): string {\n if (kind === 'id' && !isHash(value)) {\n throw new ValidationError(\n 'INVALID_INTENT',\n 'a transaction or block id must be 64 lowercase hex digits',\n );\n }\n if (kind === 'address' && !/^[0-9A-Za-z]{1,90}$/.test(value)) {\n throw new ValidationError('INVALID_ADDRESS', 'invalid Bitcoin address');\n }\n return value;\n}\n\n/** The txid of strictly decoded transaction hex, or `undefined`. */\nfunction txidOf(hex: string): { readonly txid: string } | undefined {\n try {\n return { txid: txidOfHex(hex) };\n } catch {\n return undefined;\n }\n}\n\n/** An output as a transaction's bytes hold it: its value, signed as bitcoind reads it. */\nexport interface TxOutput {\n readonly value: bigint;\n readonly script: Uint8Array;\n}\n\n/** The txid and outputs (copied) of strictly decoded transaction hex, or `undefined`. */\nfunction outputsOfHex(\n hex: string,\n): { readonly txid: string; readonly outputs: readonly TxOutput[] } | undefined {\n const tx = readTxHex(hex);\n return (\n tx && {\n txid: tx.txid,\n outputs: tx.outputs.map(({ value, script }) => ({\n value,\n script: Uint8Array.from(script),\n })),\n }\n );\n}\n\n/** Transactions kept per txid, oldest out first, by count and by bytes without witness. */\nclass TxCache {\n readonly #txs = new Map<string, PreviousTx>();\n #bytes = 0;\n\n constructor(\n private readonly bounds: { readonly entries: number; readonly bytes: number },\n ) {}\n\n has(txid: string): boolean {\n return this.#txs.has(txid);\n }\n\n /** The transaction, now the most recently used, or `undefined`. */\n get(txid: string): PreviousTx | undefined {\n const tx = this.#txs.get(txid);\n if (tx) {\n this.#txs.delete(txid);\n this.#txs.set(txid, tx);\n }\n return tx;\n }\n\n set(tx: PreviousTx): void {\n if (tx.bytes.length > this.bounds.bytes) return;\n const old = this.#txs.get(tx.txid);\n if (old) {\n this.#txs.delete(tx.txid);\n this.#bytes -= old.bytes.length;\n }\n this.#txs.set(tx.txid, tx);\n this.#bytes += tx.bytes.length;\n // The oldest go first (a Map iterates in insertion order).\n for (const [id, entry] of this.#txs) {\n if (this.#txs.size <= this.bounds.entries && this.#bytes <= this.bounds.bytes)\n break;\n this.#txs.delete(id);\n this.#bytes -= entry.bytes.length;\n }\n }\n}\n\n/** One Esplora endpoint family (the `rpc` transport) and its address index (`indexer`). */\nexport class EsploraClient {\n readonly #previous: TxCache;\n readonly #own: TxCache;\n\n constructor(\n private readonly chain: Transport,\n private readonly indexer: Transport,\n private readonly cache: {\n readonly entries: number;\n readonly bytes: number;\n } = PREVIOUS_TX_CACHE,\n ) {\n this.#previous = new TxCache(cache);\n this.#own = new TxCache(cache);\n }\n\n #get<T>(\n transport: Transport,\n path: string,\n route: string,\n tags: AddressTags,\n responseType: 'json' | 'text' | 'bytes' = 'json',\n exactIntegers = false,\n ): Promise<T> {\n const request: HttpRequest = { method: 'GET', path, route, responseType };\n return transport.http<T>(request, exactIntegers ? { ...tags, exactIntegers } : tags);\n }\n\n async #orNull<T>(work: () => Promise<T>): Promise<T | null> {\n try {\n return await work();\n } catch (error) {\n if (isNotFound(error)) return null;\n throw error;\n }\n }\n\n async tipHeight(tags: UtxoCallTags): Promise<bigint> {\n return parseHeight(\n await this.#get(\n this.chain,\n '/blocks/tip/height',\n '/blocks/tip/height',\n tags,\n 'text',\n ),\n );\n }\n\n /** The hash of the block at `height` on this endpoint's best chain, or `null` above its tip. */\n blockHashAt(height: bigint, tags: UtxoCallTags): Promise<string | null> {\n return this.#orNull(async () =>\n parseHash(\n await this.#get(\n this.chain,\n `/block-height/${height}`,\n '/block-height/:height',\n tags,\n 'text',\n ),\n ),\n );\n }\n\n block(blockHash: string, tags: UtxoCallTags): Promise<EsploraBlock | null> {\n return this.#orNull(async () => {\n const block = parseBlock(\n await this.#get(\n this.chain,\n `/block/${segment(blockHash, 'id')}`,\n '/block/:hash',\n tags,\n ),\n );\n // The answer must be the block asked for.\n if (block.hash !== blockHash) throw malformed('block.id');\n return block;\n });\n }\n\n /**\n * `/block/:hash/raw`, the block's own bytes, read strictly once (`rawblock.ts`) and bound to\n * `blockHash`: bytes that do not decode are malformed, and bytes whose header hashes to\n * another block, or whose transactions are not the ones that header commits to, are a\n * retryable `PROVIDER_INCONSISTENT`. So no endpoint can add, drop or alter a transaction of\n * a block whose hash is right. A 404 (a backend that does not have the block) is `null`.\n */\n rawBlock(blockHash: string, tags: UtxoCallTags): Promise<RawBlock | null> {\n return this.#orNull(async () => {\n const answer = await this.#get<unknown>(\n this.chain,\n `/block/${segment(blockHash, 'id')}/raw`,\n '/block/:hash/raw',\n tags,\n 'bytes',\n );\n const block = answer instanceof Uint8Array ? readBlock(answer) : undefined;\n if (!block) throw malformed('raw block');\n if (block.hash !== blockHash) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the block bytes do not hash to the block asked for',\n { retryable: true },\n );\n }\n if (!commitsToTransactions(block)) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n \"the block's transactions are not the ones its header commits to\",\n { retryable: true },\n );\n }\n return block;\n });\n }\n\n async blockTxids(blockHash: string, tags: UtxoCallTags): Promise<string[]> {\n const ids = await this.#get(\n this.chain,\n `/block/${segment(blockHash, 'id')}/txids`,\n '/block/:hash/txids',\n tags,\n );\n return list(ids, 'txids', (id) => hash(id, 'txid'));\n }\n\n /** Up to 25 transactions of a block from `start` (a multiple of 25). */\n async blockTxs(\n blockHash: string,\n start: number,\n tags: UtxoCallTags,\n ): Promise<EsploraTx[]> {\n const txs = await this.#get(\n this.chain,\n `/block/${segment(blockHash, 'id')}/txs/${start}`,\n '/block/:hash/txs/:start',\n tags,\n );\n return list(txs, 'block txs', parseTx);\n }\n\n tx(txid: string, tags: UtxoCallTags): Promise<EsploraTx | null> {\n return this.#orNull(async () => {\n const tx = parseTx(\n await this.#get(this.chain, `/tx/${segment(txid, 'id')}`, '/tx/:txid', tags),\n );\n // The answer must be the transaction asked for.\n if (tx.txid !== txid) throw malformed('tx.txid');\n return tx;\n });\n }\n\n /**\n * `/tx/:txid/hex`, decoded strictly once and bound to `txid`: bytes that do not decode are\n * malformed, and the bytes of another transaction are a retryable `PROVIDER_INCONSISTENT`,\n * so a garbled answer is never taken for the caller's error. The decoder's cap is the\n * largest transaction a block can hold, never what this library builds. Under\n * a quorum, each endpoint's answer is keyed on the txid its bytes hash to, and the answer\n * the quorum returns is not decoded again.\n */\n async #rawTx<T extends { readonly txid: string }>(\n txid: string,\n tags: UtxoCallTags,\n decode: (hex: string) => T | undefined,\n ): Promise<{ readonly hex: string; readonly tx: T }> {\n const decoded = new Map<string, T | undefined>();\n const read = (answer: unknown): { hex: string; tx: T | undefined } => {\n const hex = typeof answer === 'string' ? answer.trim() : '';\n if (!decoded.has(hex)) {\n decoded.set(hex, hex.length > 0 && isHex(hex) ? decode(hex) : undefined);\n }\n return { hex, tx: decoded.get(hex) };\n };\n const keyed: UtxoCallTags =\n tags.quorum === undefined\n ? tags\n : {\n ...tags,\n // A throwing key counts as a disagreement.\n quorumKey: (answer) => {\n const { tx } = read(answer);\n if (!tx) throw malformed('tx hex');\n return tx.txid;\n },\n };\n const answer = await this.#get(\n this.chain,\n `/tx/${segment(txid, 'id')}/hex`,\n '/tx/:txid/hex',\n keyed,\n 'text',\n );\n const { hex, tx } = read(answer);\n if (!tx) throw malformed('tx hex');\n if (tx.txid !== txid) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the transaction bytes do not hash to the id asked for',\n { retryable: true },\n );\n }\n return { hex, tx };\n }\n\n /** The raw transaction, as hex, bound to `txid` (see `#rawTx`). */\n txHex(txid: string, tags: UtxoCallTags): Promise<string | null> {\n return this.#orNull(async () => (await this.#rawTx(txid, tags, txidOf)).hex);\n }\n\n /**\n * An input's previous transaction, decoded once and bound to `txid` (see\n * `#rawTx`). Its bytes authenticate themselves, so it is kept per txid, whatever endpoint\n * served it, in a bounded cache: a replacement's inputs are read once per client.\n */\n async previousTx(txid: string, tags: UtxoCallTags): Promise<PreviousTx | null> {\n const known = this.#own.get(txid) ?? this.#previous.get(txid);\n if (known) return known;\n const found = await this.#orNull(\n async () => (await this.#rawTx(txid, tags, previousTxOf)).tx,\n );\n if (found) this.#previous.set(found);\n return found;\n }\n\n /**\n * The outputs of transaction `txid`, from its bytes, bound to `txid` (see `#rawTx`), or\n * `null` when the endpoint does not have it: what an input naming `txid:vout` spends. A\n * previous transaction this client keeps answers without a read; one read here is not kept,\n * since a block scan reads thousands, which would evict a build's.\n */\n async outputsOf(txid: string, tags: UtxoCallTags): Promise<readonly TxOutput[] | null> {\n const known = this.#own.get(txid) ?? this.#previous.get(txid);\n if (known) return known.outputs;\n return this.#orNull(\n async () => (await this.#rawTx(txid, tags, outputsOfHex)).tx.outputs,\n );\n }\n\n /**\n * A transaction this client sent for an Attempt and a node took. Its bytes are\n * known here, so its outputs are not an indexer's word even before a block holds it, and\n * under `minInputConfirmations: 0` they may be spent unconfirmed. Kept like the cache.\n */\n rememberOwn(tx: PreviousTx): void {\n this.#own.set(tx);\n }\n\n isOwn(txid: string): boolean {\n return this.#own.has(txid);\n }\n\n async outspend(\n txid: string,\n vout: number,\n tags: UtxoCallTags,\n ): Promise<EsploraOutspend> {\n return parseOutspend(\n await this.#get(\n this.chain,\n `/tx/${segment(txid, 'id')}/outspend/${vout}`,\n '/tx/:txid/outspend/:vout',\n tags,\n ),\n );\n }\n\n async feeEstimates(tags: UtxoCallTags): Promise<ReadonlyMap<number, number>> {\n return parseFeeEstimates(\n await this.#get(this.chain, '/fee-estimates', '/fee-estimates', tags),\n );\n }\n\n /** `POST /tx`: the node's txid on success; a node refusal is the transport's `RPC_ERROR`. */\n async broadcast(hex: string, tags: UtxoCallTags): Promise<string> {\n const answer = await this.chain.http<string>(\n { method: 'POST', path: '/tx', route: '/tx', body: hex, responseType: 'text' },\n tags,\n );\n if (typeof answer !== 'string' || !HEX64.test(answer.trim())) {\n // The node answered 2xx, so the bytes may have been accepted.\n throw new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n 'malformed Esplora answer: broadcast txid',\n {\n ambiguous: true,\n },\n );\n }\n return answer.trim();\n }\n\n async addressUtxos(address: string, tags: UtxoCallTags): Promise<EsploraUtxo[]> {\n const utxos = await this.#get(\n this.indexer,\n `/address/${segment(address, 'address')}/utxo`,\n '/address/:address/utxo',\n addressRead(tags),\n );\n return list(utxos, 'utxo list', parseUtxo);\n }\n\n async addressStats(address: string, tags: UtxoCallTags): Promise<EsploraAddressStats> {\n const info = record(\n await this.#get(\n this.indexer,\n `/address/${segment(address, 'address')}`,\n '/address/:address',\n addressRead(tags),\n 'json',\n true,\n ),\n 'address',\n );\n const chain = record(info.chain_stats, 'chain_stats');\n const funded = total(chain.funded_txo_sum, 'funded_txo_sum');\n const spent = total(chain.spent_txo_sum, 'spent_txo_sum');\n // The totals are unbounded; the balance is the chain's: 0 to 21 million bitcoin.\n if (spent > funded || funded - spent > MAX_MONEY) throw malformed('address balance');\n return { funded, spent };\n }\n\n /** Confirmed history, newest first, 25 per page, after `lastSeen` when given. */\n async addressTxs(\n address: string,\n lastSeen: string | undefined,\n tags: UtxoCallTags,\n ): Promise<EsploraTx[]> {\n const base = `/address/${segment(address, 'address')}/txs/chain`;\n const path = lastSeen ? `${base}/${segment(lastSeen, 'id')}` : base;\n const route = lastSeen\n ? '/address/:address/txs/chain/:last_seen_txid'\n : '/address/:address/txs/chain';\n return list(\n await this.#get(this.indexer, path, route, addressRead(tags)),\n 'address txs',\n parseTx,\n );\n }\n}\n"]}
@@ -76,6 +76,7 @@ export interface UtxoUnspent {
76
76
  readonly confirmed: boolean;
77
77
  readonly blockHeight?: bigint;
78
78
  }
79
+ /** What `ext.utxo.coinSelection()` previews: a transfer of `outputs` from `from`. */
79
80
  export interface UtxoSelectionRequest {
80
81
  readonly from: string;
81
82
  readonly outputs: readonly {
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/utxo/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * SDK-free types of the UTXO family: the `ext.utxo` API, fee details and overrides, wallet\n * options, and the Esplora wire types the driver reads. Nothing here imports an\n * SDK, so the composition root can export these types.\n */\nimport type { FeeSpeed } from '../../core/model/fee';\nimport type { CallOptions } from '../../core/transport/types';\n\n// Augment the registries through the package entry, as users do with 'crypto-aio'.\ndeclare module '../../index' {\n interface ChainRegistry {\n bitcoin: {\n family: 'utxo';\n network: 'mainnet' | 'testnet' | 'testnet4' | 'signet' | 'regtest';\n };\n }\n interface FamilyRegistry {\n utxo: { library: 'bitcoinjs-lib'; ext: UtxoExt; fee: UtxoFeeDetails };\n }\n}\n\n/** A network's address encoding: the bech32 human-readable part and base58 version bytes. */\nexport interface AddressParams {\n readonly bech32: string;\n readonly pubKeyHash: number;\n readonly scriptHash: number;\n}\n\n/** The address (and so the input) type of a UTXO wallet; `p2wpkh` is the default. */\nexport type UtxoAddressType = 'p2wpkh' | 'p2sh-p2wpkh' | 'p2pkh' | 'p2tr';\n\n/** Every standard output type a UTXO transfer may pay to. */\nexport type UtxoOutputType = 'p2pkh' | 'p2sh' | 'p2wpkh' | 'p2wsh' | 'p2tr';\n\n/** `WalletConfig.utxo`. */\nexport interface UtxoWalletOptions {\n readonly addressType?: UtxoAddressType;\n /**\n * Where change goes; default: the wallet's own address. It must be derivable from the\n * wallet's key (any of the four address types), unless `allowExternalChangeAddress` is set.\n */\n readonly changeAddress?: string;\n /**\n * Send change to a `changeAddress` the wallet's key does not derive (default `false`).\n * Change sent to a valid but foreign address is lost, so without it a mistyped address\n * is refused.\n */\n readonly allowExternalChangeAddress?: boolean;\n}\n\n/** `FeeEstimate.details` of the `utxo` fee kind. */\nexport interface UtxoFeeDetails {\n /** The fee rate in satoshis per 1,000 virtual bytes (Bitcoin Core's unit). */\n readonly satPerKvB: bigint;\n /** Virtual size of the transaction, counting worst-case (72-byte) ECDSA signatures. */\n readonly vsize: number;\n readonly inputs: number;\n /** Outputs including change. */\n readonly outputs: number;\n /** The change amount; `0n` when there is no change output. */\n readonly change: bigint;\n /** Index of the change output, or `-1` when there is none. */\n readonly changeIndex: number;\n}\n\n/**\n * An explicit UTXO fee (`TransferIntent.fee`): satoshis per virtual byte, as a bigint or a\n * decimal string with at most three fractional digits (e.g. `'1.5'`).\n */\nexport type UtxoFeeOverride = { readonly satPerVByte: bigint | string };\n\n/** An unspent output of an address, as `ext.utxo.listUnspent` reports it. */\nexport interface UtxoUnspent {\n /** `txid:vout`, the reservation key of this output. */\n readonly outpoint: string;\n readonly txid: string;\n readonly vout: number;\n readonly value: bigint;\n readonly confirmed: boolean;\n readonly blockHeight?: bigint;\n}\n\nexport interface UtxoSelectionRequest {\n readonly from: string;\n readonly outputs: readonly { readonly to: string; readonly amount: bigint }[];\n readonly fee?: FeeSpeed | UtxoFeeOverride;\n /** Outpoints to leave out (e.g. those held by live Operations). */\n readonly exclude?: readonly string[];\n}\n\n/** A dry run of the configured coin selection. */\nexport interface UtxoSelectionPreview {\n /** The outputs it would spend (every eligible one when `sufficient` is `false`). */\n readonly inputs: readonly { readonly outpoint: string; readonly value: bigint }[];\n readonly fee: bigint;\n readonly satPerKvB: bigint;\n readonly vsize: number;\n readonly change: bigint;\n /** `false` when the eligible outputs cannot pay for the outputs and the fee. */\n readonly sufficient: boolean;\n}\n\n/** `bc.ext.utxo`: the UTXO family extension. */\nexport interface UtxoExt {\n readonly utxo: {\n /** Unspent outputs of an address (indexer), confirmed first, oldest first. */\n listUnspent(address: string): Promise<readonly UtxoUnspent[]>;\n /** What the configured coin selection would pick for these outputs. Signs nothing. */\n coinSelection(request: UtxoSelectionRequest): Promise<UtxoSelectionPreview>;\n };\n}\n\n/** The transport tags every UTXO I/O call carries (the `ChainDriver` contract table). */\nexport type UtxoCallTags = Pick<\n CallOptions,\n 'purpose' | 'retry' | 'quorum' | 'quorumKey' | 'fanout' | 'signal'\n>;\n\n/** Esplora's `status` object of a transaction or of a spending transaction. */\nexport interface EsploraStatus {\n readonly confirmed: boolean;\n readonly blockHeight?: bigint;\n readonly blockHash?: string;\n readonly blockTime?: number;\n}\n\nexport interface EsploraOutput {\n readonly script: string;\n readonly type: string;\n readonly address?: string;\n readonly value: bigint;\n}\n\nexport interface EsploraInput {\n readonly txid: string;\n readonly vout: number;\n readonly coinbase: boolean;\n readonly sequence: number;\n /** `undefined` for a coinbase input. */\n readonly prevout?: EsploraOutput;\n}\n\nexport interface EsploraTx {\n readonly txid: string;\n readonly version: number;\n readonly locktime: number;\n readonly weight: number;\n readonly fee: bigint;\n readonly vin: readonly EsploraInput[];\n readonly vout: readonly EsploraOutput[];\n readonly status: EsploraStatus;\n}\n\nexport interface EsploraBlock {\n readonly hash: string;\n readonly height: bigint;\n readonly parentHash: string;\n readonly timestamp: number;\n readonly txCount: number;\n}\n\nexport interface EsploraOutspend {\n readonly spent: boolean;\n readonly txid?: string;\n readonly vin?: number;\n readonly status?: EsploraStatus;\n}\n\nexport interface EsploraUtxo {\n readonly txid: string;\n readonly vout: number;\n readonly value: bigint;\n readonly status: EsploraStatus;\n}\n\nexport interface EsploraAddressStats {\n readonly funded: bigint;\n readonly spent: bigint;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/utxo/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * SDK-free types of the UTXO family: the `ext.utxo` API, fee details and overrides, wallet\n * options, and the Esplora wire types the driver reads. Nothing here imports an\n * SDK, so the composition root can export these types.\n */\nimport type { FeeSpeed } from '../../core/model/fee';\nimport type { CallOptions } from '../../core/transport/types';\n\n// Augment the registries through the package entry, as users do with 'crypto-aio'.\ndeclare module '../../index' {\n interface ChainRegistry {\n bitcoin: {\n family: 'utxo';\n network: 'mainnet' | 'testnet' | 'testnet4' | 'signet' | 'regtest';\n };\n }\n interface FamilyRegistry {\n utxo: { library: 'bitcoinjs-lib'; ext: UtxoExt; fee: UtxoFeeDetails };\n }\n}\n\n/** A network's address encoding: the bech32 human-readable part and base58 version bytes. */\nexport interface AddressParams {\n readonly bech32: string;\n readonly pubKeyHash: number;\n readonly scriptHash: number;\n}\n\n/** The address (and so the input) type of a UTXO wallet; `p2wpkh` is the default. */\nexport type UtxoAddressType = 'p2wpkh' | 'p2sh-p2wpkh' | 'p2pkh' | 'p2tr';\n\n/** Every standard output type a UTXO transfer may pay to. */\nexport type UtxoOutputType = 'p2pkh' | 'p2sh' | 'p2wpkh' | 'p2wsh' | 'p2tr';\n\n/** `WalletConfig.utxo`. */\nexport interface UtxoWalletOptions {\n readonly addressType?: UtxoAddressType;\n /**\n * Where change goes; default: the wallet's own address. It must be derivable from the\n * wallet's key (any of the four address types), unless `allowExternalChangeAddress` is set.\n */\n readonly changeAddress?: string;\n /**\n * Send change to a `changeAddress` the wallet's key does not derive (default `false`).\n * Change sent to a valid but foreign address is lost, so without it a mistyped address\n * is refused.\n */\n readonly allowExternalChangeAddress?: boolean;\n}\n\n/** `FeeEstimate.details` of the `utxo` fee kind. */\nexport interface UtxoFeeDetails {\n /** The fee rate in satoshis per 1,000 virtual bytes (Bitcoin Core's unit). */\n readonly satPerKvB: bigint;\n /** Virtual size of the transaction, counting worst-case (72-byte) ECDSA signatures. */\n readonly vsize: number;\n readonly inputs: number;\n /** Outputs including change. */\n readonly outputs: number;\n /** The change amount; `0n` when there is no change output. */\n readonly change: bigint;\n /** Index of the change output, or `-1` when there is none. */\n readonly changeIndex: number;\n}\n\n/**\n * An explicit UTXO fee (`TransferIntent.fee`): satoshis per virtual byte, as a bigint or a\n * decimal string with at most three fractional digits (e.g. `'1.5'`).\n */\nexport type UtxoFeeOverride = { readonly satPerVByte: bigint | string };\n\n/** An unspent output of an address, as `ext.utxo.listUnspent` reports it. */\nexport interface UtxoUnspent {\n /** `txid:vout`, the reservation key of this output. */\n readonly outpoint: string;\n readonly txid: string;\n readonly vout: number;\n readonly value: bigint;\n readonly confirmed: boolean;\n readonly blockHeight?: bigint;\n}\n\n/** What `ext.utxo.coinSelection()` previews: a transfer of `outputs` from `from`. */\nexport interface UtxoSelectionRequest {\n readonly from: string;\n readonly outputs: readonly { readonly to: string; readonly amount: bigint }[];\n readonly fee?: FeeSpeed | UtxoFeeOverride;\n /** Outpoints to leave out (e.g. those held by live Operations). */\n readonly exclude?: readonly string[];\n}\n\n/** A dry run of the configured coin selection. */\nexport interface UtxoSelectionPreview {\n /** The outputs it would spend (every eligible one when `sufficient` is `false`). */\n readonly inputs: readonly { readonly outpoint: string; readonly value: bigint }[];\n readonly fee: bigint;\n readonly satPerKvB: bigint;\n readonly vsize: number;\n readonly change: bigint;\n /** `false` when the eligible outputs cannot pay for the outputs and the fee. */\n readonly sufficient: boolean;\n}\n\n/** `bc.ext.utxo`: the UTXO family extension. */\nexport interface UtxoExt {\n readonly utxo: {\n /** Unspent outputs of an address (indexer), confirmed first, oldest first. */\n listUnspent(address: string): Promise<readonly UtxoUnspent[]>;\n /** What the configured coin selection would pick for these outputs. Signs nothing. */\n coinSelection(request: UtxoSelectionRequest): Promise<UtxoSelectionPreview>;\n };\n}\n\n/** The transport tags every UTXO I/O call carries (the `ChainDriver` contract table). */\nexport type UtxoCallTags = Pick<\n CallOptions,\n 'purpose' | 'retry' | 'quorum' | 'quorumKey' | 'fanout' | 'signal'\n>;\n\n/** Esplora's `status` object of a transaction or of a spending transaction. */\nexport interface EsploraStatus {\n readonly confirmed: boolean;\n readonly blockHeight?: bigint;\n readonly blockHash?: string;\n readonly blockTime?: number;\n}\n\nexport interface EsploraOutput {\n readonly script: string;\n readonly type: string;\n readonly address?: string;\n readonly value: bigint;\n}\n\nexport interface EsploraInput {\n readonly txid: string;\n readonly vout: number;\n readonly coinbase: boolean;\n readonly sequence: number;\n /** `undefined` for a coinbase input. */\n readonly prevout?: EsploraOutput;\n}\n\nexport interface EsploraTx {\n readonly txid: string;\n readonly version: number;\n readonly locktime: number;\n readonly weight: number;\n readonly fee: bigint;\n readonly vin: readonly EsploraInput[];\n readonly vout: readonly EsploraOutput[];\n readonly status: EsploraStatus;\n}\n\nexport interface EsploraBlock {\n readonly hash: string;\n readonly height: bigint;\n readonly parentHash: string;\n readonly timestamp: number;\n readonly txCount: number;\n}\n\nexport interface EsploraOutspend {\n readonly spent: boolean;\n readonly txid?: string;\n readonly vin?: number;\n readonly status?: EsploraStatus;\n}\n\nexport interface EsploraUtxo {\n readonly txid: string;\n readonly vout: number;\n readonly value: bigint;\n readonly status: EsploraStatus;\n}\n\nexport interface EsploraAddressStats {\n readonly funded: bigint;\n readonly spent: bigint;\n}\n"]}
@@ -11,15 +11,20 @@ import type { Block, RawTx, Transaction, TxStatus } from '../model/transaction';
11
11
  import { type TransferOptions } from '../lifecycle/engine';
12
12
  import { type ConfirmationResult, type TxStatusEvent, type WaitOptions } from '../lifecycle/monitor';
13
13
  import { type OperationView, type PreparedOperation, type Submission } from '../lifecycle/views';
14
- import { Scanner, type ScannerOptions } from '../observe/scanner';
14
+ import { type Scanner, type ScannerOptions } from '../observe/scanner';
15
15
  import type { SignatureBundle } from '../signing/types';
16
16
  import type { EndpointStatus } from '../transport/types';
17
17
  import { type HandleInternals } from './internal';
18
+ /** `bc.getBalance()`'s answer: what `address` holds of `asset`, as one endpoint reads it. */
18
19
  export interface Balance {
19
20
  readonly address: Address;
20
21
  readonly asset: AssetInfo;
21
22
  readonly amount: Amount;
22
23
  }
24
+ /**
25
+ * `bc.getNetworkStatus()`'s answer: the chain's head and finalized heights as the handle's
26
+ * endpoints report them, and each provider and indexer endpoint's health.
27
+ */
23
28
  export interface NetworkStatus {
24
29
  readonly chain: string;
25
30
  readonly network: string;
@@ -262,7 +262,7 @@ class Blockchain {
262
262
  const internals = (0, internal_1.internalsOf)(this);
263
263
  const container = (0, internals_1.containerOf)(internals.container);
264
264
  const { runtime } = container;
265
- return new scanner_1.Scanner({
265
+ return (0, scanner_1.createScanner)({
266
266
  load: async () => {
267
267
  // One pooled entry, so the driver and its transport always belong together.
268
268
  const { driver, transport } = await internals.pooled();
@@ -1 +1 @@
1
- {"version":3,"file":"handle.js","sourceRoot":"","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,IAAI,CAAC,2BAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC7E,MAAM,GAAG,GAAG,MAAM,IAAA,uBAAa,EAC7B;QACE,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;QAC5B,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,EACD,QAAQ,CAAC,GAAG,CACb,CAAC;IACF,OAAO;QACL,SAAS;QACT,QAAQ,EAAE;YACR,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtE,GAAG;SACJ;KACF,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAA+C,CAAC;IAC3E,OAAO,CACL,CAAC,QAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,CAAC;QACpE,OAAO,IAAI,KAAK,QAAQ,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { describeSelection, resolveSelection } from '../config/resolve';\nimport type { HandleConfig, HandleOptions } from '../config/types';\nimport { containerOf } from '../container/internals';\nimport type { BroadcastResult, DriverLimits, WalletOptions } from '../driver/types';\nimport {\n ConfigError,\n ProviderError,\n StateError,\n UnsupportedCapabilityError,\n ValidationError,\n isCryptoAioError,\n} from '../errors/error';\nimport { Address } from '../model/address';\nimport { Amount } from '../model/amount';\nimport type { AssetInfo, AssetRef } from '../model/asset';\nimport type { Capability } from '../model/capability';\nimport type { FeeEstimate, FeeOverride, FeeSpeed } from '../model/fee';\nimport type { ChainId, ExtOf, LibraryOf, NetworkOf } from '../model/ids';\nimport { toStoredIntent, type TransferIntent } from '../model/intent';\nimport type { Block, RawTx, Transaction, TxStatus } from '../model/transaction';\nimport {\n PRE_SIGNING_STATES,\n withLifecycleDefaults,\n type OperationEngine,\n type OperationTarget,\n type ReadTarget,\n type TransferOptions,\n} from '../lifecycle/engine';\nimport { normalizeIntent } from '../lifecycle/intent';\nimport {\n assertSameNetwork,\n type ConfirmationResult,\n type Monitor,\n type TxStatusEvent,\n type WaitOptions,\n} from '../lifecycle/monitor';\nimport { loadObservations } from '../lifecycle/observations';\nimport {\n toView,\n type OperationView,\n type PreparedOperation,\n type Submission,\n} from '../lifecycle/views';\nimport { Scanner, type ScannerOptions } from '../observe/scanner';\nimport { deriveXpubChild } from '../signing/hd';\nimport type { SignatureBundle } from '../signing/types';\nimport { resolveWallet, walletOptionsOf, xpubPathOf } from '../signing/wallet';\nimport type { OperationRecord } from '../store/types';\nimport type { EndpointState, EndpointStatus } from '../transport/types';\nimport { fromHex } from '../util/bytes';\nimport { unknownName } from '../util/names';\nimport { defaultBlockchain } from './default-ref';\nimport { bindInternals, internalsOf, type HandleInternals } from './internal';\nimport {\n toAddress,\n toBlock,\n toFeeEstimate,\n toTransaction,\n type MappingContext,\n} from './mapping';\n\nexport interface Balance {\n readonly address: Address;\n readonly asset: AssetInfo;\n readonly amount: Amount;\n}\n\nexport interface NetworkStatus {\n readonly chain: string;\n readonly network: string;\n readonly height: bigint;\n readonly finalizedHeight: bigint;\n readonly endpoints: readonly EndpointStatus[];\n readonly indexers: readonly EndpointStatus[];\n}\n\n/** Immutable handle bound to one chain, network, library, provider set and wallet. */\nexport class Blockchain<C extends ChainId = ChainId> {\n /** Handles come from `CryptoAio#blockchain` or `Blockchain.create`. */\n private constructor(internals: HandleInternals) {\n bindInternals(this, internals);\n Object.freeze(this);\n }\n\n /** Creates a handle on the default container (see `configure`). */\n static create<C extends ChainId>(config: HandleConfig<C>): Blockchain<C> {\n return defaultBlockchain(config as HandleOptions) as unknown as Blockchain<C>;\n }\n\n get chain(): C {\n return internalsOf(this).selection.chain.id as C;\n }\n\n get network(): NetworkOf<C> {\n return internalsOf(this).selection.network.id as NetworkOf<C>;\n }\n\n get library(): LibraryOf<C> {\n return internalsOf(this).selection.library as LibraryOf<C>;\n }\n\n /** Frozen, redacted snapshot of the resolved configuration. */\n get config(): Readonly<Record<string, unknown>> {\n return describeSelection(internalsOf(this).selection);\n }\n\n /** A fresh copy on every read; mutating the result never affects `supports()`. */\n get capabilities(): ReadonlySet<Capability> {\n return new Set(internalsOf(this).selection.capabilities);\n }\n\n supports(capability: Capability): boolean {\n return internalsOf(this).selection.capabilities.has(capability);\n }\n\n /** Returns a NEW handle; this handle and operations started from it are unaffected. */\n with(overrides: Partial<Omit<HandleConfig<C>, 'chain'>>): Blockchain<C> {\n const { selection, container } = internalsOf(this);\n return container.blockchain({\n ...selection.handle,\n ...overrides,\n chain: this.chain,\n } as HandleConfig<C>);\n }\n\n /**\n * Loads the adapter, connects its transport and validates it's actually usable; fails fast\n * on a missing dependency (`DEPENDENCY_MISSING`), an invalid wallet (surfaced by resolving\n * it), or a provider that can't serve reads: `PROVIDER_UNAVAILABLE` when no configured\n * endpoint is usable, `PROVIDER_MISCONFIGURED` (non-retryable) when every endpoint's\n * identity mismatches the configured network. An endpoint is usable when it's 'healthy',\n * 'lagging' or 'half-open' (the breaker is willing to try it), or 'unknown' while the\n * transport has no health probes configured at all — nothing could ever have marked it\n * healthy/lagging in that case, so 'unknown' is simply its steady state.\n */\n async ready(): Promise<this> {\n const internals = internalsOf(this);\n const pooled = await internals.pooled();\n await pooled.transport.refreshHealth();\n const statuses = pooled.transport.status();\n if (statuses.length > 0 && statuses.every((s) => s.state === 'disabled')) {\n throw new ProviderError(\n 'PROVIDER_MISCONFIGURED',\n `every endpoint for ${this.chain} serves a different network than configured`,\n { retryable: false },\n );\n }\n const usable = (state: EndpointState): boolean =>\n state === 'healthy' ||\n state === 'lagging' ||\n state === 'half-open' ||\n (state === 'unknown' && !pooled.transport.hasProbes());\n if (!statuses.some((s) => usable(s.state))) {\n throw new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n `no healthy endpoint for ${this.chain}`,\n );\n }\n if (internals.selection.wallet) await internals.wallet();\n return this;\n }\n\n async limits(): Promise<DriverLimits> {\n const { driver } = await internalsOf(this).pooled();\n const wallet = internalsOf(this).selection.wallet;\n const options: WalletOptions = wallet ? walletOptionsOf(wallet.config) : {};\n return (\n driver.limits?.(options) ?? {\n maxOutputs: this.supports('batch-transfer') ? Number.MAX_SAFE_INTEGER : 1,\n }\n );\n }\n\n async validateAddress(address: string): Promise<boolean> {\n return (await mappingOf(this)).driver.address.validate(address);\n }\n\n async normalizeAddress(address: string): Promise<Address> {\n return toAddress(await mappingOf(this), address);\n }\n\n /** The chain's address for `publicKey`. `options.hd` is reserved: the core builds it\n * from a wallet's `xpub`, so a caller's `hd` is dropped and never reaches the driver.\n * `null` options (from an untyped caller) are none. */\n async addressFromPublicKey(\n publicKey: Uint8Array | string,\n options: WalletOptions = {},\n ): Promise<Address> {\n const { hd: _reserved, ...callerOptions } = options ?? {};\n const bytes = typeof publicKey === 'string' ? fromHex(publicKey) : publicKey;\n return driverAddress(this, bytes, callerOptions);\n }\n\n /** Address of the handle's own selected wallet, or of another configured `wallet` by name\n * — resolved fresh against this handle's driver, without switching the handle.\n * Re-resolved through `resolveSelection` (not `resolveWallet` directly) so a\n * named wallet gets the same `wallet.chains` enablement check, unknown-signer validation and\n * signer-scheme compatibility check that the handle's own wallet got at construction. */\n async walletAddress(wallet?: string): Promise<Address> {\n const internals = internalsOf(this);\n const selection = internals.selection;\n if (wallet === undefined || wallet === selection.wallet?.name) {\n return (await internals.wallet()).address;\n }\n const container = containerOf(internals.container);\n const effective = container.effective();\n // An own-property check, so a wallet literally named 'constructor' (or any other\n // Object.prototype key) can never be mistaken for one that exists.\n if (!Object.hasOwn(effective.wallets, wallet)) {\n throw new ConfigError(\n 'CONFIG_INVALID',\n unknownName('wallet', Object.keys(effective.wallets)),\n );\n }\n const { driver } = await internals.pooled();\n const resolved = resolveSelection({\n handle: { ...selection.handle, wallet, signer: undefined },\n effective,\n catalogs: container.runtime.catalogs,\n });\n const resolvedWallet = await resolveWallet(\n resolved,\n driver,\n effective.signers,\n container.runtime.catalogs.schemes,\n container.signerDeadline(),\n );\n return resolvedWallet.address;\n }\n\n /** Derives a deposit address from the wallet's xpub (capability `hd-public-derivation`). */\n async deriveAddress(wallet: string, index: number): Promise<Address> {\n if (!this.supports('hd-public-derivation')) {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} does not support public derivation`,\n );\n }\n if (!Number.isInteger(index) || index < 0 || index >= 2 ** 31) {\n throw new ValidationError(\n 'INVALID_INTENT',\n 'derivation index must be an integer in [0, 2^31)',\n );\n }\n const internals = internalsOf(this);\n const { wallets } = containerOf(internals.container).effective();\n // Own keys only, so `toString` is no wallet. The caller's text is never repeated: it\n // may be a pasted secret.\n if (!Object.hasOwn(wallets, wallet)) {\n throw new ConfigError(\n 'CONFIG_INVALID',\n unknownName('wallet', Object.keys(wallets)),\n );\n }\n const config = wallets[wallet];\n if (!config?.xpub)\n throw new ConfigError('CONFIG_INVALID', `wallet '${wallet}' has no xpub`);\n // A non-string xpubPath is CONFIG_INVALID, as at wallet resolution.\n const path = (xpubPathOf(config) ?? '0/{index}').replace('{index}', String(index));\n // A UTXO chain's extended keys carry its network class; account-model\n // wallets (EVM, Tron) export `xpub` on every network, so theirs is not checked. A chain\n // whose wallets do the same says so (`xpubNetworkClass: false`, Avalanche X/P).\n const { chain, network } = internals.selection;\n const classed = chain.xpubNetworkClass ?? chain.model === 'utxo';\n const publicKey = deriveXpubChild(\n config.xpub,\n path,\n config.xpubVersions,\n classed ? { testnet: network.testnet } : undefined,\n );\n // The core's own options, with the wallet's `hd`, reach the driver directly.\n return driverAddress(this, publicKey, walletOptionsOf(config));\n }\n\n async resolveAsset(asset?: AssetRef | string): Promise<AssetInfo> {\n const m = await mappingOf(this);\n return m.assets.resolve(m.selection, m.driver, asset);\n }\n\n async getBalance(address: string, asset?: AssetRef | string): Promise<Balance> {\n const m = await mappingOf(this);\n const target = toAddress(m, address);\n const info = await m.assets.resolve(m.selection, m.driver, asset);\n const base = await m.driver.reader.getBalance(target.canonical, info.ref);\n return { address: target, asset: info, amount: Amount.fromBase(base, info) };\n }\n\n async getBalances(\n address: string,\n assets: readonly (AssetRef | string)[],\n ): Promise<Balance[]> {\n return Promise.all(assets.map((asset) => this.getBalance(address, asset)));\n }\n\n async estimateFee(intent: TransferIntent): Promise<FeeEstimate> {\n const m = await mappingOf(this);\n const internals = internalsOf(this);\n const wallet = internals.selection.wallet ? await internals.wallet() : undefined;\n const from = intent.from !== undefined ? toAddress(m, intent.from) : wallet?.address;\n if (!from)\n throw new ValidationError(\n 'INVALID_INTENT',\n 'estimateFee needs a wallet or intent.from',\n );\n const normalized = await normalizeIntent(m, intent, from);\n const draft = await m.driver.builder.estimateFee(toStoredIntent(normalized), {\n from: from.canonical,\n keys: wallet?.keys ?? [],\n wallet: wallet?.options ?? {},\n decimals: normalized.asset.metadata.decimals,\n });\n return toFeeEstimate(m, draft);\n }\n\n async getTransaction(id: string): Promise<Transaction | null> {\n const m = await mappingOf(this);\n const tx = await m.driver.reader.getTransaction(id);\n if (!tx) return null;\n const [head, finalized] = await Promise.all([\n m.driver.reader.getBlockHeight(),\n m.driver.reader.getFinalizedHeight(),\n ]);\n return toTransaction(m, tx, head, finalized);\n }\n\n /** Status of a managed Operation (by id, Attempt ref or tx hash) or of any transaction id. */\n async getTransactionStatus(id: string): Promise<TxStatus> {\n return (await monitorOf(this).status(await readTargetOf(this), id)).status;\n }\n\n /**\n * Resolves once `confirmations` (default: the handle's) are reached. With\n * `finality: 'final'`, a managed Operation (by id, Attempt ref or tx hash) resolves on\n * **proven** finality (finalized data confirmed by quorum proof reads); a transaction the\n * library does not manage resolves on **observed** finality (one endpoint's view of a\n * block at or below the finalized height). Rejects with the chain error when the\n * Operation fails, expires or is replaced (`TX_REVERTED` for an unmanaged transaction\n * that reverted), with `TIMEOUT` (retryable, state unchanged) when time runs out, and\n * with the reason of an aborted `signal`.\n */\n async waitForConfirmation(\n ref: string,\n options: WaitOptions = {},\n ): Promise<ConfirmationResult> {\n const { status, record } = await monitorOf(this).waitFor(\n await readTargetOf(this),\n ref,\n options,\n );\n return { status, ...(record ? { operation: await viewOf(this, record) } : {}) };\n }\n\n /** Yields each status change until the Operation is terminal (or the transaction is final). */\n watch(\n ref: string,\n options: { readonly pollIntervalMs?: number; readonly signal?: AbortSignal } = {},\n ): AsyncIterable<TxStatusEvent> {\n const readTarget = () => readTargetOf(this);\n const monitor = () => monitorOf(this);\n const view = (record: OperationRecord) => viewOf(this, record);\n return {\n async *[Symbol.asyncIterator]() {\n const target = await readTarget();\n for await (const snapshot of monitor().watch(target, ref, options)) {\n yield {\n status: snapshot.status,\n ...(snapshot.record ? { operation: await view(snapshot.record) } : {}),\n };\n }\n },\n };\n }\n\n async getBlockHeight(): Promise<bigint> {\n return (await mappingOf(this)).driver.reader.getBlockHeight();\n }\n\n async getBlock(ref: bigint | string): Promise<Block | null> {\n const block = await (await mappingOf(this)).driver.reader.getBlock(ref);\n return block ? toBlock(block) : null;\n }\n\n /**\n * Reorg-aware, at-least-once block scanner (capability `block-scan`): `ack()` each event\n * to commit the cursor before asking for the next. Invalid options throw `CONFIG_INVALID`.\n */\n scanner(options: ScannerOptions): Scanner {\n if (!this.supports('block-scan')) {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} does not support block scanning`,\n );\n }\n const internals = internalsOf(this);\n const container = containerOf(internals.container);\n const { runtime } = container;\n return new Scanner(\n {\n load: async () => {\n // One pooled entry, so the driver and its transport always belong together.\n const { driver, transport } = await internals.pooled();\n const blocks = driver.blocks;\n if (!blocks)\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} driver has no block source`,\n );\n const mapping = {\n selection: internals.selection,\n driver,\n assets: runtime.assets,\n };\n return { mapping, blocks, transport };\n },\n cursors: runtime.stores.cursors,\n events: runtime.events,\n clock: runtime.clock,\n namespace: runtime.namespace,\n defaults: {\n reorgWindow: internals.selection.network.reorgWindow,\n pollIntervalMs: withLifecycleDefaults(container.effective().lifecycle)\n .pollIntervalMs,\n },\n },\n options,\n );\n }\n\n /** Indexer-backed transaction history of an address (capability `address-history`). */\n async history(\n address: string,\n options: { readonly cursor?: string; readonly limit?: number } = {},\n ): Promise<{ readonly items: readonly Transaction[]; readonly next?: string }> {\n if (!this.supports('address-history')) {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} has no address history (configure an indexer)`,\n );\n }\n const { cursor, limit = 50 } = options;\n if (!Number.isSafeInteger(limit) || limit < 1) {\n throw new ConfigError('CONFIG_INVALID', 'history limit must be a positive integer');\n }\n if (cursor !== undefined && typeof cursor !== 'string') {\n throw new ConfigError('CONFIG_INVALID', 'history cursor must be a string');\n }\n const m = await mappingOf(this);\n const source = m.driver.history;\n if (!source)\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} driver has no history source`,\n );\n const page = await source.list(toAddress(m, address).canonical, {\n ...(cursor !== undefined ? { cursor } : {}),\n limit,\n });\n const [head, finalized] = await Promise.all([\n m.driver.reader.getBlockHeight(),\n m.driver.reader.getFinalizedHeight(),\n ]);\n return {\n items: await Promise.all(\n page.items.map((tx) => toTransaction(m, tx, head, finalized)),\n ),\n ...(page.next !== undefined ? { next: page.next } : {}),\n };\n }\n\n async getNetworkStatus(): Promise<NetworkStatus> {\n const pooled = await internalsOf(this).pooled();\n await pooled.transport.refreshHealth();\n if (pooled.indexer) await pooled.indexer.refreshHealth();\n const [height, finalized] = await Promise.all([\n pooled.driver.reader.getBlockHeight(),\n pooled.driver.reader.getFinalizedHeight(),\n ]);\n return {\n chain: this.chain,\n network: this.network,\n height,\n // Two reads, possibly from different endpoints, with blocks landing between\n // them: where the latest block is final, the finalized height can pass the head read.\n // Every height below a final one is final, so the clamp keeps the status true.\n finalizedHeight: finalized > height ? height : finalized,\n endpoints: pooled.transport.status(),\n indexers: pooled.indexer?.status() ?? [],\n };\n }\n\n /** Builds and persists the unsigned transaction (reserving nonce/inputs) for offline or async signing. */\n async prepareTransfer(\n intent: TransferIntent,\n options: TransferOptions = {},\n ): Promise<PreparedOperation> {\n const target = await targetOf(this);\n return preparedOf(\n this,\n target,\n await engineOf(this).prepare(target, intent, options),\n );\n }\n\n /**\n * Idempotent transfer. Throws the mapped chain error when the Operation stalls or fails;\n * throws an `ambiguous` error (with `context.operationId`) when the broadcast outcome is\n * unknown. Retry with the same `idempotencyKey` in both cases.\n */\n async transfer(\n intent: TransferIntent,\n options: TransferOptions = {},\n ): Promise<Submission> {\n const target = await targetOf(this);\n return submissionOf(this, await engineOf(this).transfer(target, intent, options));\n }\n\n /**\n * Completes an Operation that awaits signatures, with signature bundles or with the whole\n * payload signed elsewhere, e.g. a signed PSBT: the driver extracts its signatures\n * (`TxBuilder.signaturesFrom`), and each is verified against the stored request exactly\n * like a bundle. `UNSUPPORTED_CAPABILITY` when the chain's driver cannot read one.\n */\n async submitSignatures(\n operationId: string,\n signatures: readonly SignatureBundle[] | RawTx,\n ): Promise<Submission> {\n const target = await targetOf(this);\n let bundles: readonly SignatureBundle[];\n if (Array.isArray(signatures)) {\n bundles = signatures;\n } else {\n if (!isRawTx(signatures)) {\n throw new ValidationError(\n 'INVALID_INTENT',\n 'signatures must be signature bundles or a signed payload { encoding, data }',\n );\n }\n const { builder } = target.pooled.driver;\n if (!builder.signaturesFrom) {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} cannot read a signed payload; submit signature bundles`,\n );\n }\n // Ownership first, so another wallet's Operation never reaches the driver.\n const record = await engineOf(this).requireOwned(target, operationId);\n if (!record.unsigned) {\n throw new StateError(\n 'INVALID_TRANSITION',\n `operation '${operationId}' has no transaction awaiting signatures`,\n { context: { operationId } },\n );\n }\n try {\n bundles = builder.signaturesFrom(record.unsigned, signatures);\n } catch (error) {\n // A driver's own classified error passes through; a foreign one (an SDK's\n // parse error, which may quote the payload) becomes a fixed text with no cause.\n if (isCryptoAioError(error)) throw error;\n throw new ValidationError(\n 'INVALID_INTENT',\n 'the signed payload could not be read',\n );\n }\n }\n return submissionOf(\n this,\n await engineOf(this).submitSignatures(target, operationId, bundles),\n );\n }\n\n /** Resends the active Attempt's stored raw transaction (e.g. after topping up a stalled wallet). */\n async rebroadcast(operationId: string): Promise<Submission> {\n return submissionOf(\n this,\n await engineOf(this).rebroadcast(await targetOf(this), operationId),\n );\n }\n\n /**\n * Replaces a pending transfer with a higher-fee, mutually exclusive Attempt (capability\n * `replace-fee`; a synchronous signer). If the node refuses it, the original stays live\n * and active, and the node's error is thrown.\n *\n * Idempotent per fee spec: repeating the call with the same `fee` (the same speed name,\n * or an equal override) returns the replacement it already made, resending it if its\n * broadcast was never recorded or it was refused; nothing is signed again, and a refusal\n * is thrown, never reported as a success. To bump again, pass another spec, such as a\n * higher explicit override.\n *\n * While that replacement is stored but not yet sent, another fee spec (or a cancel) is\n * refused with `INVALID_TRANSITION`: repeat the same spec, or call `rebroadcast`, first.\n */\n async replace(\n operationId: string,\n options: { readonly fee: FeeSpeed | FeeOverride },\n ): Promise<Submission> {\n return submissionOf(\n this,\n await engineOf(this).replace(await targetOf(this), operationId, options.fee),\n );\n }\n\n /**\n * Tries to cancel with a conflicting Attempt (capability `cancel`); the outcome is\n * `cancelled` only if the cancel wins at finality, and the original may still win. The\n * cancel pays the network's minimum bump over the highest earlier cancel, or `options.fee`\n * (refused below that bump).\n *\n * Repeating the call while a cancel is pending resends it if its broadcast was never\n * recorded, and returns it while a node holds it or once it is on chain, so concurrent and\n * retried calls create one cancel. Only a cancel the node refused or dropped is bumped by\n * a repeat, one step at a time; when the node's minimum fee is more than one bump away,\n * pass `options.fee`, which always builds a new cancel while none is on chain.\n *\n * While a replacement is stored but not yet sent, a cancel is refused with\n * `INVALID_TRANSITION`: repeat that replacement's fee, or call `rebroadcast`, first.\n */\n async cancel(\n operationId: string,\n options: { readonly fee?: FeeSpeed | FeeOverride } = {},\n ): Promise<Submission> {\n return submissionOf(\n this,\n await engineOf(this).cancel(await targetOf(this), operationId, options.fee),\n );\n }\n\n /** Expiry-based chains: re-issues an Operation whose earlier Attempts are provably expired. */\n async rebuild(operationId: string): Promise<Submission> {\n return submissionOf(\n this,\n await engineOf(this).rebuild(await targetOf(this), operationId),\n );\n }\n\n /**\n * Broadcasts an externally signed transaction WITHOUT creating an Operation: no idempotency,\n * persistence or monitoring. Prefer prepareTransfer + submitSignatures for managed flows.\n */\n async broadcast(raw: RawTx): Promise<BroadcastResult> {\n const { driver } = await internalsOf(this).pooled();\n return driver.broadcaster.broadcast({\n raw,\n ref: { id: '', idKind: 'tx-hash', canonical: false },\n });\n }\n\n /** Abandons an Operation that has no signed transaction yet and releases its reservation. */\n async abandon(operationId: string): Promise<OperationView> {\n return viewOf(this, await engineOf(this).abandon(await targetOf(this), operationId));\n }\n\n /** An Operation of this handle's chain and network (another one is INVALID_INTENT). */\n async getOperation(operationId: string): Promise<OperationView | null> {\n const record = await engineOf(this).get(operationId);\n if (!record) return null;\n assertSameNetwork(internalsOf(this).selection, record);\n return viewOf(this, record);\n }\n\n /** Typed family extensions: `bc.ext.<family>.<method>(...)` (async, loads the adapter on demand). */\n get ext(): ExtOf<C> {\n const internals = internalsOf(this);\n const where = `${internals.selection.chain.id}/${internals.selection.library}`;\n return new Proxy(\n {},\n {\n get: (_target, family) => {\n if (typeof family !== 'string' || family === 'then') return undefined;\n return new Proxy(\n {},\n {\n get: (_inner, method) => {\n if (typeof method !== 'string' || method === 'then') return undefined;\n return async (...args: unknown[]) => {\n const { driver } = await internals.pooled();\n // Own-property checks at both levels, so a name inherited from\n // Object.prototype (`constructor`, `toString`, ...) can never be mistaken\n // for a real family method.\n const familyExt =\n driver.ext && Object.hasOwn(driver.ext, family)\n ? driver.ext[family]\n : undefined;\n const fn =\n familyExt && Object.hasOwn(familyExt, method)\n ? (familyExt[method] as (...a: unknown[]) => Promise<unknown>)\n : undefined;\n if (typeof fn !== 'function') {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `ext.${family}.${method} is not available on ${where}`,\n );\n }\n return fn(...args);\n };\n },\n },\n );\n },\n },\n ) as ExtOf<C>;\n }\n}\n\n/** A handle on `internals`; the container's way past the private constructor. */\nexport function createBlockchain<C extends ChainId>(\n internals: HandleInternals,\n): Blockchain<C> {\n const Handle = Blockchain as unknown as new (\n internals: HandleInternals,\n ) => Blockchain<C>;\n return new Handle(internals);\n}\n\n/** The driver's address for `publicKey` under options the core built. */\nasync function driverAddress(\n handle: Blockchain,\n publicKey: Uint8Array,\n options: WalletOptions,\n): Promise<Address> {\n const { driver, selection } = await mappingOf(handle);\n return new Address(\n selection.chain.id,\n driver.address.fromPublicKey(publicKey, options),\n driver.address.format,\n );\n}\n\nasync function mappingOf(handle: Blockchain): Promise<MappingContext> {\n const internals = internalsOf(handle);\n const { driver } = await internals.pooled();\n return {\n selection: internals.selection,\n driver,\n assets: containerOf(internals.container).runtime.assets,\n };\n}\n\nfunction engineOf(handle: Blockchain): OperationEngine {\n const internals = internalsOf(handle);\n internals.assertOpen();\n return containerOf(internals.container).engine();\n}\n\nfunction monitorOf(handle: Blockchain): Monitor {\n return containerOf(internalsOf(handle).container).monitor();\n}\n\nasync function readTargetOf(handle: Blockchain): Promise<ReadTarget> {\n const internals = internalsOf(handle);\n return { selection: internals.selection, pooled: await internals.pooled() };\n}\n\nasync function targetOf(handle: Blockchain): Promise<OperationTarget> {\n const internals = internalsOf(handle);\n const [pooled, wallet] = await Promise.all([internals.pooled(), internals.wallet()]);\n return {\n selection: internals.selection,\n pooled,\n wallet,\n assets: containerOf(internals.container).runtime.assets,\n };\n}\n\nasync function viewOf(\n handle: Blockchain,\n record: OperationRecord,\n): Promise<OperationView> {\n const { runtime } = containerOf(internalsOf(handle).container);\n return toView(record, await loadObservations(runtime.stores.operations, record));\n}\n\nasync function submissionOf(\n handle: Blockchain,\n record: OperationRecord,\n): Promise<Submission> {\n const view = await viewOf(handle, record);\n return {\n ...view,\n operationId: view.id,\n ...(view.activeAttempt ? { attempt: view.activeAttempt } : {}),\n wait: (options?: WaitOptions) => handle.waitForConfirmation(view.id, options),\n };\n}\n\n/**\n * Signing material only while the Operation awaits signatures: an idempotent repeat of an\n * abandoned Operation returns its view alone.\n */\nasync function preparedOf(\n handle: Blockchain,\n target: OperationTarget,\n record: OperationRecord,\n): Promise<PreparedOperation> {\n const operation = await viewOf(handle, record);\n const unsigned = record.unsigned;\n if (!unsigned || !PRE_SIGNING_STATES.has(record.state)) return { operation };\n const fee = await toFeeEstimate(\n {\n selection: target.selection,\n driver: target.pooled.driver,\n assets: target.assets,\n },\n unsigned.fee,\n );\n return {\n operation,\n unsigned: {\n payload: unsigned.payload,\n signingRequests: unsigned.signingRequests,\n ...(unsigned.expectedRef ? { expectedRef: unsigned.expectedRef } : {}),\n fee,\n },\n };\n}\n\n/** The shape of a signed payload (`RawTx`), checked at run time. */\nfunction isRawTx(value: unknown): value is RawTx {\n if (value === null || typeof value !== 'object') return false;\n const { encoding, data } = value as { encoding?: unknown; data?: unknown };\n return (\n (encoding === 'hex' || encoding === 'base64' || encoding === 'json') &&\n typeof data === 'string'\n );\n}\n"]}
1
+ {"version":3,"file":"handle.js","sourceRoot":"","sources":["../../../src/core/blockchain/handle.ts"],"names":[],"mappings":";;;AAusBA,4CAOC;AA9sBD,+CAAwE;AAExE,sDAAqD;AAErD,2CAOyB;AACzB,8CAA2C;AAC3C,4CAAyC;AAKzC,4CAAsE;AAEtE,gDAO6B;AAC7B,gDAAsD;AACtD,kDAM8B;AAC9B,4DAA6D;AAC7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AC,MAAM,CAAC,MAAM;QAC5B,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,EACD,QAAQ,CAAC,GAAG,CACb,CAAC;IACF,OAAO;QACL,SAAS;QACT,QAAQ,EAAE;YACR,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtE,GAAG;SACJ;KACF,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAA+C,CAAC;IAC3E,OAAO,CACL,CAAC,QAAQ,KAAK,KAAK,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,CAAC;QACpE,OAAO,IAAI,KAAK,QAAQ,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { describeSelection, resolveSelection } from '../config/resolve';\nimport type { HandleConfig, HandleOptions } from '../config/types';\nimport { containerOf } from '../container/internals';\nimport type { BroadcastResult, DriverLimits, WalletOptions } from '../driver/types';\nimport {\n ConfigError,\n ProviderError,\n StateError,\n UnsupportedCapabilityError,\n ValidationError,\n isCryptoAioError,\n} from '../errors/error';\nimport { Address } from '../model/address';\nimport { Amount } from '../model/amount';\nimport type { AssetInfo, AssetRef } from '../model/asset';\nimport type { Capability } from '../model/capability';\nimport type { FeeEstimate, FeeOverride, FeeSpeed } from '../model/fee';\nimport type { ChainId, ExtOf, LibraryOf, NetworkOf } from '../model/ids';\nimport { toStoredIntent, type TransferIntent } from '../model/intent';\nimport type { Block, RawTx, Transaction, TxStatus } from '../model/transaction';\nimport {\n PRE_SIGNING_STATES,\n withLifecycleDefaults,\n type OperationEngine,\n type OperationTarget,\n type ReadTarget,\n type TransferOptions,\n} from '../lifecycle/engine';\nimport { normalizeIntent } from '../lifecycle/intent';\nimport {\n assertSameNetwork,\n type ConfirmationResult,\n type Monitor,\n type TxStatusEvent,\n type WaitOptions,\n} from '../lifecycle/monitor';\nimport { loadObservations } from '../lifecycle/observations';\nimport {\n toView,\n type OperationView,\n type PreparedOperation,\n type Submission,\n} from '../lifecycle/views';\nimport { createScanner, type Scanner, type ScannerOptions } from '../observe/scanner';\nimport { deriveXpubChild } from '../signing/hd';\nimport type { SignatureBundle } from '../signing/types';\nimport { resolveWallet, walletOptionsOf, xpubPathOf } from '../signing/wallet';\nimport type { OperationRecord } from '../store/types';\nimport type { EndpointState, EndpointStatus } from '../transport/types';\nimport { fromHex } from '../util/bytes';\nimport { unknownName } from '../util/names';\nimport { defaultBlockchain } from './default-ref';\nimport { bindInternals, internalsOf, type HandleInternals } from './internal';\nimport {\n toAddress,\n toBlock,\n toFeeEstimate,\n toTransaction,\n type MappingContext,\n} from './mapping';\n\n/** `bc.getBalance()`'s answer: what `address` holds of `asset`, as one endpoint reads it. */\nexport interface Balance {\n readonly address: Address;\n readonly asset: AssetInfo;\n readonly amount: Amount;\n}\n\n/**\n * `bc.getNetworkStatus()`'s answer: the chain's head and finalized heights as the handle's\n * endpoints report them, and each provider and indexer endpoint's health.\n */\nexport interface NetworkStatus {\n readonly chain: string;\n readonly network: string;\n readonly height: bigint;\n readonly finalizedHeight: bigint;\n readonly endpoints: readonly EndpointStatus[];\n readonly indexers: readonly EndpointStatus[];\n}\n\n/** Immutable handle bound to one chain, network, library, provider set and wallet. */\nexport class Blockchain<C extends ChainId = ChainId> {\n /** Handles come from `CryptoAio#blockchain` or `Blockchain.create`. */\n private constructor(internals: HandleInternals) {\n bindInternals(this, internals);\n Object.freeze(this);\n }\n\n /** Creates a handle on the default container (see `configure`). */\n static create<C extends ChainId>(config: HandleConfig<C>): Blockchain<C> {\n return defaultBlockchain(config as HandleOptions) as unknown as Blockchain<C>;\n }\n\n get chain(): C {\n return internalsOf(this).selection.chain.id as C;\n }\n\n get network(): NetworkOf<C> {\n return internalsOf(this).selection.network.id as NetworkOf<C>;\n }\n\n get library(): LibraryOf<C> {\n return internalsOf(this).selection.library as LibraryOf<C>;\n }\n\n /** Frozen, redacted snapshot of the resolved configuration. */\n get config(): Readonly<Record<string, unknown>> {\n return describeSelection(internalsOf(this).selection);\n }\n\n /** A fresh copy on every read; mutating the result never affects `supports()`. */\n get capabilities(): ReadonlySet<Capability> {\n return new Set(internalsOf(this).selection.capabilities);\n }\n\n supports(capability: Capability): boolean {\n return internalsOf(this).selection.capabilities.has(capability);\n }\n\n /** Returns a NEW handle; this handle and operations started from it are unaffected. */\n with(overrides: Partial<Omit<HandleConfig<C>, 'chain'>>): Blockchain<C> {\n const { selection, container } = internalsOf(this);\n return container.blockchain({\n ...selection.handle,\n ...overrides,\n chain: this.chain,\n } as HandleConfig<C>);\n }\n\n /**\n * Loads the adapter, connects its transport and validates it's actually usable; fails fast\n * on a missing dependency (`DEPENDENCY_MISSING`), an invalid wallet (surfaced by resolving\n * it), or a provider that can't serve reads: `PROVIDER_UNAVAILABLE` when no configured\n * endpoint is usable, `PROVIDER_MISCONFIGURED` (non-retryable) when every endpoint's\n * identity mismatches the configured network. An endpoint is usable when it's 'healthy',\n * 'lagging' or 'half-open' (the breaker is willing to try it), or 'unknown' while the\n * transport has no health probes configured at all — nothing could ever have marked it\n * healthy/lagging in that case, so 'unknown' is simply its steady state.\n */\n async ready(): Promise<this> {\n const internals = internalsOf(this);\n const pooled = await internals.pooled();\n await pooled.transport.refreshHealth();\n const statuses = pooled.transport.status();\n if (statuses.length > 0 && statuses.every((s) => s.state === 'disabled')) {\n throw new ProviderError(\n 'PROVIDER_MISCONFIGURED',\n `every endpoint for ${this.chain} serves a different network than configured`,\n { retryable: false },\n );\n }\n const usable = (state: EndpointState): boolean =>\n state === 'healthy' ||\n state === 'lagging' ||\n state === 'half-open' ||\n (state === 'unknown' && !pooled.transport.hasProbes());\n if (!statuses.some((s) => usable(s.state))) {\n throw new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n `no healthy endpoint for ${this.chain}`,\n );\n }\n if (internals.selection.wallet) await internals.wallet();\n return this;\n }\n\n async limits(): Promise<DriverLimits> {\n const { driver } = await internalsOf(this).pooled();\n const wallet = internalsOf(this).selection.wallet;\n const options: WalletOptions = wallet ? walletOptionsOf(wallet.config) : {};\n return (\n driver.limits?.(options) ?? {\n maxOutputs: this.supports('batch-transfer') ? Number.MAX_SAFE_INTEGER : 1,\n }\n );\n }\n\n async validateAddress(address: string): Promise<boolean> {\n return (await mappingOf(this)).driver.address.validate(address);\n }\n\n async normalizeAddress(address: string): Promise<Address> {\n return toAddress(await mappingOf(this), address);\n }\n\n /** The chain's address for `publicKey`. `options.hd` is reserved: the core builds it\n * from a wallet's `xpub`, so a caller's `hd` is dropped and never reaches the driver.\n * `null` options (from an untyped caller) are none. */\n async addressFromPublicKey(\n publicKey: Uint8Array | string,\n options: WalletOptions = {},\n ): Promise<Address> {\n const { hd: _reserved, ...callerOptions } = options ?? {};\n const bytes = typeof publicKey === 'string' ? fromHex(publicKey) : publicKey;\n return driverAddress(this, bytes, callerOptions);\n }\n\n /** Address of the handle's own selected wallet, or of another configured `wallet` by name\n * — resolved fresh against this handle's driver, without switching the handle.\n * Re-resolved through `resolveSelection` (not `resolveWallet` directly) so a\n * named wallet gets the same `wallet.chains` enablement check, unknown-signer validation and\n * signer-scheme compatibility check that the handle's own wallet got at construction. */\n async walletAddress(wallet?: string): Promise<Address> {\n const internals = internalsOf(this);\n const selection = internals.selection;\n if (wallet === undefined || wallet === selection.wallet?.name) {\n return (await internals.wallet()).address;\n }\n const container = containerOf(internals.container);\n const effective = container.effective();\n // An own-property check, so a wallet literally named 'constructor' (or any other\n // Object.prototype key) can never be mistaken for one that exists.\n if (!Object.hasOwn(effective.wallets, wallet)) {\n throw new ConfigError(\n 'CONFIG_INVALID',\n unknownName('wallet', Object.keys(effective.wallets)),\n );\n }\n const { driver } = await internals.pooled();\n const resolved = resolveSelection({\n handle: { ...selection.handle, wallet, signer: undefined },\n effective,\n catalogs: container.runtime.catalogs,\n });\n const resolvedWallet = await resolveWallet(\n resolved,\n driver,\n effective.signers,\n container.runtime.catalogs.schemes,\n container.signerDeadline(),\n );\n return resolvedWallet.address;\n }\n\n /** Derives a deposit address from the wallet's xpub (capability `hd-public-derivation`). */\n async deriveAddress(wallet: string, index: number): Promise<Address> {\n if (!this.supports('hd-public-derivation')) {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} does not support public derivation`,\n );\n }\n if (!Number.isInteger(index) || index < 0 || index >= 2 ** 31) {\n throw new ValidationError(\n 'INVALID_INTENT',\n 'derivation index must be an integer in [0, 2^31)',\n );\n }\n const internals = internalsOf(this);\n const { wallets } = containerOf(internals.container).effective();\n // Own keys only, so `toString` is no wallet. The caller's text is never repeated: it\n // may be a pasted secret.\n if (!Object.hasOwn(wallets, wallet)) {\n throw new ConfigError(\n 'CONFIG_INVALID',\n unknownName('wallet', Object.keys(wallets)),\n );\n }\n const config = wallets[wallet];\n if (!config?.xpub)\n throw new ConfigError('CONFIG_INVALID', `wallet '${wallet}' has no xpub`);\n // A non-string xpubPath is CONFIG_INVALID, as at wallet resolution.\n const path = (xpubPathOf(config) ?? '0/{index}').replace('{index}', String(index));\n // A UTXO chain's extended keys carry its network class; account-model\n // wallets (EVM, Tron) export `xpub` on every network, so theirs is not checked. A chain\n // whose wallets do the same says so (`xpubNetworkClass: false`, Avalanche X/P).\n const { chain, network } = internals.selection;\n const classed = chain.xpubNetworkClass ?? chain.model === 'utxo';\n const publicKey = deriveXpubChild(\n config.xpub,\n path,\n config.xpubVersions,\n classed ? { testnet: network.testnet } : undefined,\n );\n // The core's own options, with the wallet's `hd`, reach the driver directly.\n return driverAddress(this, publicKey, walletOptionsOf(config));\n }\n\n async resolveAsset(asset?: AssetRef | string): Promise<AssetInfo> {\n const m = await mappingOf(this);\n return m.assets.resolve(m.selection, m.driver, asset);\n }\n\n async getBalance(address: string, asset?: AssetRef | string): Promise<Balance> {\n const m = await mappingOf(this);\n const target = toAddress(m, address);\n const info = await m.assets.resolve(m.selection, m.driver, asset);\n const base = await m.driver.reader.getBalance(target.canonical, info.ref);\n return { address: target, asset: info, amount: Amount.fromBase(base, info) };\n }\n\n async getBalances(\n address: string,\n assets: readonly (AssetRef | string)[],\n ): Promise<Balance[]> {\n return Promise.all(assets.map((asset) => this.getBalance(address, asset)));\n }\n\n async estimateFee(intent: TransferIntent): Promise<FeeEstimate> {\n const m = await mappingOf(this);\n const internals = internalsOf(this);\n const wallet = internals.selection.wallet ? await internals.wallet() : undefined;\n const from = intent.from !== undefined ? toAddress(m, intent.from) : wallet?.address;\n if (!from)\n throw new ValidationError(\n 'INVALID_INTENT',\n 'estimateFee needs a wallet or intent.from',\n );\n const normalized = await normalizeIntent(m, intent, from);\n const draft = await m.driver.builder.estimateFee(toStoredIntent(normalized), {\n from: from.canonical,\n keys: wallet?.keys ?? [],\n wallet: wallet?.options ?? {},\n decimals: normalized.asset.metadata.decimals,\n });\n return toFeeEstimate(m, draft);\n }\n\n async getTransaction(id: string): Promise<Transaction | null> {\n const m = await mappingOf(this);\n const tx = await m.driver.reader.getTransaction(id);\n if (!tx) return null;\n const [head, finalized] = await Promise.all([\n m.driver.reader.getBlockHeight(),\n m.driver.reader.getFinalizedHeight(),\n ]);\n return toTransaction(m, tx, head, finalized);\n }\n\n /** Status of a managed Operation (by id, Attempt ref or tx hash) or of any transaction id. */\n async getTransactionStatus(id: string): Promise<TxStatus> {\n return (await monitorOf(this).status(await readTargetOf(this), id)).status;\n }\n\n /**\n * Resolves once `confirmations` (default: the handle's) are reached. With\n * `finality: 'final'`, a managed Operation (by id, Attempt ref or tx hash) resolves on\n * **proven** finality (finalized data confirmed by quorum proof reads); a transaction the\n * library does not manage resolves on **observed** finality (one endpoint's view of a\n * block at or below the finalized height). Rejects with the chain error when the\n * Operation fails, expires or is replaced (`TX_REVERTED` for an unmanaged transaction\n * that reverted), with `TIMEOUT` (retryable, state unchanged) when time runs out, and\n * with the reason of an aborted `signal`.\n */\n async waitForConfirmation(\n ref: string,\n options: WaitOptions = {},\n ): Promise<ConfirmationResult> {\n const { status, record } = await monitorOf(this).waitFor(\n await readTargetOf(this),\n ref,\n options,\n );\n return { status, ...(record ? { operation: await viewOf(this, record) } : {}) };\n }\n\n /** Yields each status change until the Operation is terminal (or the transaction is final). */\n watch(\n ref: string,\n options: { readonly pollIntervalMs?: number; readonly signal?: AbortSignal } = {},\n ): AsyncIterable<TxStatusEvent> {\n const readTarget = () => readTargetOf(this);\n const monitor = () => monitorOf(this);\n const view = (record: OperationRecord) => viewOf(this, record);\n return {\n async *[Symbol.asyncIterator]() {\n const target = await readTarget();\n for await (const snapshot of monitor().watch(target, ref, options)) {\n yield {\n status: snapshot.status,\n ...(snapshot.record ? { operation: await view(snapshot.record) } : {}),\n };\n }\n },\n };\n }\n\n async getBlockHeight(): Promise<bigint> {\n return (await mappingOf(this)).driver.reader.getBlockHeight();\n }\n\n async getBlock(ref: bigint | string): Promise<Block | null> {\n const block = await (await mappingOf(this)).driver.reader.getBlock(ref);\n return block ? toBlock(block) : null;\n }\n\n /**\n * Reorg-aware, at-least-once block scanner (capability `block-scan`): `ack()` each event\n * to commit the cursor before asking for the next. Invalid options throw `CONFIG_INVALID`.\n */\n scanner(options: ScannerOptions): Scanner {\n if (!this.supports('block-scan')) {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} does not support block scanning`,\n );\n }\n const internals = internalsOf(this);\n const container = containerOf(internals.container);\n const { runtime } = container;\n return createScanner(\n {\n load: async () => {\n // One pooled entry, so the driver and its transport always belong together.\n const { driver, transport } = await internals.pooled();\n const blocks = driver.blocks;\n if (!blocks)\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} driver has no block source`,\n );\n const mapping = {\n selection: internals.selection,\n driver,\n assets: runtime.assets,\n };\n return { mapping, blocks, transport };\n },\n cursors: runtime.stores.cursors,\n events: runtime.events,\n clock: runtime.clock,\n namespace: runtime.namespace,\n defaults: {\n reorgWindow: internals.selection.network.reorgWindow,\n pollIntervalMs: withLifecycleDefaults(container.effective().lifecycle)\n .pollIntervalMs,\n },\n },\n options,\n );\n }\n\n /** Indexer-backed transaction history of an address (capability `address-history`). */\n async history(\n address: string,\n options: { readonly cursor?: string; readonly limit?: number } = {},\n ): Promise<{ readonly items: readonly Transaction[]; readonly next?: string }> {\n if (!this.supports('address-history')) {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} has no address history (configure an indexer)`,\n );\n }\n const { cursor, limit = 50 } = options;\n if (!Number.isSafeInteger(limit) || limit < 1) {\n throw new ConfigError('CONFIG_INVALID', 'history limit must be a positive integer');\n }\n if (cursor !== undefined && typeof cursor !== 'string') {\n throw new ConfigError('CONFIG_INVALID', 'history cursor must be a string');\n }\n const m = await mappingOf(this);\n const source = m.driver.history;\n if (!source)\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} driver has no history source`,\n );\n const page = await source.list(toAddress(m, address).canonical, {\n ...(cursor !== undefined ? { cursor } : {}),\n limit,\n });\n const [head, finalized] = await Promise.all([\n m.driver.reader.getBlockHeight(),\n m.driver.reader.getFinalizedHeight(),\n ]);\n return {\n items: await Promise.all(\n page.items.map((tx) => toTransaction(m, tx, head, finalized)),\n ),\n ...(page.next !== undefined ? { next: page.next } : {}),\n };\n }\n\n async getNetworkStatus(): Promise<NetworkStatus> {\n const pooled = await internalsOf(this).pooled();\n await pooled.transport.refreshHealth();\n if (pooled.indexer) await pooled.indexer.refreshHealth();\n const [height, finalized] = await Promise.all([\n pooled.driver.reader.getBlockHeight(),\n pooled.driver.reader.getFinalizedHeight(),\n ]);\n return {\n chain: this.chain,\n network: this.network,\n height,\n // Two reads, possibly from different endpoints, with blocks landing between\n // them: where the latest block is final, the finalized height can pass the head read.\n // Every height below a final one is final, so the clamp keeps the status true.\n finalizedHeight: finalized > height ? height : finalized,\n endpoints: pooled.transport.status(),\n indexers: pooled.indexer?.status() ?? [],\n };\n }\n\n /** Builds and persists the unsigned transaction (reserving nonce/inputs) for offline or async signing. */\n async prepareTransfer(\n intent: TransferIntent,\n options: TransferOptions = {},\n ): Promise<PreparedOperation> {\n const target = await targetOf(this);\n return preparedOf(\n this,\n target,\n await engineOf(this).prepare(target, intent, options),\n );\n }\n\n /**\n * Idempotent transfer. Throws the mapped chain error when the Operation stalls or fails;\n * throws an `ambiguous` error (with `context.operationId`) when the broadcast outcome is\n * unknown. Retry with the same `idempotencyKey` in both cases.\n */\n async transfer(\n intent: TransferIntent,\n options: TransferOptions = {},\n ): Promise<Submission> {\n const target = await targetOf(this);\n return submissionOf(this, await engineOf(this).transfer(target, intent, options));\n }\n\n /**\n * Completes an Operation that awaits signatures, with signature bundles or with the whole\n * payload signed elsewhere, e.g. a signed PSBT: the driver extracts its signatures\n * (`TxBuilder.signaturesFrom`), and each is verified against the stored request exactly\n * like a bundle. `UNSUPPORTED_CAPABILITY` when the chain's driver cannot read one.\n */\n async submitSignatures(\n operationId: string,\n signatures: readonly SignatureBundle[] | RawTx,\n ): Promise<Submission> {\n const target = await targetOf(this);\n let bundles: readonly SignatureBundle[];\n if (Array.isArray(signatures)) {\n bundles = signatures;\n } else {\n if (!isRawTx(signatures)) {\n throw new ValidationError(\n 'INVALID_INTENT',\n 'signatures must be signature bundles or a signed payload { encoding, data }',\n );\n }\n const { builder } = target.pooled.driver;\n if (!builder.signaturesFrom) {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `${this.chain} cannot read a signed payload; submit signature bundles`,\n );\n }\n // Ownership first, so another wallet's Operation never reaches the driver.\n const record = await engineOf(this).requireOwned(target, operationId);\n if (!record.unsigned) {\n throw new StateError(\n 'INVALID_TRANSITION',\n `operation '${operationId}' has no transaction awaiting signatures`,\n { context: { operationId } },\n );\n }\n try {\n bundles = builder.signaturesFrom(record.unsigned, signatures);\n } catch (error) {\n // A driver's own classified error passes through; a foreign one (an SDK's\n // parse error, which may quote the payload) becomes a fixed text with no cause.\n if (isCryptoAioError(error)) throw error;\n throw new ValidationError(\n 'INVALID_INTENT',\n 'the signed payload could not be read',\n );\n }\n }\n return submissionOf(\n this,\n await engineOf(this).submitSignatures(target, operationId, bundles),\n );\n }\n\n /** Resends the active Attempt's stored raw transaction (e.g. after topping up a stalled wallet). */\n async rebroadcast(operationId: string): Promise<Submission> {\n return submissionOf(\n this,\n await engineOf(this).rebroadcast(await targetOf(this), operationId),\n );\n }\n\n /**\n * Replaces a pending transfer with a higher-fee, mutually exclusive Attempt (capability\n * `replace-fee`; a synchronous signer). If the node refuses it, the original stays live\n * and active, and the node's error is thrown.\n *\n * Idempotent per fee spec: repeating the call with the same `fee` (the same speed name,\n * or an equal override) returns the replacement it already made, resending it if its\n * broadcast was never recorded or it was refused; nothing is signed again, and a refusal\n * is thrown, never reported as a success. To bump again, pass another spec, such as a\n * higher explicit override.\n *\n * While that replacement is stored but not yet sent, another fee spec (or a cancel) is\n * refused with `INVALID_TRANSITION`: repeat the same spec, or call `rebroadcast`, first.\n */\n async replace(\n operationId: string,\n options: { readonly fee: FeeSpeed | FeeOverride },\n ): Promise<Submission> {\n return submissionOf(\n this,\n await engineOf(this).replace(await targetOf(this), operationId, options.fee),\n );\n }\n\n /**\n * Tries to cancel with a conflicting Attempt (capability `cancel`); the outcome is\n * `cancelled` only if the cancel wins at finality, and the original may still win. The\n * cancel pays the network's minimum bump over the highest earlier cancel, or `options.fee`\n * (refused below that bump).\n *\n * Repeating the call while a cancel is pending resends it if its broadcast was never\n * recorded, and returns it while a node holds it or once it is on chain, so concurrent and\n * retried calls create one cancel. Only a cancel the node refused or dropped is bumped by\n * a repeat, one step at a time; when the node's minimum fee is more than one bump away,\n * pass `options.fee`, which always builds a new cancel while none is on chain.\n *\n * While a replacement is stored but not yet sent, a cancel is refused with\n * `INVALID_TRANSITION`: repeat that replacement's fee, or call `rebroadcast`, first.\n */\n async cancel(\n operationId: string,\n options: { readonly fee?: FeeSpeed | FeeOverride } = {},\n ): Promise<Submission> {\n return submissionOf(\n this,\n await engineOf(this).cancel(await targetOf(this), operationId, options.fee),\n );\n }\n\n /** Expiry-based chains: re-issues an Operation whose earlier Attempts are provably expired. */\n async rebuild(operationId: string): Promise<Submission> {\n return submissionOf(\n this,\n await engineOf(this).rebuild(await targetOf(this), operationId),\n );\n }\n\n /**\n * Broadcasts an externally signed transaction WITHOUT creating an Operation: no idempotency,\n * persistence or monitoring. Prefer prepareTransfer + submitSignatures for managed flows.\n */\n async broadcast(raw: RawTx): Promise<BroadcastResult> {\n const { driver } = await internalsOf(this).pooled();\n return driver.broadcaster.broadcast({\n raw,\n ref: { id: '', idKind: 'tx-hash', canonical: false },\n });\n }\n\n /** Abandons an Operation that has no signed transaction yet and releases its reservation. */\n async abandon(operationId: string): Promise<OperationView> {\n return viewOf(this, await engineOf(this).abandon(await targetOf(this), operationId));\n }\n\n /** An Operation of this handle's chain and network (another one is INVALID_INTENT). */\n async getOperation(operationId: string): Promise<OperationView | null> {\n const record = await engineOf(this).get(operationId);\n if (!record) return null;\n assertSameNetwork(internalsOf(this).selection, record);\n return viewOf(this, record);\n }\n\n /** Typed family extensions: `bc.ext.<family>.<method>(...)` (async, loads the adapter on demand). */\n get ext(): ExtOf<C> {\n const internals = internalsOf(this);\n const where = `${internals.selection.chain.id}/${internals.selection.library}`;\n return new Proxy(\n {},\n {\n get: (_target, family) => {\n if (typeof family !== 'string' || family === 'then') return undefined;\n return new Proxy(\n {},\n {\n get: (_inner, method) => {\n if (typeof method !== 'string' || method === 'then') return undefined;\n return async (...args: unknown[]) => {\n const { driver } = await internals.pooled();\n // Own-property checks at both levels, so a name inherited from\n // Object.prototype (`constructor`, `toString`, ...) can never be mistaken\n // for a real family method.\n const familyExt =\n driver.ext && Object.hasOwn(driver.ext, family)\n ? driver.ext[family]\n : undefined;\n const fn =\n familyExt && Object.hasOwn(familyExt, method)\n ? (familyExt[method] as (...a: unknown[]) => Promise<unknown>)\n : undefined;\n if (typeof fn !== 'function') {\n throw new UnsupportedCapabilityError(\n 'UNSUPPORTED_CAPABILITY',\n `ext.${family}.${method} is not available on ${where}`,\n );\n }\n return fn(...args);\n };\n },\n },\n );\n },\n },\n ) as ExtOf<C>;\n }\n}\n\n/** A handle on `internals`; the container's way past the private constructor. */\nexport function createBlockchain<C extends ChainId>(\n internals: HandleInternals,\n): Blockchain<C> {\n const Handle = Blockchain as unknown as new (\n internals: HandleInternals,\n ) => Blockchain<C>;\n return new Handle(internals);\n}\n\n/** The driver's address for `publicKey` under options the core built. */\nasync function driverAddress(\n handle: Blockchain,\n publicKey: Uint8Array,\n options: WalletOptions,\n): Promise<Address> {\n const { driver, selection } = await mappingOf(handle);\n return new Address(\n selection.chain.id,\n driver.address.fromPublicKey(publicKey, options),\n driver.address.format,\n );\n}\n\nasync function mappingOf(handle: Blockchain): Promise<MappingContext> {\n const internals = internalsOf(handle);\n const { driver } = await internals.pooled();\n return {\n selection: internals.selection,\n driver,\n assets: containerOf(internals.container).runtime.assets,\n };\n}\n\nfunction engineOf(handle: Blockchain): OperationEngine {\n const internals = internalsOf(handle);\n internals.assertOpen();\n return containerOf(internals.container).engine();\n}\n\nfunction monitorOf(handle: Blockchain): Monitor {\n return containerOf(internalsOf(handle).container).monitor();\n}\n\nasync function readTargetOf(handle: Blockchain): Promise<ReadTarget> {\n const internals = internalsOf(handle);\n return { selection: internals.selection, pooled: await internals.pooled() };\n}\n\nasync function targetOf(handle: Blockchain): Promise<OperationTarget> {\n const internals = internalsOf(handle);\n const [pooled, wallet] = await Promise.all([internals.pooled(), internals.wallet()]);\n return {\n selection: internals.selection,\n pooled,\n wallet,\n assets: containerOf(internals.container).runtime.assets,\n };\n}\n\nasync function viewOf(\n handle: Blockchain,\n record: OperationRecord,\n): Promise<OperationView> {\n const { runtime } = containerOf(internalsOf(handle).container);\n return toView(record, await loadObservations(runtime.stores.operations, record));\n}\n\nasync function submissionOf(\n handle: Blockchain,\n record: OperationRecord,\n): Promise<Submission> {\n const view = await viewOf(handle, record);\n return {\n ...view,\n operationId: view.id,\n ...(view.activeAttempt ? { attempt: view.activeAttempt } : {}),\n wait: (options?: WaitOptions) => handle.waitForConfirmation(view.id, options),\n };\n}\n\n/**\n * Signing material only while the Operation awaits signatures: an idempotent repeat of an\n * abandoned Operation returns its view alone.\n */\nasync function preparedOf(\n handle: Blockchain,\n target: OperationTarget,\n record: OperationRecord,\n): Promise<PreparedOperation> {\n const operation = await viewOf(handle, record);\n const unsigned = record.unsigned;\n if (!unsigned || !PRE_SIGNING_STATES.has(record.state)) return { operation };\n const fee = await toFeeEstimate(\n {\n selection: target.selection,\n driver: target.pooled.driver,\n assets: target.assets,\n },\n unsigned.fee,\n );\n return {\n operation,\n unsigned: {\n payload: unsigned.payload,\n signingRequests: unsigned.signingRequests,\n ...(unsigned.expectedRef ? { expectedRef: unsigned.expectedRef } : {}),\n fee,\n },\n };\n}\n\n/** The shape of a signed payload (`RawTx`), checked at run time. */\nfunction isRawTx(value: unknown): value is RawTx {\n if (value === null || typeof value !== 'object') return false;\n const { encoding, data } = value as { encoding?: unknown; data?: unknown };\n return (\n (encoding === 'hex' || encoding === 'base64' || encoding === 'json') &&\n typeof data === 'string'\n );\n}\n"]}