@btc-vision/bitcoin 7.0.0-alpha.0 → 7.0.0-alpha.10

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 (369) hide show
  1. package/README.md +455 -155
  2. package/browser/address.d.ts +6 -2
  3. package/browser/address.d.ts.map +1 -1
  4. package/browser/block.d.ts.map +1 -1
  5. package/browser/branded.d.ts +3 -14
  6. package/browser/branded.d.ts.map +1 -1
  7. package/browser/chunks/psbt-parallel-BBFlkmiv.js +10717 -0
  8. package/browser/crypto.d.ts +1 -1
  9. package/browser/ecc/context.d.ts +25 -24
  10. package/browser/ecc/context.d.ts.map +1 -1
  11. package/browser/ecc/index.d.ts +1 -1
  12. package/browser/ecc/index.d.ts.map +1 -1
  13. package/browser/ecc/types.d.ts +10 -123
  14. package/browser/ecc/types.d.ts.map +1 -1
  15. package/browser/env.d.ts +13 -0
  16. package/browser/env.d.ts.map +1 -0
  17. package/browser/index.d.ts +7 -7
  18. package/browser/index.d.ts.map +1 -1
  19. package/browser/index.js +2497 -11686
  20. package/browser/io/BinaryReader.d.ts +15 -15
  21. package/browser/io/BinaryReader.d.ts.map +1 -1
  22. package/browser/io/BinaryWriter.d.ts +17 -17
  23. package/browser/io/BinaryWriter.d.ts.map +1 -1
  24. package/browser/io/hex.d.ts.map +1 -1
  25. package/browser/io/index.d.ts +0 -1
  26. package/browser/io/index.d.ts.map +1 -1
  27. package/browser/opcodes.d.ts +11 -0
  28. package/browser/opcodes.d.ts.map +1 -1
  29. package/browser/payments/bip341.d.ts +1 -1
  30. package/browser/payments/bip341.d.ts.map +1 -1
  31. package/browser/payments/embed.d.ts +1 -1
  32. package/browser/payments/embed.d.ts.map +1 -1
  33. package/browser/payments/p2ms.d.ts.map +1 -1
  34. package/browser/payments/p2op.d.ts +1 -1
  35. package/browser/payments/p2op.d.ts.map +1 -1
  36. package/browser/payments/p2pk.d.ts +1 -1
  37. package/browser/payments/p2pk.d.ts.map +1 -1
  38. package/browser/payments/p2pkh.d.ts +1 -1
  39. package/browser/payments/p2pkh.d.ts.map +1 -1
  40. package/browser/payments/p2sh.d.ts.map +1 -1
  41. package/browser/payments/p2tr.d.ts +2 -2
  42. package/browser/payments/p2tr.d.ts.map +1 -1
  43. package/browser/payments/p2wpkh.d.ts +1 -1
  44. package/browser/payments/p2wpkh.d.ts.map +1 -1
  45. package/browser/payments/p2wsh.d.ts.map +1 -1
  46. package/browser/payments/types.d.ts +1 -1
  47. package/browser/payments/types.d.ts.map +1 -1
  48. package/browser/psbt/PsbtCache.d.ts +54 -0
  49. package/browser/psbt/PsbtCache.d.ts.map +1 -0
  50. package/browser/psbt/PsbtFinalizer.d.ts +21 -0
  51. package/browser/psbt/PsbtFinalizer.d.ts.map +1 -0
  52. package/browser/psbt/PsbtSigner.d.ts +32 -0
  53. package/browser/psbt/PsbtSigner.d.ts.map +1 -0
  54. package/browser/psbt/PsbtTransaction.d.ts +25 -0
  55. package/browser/psbt/PsbtTransaction.d.ts.map +1 -0
  56. package/browser/psbt/bip371.d.ts.map +1 -1
  57. package/browser/psbt/types.d.ts +5 -71
  58. package/browser/psbt/types.d.ts.map +1 -1
  59. package/browser/psbt/validation.d.ts +1 -1
  60. package/browser/psbt/validation.d.ts.map +1 -1
  61. package/browser/psbt.d.ts +26 -40
  62. package/browser/psbt.d.ts.map +1 -1
  63. package/browser/script.d.ts.map +1 -1
  64. package/browser/transaction.d.ts +4 -4
  65. package/browser/transaction.d.ts.map +1 -1
  66. package/browser/types.d.ts +5 -3
  67. package/browser/types.d.ts.map +1 -1
  68. package/browser/workers/WorkerSigningPool.d.ts +24 -17
  69. package/browser/workers/WorkerSigningPool.d.ts.map +1 -1
  70. package/browser/workers/WorkerSigningPool.node.d.ts +19 -12
  71. package/browser/workers/WorkerSigningPool.node.d.ts.map +1 -1
  72. package/browser/workers/WorkerSigningPool.sequential.d.ts +67 -0
  73. package/browser/workers/WorkerSigningPool.sequential.d.ts.map +1 -0
  74. package/browser/workers/WorkerSigningPool.worklet.d.ts +64 -0
  75. package/browser/workers/WorkerSigningPool.worklet.d.ts.map +1 -0
  76. package/browser/workers/index.browser.d.ts +16 -0
  77. package/browser/workers/index.browser.d.ts.map +1 -0
  78. package/browser/workers/index.d.ts +4 -64
  79. package/browser/workers/index.d.ts.map +1 -1
  80. package/browser/workers/index.js +28 -0
  81. package/browser/workers/index.node.d.ts +17 -0
  82. package/browser/workers/index.node.d.ts.map +1 -0
  83. package/browser/workers/index.react-native.d.ts +28 -0
  84. package/browser/workers/index.react-native.d.ts.map +1 -0
  85. package/browser/workers/index.shared.d.ts +15 -0
  86. package/browser/workers/index.shared.d.ts.map +1 -0
  87. package/browser/workers/psbt-parallel.d.ts +2 -3
  88. package/browser/workers/psbt-parallel.d.ts.map +1 -1
  89. package/browser/workers/types.d.ts +17 -0
  90. package/browser/workers/types.d.ts.map +1 -1
  91. package/build/address.d.ts +6 -2
  92. package/build/address.d.ts.map +1 -1
  93. package/build/address.js +32 -19
  94. package/build/address.js.map +1 -1
  95. package/build/bech32utils.js.map +1 -1
  96. package/build/block.d.ts.map +1 -1
  97. package/build/block.js +2 -4
  98. package/build/block.js.map +1 -1
  99. package/build/branded.d.ts +3 -14
  100. package/build/branded.d.ts.map +1 -1
  101. package/build/branded.js +0 -5
  102. package/build/branded.js.map +1 -1
  103. package/build/crypto.d.ts +1 -1
  104. package/build/ecc/context.d.ts +25 -24
  105. package/build/ecc/context.d.ts.map +1 -1
  106. package/build/ecc/context.js +29 -101
  107. package/build/ecc/context.js.map +1 -1
  108. package/build/ecc/index.d.ts +1 -1
  109. package/build/ecc/index.d.ts.map +1 -1
  110. package/build/ecc/types.d.ts +7 -126
  111. package/build/ecc/types.d.ts.map +1 -1
  112. package/build/ecc/types.js +4 -1
  113. package/build/ecc/types.js.map +1 -1
  114. package/build/env.d.ts +13 -0
  115. package/build/env.d.ts.map +1 -0
  116. package/build/env.js +198 -0
  117. package/build/env.js.map +1 -0
  118. package/build/index.d.ts +8 -7
  119. package/build/index.d.ts.map +1 -1
  120. package/build/index.js +9 -7
  121. package/build/index.js.map +1 -1
  122. package/build/io/BinaryReader.d.ts +15 -15
  123. package/build/io/BinaryReader.d.ts.map +1 -1
  124. package/build/io/BinaryReader.js +17 -17
  125. package/build/io/BinaryReader.js.map +1 -1
  126. package/build/io/BinaryWriter.d.ts +17 -17
  127. package/build/io/BinaryWriter.d.ts.map +1 -1
  128. package/build/io/BinaryWriter.js +39 -39
  129. package/build/io/BinaryWriter.js.map +1 -1
  130. package/build/io/hex.d.ts.map +1 -1
  131. package/build/io/hex.js +2 -1
  132. package/build/io/hex.js.map +1 -1
  133. package/build/io/index.d.ts +0 -1
  134. package/build/io/index.d.ts.map +1 -1
  135. package/build/io/index.js +0 -2
  136. package/build/io/index.js.map +1 -1
  137. package/build/opcodes.d.ts +11 -0
  138. package/build/opcodes.d.ts.map +1 -1
  139. package/build/opcodes.js +19 -4
  140. package/build/opcodes.js.map +1 -1
  141. package/build/payments/bip341.d.ts +1 -2
  142. package/build/payments/bip341.d.ts.map +1 -1
  143. package/build/payments/bip341.js +1 -2
  144. package/build/payments/bip341.js.map +1 -1
  145. package/build/payments/embed.d.ts +1 -1
  146. package/build/payments/embed.d.ts.map +1 -1
  147. package/build/payments/embed.js +14 -14
  148. package/build/payments/embed.js.map +1 -1
  149. package/build/payments/p2ms.d.ts.map +1 -1
  150. package/build/payments/p2ms.js +21 -21
  151. package/build/payments/p2ms.js.map +1 -1
  152. package/build/payments/p2op.d.ts +1 -1
  153. package/build/payments/p2op.d.ts.map +1 -1
  154. package/build/payments/p2op.js +18 -18
  155. package/build/payments/p2op.js.map +1 -1
  156. package/build/payments/p2pk.d.ts +1 -1
  157. package/build/payments/p2pk.d.ts.map +1 -1
  158. package/build/payments/p2pk.js +17 -17
  159. package/build/payments/p2pk.js.map +1 -1
  160. package/build/payments/p2pkh.d.ts +1 -1
  161. package/build/payments/p2pkh.d.ts.map +1 -1
  162. package/build/payments/p2pkh.js +20 -20
  163. package/build/payments/p2pkh.js.map +1 -1
  164. package/build/payments/p2sh.d.ts.map +1 -1
  165. package/build/payments/p2sh.js +22 -20
  166. package/build/payments/p2sh.js.map +1 -1
  167. package/build/payments/p2tr.d.ts +2 -2
  168. package/build/payments/p2tr.d.ts.map +1 -1
  169. package/build/payments/p2tr.js +25 -26
  170. package/build/payments/p2tr.js.map +1 -1
  171. package/build/payments/p2wpkh.d.ts +1 -1
  172. package/build/payments/p2wpkh.d.ts.map +1 -1
  173. package/build/payments/p2wpkh.js +20 -20
  174. package/build/payments/p2wpkh.js.map +1 -1
  175. package/build/payments/p2wsh.d.ts.map +1 -1
  176. package/build/payments/p2wsh.js +22 -22
  177. package/build/payments/p2wsh.js.map +1 -1
  178. package/build/payments/types.d.ts +1 -1
  179. package/build/payments/types.d.ts.map +1 -1
  180. package/build/psbt/PsbtCache.d.ts +54 -0
  181. package/build/psbt/PsbtCache.d.ts.map +1 -0
  182. package/build/psbt/PsbtCache.js +249 -0
  183. package/build/psbt/PsbtCache.js.map +1 -0
  184. package/build/psbt/PsbtFinalizer.d.ts +21 -0
  185. package/build/psbt/PsbtFinalizer.d.ts.map +1 -0
  186. package/build/psbt/PsbtFinalizer.js +157 -0
  187. package/build/psbt/PsbtFinalizer.js.map +1 -0
  188. package/build/psbt/PsbtSigner.d.ts +32 -0
  189. package/build/psbt/PsbtSigner.d.ts.map +1 -0
  190. package/build/psbt/PsbtSigner.js +192 -0
  191. package/build/psbt/PsbtSigner.js.map +1 -0
  192. package/build/psbt/PsbtTransaction.d.ts +25 -0
  193. package/build/psbt/PsbtTransaction.d.ts.map +1 -0
  194. package/build/psbt/PsbtTransaction.js +61 -0
  195. package/build/psbt/PsbtTransaction.js.map +1 -0
  196. package/build/psbt/bip371.d.ts.map +1 -1
  197. package/build/psbt/bip371.js +6 -2
  198. package/build/psbt/bip371.js.map +1 -1
  199. package/build/psbt/psbtutils.js +1 -1
  200. package/build/psbt/psbtutils.js.map +1 -1
  201. package/build/psbt/types.d.ts +5 -71
  202. package/build/psbt/types.d.ts.map +1 -1
  203. package/build/psbt/validation.d.ts +1 -1
  204. package/build/psbt/validation.d.ts.map +1 -1
  205. package/build/psbt/validation.js +1 -1
  206. package/build/psbt/validation.js.map +1 -1
  207. package/build/psbt.d.ts +26 -40
  208. package/build/psbt.d.ts.map +1 -1
  209. package/build/psbt.js +180 -808
  210. package/build/psbt.js.map +1 -1
  211. package/build/script.d.ts.map +1 -1
  212. package/build/script.js +4 -4
  213. package/build/script.js.map +1 -1
  214. package/build/transaction.d.ts +4 -4
  215. package/build/transaction.d.ts.map +1 -1
  216. package/build/transaction.js +6 -5
  217. package/build/transaction.js.map +1 -1
  218. package/build/tsconfig.build.tsbuildinfo +1 -1
  219. package/build/types.d.ts +5 -3
  220. package/build/types.d.ts.map +1 -1
  221. package/build/types.js +14 -25
  222. package/build/types.js.map +1 -1
  223. package/build/workers/WorkerSigningPool.d.ts +24 -17
  224. package/build/workers/WorkerSigningPool.d.ts.map +1 -1
  225. package/build/workers/WorkerSigningPool.js +36 -25
  226. package/build/workers/WorkerSigningPool.js.map +1 -1
  227. package/build/workers/WorkerSigningPool.node.d.ts +19 -12
  228. package/build/workers/WorkerSigningPool.node.d.ts.map +1 -1
  229. package/build/workers/WorkerSigningPool.node.js +60 -28
  230. package/build/workers/WorkerSigningPool.node.js.map +1 -1
  231. package/build/workers/WorkerSigningPool.sequential.d.ts +76 -0
  232. package/build/workers/WorkerSigningPool.sequential.d.ts.map +1 -0
  233. package/build/workers/WorkerSigningPool.sequential.js +160 -0
  234. package/build/workers/WorkerSigningPool.sequential.js.map +1 -0
  235. package/build/workers/WorkerSigningPool.worklet.d.ts +79 -0
  236. package/build/workers/WorkerSigningPool.worklet.d.ts.map +1 -0
  237. package/build/workers/WorkerSigningPool.worklet.js +390 -0
  238. package/build/workers/WorkerSigningPool.worklet.js.map +1 -0
  239. package/build/workers/index.browser.d.ts +24 -0
  240. package/build/workers/index.browser.d.ts.map +1 -0
  241. package/build/workers/index.browser.js +30 -0
  242. package/build/workers/index.browser.js.map +1 -0
  243. package/build/workers/index.d.ts +6 -18
  244. package/build/workers/index.d.ts.map +1 -1
  245. package/build/workers/index.js +12 -14
  246. package/build/workers/index.js.map +1 -1
  247. package/build/workers/index.node.d.ts +38 -0
  248. package/build/workers/index.node.d.ts.map +1 -0
  249. package/build/workers/index.node.js +45 -0
  250. package/build/workers/index.node.js.map +1 -0
  251. package/build/workers/index.react-native.d.ts +28 -0
  252. package/build/workers/index.react-native.d.ts.map +1 -0
  253. package/build/workers/index.react-native.js +67 -0
  254. package/build/workers/index.react-native.js.map +1 -0
  255. package/build/workers/index.shared.d.ts +15 -0
  256. package/build/workers/index.shared.d.ts.map +1 -0
  257. package/build/workers/index.shared.js +20 -0
  258. package/build/workers/index.shared.js.map +1 -0
  259. package/build/workers/psbt-parallel.d.ts +2 -3
  260. package/build/workers/psbt-parallel.d.ts.map +1 -1
  261. package/build/workers/psbt-parallel.js +4 -4
  262. package/build/workers/psbt-parallel.js.map +1 -1
  263. package/build/workers/types.d.ts +17 -0
  264. package/build/workers/types.d.ts.map +1 -1
  265. package/build/workers/types.js.map +1 -1
  266. package/package.json +48 -9
  267. package/src/address.ts +53 -21
  268. package/src/bech32utils.ts +3 -3
  269. package/src/block.ts +17 -10
  270. package/src/branded.ts +15 -13
  271. package/src/crypto.ts +1 -1
  272. package/src/ecc/context.ts +36 -136
  273. package/src/ecc/index.ts +2 -2
  274. package/src/ecc/types.ts +7 -145
  275. package/src/env.ts +239 -0
  276. package/src/index.ts +57 -22
  277. package/src/io/BinaryReader.ts +18 -18
  278. package/src/io/BinaryWriter.ts +43 -43
  279. package/src/io/hex.ts +2 -1
  280. package/src/io/index.ts +0 -3
  281. package/src/opcodes.ts +21 -4
  282. package/src/payments/bip341.ts +5 -7
  283. package/src/payments/embed.ts +19 -19
  284. package/src/payments/p2ms.ts +34 -27
  285. package/src/payments/p2op.ts +22 -22
  286. package/src/payments/p2pk.ts +22 -22
  287. package/src/payments/p2pkh.ts +28 -28
  288. package/src/payments/p2sh.ts +33 -30
  289. package/src/payments/p2tr.ts +40 -40
  290. package/src/payments/p2wpkh.ts +30 -30
  291. package/src/payments/p2wsh.ts +29 -29
  292. package/src/payments/types.ts +1 -1
  293. package/src/psbt/PsbtCache.ts +325 -0
  294. package/src/psbt/PsbtFinalizer.ts +213 -0
  295. package/src/psbt/PsbtSigner.ts +302 -0
  296. package/src/psbt/PsbtTransaction.ts +82 -0
  297. package/src/psbt/bip371.ts +7 -3
  298. package/src/psbt/psbtutils.ts +1 -1
  299. package/src/psbt/types.ts +5 -94
  300. package/src/psbt/validation.ts +5 -12
  301. package/src/psbt.ts +376 -1201
  302. package/src/script.ts +6 -9
  303. package/src/transaction.ts +19 -15
  304. package/src/types.ts +33 -45
  305. package/src/workers/WorkerSigningPool.node.ts +72 -36
  306. package/src/workers/WorkerSigningPool.sequential.ts +191 -0
  307. package/src/workers/WorkerSigningPool.ts +48 -39
  308. package/src/workers/WorkerSigningPool.worklet.ts +522 -0
  309. package/src/workers/index.browser.ts +34 -0
  310. package/src/workers/index.node.ts +50 -0
  311. package/src/workers/index.react-native.ts +110 -0
  312. package/src/workers/index.shared.ts +58 -0
  313. package/src/workers/index.ts +14 -65
  314. package/src/workers/psbt-parallel.ts +8 -13
  315. package/src/workers/types.ts +26 -1
  316. package/test/address.spec.ts +2 -2
  317. package/test/bitcoin.core.spec.ts +5 -2
  318. package/test/browser/payments.spec.ts +151 -0
  319. package/test/browser/psbt.spec.ts +1510 -0
  320. package/test/browser/script.spec.ts +223 -0
  321. package/test/browser/setup.ts +13 -0
  322. package/test/browser/workers-signing.spec.ts +537 -0
  323. package/test/crypto.spec.ts +2 -2
  324. package/test/env.spec.ts +418 -0
  325. package/test/fixtures/core/base58_encode_decode.json +12 -48
  326. package/test/fixtures/core/base58_keys_invalid.json +50 -150
  327. package/test/fixtures/core/sighash.json +1 -3
  328. package/test/fixtures/core/tx_valid.json +133 -501
  329. package/test/fixtures/embed.json +3 -11
  330. package/test/fixtures/p2ms.json +21 -91
  331. package/test/fixtures/p2pk.json +5 -24
  332. package/test/fixtures/p2pkh.json +7 -36
  333. package/test/fixtures/p2sh.json +8 -54
  334. package/test/fixtures/p2tr.json +2 -6
  335. package/test/fixtures/p2wpkh.json +7 -36
  336. package/test/fixtures/p2wsh.json +14 -59
  337. package/test/fixtures/psbt.json +2 -6
  338. package/test/fixtures/script.json +12 -48
  339. package/test/integration/addresses.spec.ts +11 -5
  340. package/test/integration/bip32.spec.ts +1 -1
  341. package/test/integration/cltv.spec.ts +10 -6
  342. package/test/integration/csv.spec.ts +10 -9
  343. package/test/integration/payments.spec.ts +8 -4
  344. package/test/integration/taproot.spec.ts +26 -6
  345. package/test/integration/transactions.spec.ts +22 -8
  346. package/test/payments.spec.ts +1 -1
  347. package/test/payments.utils.ts +1 -1
  348. package/test/psbt.spec.ts +250 -64
  349. package/test/script_signature.spec.ts +1 -1
  350. package/test/transaction.spec.ts +18 -5
  351. package/test/tsconfig.json +6 -20
  352. package/test/workers-pool.spec.ts +65 -23
  353. package/test/workers-sequential.spec.ts +669 -0
  354. package/test/workers-signing.spec.ts +7 -3
  355. package/test/workers-worklet.spec.ts +500 -0
  356. package/test/workers.spec.ts +6 -7
  357. package/typedoc.json +39 -0
  358. package/vite.config.browser.ts +31 -6
  359. package/vitest.config.browser.ts +68 -0
  360. package/browser/ecpair.d.ts +0 -99
  361. package/browser/io/MemoryPool.d.ts +0 -220
  362. package/browser/io/MemoryPool.d.ts.map +0 -1
  363. package/build/io/MemoryPool.d.ts +0 -220
  364. package/build/io/MemoryPool.d.ts.map +0 -1
  365. package/build/io/MemoryPool.js +0 -309
  366. package/build/io/MemoryPool.js.map +0 -1
  367. package/src/ecpair.d.ts +0 -99
  368. package/src/io/MemoryPool.ts +0 -343
  369. package/test/taproot-cache.spec.ts +0 -694
@@ -1,99 +0,0 @@
1
- /**
2
- * Ambient module declaration for ecpair.
3
- *
4
- * The upstream ecpair@3 .d.ts files depend on valibot@^0.37 type-level APIs.
5
- * When a different valibot major is hoisted (e.g. v1.x required by bip32),
6
- * @typescript-eslint resolves valibot from the project root instead of
7
- * ecpair's nested node_modules, turning every ecpair type into an error type.
8
- *
9
- * This local declaration re-exports the subset of ecpair's public API that
10
- * this project actually uses, without any valibot dependency.
11
- */
12
- declare module 'ecpair' {
13
- interface Network {
14
- messagePrefix: string | Uint8Array;
15
- bech32: string;
16
- bip32: {
17
- public: number;
18
- private: number;
19
- };
20
- pubKeyHash: number;
21
- scriptHash: number;
22
- wif: number;
23
- }
24
-
25
- interface Signer {
26
- publicKey: Uint8Array;
27
- network?: unknown;
28
- sign(hash: Uint8Array, lowR?: boolean): Uint8Array;
29
- }
30
-
31
- interface SignerAsync {
32
- publicKey: Uint8Array;
33
- network?: unknown;
34
- sign(hash: Uint8Array, lowR?: boolean): Promise<Uint8Array>;
35
- }
36
-
37
- interface ECPairInterface extends Signer {
38
- compressed: boolean;
39
- network: Network;
40
- lowR: boolean;
41
- privateKey?: Uint8Array;
42
- toWIF(): string;
43
- tweak(t: Uint8Array): ECPairInterface;
44
- verify(hash: Uint8Array, signature: Uint8Array): boolean;
45
- verifySchnorr(hash: Uint8Array, signature: Uint8Array): boolean;
46
- signSchnorr(hash: Uint8Array): Uint8Array;
47
- }
48
-
49
- interface ECPairOptions {
50
- compressed?: boolean;
51
- network?: Network;
52
- rng?: (arg?: number) => Uint8Array;
53
- }
54
-
55
- interface ECPairAPI {
56
- isPoint(maybePoint: unknown): boolean;
57
- fromPrivateKey(buffer: Uint8Array, options?: ECPairOptions): ECPairInterface;
58
- fromPublicKey(buffer: Uint8Array, options?: ECPairOptions): ECPairInterface;
59
- fromWIF(wifString: string, network?: Network | Network[]): ECPairInterface;
60
- makeRandom(options?: ECPairOptions): ECPairInterface;
61
- }
62
-
63
- interface TinySecp256k1Interface {
64
- isPoint(p: Uint8Array): boolean;
65
- pointCompress(p: Uint8Array, compressed?: boolean): Uint8Array;
66
- isPrivate(d: Uint8Array): boolean;
67
- pointFromScalar(d: Uint8Array, compressed?: boolean): Uint8Array | null;
68
- xOnlyPointAddTweak(
69
- p: Uint8Array,
70
- tweak: Uint8Array,
71
- ): { parity: 1 | 0; xOnlyPubkey: Uint8Array } | null;
72
- privateAdd(d: Uint8Array, tweak: Uint8Array): Uint8Array | null;
73
- privateNegate(d: Uint8Array): Uint8Array;
74
- sign(h: Uint8Array, d: Uint8Array, e?: Uint8Array): Uint8Array;
75
- signSchnorr?(h: Uint8Array, d: Uint8Array, e?: Uint8Array): Uint8Array;
76
- verify(h: Uint8Array, Q: Uint8Array, signature: Uint8Array, strict?: boolean): boolean;
77
- verifySchnorr?(h: Uint8Array, Q: Uint8Array, signature: Uint8Array): boolean;
78
- }
79
-
80
- const networks: {
81
- bitcoin: Network;
82
- testnet: Network;
83
- };
84
-
85
- function ECPairFactory(ecc: TinySecp256k1Interface): ECPairAPI;
86
- export default ECPairFactory;
87
-
88
- export {
89
- ECPairFactory,
90
- Signer,
91
- SignerAsync,
92
- ECPairAPI,
93
- ECPairInterface,
94
- ECPairOptions,
95
- TinySecp256k1Interface,
96
- Network,
97
- networks,
98
- };
99
- }
@@ -1,220 +0,0 @@
1
- /**
2
- * Memory pool using SharedArrayBuffer for zero-allocation operations.
3
- *
4
- * Provides thread-safe memory allocation using Atomics for concurrent access.
5
- * Ideal for parsing operations where temporary buffers are needed.
6
- *
7
- * @packageDocumentation
8
- */
9
- /**
10
- * Thread-safe memory pool using SharedArrayBuffer.
11
- *
12
- * Allocates memory from a pre-allocated SharedArrayBuffer pool,
13
- * eliminating garbage collection pressure from repeated allocations.
14
- *
15
- * Uses Atomics for thread-safe allocation when used with Workers.
16
- *
17
- * @example
18
- * ```typescript
19
- * import { MemoryPool } from '@btc-vision/bitcoin';
20
- *
21
- * // Create a 1MB pool
22
- * const pool = new MemoryPool(1024 * 1024);
23
- *
24
- * // Allocate memory for transaction parsing
25
- * const txBuffer = pool.alloc(500);
26
- * // ... use txBuffer ...
27
- *
28
- * // Reset pool when done (all allocations become invalid)
29
- * pool.reset();
30
- * ```
31
- */
32
- export declare class MemoryPool {
33
- #private;
34
- /**
35
- * Creates a new MemoryPool.
36
- *
37
- * @param size - Size of the pool in bytes (default 4MB)
38
- *
39
- * @example
40
- * ```typescript
41
- * import { MemoryPool } from '@btc-vision/bitcoin';
42
- *
43
- * // 4MB pool (default)
44
- * const pool = new MemoryPool();
45
- *
46
- * // 16MB pool
47
- * const largePool = new MemoryPool(16 * 1024 * 1024);
48
- * ```
49
- */
50
- constructor(size?: number);
51
- /**
52
- * Creates a MemoryPool from an existing SharedArrayBuffer.
53
- *
54
- * Useful for sharing a pool between Workers.
55
- *
56
- * @param buffer - Existing SharedArrayBuffer
57
- * @returns A new MemoryPool instance wrapping the buffer
58
- *
59
- * @example
60
- * ```typescript
61
- * // Main thread
62
- * const pool = new MemoryPool(1024 * 1024);
63
- * worker.postMessage({ buffer: pool.sharedBuffer });
64
- *
65
- * // Worker thread
66
- * self.onmessage = (e) => {
67
- * const pool = MemoryPool.fromSharedBuffer(e.data.buffer);
68
- * const mem = pool.alloc(100);
69
- * };
70
- * ```
71
- */
72
- static fromSharedBuffer(buffer: SharedArrayBuffer): MemoryPool;
73
- /**
74
- * Total capacity of the pool in bytes.
75
- */
76
- get capacity(): number;
77
- /**
78
- * Current allocation offset (bytes used).
79
- *
80
- * Uses Atomics for thread-safe reading.
81
- */
82
- get used(): number;
83
- /**
84
- * Remaining available bytes.
85
- */
86
- get available(): number;
87
- /**
88
- * The underlying SharedArrayBuffer.
89
- *
90
- * Can be transferred to Workers for shared memory access.
91
- */
92
- get sharedBuffer(): SharedArrayBuffer;
93
- /**
94
- * Allocates memory from the pool.
95
- *
96
- * Thread-safe using Atomics.add for concurrent access.
97
- *
98
- * @param size - Number of bytes to allocate
99
- * @returns Uint8Array view into the pool
100
- * @throws RangeError if pool is exhausted
101
- *
102
- * @example
103
- * ```typescript
104
- * const pool = new MemoryPool(1024);
105
- * const buf1 = pool.alloc(100); // First 100 bytes
106
- * const buf2 = pool.alloc(200); // Next 200 bytes
107
- * ```
108
- */
109
- alloc(size: number): Uint8Array;
110
- /**
111
- * Allocates memory and fills it with zeros.
112
- *
113
- * @param size - Number of bytes to allocate
114
- * @returns Uint8Array view into the pool, filled with zeros
115
- * @throws RangeError if pool is exhausted
116
- */
117
- allocZeroed(size: number): Uint8Array;
118
- /**
119
- * Allocates memory for a specific typed array.
120
- *
121
- * @param length - Number of elements
122
- * @param bytesPerElement - Size of each element in bytes
123
- * @returns Uint8Array view (use constructor of target type on underlying buffer)
124
- * @throws RangeError if pool is exhausted
125
- *
126
- * @example
127
- * ```typescript
128
- * const pool = new MemoryPool(1024);
129
- * const bytes = pool.allocTyped(10, 4); // 40 bytes for 10 Uint32
130
- * const u32View = new Uint32Array(bytes.buffer, bytes.byteOffset, 10);
131
- * ```
132
- */
133
- allocTyped(length: number, bytesPerElement: number): Uint8Array;
134
- /**
135
- * Resets the pool, making all memory available again.
136
- *
137
- * WARNING: All previously allocated views become invalid.
138
- * Only call when you're sure no references are held.
139
- *
140
- * Thread-safe using Atomics.store.
141
- *
142
- * @example
143
- * ```typescript
144
- * const pool = new MemoryPool(1024);
145
- * const buf = pool.alloc(100);
146
- * // ... use buf ...
147
- * pool.reset(); // buf is now invalid!
148
- * ```
149
- */
150
- reset(): void;
151
- /**
152
- * Checks if the pool can accommodate an allocation.
153
- *
154
- * @param size - Number of bytes needed
155
- * @returns True if allocation would succeed
156
- */
157
- canAlloc(size: number): boolean;
158
- }
159
- /**
160
- * Non-shared memory pool using regular ArrayBuffer.
161
- *
162
- * Use when SharedArrayBuffer is not available (e.g., browsers without
163
- * proper COOP/COEP headers) or when thread-safety is not needed.
164
- *
165
- * @example
166
- * ```typescript
167
- * import { SimpleMemoryPool } from '@btc-vision/bitcoin';
168
- *
169
- * const pool = new SimpleMemoryPool(1024 * 1024);
170
- * const buf = pool.alloc(100);
171
- * ```
172
- */
173
- export declare class SimpleMemoryPool {
174
- #private;
175
- /**
176
- * Creates a new SimpleMemoryPool.
177
- *
178
- * @param size - Size of the pool in bytes
179
- */
180
- constructor(size: number);
181
- /**
182
- * Total capacity of the pool in bytes.
183
- */
184
- get capacity(): number;
185
- /**
186
- * Current allocation offset (bytes used).
187
- */
188
- get used(): number;
189
- /**
190
- * Remaining available bytes.
191
- */
192
- get available(): number;
193
- /**
194
- * Allocates memory from the pool.
195
- *
196
- * @param size - Number of bytes to allocate
197
- * @returns Uint8Array view into the pool
198
- * @throws RangeError if pool is exhausted
199
- */
200
- alloc(size: number): Uint8Array;
201
- /**
202
- * Allocates memory and fills it with zeros.
203
- *
204
- * @param size - Number of bytes to allocate
205
- * @returns Uint8Array view into the pool, filled with zeros
206
- */
207
- allocZeroed(size: number): Uint8Array;
208
- /**
209
- * Resets the pool, making all memory available again.
210
- */
211
- reset(): void;
212
- /**
213
- * Checks if the pool can accommodate an allocation.
214
- *
215
- * @param size - Number of bytes needed
216
- * @returns True if allocation would succeed
217
- */
218
- canAlloc(size: number): boolean;
219
- }
220
- //# sourceMappingURL=MemoryPool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MemoryPool.d.ts","sourceRoot":"","sources":["../../src/io/MemoryPool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,UAAU;;IAsBnB;;;;;;;;;;;;;;;OAeG;gBACgB,IAAI,GAAE,MAAwB;IASjD;;;;;;;;;;;;;;;;;;;;OAoBG;WACW,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU;IAarE;;OAEG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;;OAIG;IACH,IAAW,YAAY,IAAI,iBAAiB,CAE3C;IAED;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAmBtC;;;;;;OAMG;IACI,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAM5C;;;;;;;;;;;;;;OAcG;IACI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,UAAU;IAItE;;;;;;;;;;;;;;;OAeG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;;OAKG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGzC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAgB;;IAIzB;;;;OAIG;gBACgB,IAAI,EAAE,MAAM;IAI/B;;OAEG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;;;;OAMG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAgBtC;;;;;OAKG;IACI,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAM5C;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;;OAKG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGzC"}
@@ -1,220 +0,0 @@
1
- /**
2
- * Memory pool using SharedArrayBuffer for zero-allocation operations.
3
- *
4
- * Provides thread-safe memory allocation using Atomics for concurrent access.
5
- * Ideal for parsing operations where temporary buffers are needed.
6
- *
7
- * @packageDocumentation
8
- */
9
- /**
10
- * Thread-safe memory pool using SharedArrayBuffer.
11
- *
12
- * Allocates memory from a pre-allocated SharedArrayBuffer pool,
13
- * eliminating garbage collection pressure from repeated allocations.
14
- *
15
- * Uses Atomics for thread-safe allocation when used with Workers.
16
- *
17
- * @example
18
- * ```typescript
19
- * import { MemoryPool } from '@btc-vision/bitcoin';
20
- *
21
- * // Create a 1MB pool
22
- * const pool = new MemoryPool(1024 * 1024);
23
- *
24
- * // Allocate memory for transaction parsing
25
- * const txBuffer = pool.alloc(500);
26
- * // ... use txBuffer ...
27
- *
28
- * // Reset pool when done (all allocations become invalid)
29
- * pool.reset();
30
- * ```
31
- */
32
- export declare class MemoryPool {
33
- #private;
34
- /**
35
- * Creates a new MemoryPool.
36
- *
37
- * @param size - Size of the pool in bytes (default 4MB)
38
- *
39
- * @example
40
- * ```typescript
41
- * import { MemoryPool } from '@btc-vision/bitcoin';
42
- *
43
- * // 4MB pool (default)
44
- * const pool = new MemoryPool();
45
- *
46
- * // 16MB pool
47
- * const largePool = new MemoryPool(16 * 1024 * 1024);
48
- * ```
49
- */
50
- constructor(size?: number);
51
- /**
52
- * Creates a MemoryPool from an existing SharedArrayBuffer.
53
- *
54
- * Useful for sharing a pool between Workers.
55
- *
56
- * @param buffer - Existing SharedArrayBuffer
57
- * @returns A new MemoryPool instance wrapping the buffer
58
- *
59
- * @example
60
- * ```typescript
61
- * // Main thread
62
- * const pool = new MemoryPool(1024 * 1024);
63
- * worker.postMessage({ buffer: pool.sharedBuffer });
64
- *
65
- * // Worker thread
66
- * self.onmessage = (e) => {
67
- * const pool = MemoryPool.fromSharedBuffer(e.data.buffer);
68
- * const mem = pool.alloc(100);
69
- * };
70
- * ```
71
- */
72
- static fromSharedBuffer(buffer: SharedArrayBuffer): MemoryPool;
73
- /**
74
- * Total capacity of the pool in bytes.
75
- */
76
- get capacity(): number;
77
- /**
78
- * Current allocation offset (bytes used).
79
- *
80
- * Uses Atomics for thread-safe reading.
81
- */
82
- get used(): number;
83
- /**
84
- * Remaining available bytes.
85
- */
86
- get available(): number;
87
- /**
88
- * The underlying SharedArrayBuffer.
89
- *
90
- * Can be transferred to Workers for shared memory access.
91
- */
92
- get sharedBuffer(): SharedArrayBuffer;
93
- /**
94
- * Allocates memory from the pool.
95
- *
96
- * Thread-safe using Atomics.add for concurrent access.
97
- *
98
- * @param size - Number of bytes to allocate
99
- * @returns Uint8Array view into the pool
100
- * @throws RangeError if pool is exhausted
101
- *
102
- * @example
103
- * ```typescript
104
- * const pool = new MemoryPool(1024);
105
- * const buf1 = pool.alloc(100); // First 100 bytes
106
- * const buf2 = pool.alloc(200); // Next 200 bytes
107
- * ```
108
- */
109
- alloc(size: number): Uint8Array;
110
- /**
111
- * Allocates memory and fills it with zeros.
112
- *
113
- * @param size - Number of bytes to allocate
114
- * @returns Uint8Array view into the pool, filled with zeros
115
- * @throws RangeError if pool is exhausted
116
- */
117
- allocZeroed(size: number): Uint8Array;
118
- /**
119
- * Allocates memory for a specific typed array.
120
- *
121
- * @param length - Number of elements
122
- * @param bytesPerElement - Size of each element in bytes
123
- * @returns Uint8Array view (use constructor of target type on underlying buffer)
124
- * @throws RangeError if pool is exhausted
125
- *
126
- * @example
127
- * ```typescript
128
- * const pool = new MemoryPool(1024);
129
- * const bytes = pool.allocTyped(10, 4); // 40 bytes for 10 Uint32
130
- * const u32View = new Uint32Array(bytes.buffer, bytes.byteOffset, 10);
131
- * ```
132
- */
133
- allocTyped(length: number, bytesPerElement: number): Uint8Array;
134
- /**
135
- * Resets the pool, making all memory available again.
136
- *
137
- * WARNING: All previously allocated views become invalid.
138
- * Only call when you're sure no references are held.
139
- *
140
- * Thread-safe using Atomics.store.
141
- *
142
- * @example
143
- * ```typescript
144
- * const pool = new MemoryPool(1024);
145
- * const buf = pool.alloc(100);
146
- * // ... use buf ...
147
- * pool.reset(); // buf is now invalid!
148
- * ```
149
- */
150
- reset(): void;
151
- /**
152
- * Checks if the pool can accommodate an allocation.
153
- *
154
- * @param size - Number of bytes needed
155
- * @returns True if allocation would succeed
156
- */
157
- canAlloc(size: number): boolean;
158
- }
159
- /**
160
- * Non-shared memory pool using regular ArrayBuffer.
161
- *
162
- * Use when SharedArrayBuffer is not available (e.g., browsers without
163
- * proper COOP/COEP headers) or when thread-safety is not needed.
164
- *
165
- * @example
166
- * ```typescript
167
- * import { SimpleMemoryPool } from '@btc-vision/bitcoin';
168
- *
169
- * const pool = new SimpleMemoryPool(1024 * 1024);
170
- * const buf = pool.alloc(100);
171
- * ```
172
- */
173
- export declare class SimpleMemoryPool {
174
- #private;
175
- /**
176
- * Creates a new SimpleMemoryPool.
177
- *
178
- * @param size - Size of the pool in bytes
179
- */
180
- constructor(size: number);
181
- /**
182
- * Total capacity of the pool in bytes.
183
- */
184
- get capacity(): number;
185
- /**
186
- * Current allocation offset (bytes used).
187
- */
188
- get used(): number;
189
- /**
190
- * Remaining available bytes.
191
- */
192
- get available(): number;
193
- /**
194
- * Allocates memory from the pool.
195
- *
196
- * @param size - Number of bytes to allocate
197
- * @returns Uint8Array view into the pool
198
- * @throws RangeError if pool is exhausted
199
- */
200
- alloc(size: number): Uint8Array;
201
- /**
202
- * Allocates memory and fills it with zeros.
203
- *
204
- * @param size - Number of bytes to allocate
205
- * @returns Uint8Array view into the pool, filled with zeros
206
- */
207
- allocZeroed(size: number): Uint8Array;
208
- /**
209
- * Resets the pool, making all memory available again.
210
- */
211
- reset(): void;
212
- /**
213
- * Checks if the pool can accommodate an allocation.
214
- *
215
- * @param size - Number of bytes needed
216
- * @returns True if allocation would succeed
217
- */
218
- canAlloc(size: number): boolean;
219
- }
220
- //# sourceMappingURL=MemoryPool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MemoryPool.d.ts","sourceRoot":"","sources":["../../src/io/MemoryPool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,UAAU;;IAsBnB;;;;;;;;;;;;;;;OAeG;gBACgB,IAAI,GAAE,MAAwB;IASjD;;;;;;;;;;;;;;;;;;;;OAoBG;WACW,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU;IAarE;;OAEG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;;OAIG;IACH,IAAW,YAAY,IAAI,iBAAiB,CAE3C;IAED;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAmBtC;;;;;;OAMG;IACI,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAM5C;;;;;;;;;;;;;;OAcG;IACI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,UAAU;IAItE;;;;;;;;;;;;;;;OAeG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;;OAKG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGzC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAgB;;IAIzB;;;;OAIG;gBACgB,IAAI,EAAE,MAAM;IAI/B;;OAEG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;;;;OAMG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAgBtC;;;;;OAKG;IACI,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAM5C;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;;OAKG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGzC"}