@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
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@btc-vision/bitcoin",
3
3
  "type": "module",
4
- "version": "7.0.0-alpha.0",
4
+ "version": "7.0.0-alpha.10",
5
5
  "sideEffects": false,
6
- "overrides": {
7
- "ecpair": {
8
- "valibot": "^1.2.0"
9
- }
10
- },
11
6
  "description": "Client-side Bitcoin JavaScript library",
12
7
  "engines": {
13
8
  "node": ">=24.0.0"
14
9
  },
15
10
  "exports": {
16
11
  ".": {
12
+ "react-native": {
13
+ "types": "./build/index.d.ts",
14
+ "import": "./build/index.js",
15
+ "default": "./build/index.js"
16
+ },
17
17
  "browser": {
18
18
  "types": "./browser/index.d.ts",
19
19
  "import": "./browser/index.js",
@@ -33,6 +33,26 @@
33
33
  "import": "./browser/index.js",
34
34
  "default": "./browser/index.js"
35
35
  },
36
+ "./workers": {
37
+ "react-native": {
38
+ "types": "./build/workers/index.react-native.d.ts",
39
+ "import": "./build/workers/index.react-native.js",
40
+ "default": "./build/workers/index.react-native.js"
41
+ },
42
+ "browser": {
43
+ "types": "./browser/workers/index.d.ts",
44
+ "import": "./browser/workers/index.js",
45
+ "default": "./browser/workers/index.js"
46
+ },
47
+ "node": {
48
+ "types": "./build/workers/index.node.d.ts",
49
+ "import": "./build/workers/index.node.js",
50
+ "default": "./build/workers/index.node.js"
51
+ },
52
+ "types": "./build/workers/index.d.ts",
53
+ "import": "./build/workers/index.js",
54
+ "default": "./build/workers/index.js"
55
+ },
36
56
  "./address": {
37
57
  "types": "./build/address.d.ts",
38
58
  "import": "./build/address.js"
@@ -89,6 +109,8 @@
89
109
  "browser": {
90
110
  "./build/index.js": "./browser/index.js",
91
111
  "./build/index.d.ts": "./browser/index.d.ts",
112
+ "./build/workers/index.node.js": "./browser/workers/index.js",
113
+ "./build/workers/index.node.d.ts": "./browser/workers/index.d.ts",
92
114
  "Buffer": "buffer",
93
115
  "crypto": "./src/crypto/crypto-browser.js",
94
116
  "stream": "stream-browserify",
@@ -122,7 +144,7 @@
122
144
  "audit": "better-npm-audit audit -l high",
123
145
  "clean": "rimraf build",
124
146
  "coverage": "vitest run --coverage",
125
- "doc": "typedoc",
147
+ "doc": "typedoc --options typedoc.json",
126
148
  "format:ci": "npm run prettier -- --check && npm run prettier -- --check",
127
149
  "gitdiff:ci": "npm run build && git diff --exit-code",
128
150
  "integration": "vitest run --config vitest.config.integration.ts",
@@ -132,6 +154,8 @@
132
154
  "test": "npm run build && npm run lint && vitest run",
133
155
  "test:watch": "vitest",
134
156
  "unit": "vitest run",
157
+ "test:browser": "vitest run --config vitest.config.browser.ts",
158
+ "test:browser:watch": "vitest --config vitest.config.browser.ts",
135
159
  "bench": "vitest bench benchmark/",
136
160
  "bench:run": "npx tsx benchmark/signing.bench.ts",
137
161
  "check:circular": "madge --circular --extensions ts,tsx src/",
@@ -143,6 +167,8 @@
143
167
  "@types/bs58check": "^3.0.1",
144
168
  "@types/node": "^25.0.10",
145
169
  "@types/randombytes": "^2.0.3",
170
+ "@vitest/browser": "^4.0.18",
171
+ "@vitest/browser-playwright": "^4.0.18",
146
172
  "@vitest/coverage-v8": "^4.0.18",
147
173
  "better-npm-audit": "^3.11.0",
148
174
  "bip39": "^3.1.0",
@@ -150,12 +176,12 @@
150
176
  "bip68": "^1.0.4",
151
177
  "bs58": "^6.0.0",
152
178
  "dhttp": "^3.0.3",
153
- "ecpair": "^3.0.0",
154
179
  "eslint": "^9.39.2",
155
180
  "https-browserify": "^1.0.0",
156
181
  "madge": "^8.0.0",
157
182
  "minimaldata": "^1.0.2",
158
183
  "os-browserify": "^0.3.0",
184
+ "playwright": "^1.58.0",
159
185
  "prettier": "^3.8.1",
160
186
  "randombytes": "^2.1.0",
161
187
  "regtest-client": "0.2.1",
@@ -165,15 +191,27 @@
165
191
  "tiny-secp256k1": "^2.2.4",
166
192
  "ts-node": "^10.9.2",
167
193
  "typedoc": "^0.28.16",
194
+ "typedoc-material-theme": "^1.4.1",
168
195
  "typescript": "^5.9.3",
169
196
  "typescript-eslint": "^8.53.1",
170
197
  "vite": "^7.3.1",
171
198
  "vite-plugin-dts": "^4.5.4",
172
199
  "vite-plugin-node-polyfills": "^0.25.0",
200
+ "vite-plugin-top-level-await": "^1.6.0",
201
+ "vite-plugin-wasm": "^3.5.0",
173
202
  "vitest": "^4.0.18"
174
203
  },
204
+ "peerDependencies": {
205
+ "react-native-worklets": ">=0.7.0"
206
+ },
207
+ "peerDependenciesMeta": {
208
+ "react-native-worklets": {
209
+ "optional": true
210
+ }
211
+ },
175
212
  "dependencies": {
176
- "@btc-vision/bip32": "^6.1.0",
213
+ "@btc-vision/bip32": "^7.0.2",
214
+ "@btc-vision/ecpair": "^4.0.2",
177
215
  "@btc-vision/logger": "^1.0.8",
178
216
  "@noble/hashes": "^2.0.1",
179
217
  "@noble/secp256k1": "^3.0.0",
@@ -183,6 +221,7 @@
183
221
  "browserify-zlib": "^0.2.0",
184
222
  "bs58check": "^4.0.0",
185
223
  "buffer": "^6.0.3",
224
+ "esbuild": "^0.27.2",
186
225
  "process": "^0.11.10",
187
226
  "varuint-bitcoin": "^2.0.0"
188
227
  }
package/src/address.ts CHANGED
@@ -9,10 +9,10 @@
9
9
  */
10
10
  import { bech32, bech32m } from 'bech32';
11
11
  import * as bs58check from 'bs58check';
12
- import { fromBech32, type Bech32Result } from './bech32utils.js';
12
+ import { type Bech32Result, fromBech32 } from './bech32utils.js';
13
13
  import { alloc } from './io/index.js';
14
- import * as networks from './networks.js';
15
14
  import type { Network } from './networks.js';
15
+ import * as networks from './networks.js';
16
16
  import { p2op } from './payments/p2op.js';
17
17
  import { p2pkh } from './payments/p2pkh.js';
18
18
  import { p2sh } from './payments/p2sh.js';
@@ -21,7 +21,14 @@ import { p2wpkh } from './payments/p2wpkh.js';
21
21
  import { p2wsh } from './payments/p2wsh.js';
22
22
  import * as bscript from './script.js';
23
23
  import { opcodes } from './script.js';
24
- import { isBytes20, isUInt8, toBytes20, toBytes32, type Bytes20, type XOnlyPublicKey, type Script } from './types.js';
24
+ import {
25
+ type Bytes20,
26
+ isBytes20,
27
+ isUInt8,
28
+ toBytes20,
29
+ toBytes32,
30
+ type XOnlyPublicKey,
31
+ } from './types.js';
25
32
 
26
33
  export { fromBech32, type Bech32Result };
27
34
 
@@ -180,27 +187,51 @@ export function toBech32(
180
187
  }
181
188
 
182
189
  /**
183
- * decode address from output script with network, return address if matched
190
+ * decode address from output script with network, return address if matched.
191
+ *
192
+ * Uses fast byte-pattern matching for common script types (P2PKH, P2SH,
193
+ * P2WPKH, P2WSH, P2TR) to avoid constructing payment objects and catching
194
+ * exceptions. Falls back to payment constructors for exotic types.
184
195
  */
185
196
  export function fromOutputScript(output: Uint8Array, network?: Network): string {
186
- // TODO: Network
187
197
  network = network || networks.bitcoin;
198
+ const len = output.length;
199
+
200
+ // P2PKH: OP_DUP(0x76) OP_HASH160(0xa9) 0x14 <20-byte hash> OP_EQUALVERIFY(0x88) OP_CHECKSIG(0xac)
201
+ if (
202
+ len === 25 &&
203
+ output[0] === 0x76 &&
204
+ output[1] === 0xa9 &&
205
+ output[2] === 0x14 &&
206
+ output[23] === 0x88 &&
207
+ output[24] === 0xac
208
+ ) {
209
+ return toBase58Check(output.subarray(3, 23) as Bytes20, network.pubKeyHash);
210
+ }
188
211
 
189
- try {
190
- return p2pkh({ output: output as Script, network }).address as string;
191
- } catch (e) {}
192
- try {
193
- return p2sh({ output: output as Script, network }).address as string;
194
- } catch (e) {}
195
- try {
196
- return p2wpkh({ output: output as Script, network }).address as string;
197
- } catch (e) {}
198
- try {
199
- return p2wsh({ output: output as Script, network }).address as string;
200
- } catch (e) {}
201
- try {
202
- return p2tr({ output: output as Script, network }).address as string;
203
- } catch (e) {}
212
+ // P2SH: OP_HASH160(0xa9) 0x14 <20-byte hash> OP_EQUAL(0x87)
213
+ if (len === 23 && output[0] === 0xa9 && output[1] === 0x14 && output[22] === 0x87) {
214
+ return toBase58Check(output.subarray(2, 22) as Bytes20, network.scriptHash);
215
+ }
216
+
217
+ // P2WPKH: OP_0(0x00) 0x14 <20-byte hash>
218
+ if (len === 22 && output[0] === 0x00 && output[1] === 0x14) {
219
+ return toBech32(output.subarray(2, 22), 0, network.bech32);
220
+ }
221
+
222
+ // P2WSH: OP_0(0x00) 0x20 <32-byte hash>
223
+ if (len === 34 && output[0] === 0x00 && output[1] === 0x20) {
224
+ return toBech32(output.subarray(2, 34), 0, network.bech32);
225
+ }
226
+
227
+ // P2TR: OP_1(0x51) 0x20 <32-byte x-only pubkey>
228
+ if (len === 34 && output[0] === 0x51 && output[1] === 0x20) {
229
+ const words = bech32m.toWords(output.subarray(2, 34));
230
+ words.unshift(1);
231
+ return bech32m.encode(network.bech32, words);
232
+ }
233
+
234
+ // Fallback for exotic types
204
235
  try {
205
236
  return toFutureOPNetAddress(output, network);
206
237
  } catch (e) {}
@@ -282,7 +313,8 @@ export function toOutputScript(
282
313
  return p2wsh({ hash: toBytes32(decodeBech32.data) }).output as Uint8Array;
283
314
  } else if (decodeBech32.version === 1) {
284
315
  if (decodeBech32.data.length === 32)
285
- return p2tr({ pubkey: decodeBech32.data as XOnlyPublicKey }).output as Uint8Array;
316
+ return p2tr({ pubkey: decodeBech32.data as XOnlyPublicKey })
317
+ .output as Uint8Array;
286
318
  } else if (decodeBech32.version === FUTURE_OPNET_VERSION) {
287
319
  if (!network.bech32Opnet) throw new Error(address + ' has an invalid prefix');
288
320
  return p2op({
@@ -25,18 +25,18 @@ export function fromBech32(address: string): Bech32Result {
25
25
  } catch (e) {}
26
26
 
27
27
  if (result) {
28
- version = result.words[0];
28
+ version = result.words[0] as number;
29
29
  if (version !== 0) throw new TypeError(address + ' uses wrong encoding');
30
30
  } else {
31
31
  result = bech32m.decode(address);
32
- version = result.words[0];
32
+ version = result.words[0] as number;
33
33
  if (version === 0) throw new TypeError(address + ' uses wrong encoding');
34
34
  }
35
35
 
36
36
  const data = bech32.fromWords(result.words.slice(1));
37
37
 
38
38
  return {
39
- version: version!,
39
+ version: version,
40
40
  prefix: result.prefix,
41
41
  data: new Uint8Array(data),
42
42
  };
package/src/block.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import * as bcrypto from './crypto.js';
2
- import { BinaryReader, BinaryWriter, varuint, equals, fromHex, alloc, compare, toHex, reverse } from './io/index.js';
2
+ import {
3
+ alloc,
4
+ BinaryReader,
5
+ BinaryWriter,
6
+ compare,
7
+ equals,
8
+ fromHex,
9
+ reverse,
10
+ toHex,
11
+ varuint,
12
+ } from './io/index.js';
3
13
  import { fastMerkleRoot } from './merkle.js';
4
14
  import { Transaction } from './transaction.js';
5
15
  import type { Bytes32 } from './types.js';
@@ -70,10 +80,7 @@ export class Block {
70
80
  if (buffer.length === 80) return block;
71
81
 
72
82
  const readTransaction = (): Transaction => {
73
- const tx = Transaction.fromBuffer(
74
- reader.data.subarray(reader.offset),
75
- true,
76
- );
83
+ const tx = Transaction.fromBuffer(reader.data.subarray(reader.offset), true);
77
84
  reader.offset += tx.byteLength();
78
85
  return tx;
79
86
  };
@@ -138,11 +145,11 @@ export class Block {
138
145
  const rootHash = fastMerkleRoot(hashes, bcrypto.hash256);
139
146
 
140
147
  if (forWitness) {
141
- const witness = transactions[0]!.ins[0]!.witness![0]!;
148
+ const witness = transactions[0]!.ins[0]!.witness[0]!;
142
149
  const combined = new Uint8Array(rootHash.length + witness.length);
143
150
  combined.set(rootHash);
144
151
  combined.set(witness, rootHash.length);
145
- return bcrypto.hash256(combined) as Bytes32;
152
+ return bcrypto.hash256(combined);
146
153
  }
147
154
  return rootHash as Bytes32;
148
155
  }
@@ -158,9 +165,9 @@ export class Block {
158
165
  // There is no rule for the index of the output, so use filter to find it.
159
166
  // The root is prepended with 0xaa21a9ed so check for 0x6a24aa21a9ed
160
167
  // If multiple commits are found, the output with highest index is assumed.
161
- const witnessCommits = this.transactions[0]!.outs
162
- .filter((out) => equals(out.script.subarray(0, 6), WITNESS_COMMIT_PREFIX))
163
- .map((out) => out.script.subarray(6, 38));
168
+ const witnessCommits = this.transactions[0]!.outs.filter((out) =>
169
+ equals(out.script.subarray(0, 6), WITNESS_COMMIT_PREFIX),
170
+ ).map((out) => out.script.subarray(6, 38));
164
171
  if (witnessCommits.length === 0) return null;
165
172
  // Use the commit with the highest output (should only be one though)
166
173
  const result = witnessCommits[witnessCommits.length - 1];
package/src/branded.ts CHANGED
@@ -1,18 +1,20 @@
1
1
  /**
2
2
  * Branded type definitions for type-safe primitives.
3
3
  *
4
+ * Re-exported from @btc-vision/ecpair to ensure cross-package type compatibility.
5
+ *
4
6
  * @packageDocumentation
5
7
  */
6
-
7
- declare const __brand: unique symbol;
8
- type Brand<T, B extends string> = T & { readonly [__brand]: B };
9
-
10
- export type Bytes32 = Brand<Uint8Array, 'Bytes32'>;
11
- export type Bytes20 = Brand<Uint8Array, 'Bytes20'>;
12
- export type PublicKey = Brand<Uint8Array, 'PublicKey'>;
13
- export type XOnlyPublicKey = Brand<Uint8Array, 'XOnlyPublicKey'>;
14
- export type Satoshi = Brand<bigint, 'Satoshi'>;
15
- export type PrivateKey = Brand<Uint8Array, 'PrivateKey'>;
16
- export type Signature = Brand<Uint8Array, 'Signature'>;
17
- export type SchnorrSignature = Brand<Uint8Array, 'SchnorrSignature'>;
18
- export type Script = Brand<Uint8Array, 'Script'>;
8
+ export type {
9
+ Brand,
10
+ Bytes32,
11
+ Bytes20,
12
+ PublicKey,
13
+ XOnlyPublicKey,
14
+ Satoshi,
15
+ PrivateKey,
16
+ Signature,
17
+ SchnorrSignature,
18
+ MessageHash,
19
+ Script,
20
+ } from '@btc-vision/ecpair';
package/src/crypto.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  import { ripemd160 as _ripemd160, sha1 as _sha1 } from '@noble/hashes/legacy.js';
8
8
  import { sha256 as _sha256 } from '@noble/hashes/sha2.js';
9
9
  import { concat } from './io/index.js';
10
- import type { Bytes32, Bytes20 } from './types.js';
10
+ import type { Bytes20, Bytes32 } from './types.js';
11
11
 
12
12
  /**
13
13
  * Computes RIPEMD-160 hash of the input.
@@ -4,9 +4,8 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- import type { EccLib } from './types.js';
8
- import { fromHex, equals } from '../io/index.js';
9
- import type { Bytes32, XOnlyPublicKey } from '../types.js';
7
+ import type { CryptoBackend } from '@btc-vision/ecpair';
8
+ import { verifyCryptoBackend } from '@btc-vision/ecpair';
10
9
 
11
10
  /**
12
11
  * Context class for managing the ECC library instance.
@@ -15,10 +14,11 @@ import type { Bytes32, XOnlyPublicKey } from '../types.js';
15
14
  * @example
16
15
  * ```typescript
17
16
  * import { EccContext } from '@btc-vision/bitcoin';
18
- * import * as secp256k1 from 'tiny-secp256k1';
17
+ * import { createNobleBackend } from '@btc-vision/ecpair';
19
18
  *
20
19
  * // Initialize once at app startup
21
- * EccContext.init(secp256k1);
20
+ * const backend = createNobleBackend();
21
+ * EccContext.init(backend);
22
22
  *
23
23
  * // Get instance anywhere in your code
24
24
  * const ecc = EccContext.get();
@@ -29,30 +29,41 @@ import type { Bytes32, XOnlyPublicKey } from '../types.js';
29
29
  */
30
30
  export class EccContext {
31
31
  static #instance: EccContext | undefined;
32
- readonly #lib: EccLib;
32
+ readonly #lib: CryptoBackend;
33
33
 
34
- private constructor(lib: EccLib) {
34
+ private constructor(lib: CryptoBackend) {
35
35
  this.#lib = lib;
36
36
  }
37
37
 
38
+ /**
39
+ * The underlying ECC library instance.
40
+ */
41
+ get lib(): CryptoBackend {
42
+ return this.#lib;
43
+ }
44
+
38
45
  /**
39
46
  * Initializes the ECC context with the provided library.
40
47
  * The library is verified before being set as active.
41
48
  *
42
- * @param lib - The ECC library instance to initialize
49
+ * @param lib - The CryptoBackend instance to initialize
43
50
  * @returns The initialized EccContext instance
44
- * @throws Error if the ECC library fails verification
51
+ * @throws Error if the CryptoBackend fails verification
45
52
  *
46
53
  * @example
47
54
  * ```typescript
48
55
  * import { EccContext } from '@btc-vision/bitcoin';
49
- * import * as secp256k1 from 'tiny-secp256k1';
56
+ * import { createNobleBackend } from '@btc-vision/ecpair';
50
57
  *
51
- * const context = EccContext.init(secp256k1);
58
+ * const context = EccContext.init(createNobleBackend());
52
59
  * ```
53
60
  */
54
- static init(lib: EccLib): EccContext {
55
- verifyEcc(lib);
61
+ static init(lib: CryptoBackend): EccContext {
62
+ // Skip re-verification if same lib is already initialized
63
+ if (EccContext.#instance && EccContext.#instance.#lib === lib) {
64
+ return EccContext.#instance;
65
+ }
66
+ verifyCryptoBackend(lib);
56
67
  EccContext.#instance = new EccContext(lib);
57
68
  return EccContext.#instance;
58
69
  }
@@ -68,7 +79,7 @@ export class EccContext {
68
79
  * import { EccContext } from '@btc-vision/bitcoin';
69
80
  *
70
81
  * const context = EccContext.get();
71
- * const isValid = context.lib.isXOnlyPoint(someKey);
82
+ * const tweaked = context.lib.xOnlyPointAddTweak(key, tweak);
72
83
  * ```
73
84
  */
74
85
  static get(): EccContext {
@@ -106,20 +117,13 @@ export class EccContext {
106
117
  * import { EccContext } from '@btc-vision/bitcoin';
107
118
  *
108
119
  * if (!EccContext.isInitialized()) {
109
- * EccContext.init(secp256k1);
120
+ * EccContext.init(createNobleBackend());
110
121
  * }
111
122
  * ```
112
123
  */
113
124
  static isInitialized(): boolean {
114
125
  return EccContext.#instance !== undefined;
115
126
  }
116
-
117
- /**
118
- * The underlying ECC library instance.
119
- */
120
- get lib(): EccLib {
121
- return this.#lib;
122
- }
123
127
  }
124
128
 
125
129
  /**
@@ -127,22 +131,22 @@ export class EccContext {
127
131
  * This is a convenience function that wraps EccContext.init().
128
132
  * Pass `undefined` to clear the library.
129
133
  *
130
- * @param eccLib - The ECC library instance to initialize, or undefined to clear
131
- * @throws Error if the ECC library fails verification
134
+ * @param eccLib - The CryptoBackend instance to initialize, or undefined to clear
135
+ * @throws Error if the CryptoBackend fails verification
132
136
  *
133
137
  * @example
134
138
  * ```typescript
135
139
  * import { initEccLib } from '@btc-vision/bitcoin';
136
- * import * as secp256k1 from 'tiny-secp256k1';
140
+ * import { createNobleBackend } from '@btc-vision/ecpair';
137
141
  *
138
142
  * // Initialize the ECC library
139
- * initEccLib(secp256k1);
143
+ * initEccLib(createNobleBackend());
140
144
  *
141
145
  * // Clear the library
142
146
  * initEccLib(undefined);
143
147
  * ```
144
148
  */
145
- export function initEccLib(eccLib: EccLib | undefined): void {
149
+ export function initEccLib(eccLib: CryptoBackend | undefined): void {
146
150
  if (eccLib === undefined) {
147
151
  EccContext.clear();
148
152
  return;
@@ -154,124 +158,20 @@ export function initEccLib(eccLib: EccLib | undefined): void {
154
158
  * Retrieves the initialized ECC library instance.
155
159
  * This is a convenience function that wraps EccContext.get().lib.
156
160
  *
157
- * @returns The ECC library instance
161
+ * @returns The CryptoBackend instance
158
162
  * @throws Error if the ECC library has not been initialized
159
163
  *
160
164
  * @example
161
165
  * ```typescript
162
166
  * import { getEccLib, initEccLib } from '@btc-vision/bitcoin';
163
- * import * as secp256k1 from 'tiny-secp256k1';
167
+ * import { createNobleBackend } from '@btc-vision/ecpair';
164
168
  *
165
- * initEccLib(secp256k1);
169
+ * initEccLib(createNobleBackend());
166
170
  *
167
171
  * const ecc = getEccLib();
168
- * const isValid = ecc.isXOnlyPoint(somePublicKey);
172
+ * const tweaked = ecc.xOnlyPointAddTweak(pubkey, tweak);
169
173
  * ```
170
174
  */
171
- export function getEccLib(): EccLib {
175
+ export function getEccLib(): CryptoBackend {
172
176
  return EccContext.get().lib;
173
177
  }
174
-
175
- // ============================================================================
176
- // Verification
177
- // ============================================================================
178
-
179
- interface TweakAddVector {
180
- pubkey: string;
181
- tweak: string;
182
- parity: 0 | 1 | -1;
183
- result: string | null;
184
- }
185
-
186
- const TWEAK_ADD_VECTORS: TweakAddVector[] = [
187
- {
188
- pubkey: '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
189
- tweak: 'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140',
190
- parity: -1,
191
- result: null,
192
- },
193
- {
194
- pubkey: '1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b',
195
- tweak: 'a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac',
196
- parity: 1,
197
- result: 'e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf',
198
- },
199
- {
200
- pubkey: '2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991',
201
- tweak: '823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47',
202
- parity: 0,
203
- result: '9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c',
204
- },
205
- ];
206
-
207
- /**
208
- * Verifies that the ECC library implementation is correct.
209
- * Tests `isXOnlyPoint` and `xOnlyPointAddTweak` with known test vectors.
210
- *
211
- * @param ecc - The ECC library to verify
212
- * @throws Error if any verification test fails
213
- */
214
- function verifyEcc(ecc: EccLib): void {
215
- if (typeof ecc.isXOnlyPoint !== 'function') {
216
- throw new Error('ECC library missing isXOnlyPoint function');
217
- }
218
-
219
- // Test isXOnlyPoint with valid points
220
- const validPoints = [
221
- '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
222
- 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e',
223
- 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9',
224
- '0000000000000000000000000000000000000000000000000000000000000001',
225
- ];
226
-
227
- for (const hex of validPoints) {
228
- if (!ecc.isXOnlyPoint(fromHex(hex))) {
229
- throw new Error(`ECC library isXOnlyPoint failed for valid point: ${hex}`);
230
- }
231
- }
232
-
233
- // Test isXOnlyPoint with invalid points
234
- const invalidPoints = [
235
- '0000000000000000000000000000000000000000000000000000000000000000',
236
- 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f',
237
- ];
238
-
239
- for (const hex of invalidPoints) {
240
- if (ecc.isXOnlyPoint(fromHex(hex))) {
241
- throw new Error(`ECC library isXOnlyPoint should reject invalid point: ${hex}`);
242
- }
243
- }
244
-
245
- // Test xOnlyPointAddTweak
246
- if (typeof ecc.xOnlyPointAddTweak !== 'function') {
247
- throw new Error('ECC library missing xOnlyPointAddTweak function');
248
- }
249
-
250
- for (const vector of TWEAK_ADD_VECTORS) {
251
- const result = ecc.xOnlyPointAddTweak(fromHex(vector.pubkey) as XOnlyPublicKey, fromHex(vector.tweak) as Bytes32);
252
-
253
- if (vector.result === null) {
254
- if (result !== null) {
255
- throw new Error(
256
- `ECC library xOnlyPointAddTweak should return null for: ${vector.pubkey}`,
257
- );
258
- }
259
- } else {
260
- if (result === null) {
261
- throw new Error(
262
- `ECC library xOnlyPointAddTweak returned null unexpectedly for: ${vector.pubkey}`,
263
- );
264
- }
265
- if (result.parity !== vector.parity) {
266
- throw new Error(
267
- `ECC library xOnlyPointAddTweak parity mismatch for: ${vector.pubkey}`,
268
- );
269
- }
270
- if (!equals(result.xOnlyPubkey, fromHex(vector.result))) {
271
- throw new Error(
272
- `ECC library xOnlyPointAddTweak result mismatch for: ${vector.pubkey}`,
273
- );
274
- }
275
- }
276
- }
277
- }
package/src/ecc/index.ts CHANGED
@@ -7,8 +7,8 @@
7
7
  * @packageDocumentation
8
8
  */
9
9
 
10
- // Core types
11
- export type { EccLib, XOnlyPointAddTweakResult, Parity } from './types.js';
10
+ // Core types (CryptoBackend is the canonical name; EccLib is a deprecated alias)
11
+ export type { CryptoBackend, EccLib, XOnlyPointAddTweakResult, Parity } from './types.js';
12
12
 
13
13
  // Context management
14
14
  export { EccContext, initEccLib, getEccLib } from './context.js';