@btc-vision/bitcoin 6.5.6 → 7.0.0-alpha.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 (456) hide show
  1. package/HOW_TO_WRITE_GOOD_CODE.md +2436 -0
  2. package/benchmark/psbt-2000-inputs.bench.ts +178 -0
  3. package/benchmark/signing.bench.ts +147 -0
  4. package/browser/address.d.ts +57 -10
  5. package/browser/address.d.ts.map +1 -0
  6. package/browser/bech32utils.d.ts +9 -1
  7. package/browser/bech32utils.d.ts.map +1 -0
  8. package/browser/bip66.d.ts +11 -6
  9. package/browser/bip66.d.ts.map +1 -0
  10. package/browser/block.d.ts +117 -11
  11. package/browser/block.d.ts.map +1 -0
  12. package/browser/branded.d.ts +20 -0
  13. package/browser/branded.d.ts.map +1 -0
  14. package/browser/crypto/crypto.d.ts +1 -0
  15. package/browser/crypto/crypto.d.ts.map +1 -0
  16. package/browser/crypto.d.ts +46 -7
  17. package/browser/crypto.d.ts.map +1 -0
  18. package/browser/ecc/context.d.ts +129 -0
  19. package/browser/ecc/context.d.ts.map +1 -0
  20. package/browser/ecc/index.d.ts +11 -0
  21. package/browser/ecc/index.d.ts.map +1 -0
  22. package/browser/ecc/types.d.ts +128 -0
  23. package/browser/ecc/types.d.ts.map +1 -0
  24. package/browser/ecpair.d.ts +99 -0
  25. package/browser/errors.d.ts +124 -0
  26. package/browser/errors.d.ts.map +1 -0
  27. package/browser/index.d.ts +32 -5
  28. package/browser/index.d.ts.map +1 -0
  29. package/browser/index.js +12477 -101
  30. package/browser/io/BinaryReader.d.ts +276 -0
  31. package/browser/io/BinaryReader.d.ts.map +1 -0
  32. package/browser/io/BinaryWriter.d.ts +391 -0
  33. package/browser/io/BinaryWriter.d.ts.map +1 -0
  34. package/browser/io/MemoryPool.d.ts +220 -0
  35. package/browser/io/MemoryPool.d.ts.map +1 -0
  36. package/browser/io/base64.d.ts +13 -0
  37. package/browser/io/base64.d.ts.map +1 -0
  38. package/browser/io/hex.d.ts +67 -0
  39. package/browser/io/hex.d.ts.map +1 -0
  40. package/browser/io/index.d.ts +17 -0
  41. package/browser/io/index.d.ts.map +1 -0
  42. package/browser/io/utils.d.ts +199 -0
  43. package/browser/io/utils.d.ts.map +1 -0
  44. package/browser/merkle.d.ts +10 -1
  45. package/browser/merkle.d.ts.map +1 -0
  46. package/browser/networks.d.ts +70 -9
  47. package/browser/networks.d.ts.map +1 -0
  48. package/browser/opcodes.d.ts +1 -0
  49. package/browser/opcodes.d.ts.map +1 -0
  50. package/browser/payments/bip341.d.ts +35 -9
  51. package/browser/payments/bip341.d.ts.map +1 -0
  52. package/browser/payments/embed.d.ts +112 -1
  53. package/browser/payments/embed.d.ts.map +1 -0
  54. package/browser/payments/index.d.ts +17 -10
  55. package/browser/payments/index.d.ts.map +1 -0
  56. package/browser/payments/p2ms.d.ts +150 -0
  57. package/browser/payments/p2ms.d.ts.map +1 -0
  58. package/browser/payments/p2op.d.ts +150 -24
  59. package/browser/payments/p2op.d.ts.map +1 -0
  60. package/browser/payments/p2pk.d.ts +154 -1
  61. package/browser/payments/p2pk.d.ts.map +1 -0
  62. package/browser/payments/p2pkh.d.ts +176 -1
  63. package/browser/payments/p2pkh.d.ts.map +1 -0
  64. package/browser/payments/p2sh.d.ts +150 -1
  65. package/browser/payments/p2sh.d.ts.map +1 -0
  66. package/browser/payments/p2tr.d.ts +185 -1
  67. package/browser/payments/p2tr.d.ts.map +1 -0
  68. package/browser/payments/p2wpkh.d.ts +161 -1
  69. package/browser/payments/p2wpkh.d.ts.map +1 -0
  70. package/browser/payments/p2wsh.d.ts +146 -1
  71. package/browser/payments/p2wsh.d.ts.map +1 -0
  72. package/browser/payments/types.d.ts +94 -64
  73. package/browser/payments/types.d.ts.map +1 -0
  74. package/browser/psbt/bip371.d.ts +34 -8
  75. package/browser/psbt/bip371.d.ts.map +1 -0
  76. package/browser/psbt/psbtutils.d.ts +56 -16
  77. package/browser/psbt/psbtutils.d.ts.map +1 -0
  78. package/browser/psbt/types.d.ts +245 -0
  79. package/browser/psbt/types.d.ts.map +1 -0
  80. package/browser/psbt/utils.d.ts +64 -0
  81. package/browser/psbt/utils.d.ts.map +1 -0
  82. package/browser/psbt/validation.d.ts +84 -0
  83. package/browser/psbt/validation.d.ts.map +1 -0
  84. package/browser/psbt.d.ts +82 -118
  85. package/browser/psbt.d.ts.map +1 -0
  86. package/browser/pubkey.d.ts +27 -6
  87. package/browser/pubkey.d.ts.map +1 -0
  88. package/browser/push_data.d.ts +24 -2
  89. package/browser/push_data.d.ts.map +1 -0
  90. package/browser/script.d.ts +33 -8
  91. package/browser/script.d.ts.map +1 -0
  92. package/browser/script_number.d.ts +17 -0
  93. package/browser/script_number.d.ts.map +1 -0
  94. package/browser/script_signature.d.ts +23 -5
  95. package/browser/script_signature.d.ts.map +1 -0
  96. package/browser/transaction.d.ts +160 -18
  97. package/browser/transaction.d.ts.map +1 -0
  98. package/browser/types.d.ts +36 -38
  99. package/browser/types.d.ts.map +1 -0
  100. package/browser/workers/WorkerSigningPool.d.ts +143 -0
  101. package/browser/workers/WorkerSigningPool.d.ts.map +1 -0
  102. package/browser/workers/WorkerSigningPool.node.d.ts +116 -0
  103. package/browser/workers/WorkerSigningPool.node.d.ts.map +1 -0
  104. package/browser/workers/ecc-bundle.d.ts +25 -0
  105. package/browser/workers/ecc-bundle.d.ts.map +1 -0
  106. package/browser/workers/index.d.ts +91 -0
  107. package/browser/workers/index.d.ts.map +1 -0
  108. package/browser/workers/psbt-parallel.d.ts +88 -0
  109. package/browser/workers/psbt-parallel.d.ts.map +1 -0
  110. package/browser/workers/signing-worker.d.ts +37 -0
  111. package/browser/workers/signing-worker.d.ts.map +1 -0
  112. package/browser/workers/types.d.ts +365 -0
  113. package/browser/workers/types.d.ts.map +1 -0
  114. package/build/address.d.ts +58 -11
  115. package/build/address.d.ts.map +1 -0
  116. package/build/address.js +82 -25
  117. package/build/address.js.map +1 -0
  118. package/build/bech32utils.d.ts +9 -1
  119. package/build/bech32utils.d.ts.map +1 -0
  120. package/build/bech32utils.js +10 -2
  121. package/build/bech32utils.js.map +1 -0
  122. package/build/bip66.d.ts +11 -6
  123. package/build/bip66.d.ts.map +1 -0
  124. package/build/bip66.js +32 -3
  125. package/build/bip66.js.map +1 -0
  126. package/build/block.d.ts +117 -11
  127. package/build/block.d.ts.map +1 -0
  128. package/build/block.js +202 -72
  129. package/build/block.js.map +1 -0
  130. package/build/branded.d.ts +20 -0
  131. package/build/branded.d.ts.map +1 -0
  132. package/build/branded.js +7 -0
  133. package/build/branded.js.map +1 -0
  134. package/build/crypto/crypto.d.ts +1 -0
  135. package/build/crypto/crypto.d.ts.map +1 -0
  136. package/build/crypto/crypto.js +1 -0
  137. package/build/crypto/crypto.js.map +1 -0
  138. package/build/crypto.d.ts +46 -7
  139. package/build/crypto.d.ts.map +1 -0
  140. package/build/crypto.js +65 -20
  141. package/build/crypto.js.map +1 -0
  142. package/build/ecc/context.d.ts +135 -0
  143. package/build/ecc/context.d.ts.map +1 -0
  144. package/build/ecc/context.js +232 -0
  145. package/build/ecc/context.js.map +1 -0
  146. package/build/ecc/index.d.ts +11 -0
  147. package/build/ecc/index.d.ts.map +1 -0
  148. package/build/ecc/index.js +11 -0
  149. package/build/ecc/index.js.map +1 -0
  150. package/build/ecc/types.d.ts +134 -0
  151. package/build/ecc/types.d.ts.map +1 -0
  152. package/build/ecc/types.js +8 -0
  153. package/build/ecc/types.js.map +1 -0
  154. package/build/errors.d.ts +124 -0
  155. package/build/errors.d.ts.map +1 -0
  156. package/build/errors.js +155 -0
  157. package/build/errors.js.map +1 -0
  158. package/build/index.d.ts +32 -5
  159. package/build/index.d.ts.map +1 -0
  160. package/build/index.js +26 -3
  161. package/build/index.js.map +1 -0
  162. package/build/io/BinaryReader.d.ts +276 -0
  163. package/build/io/BinaryReader.d.ts.map +1 -0
  164. package/build/io/BinaryReader.js +425 -0
  165. package/build/io/BinaryReader.js.map +1 -0
  166. package/build/io/BinaryWriter.d.ts +391 -0
  167. package/build/io/BinaryWriter.d.ts.map +1 -0
  168. package/build/io/BinaryWriter.js +611 -0
  169. package/build/io/BinaryWriter.js.map +1 -0
  170. package/build/io/MemoryPool.d.ts +220 -0
  171. package/build/io/MemoryPool.d.ts.map +1 -0
  172. package/build/io/MemoryPool.js +309 -0
  173. package/build/io/MemoryPool.js.map +1 -0
  174. package/build/io/base64.d.ts +13 -0
  175. package/build/io/base64.d.ts.map +1 -0
  176. package/build/io/base64.js +20 -0
  177. package/build/io/base64.js.map +1 -0
  178. package/build/io/hex.d.ts +67 -0
  179. package/build/io/hex.d.ts.map +1 -0
  180. package/build/io/hex.js +138 -0
  181. package/build/io/hex.js.map +1 -0
  182. package/build/io/index.d.ts +17 -0
  183. package/build/io/index.d.ts.map +1 -0
  184. package/build/io/index.js +23 -0
  185. package/build/io/index.js.map +1 -0
  186. package/build/io/utils.d.ts +199 -0
  187. package/build/io/utils.d.ts.map +1 -0
  188. package/build/io/utils.js +271 -0
  189. package/build/io/utils.js.map +1 -0
  190. package/build/merkle.d.ts +10 -1
  191. package/build/merkle.d.ts.map +1 -0
  192. package/build/merkle.js +12 -1
  193. package/build/merkle.js.map +1 -0
  194. package/build/networks.d.ts +70 -9
  195. package/build/networks.d.ts.map +1 -0
  196. package/build/networks.js +90 -4
  197. package/build/networks.js.map +1 -0
  198. package/build/opcodes.d.ts +1 -0
  199. package/build/opcodes.d.ts.map +1 -0
  200. package/build/opcodes.js +1 -0
  201. package/build/opcodes.js.map +1 -0
  202. package/build/payments/bip341.d.ts +35 -9
  203. package/build/payments/bip341.d.ts.map +1 -0
  204. package/build/payments/bip341.js +34 -15
  205. package/build/payments/bip341.js.map +1 -0
  206. package/build/payments/embed.d.ts +120 -1
  207. package/build/payments/embed.d.ts.map +1 -0
  208. package/build/payments/embed.js +215 -34
  209. package/build/payments/embed.js.map +1 -0
  210. package/build/payments/index.d.ts +17 -10
  211. package/build/payments/index.d.ts.map +1 -0
  212. package/build/payments/index.js +20 -10
  213. package/build/payments/index.js.map +1 -0
  214. package/build/payments/p2ms.d.ts +159 -1
  215. package/build/payments/p2ms.d.ts.map +1 -0
  216. package/build/payments/p2ms.js +427 -108
  217. package/build/payments/p2ms.js.map +1 -0
  218. package/build/payments/p2op.d.ts +158 -24
  219. package/build/payments/p2op.d.ts.map +1 -0
  220. package/build/payments/p2op.js +379 -93
  221. package/build/payments/p2op.js.map +1 -0
  222. package/build/payments/p2pk.d.ts +162 -1
  223. package/build/payments/p2pk.d.ts.map +1 -0
  224. package/build/payments/p2pk.js +327 -58
  225. package/build/payments/p2pk.js.map +1 -0
  226. package/build/payments/p2pkh.d.ts +185 -1
  227. package/build/payments/p2pkh.d.ts.map +1 -0
  228. package/build/payments/p2pkh.js +467 -114
  229. package/build/payments/p2pkh.js.map +1 -0
  230. package/build/payments/p2sh.d.ts +159 -1
  231. package/build/payments/p2sh.d.ts.map +1 -0
  232. package/build/payments/p2sh.js +500 -150
  233. package/build/payments/p2sh.js.map +1 -0
  234. package/build/payments/p2tr.d.ts +193 -1
  235. package/build/payments/p2tr.d.ts.map +1 -0
  236. package/build/payments/p2tr.js +592 -174
  237. package/build/payments/p2tr.js.map +1 -0
  238. package/build/payments/p2wpkh.d.ts +170 -1
  239. package/build/payments/p2wpkh.d.ts.map +1 -0
  240. package/build/payments/p2wpkh.js +428 -103
  241. package/build/payments/p2wpkh.js.map +1 -0
  242. package/build/payments/p2wsh.d.ts +155 -1
  243. package/build/payments/p2wsh.d.ts.map +1 -0
  244. package/build/payments/p2wsh.js +465 -143
  245. package/build/payments/p2wsh.js.map +1 -0
  246. package/build/payments/types.d.ts +98 -64
  247. package/build/payments/types.d.ts.map +1 -0
  248. package/build/payments/types.js +17 -13
  249. package/build/payments/types.js.map +1 -0
  250. package/build/psbt/bip371.d.ts +35 -9
  251. package/build/psbt/bip371.d.ts.map +1 -0
  252. package/build/psbt/bip371.js +117 -28
  253. package/build/psbt/bip371.js.map +1 -0
  254. package/build/psbt/psbtutils.d.ts +56 -16
  255. package/build/psbt/psbtutils.d.ts.map +1 -0
  256. package/build/psbt/psbtutils.js +71 -16
  257. package/build/psbt/psbtutils.js.map +1 -0
  258. package/build/psbt/types.d.ts +249 -0
  259. package/build/psbt/types.d.ts.map +1 -0
  260. package/build/psbt/types.js +6 -0
  261. package/build/psbt/types.js.map +1 -0
  262. package/build/psbt/utils.d.ts +68 -0
  263. package/build/psbt/utils.d.ts.map +1 -0
  264. package/build/psbt/utils.js +171 -0
  265. package/build/psbt/utils.js.map +1 -0
  266. package/build/psbt/validation.d.ts +88 -0
  267. package/build/psbt/validation.d.ts.map +1 -0
  268. package/build/psbt/validation.js +149 -0
  269. package/build/psbt/validation.js.map +1 -0
  270. package/build/psbt.d.ts +84 -120
  271. package/build/psbt.d.ts.map +1 -0
  272. package/build/psbt.js +406 -413
  273. package/build/psbt.js.map +1 -0
  274. package/build/pubkey.d.ts +27 -6
  275. package/build/pubkey.d.ts.map +1 -0
  276. package/build/pubkey.js +36 -12
  277. package/build/pubkey.js.map +1 -0
  278. package/build/push_data.d.ts +24 -2
  279. package/build/push_data.d.ts.map +1 -0
  280. package/build/push_data.js +44 -12
  281. package/build/push_data.js.map +1 -0
  282. package/build/script.d.ts +33 -8
  283. package/build/script.d.ts.map +1 -0
  284. package/build/script.js +101 -37
  285. package/build/script.js.map +1 -0
  286. package/build/script_number.d.ts +17 -0
  287. package/build/script_number.d.ts.map +1 -0
  288. package/build/script_number.js +19 -0
  289. package/build/script_number.js.map +1 -0
  290. package/build/script_signature.d.ts +23 -5
  291. package/build/script_signature.d.ts.map +1 -0
  292. package/build/script_signature.js +48 -15
  293. package/build/script_signature.js.map +1 -0
  294. package/build/transaction.d.ts +160 -18
  295. package/build/transaction.d.ts.map +1 -0
  296. package/build/transaction.js +443 -176
  297. package/build/transaction.js.map +1 -0
  298. package/build/tsconfig.build.tsbuildinfo +1 -0
  299. package/build/types.d.ts +36 -38
  300. package/build/types.d.ts.map +1 -0
  301. package/build/types.js +169 -57
  302. package/build/types.js.map +1 -0
  303. package/build/workers/WorkerSigningPool.d.ts +174 -0
  304. package/build/workers/WorkerSigningPool.d.ts.map +1 -0
  305. package/build/workers/WorkerSigningPool.js +553 -0
  306. package/build/workers/WorkerSigningPool.js.map +1 -0
  307. package/build/workers/WorkerSigningPool.node.d.ts +124 -0
  308. package/build/workers/WorkerSigningPool.node.d.ts.map +1 -0
  309. package/build/workers/WorkerSigningPool.node.js +753 -0
  310. package/build/workers/WorkerSigningPool.node.js.map +1 -0
  311. package/build/workers/ecc-bundle.d.ts +25 -0
  312. package/build/workers/ecc-bundle.d.ts.map +1 -0
  313. package/build/workers/ecc-bundle.js +25 -0
  314. package/build/workers/ecc-bundle.js.map +1 -0
  315. package/build/workers/index.d.ts +91 -0
  316. package/build/workers/index.d.ts.map +1 -0
  317. package/build/workers/index.js +114 -0
  318. package/build/workers/index.js.map +1 -0
  319. package/build/workers/psbt-parallel.d.ts +117 -0
  320. package/build/workers/psbt-parallel.d.ts.map +1 -0
  321. package/build/workers/psbt-parallel.js +233 -0
  322. package/build/workers/psbt-parallel.js.map +1 -0
  323. package/build/workers/signing-worker.d.ts +37 -0
  324. package/build/workers/signing-worker.d.ts.map +1 -0
  325. package/build/workers/signing-worker.js +350 -0
  326. package/build/workers/signing-worker.js.map +1 -0
  327. package/build/workers/types.d.ts +365 -0
  328. package/build/workers/types.d.ts.map +1 -0
  329. package/build/workers/types.js +60 -0
  330. package/build/workers/types.js.map +1 -0
  331. package/package.json +68 -9
  332. package/scripts/bundle-ecc.ts +111 -0
  333. package/src/address.ts +91 -45
  334. package/src/bech32utils.ts +3 -3
  335. package/src/bip66.ts +34 -24
  336. package/src/block.ts +205 -86
  337. package/src/branded.ts +18 -0
  338. package/src/crypto.ts +64 -26
  339. package/src/ecc/context.ts +280 -0
  340. package/src/ecc/index.ts +14 -0
  341. package/src/ecc/types.ts +147 -0
  342. package/src/ecpair.d.ts +99 -0
  343. package/src/errors.ts +163 -0
  344. package/src/index.ts +112 -9
  345. package/src/io/BinaryReader.ts +461 -0
  346. package/src/io/BinaryWriter.ts +696 -0
  347. package/src/io/MemoryPool.ts +343 -0
  348. package/src/io/base64.ts +20 -0
  349. package/src/io/hex.ts +155 -0
  350. package/src/io/index.ts +41 -0
  351. package/src/io/utils.ts +283 -0
  352. package/src/merkle.ts +14 -9
  353. package/src/networks.ts +9 -9
  354. package/src/payments/bip341.ts +32 -33
  355. package/src/payments/embed.ts +244 -41
  356. package/src/payments/index.ts +12 -10
  357. package/src/payments/p2ms.ts +497 -118
  358. package/src/payments/p2op.ts +432 -134
  359. package/src/payments/p2pk.ts +370 -72
  360. package/src/payments/p2pkh.ts +524 -130
  361. package/src/payments/p2sh.ts +572 -169
  362. package/src/payments/p2tr.ts +686 -194
  363. package/src/payments/p2wpkh.ts +482 -105
  364. package/src/payments/p2wsh.ts +524 -162
  365. package/src/payments/types.ts +80 -66
  366. package/src/psbt/bip371.ts +72 -51
  367. package/src/psbt/psbtutils.ts +39 -40
  368. package/src/psbt/types.ts +324 -0
  369. package/src/psbt/utils.ts +188 -0
  370. package/src/psbt/validation.ts +185 -0
  371. package/src/psbt.ts +608 -827
  372. package/src/pubkey.ts +22 -23
  373. package/src/push_data.ts +18 -16
  374. package/src/script.ts +81 -66
  375. package/src/script_number.ts +6 -6
  376. package/src/script_signature.ts +33 -36
  377. package/src/transaction.ts +462 -239
  378. package/src/types.ts +229 -100
  379. package/src/workers/WorkerSigningPool.node.ts +887 -0
  380. package/src/workers/WorkerSigningPool.ts +666 -0
  381. package/src/workers/ecc-bundle.ts +26 -0
  382. package/src/workers/index.ts +165 -0
  383. package/src/workers/psbt-parallel.ts +327 -0
  384. package/src/workers/signing-worker.ts +353 -0
  385. package/src/workers/types.ts +417 -0
  386. package/test/address.spec.ts +9 -6
  387. package/test/bitcoin.core.spec.ts +16 -17
  388. package/test/block.spec.ts +8 -7
  389. package/test/bufferutils.spec.ts +228 -214
  390. package/test/crypto.spec.ts +19 -11
  391. package/test/fixtures/p2pk.json +0 -8
  392. package/test/fixtures/p2pkh.json +1 -1
  393. package/test/fixtures/p2sh.json +1 -1
  394. package/test/fixtures/script.json +1 -1
  395. package/test/fixtures/transaction.json +2 -2
  396. package/test/integration/_regtest.ts +25 -0
  397. package/test/integration/addresses.spec.ts +4 -3
  398. package/test/integration/bip32.spec.ts +2 -1
  399. package/test/integration/blocks.spec.ts +1 -1
  400. package/test/integration/cltv.spec.ts +18 -16
  401. package/test/integration/csv.spec.ts +37 -64
  402. package/test/integration/payments.spec.ts +5 -3
  403. package/test/integration/taproot.spec.ts +76 -83
  404. package/test/integration/transactions.spec.ts +38 -35
  405. package/test/payments.spec.ts +35 -13
  406. package/test/payments.utils.ts +17 -16
  407. package/test/psbt.spec.ts +111 -100
  408. package/test/script.spec.ts +11 -10
  409. package/test/script_signature.spec.ts +9 -11
  410. package/test/taproot-cache.spec.ts +694 -0
  411. package/test/transaction.spec.ts +32 -40
  412. package/test/types.spec.ts +74 -29
  413. package/test/workers-pool.spec.ts +963 -0
  414. package/test/workers-signing.spec.ts +635 -0
  415. package/test/workers.spec.ts +1390 -0
  416. package/tsconfig.base.json +34 -18
  417. package/tsconfig.browser.json +15 -0
  418. package/tsconfig.build.json +5 -0
  419. package/tsconfig.json +5 -14
  420. package/typedoc.json +29 -0
  421. package/vite.config.browser.ts +3 -42
  422. package/vitest.config.integration.ts +2 -0
  423. package/browser/bufferutils.d.ts +0 -34
  424. package/browser/chunks/crypto-BhCpKpek.js +0 -2033
  425. package/browser/chunks/payments-B1wlSccx.js +0 -1089
  426. package/browser/chunks/psbt-BCNk7JUx.js +0 -4055
  427. package/browser/chunks/script-DyPItFEl.js +0 -318
  428. package/browser/chunks/transaction-C_UbhMGn.js +0 -432
  429. package/browser/chunks/utils-DNZi-T5W.js +0 -761
  430. package/browser/ecc_lib.d.ts +0 -3
  431. package/browser/hooks/AdvancedSignatureManager.d.ts +0 -16
  432. package/browser/hooks/HookedSigner.d.ts +0 -4
  433. package/browser/hooks/SignatureManager.d.ts +0 -13
  434. package/browser/payments/lazy.d.ts +0 -2
  435. package/browser/typeforce.d.ts +0 -38
  436. package/build/bufferutils.d.ts +0 -34
  437. package/build/bufferutils.js +0 -141
  438. package/build/ecc_lib.d.ts +0 -3
  439. package/build/ecc_lib.js +0 -61
  440. package/build/hooks/AdvancedSignatureManager.d.ts +0 -16
  441. package/build/hooks/AdvancedSignatureManager.js +0 -52
  442. package/build/hooks/HookedSigner.d.ts +0 -4
  443. package/build/hooks/HookedSigner.js +0 -64
  444. package/build/hooks/SignatureManager.d.ts +0 -13
  445. package/build/hooks/SignatureManager.js +0 -45
  446. package/build/payments/lazy.d.ts +0 -2
  447. package/build/payments/lazy.js +0 -28
  448. package/build/tsconfig.tsbuildinfo +0 -1
  449. package/src/bufferutils.ts +0 -188
  450. package/src/ecc_lib.ts +0 -94
  451. package/src/hooks/AdvancedSignatureManager.ts +0 -104
  452. package/src/hooks/HookedSigner.ts +0 -108
  453. package/src/hooks/SignatureManager.ts +0 -84
  454. package/src/payments/lazy.ts +0 -28
  455. package/src/typeforce.d.ts +0 -38
  456. package/tsconfig.webpack.json +0 -18
@@ -1,135 +1,454 @@
1
+ /**
2
+ * Pay-to-Multisig (P2MS) payment class.
3
+ *
4
+ * P2MS is a bare multisig script where M-of-N signatures are required
5
+ * to spend the output. The public keys are embedded directly in the script.
6
+ *
7
+ * @packageDocumentation
8
+ */
1
9
  import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
2
10
  import * as bscript from '../script.js';
3
- import { isPoint, stacksEqual, typeforce as typef } from '../types.js';
11
+ import { isPoint, stacksEqual, } from '../types.js';
4
12
  import { PaymentType } from './types.js';
5
- import * as lazy from './lazy.js';
6
13
  const OPS = bscript.opcodes;
7
- const OP_INT_BASE = OPS.OP_RESERVED;
8
- export function p2ms(a, opts) {
9
- if (!a.input && !a.output && !(a.pubkeys && a.m !== undefined) && !a.signatures)
10
- throw new TypeError('Not enough data');
11
- opts = Object.assign({ validate: true }, opts || {});
12
- function isAcceptableSignature(x) {
13
- return (bscript.isCanonicalScriptSignature(x) ||
14
- (opts.allowIncomplete && x === OPS.OP_0) !== undefined);
15
- }
16
- typef({
17
- network: typef.maybe(typef.Object),
18
- m: typef.maybe(typef.Number),
19
- n: typef.maybe(typef.Number),
20
- output: typef.maybe(typef.Buffer),
21
- pubkeys: typef.maybe(typef.arrayOf(isPoint)),
22
- signatures: typef.maybe(typef.arrayOf(isAcceptableSignature)),
23
- input: typef.maybe(typef.Buffer),
24
- }, a);
25
- const network = a.network || BITCOIN_NETWORK;
26
- const o = {
27
- network,
28
- name: PaymentType.P2MS,
29
- };
30
- let chunks = [];
31
- let decoded = false;
32
- function decode(output) {
33
- if (decoded)
34
- return;
35
- decoded = true;
36
- chunks = bscript.decompile(output);
37
- o.m = chunks[0] - OP_INT_BASE;
38
- o.n = chunks[chunks.length - 2] - OP_INT_BASE;
39
- o.pubkeys = chunks.slice(1, -2);
40
- }
41
- lazy.prop(o, 'output', () => {
42
- if (!a.m)
43
- return;
44
- if (!o.n)
45
- return;
46
- if (!a.pubkeys)
47
- return;
48
- return bscript.compile([].concat(OP_INT_BASE + a.m, a.pubkeys, OP_INT_BASE + o.n, OPS.OP_CHECKMULTISIG));
49
- });
50
- lazy.prop(o, 'm', () => {
51
- if (!o.output)
52
- return;
53
- decode(o.output);
54
- return o.m;
55
- });
56
- lazy.prop(o, 'n', () => {
57
- if (!o.pubkeys)
58
- return;
59
- return o.pubkeys.length;
60
- });
61
- lazy.prop(o, 'pubkeys', () => {
62
- if (!a.output)
63
- return;
64
- decode(a.output);
65
- return o.pubkeys;
66
- });
67
- lazy.prop(o, 'signatures', () => {
68
- if (!a.input)
69
- return;
70
- const decompiled = bscript.decompile(a.input);
71
- if (decompiled === null || decompiled === undefined)
72
- return;
73
- return decompiled.slice(1);
74
- });
75
- lazy.prop(o, 'input', () => {
76
- if (!a.signatures)
77
- return;
78
- return bscript.compile([OPS.OP_0].concat(a.signatures));
79
- });
80
- lazy.prop(o, 'witness', () => {
81
- if (!o.input)
82
- return;
83
- return [];
84
- });
85
- lazy.prop(o, 'name', () => {
86
- if (!o.m || !o.n)
14
+ const OP_INT_BASE = OPS.OP_RESERVED; // OP_1 - 1
15
+ /**
16
+ * Pay-to-Multisig (P2MS) payment class.
17
+ *
18
+ * Creates locking scripts of the form:
19
+ * `m {pubKey1} {pubKey2} ... {pubKeyN} n OP_CHECKMULTISIG`
20
+ *
21
+ * Spending requires: `OP_0 {sig1} {sig2} ... {sigM}`
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * import { P2MS } from '@btc-vision/bitcoin';
26
+ *
27
+ * // Create a 2-of-3 multisig
28
+ * const payment = P2MS.fromPubkeys(2, [pubkey1, pubkey2, pubkey3]);
29
+ * console.log(payment.output); // scriptPubKey
30
+ * console.log(payment.m); // 2
31
+ * console.log(payment.n); // 3
32
+ *
33
+ * // Decode an existing output
34
+ * const decoded = P2MS.fromOutput(scriptPubKey);
35
+ * console.log(decoded.pubkeys); // array of public keys
36
+ * ```
37
+ */
38
+ export class P2MS {
39
+ // Static public fields
40
+ static NAME = PaymentType.P2MS;
41
+ // Private instance fields
42
+ #network;
43
+ #opts;
44
+ // Input data (provided by user)
45
+ #inputM;
46
+ #inputN;
47
+ #inputPubkeys;
48
+ #inputSignatures;
49
+ #inputOutput;
50
+ #inputInput;
51
+ // Cached computed values
52
+ #m;
53
+ #n;
54
+ #pubkeys;
55
+ #signatures;
56
+ #output;
57
+ #input;
58
+ #witness;
59
+ // Cache flags
60
+ #mComputed = false;
61
+ #nComputed = false;
62
+ #pubkeysComputed = false;
63
+ #signaturesComputed = false;
64
+ #outputComputed = false;
65
+ #inputComputed = false;
66
+ #witnessComputed = false;
67
+ // Decoded chunks cache
68
+ #decodedChunks;
69
+ #decoded = false;
70
+ /**
71
+ * Creates a new P2MS payment instance.
72
+ *
73
+ * @param params - Payment parameters
74
+ * @param params.m - Required number of signatures
75
+ * @param params.n - Total number of public keys (optional, derived from pubkeys)
76
+ * @param params.pubkeys - Array of public keys
77
+ * @param params.signatures - Array of signatures
78
+ * @param params.output - The scriptPubKey
79
+ * @param params.input - The scriptSig
80
+ * @param params.network - Network parameters (defaults to mainnet)
81
+ * @param opts - Payment options
82
+ * @param opts.validate - Whether to validate inputs (default: true)
83
+ * @param opts.allowIncomplete - Allow incomplete signatures (default: false)
84
+ *
85
+ * @throws {TypeError} If validation is enabled and data is invalid
86
+ */
87
+ constructor(params, opts) {
88
+ this.#network = params.network ?? BITCOIN_NETWORK;
89
+ this.#opts = {
90
+ validate: opts?.validate ?? true,
91
+ allowIncomplete: opts?.allowIncomplete ?? false,
92
+ };
93
+ // Store input data
94
+ this.#inputM = params.m;
95
+ this.#inputN = params.n;
96
+ this.#inputPubkeys = params.pubkeys;
97
+ this.#inputSignatures = params.signatures;
98
+ this.#inputOutput = params.output;
99
+ this.#inputInput = params.input;
100
+ // Validate if requested
101
+ if (this.#opts.validate) {
102
+ this.#validate();
103
+ }
104
+ }
105
+ // Public getters
106
+ /**
107
+ * Payment type discriminant.
108
+ */
109
+ get name() {
110
+ const m = this.m;
111
+ const n = this.n;
112
+ if (m !== undefined && n !== undefined) {
113
+ return `p2ms(${m} of ${n})`;
114
+ }
115
+ return PaymentType.P2MS;
116
+ }
117
+ /**
118
+ * Network parameters.
119
+ */
120
+ get network() {
121
+ return this.#network;
122
+ }
123
+ /**
124
+ * Required number of signatures (M in M-of-N).
125
+ */
126
+ get m() {
127
+ if (!this.#mComputed) {
128
+ this.#m = this.#computeM();
129
+ this.#mComputed = true;
130
+ }
131
+ return this.#m;
132
+ }
133
+ /**
134
+ * Total number of public keys (N in M-of-N).
135
+ */
136
+ get n() {
137
+ if (!this.#nComputed) {
138
+ this.#n = this.#computeN();
139
+ this.#nComputed = true;
140
+ }
141
+ return this.#n;
142
+ }
143
+ /**
144
+ * Array of public keys.
145
+ */
146
+ get pubkeys() {
147
+ if (!this.#pubkeysComputed) {
148
+ this.#pubkeys = this.#computePubkeys();
149
+ this.#pubkeysComputed = true;
150
+ }
151
+ return this.#pubkeys;
152
+ }
153
+ /**
154
+ * Array of signatures.
155
+ */
156
+ get signatures() {
157
+ if (!this.#signaturesComputed) {
158
+ this.#signatures = this.#computeSignatures();
159
+ this.#signaturesComputed = true;
160
+ }
161
+ return this.#signatures;
162
+ }
163
+ /**
164
+ * The scriptPubKey: `m {pubkeys} n OP_CHECKMULTISIG`
165
+ */
166
+ get output() {
167
+ if (!this.#outputComputed) {
168
+ this.#output = this.#computeOutput();
169
+ this.#outputComputed = true;
170
+ }
171
+ return this.#output;
172
+ }
173
+ /**
174
+ * The scriptSig: `OP_0 {signatures}`
175
+ */
176
+ get input() {
177
+ if (!this.#inputComputed) {
178
+ this.#input = this.#computeInput();
179
+ this.#inputComputed = true;
180
+ }
181
+ return this.#input;
182
+ }
183
+ /**
184
+ * Witness stack (empty for P2MS as it's not a SegWit type).
185
+ */
186
+ get witness() {
187
+ if (!this.#witnessComputed) {
188
+ this.#witness = this.#computeWitness();
189
+ this.#witnessComputed = true;
190
+ }
191
+ return this.#witness;
192
+ }
193
+ // Static factory methods
194
+ /**
195
+ * Creates a P2MS payment from public keys.
196
+ *
197
+ * @param m - Required number of signatures
198
+ * @param pubkeys - Array of public keys
199
+ * @param network - Network parameters (defaults to mainnet)
200
+ * @returns A new P2MS payment instance
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * // Create a 2-of-3 multisig
205
+ * const payment = P2MS.fromPubkeys(2, [pubkey1, pubkey2, pubkey3]);
206
+ * ```
207
+ */
208
+ static fromPubkeys(m, pubkeys, network) {
209
+ return new P2MS({ m, pubkeys, network });
210
+ }
211
+ /**
212
+ * Creates a P2MS payment from a scriptPubKey.
213
+ *
214
+ * @param output - The scriptPubKey
215
+ * @param network - Network parameters (defaults to mainnet)
216
+ * @returns A new P2MS payment instance
217
+ */
218
+ static fromOutput(output, network) {
219
+ return new P2MS({ output, network });
220
+ }
221
+ /**
222
+ * Creates a P2MS payment from signatures (for spending).
223
+ *
224
+ * @param signatures - Array of signatures
225
+ * @param m - Required number of signatures (optional)
226
+ * @param pubkeys - Array of public keys (optional, for validation)
227
+ * @param network - Network parameters (defaults to mainnet)
228
+ * @returns A new P2MS payment instance
229
+ */
230
+ static fromSignatures(signatures, m, pubkeys, network) {
231
+ return new P2MS({ signatures, m, pubkeys, network });
232
+ }
233
+ // Private helper methods
234
+ /**
235
+ * Converts to a plain P2MSPayment object for backwards compatibility.
236
+ *
237
+ * @returns A P2MSPayment object
238
+ */
239
+ toPayment() {
240
+ return {
241
+ name: this.name,
242
+ network: this.network,
243
+ m: this.m,
244
+ n: this.n,
245
+ pubkeys: this.pubkeys,
246
+ signatures: this.signatures,
247
+ output: this.output,
248
+ input: this.input,
249
+ witness: this.witness,
250
+ };
251
+ }
252
+ // Private computation methods
253
+ #decode(output) {
254
+ if (this.#decoded)
87
255
  return;
88
- return `p2ms(${o.m} of ${o.n})`;
89
- });
90
- if (opts.validate) {
91
- if (a.output) {
92
- decode(a.output);
93
- if (!typef.Number(chunks[0]))
256
+ this.#decoded = true;
257
+ this.#decodedChunks = (bscript.decompile(output) ?? []);
258
+ this.#m = this.#decodedChunks[0] - OP_INT_BASE;
259
+ this.#n = this.#decodedChunks[this.#decodedChunks.length - 2] - OP_INT_BASE;
260
+ this.#pubkeys = this.#decodedChunks.slice(1, -2);
261
+ this.#mComputed = true;
262
+ this.#nComputed = true;
263
+ this.#pubkeysComputed = true;
264
+ }
265
+ #computeM() {
266
+ if (this.#inputM !== undefined) {
267
+ return this.#inputM;
268
+ }
269
+ const output = this.#inputOutput ?? this.output;
270
+ if (output) {
271
+ this.#decode(output);
272
+ return this.#m;
273
+ }
274
+ return undefined;
275
+ }
276
+ #computeN() {
277
+ if (this.#inputN !== undefined) {
278
+ return this.#inputN;
279
+ }
280
+ if (this.#inputPubkeys) {
281
+ return this.#inputPubkeys.length;
282
+ }
283
+ if (this.#inputOutput) {
284
+ this.#decode(this.#inputOutput);
285
+ return this.#n;
286
+ }
287
+ return undefined;
288
+ }
289
+ #computePubkeys() {
290
+ if (this.#inputPubkeys) {
291
+ return this.#inputPubkeys;
292
+ }
293
+ if (this.#inputOutput) {
294
+ this.#decode(this.#inputOutput);
295
+ return this.#pubkeys;
296
+ }
297
+ return undefined;
298
+ }
299
+ #computeSignatures() {
300
+ if (this.#inputSignatures) {
301
+ return this.#inputSignatures;
302
+ }
303
+ if (this.#inputInput) {
304
+ const decompiled = bscript.decompile(this.#inputInput);
305
+ if (decompiled === null || decompiled === undefined) {
306
+ return undefined;
307
+ }
308
+ return decompiled.slice(1);
309
+ }
310
+ return undefined;
311
+ }
312
+ #computeOutput() {
313
+ if (this.#inputOutput) {
314
+ return this.#inputOutput;
315
+ }
316
+ const m = this.#inputM;
317
+ const n = this.n;
318
+ const pubkeys = this.#inputPubkeys;
319
+ if (m === undefined || n === undefined || !pubkeys) {
320
+ return undefined;
321
+ }
322
+ return bscript.compile([].concat(OP_INT_BASE + m, pubkeys, OP_INT_BASE + n, OPS.OP_CHECKMULTISIG));
323
+ }
324
+ #computeInput() {
325
+ if (this.#inputInput) {
326
+ return this.#inputInput;
327
+ }
328
+ if (!this.#inputSignatures) {
329
+ return undefined;
330
+ }
331
+ return bscript.compile([OPS.OP_0].concat(this.#inputSignatures));
332
+ }
333
+ // Validation
334
+ #computeWitness() {
335
+ if (this.input) {
336
+ return [];
337
+ }
338
+ return undefined;
339
+ }
340
+ #isAcceptableSignature(x) {
341
+ return (bscript.isCanonicalScriptSignature(x) ||
342
+ (this.#opts.allowIncomplete && x === OPS.OP_0));
343
+ }
344
+ #validate() {
345
+ if (this.#inputOutput) {
346
+ this.#decode(this.#inputOutput);
347
+ const chunks = this.#decodedChunks;
348
+ if (!chunks) {
349
+ throw new TypeError('Output is invalid');
350
+ }
351
+ if (typeof chunks[0] !== 'number') {
352
+ throw new TypeError('Output is invalid');
353
+ }
354
+ if (typeof chunks[chunks.length - 2] !== 'number') {
94
355
  throw new TypeError('Output is invalid');
95
- if (!typef.Number(chunks[chunks.length - 2]))
356
+ }
357
+ if (chunks[chunks.length - 1] !== OPS.OP_CHECKMULTISIG) {
96
358
  throw new TypeError('Output is invalid');
97
- if (chunks[chunks.length - 1] !== OPS.OP_CHECKMULTISIG)
359
+ }
360
+ const m = this.#m;
361
+ const n = this.#n;
362
+ const pubkeys = this.#pubkeys;
363
+ if (m === undefined || n === undefined || !pubkeys) {
98
364
  throw new TypeError('Output is invalid');
99
- if (o.m <= 0 || o.n > 16 || o.m > o.n || o.n !== chunks.length - 3)
365
+ }
366
+ if (m <= 0 || n > 16 || m > n || n !== chunks.length - 3) {
100
367
  throw new TypeError('Output is invalid');
101
- if (!o.pubkeys.every((x) => isPoint(x)))
368
+ }
369
+ if (!pubkeys.every((x) => isPoint(x))) {
102
370
  throw new TypeError('Output is invalid');
103
- if (a.m !== undefined && a.m !== o.m)
371
+ }
372
+ if (this.#inputM !== undefined && this.#inputM !== m) {
104
373
  throw new TypeError('m mismatch');
105
- if (a.n !== undefined && a.n !== o.n)
374
+ }
375
+ if (this.#inputN !== undefined && this.#inputN !== n) {
106
376
  throw new TypeError('n mismatch');
107
- if (a.pubkeys && !stacksEqual(a.pubkeys, o.pubkeys))
377
+ }
378
+ if (this.#inputPubkeys && !stacksEqual(this.#inputPubkeys, pubkeys)) {
108
379
  throw new TypeError('Pubkeys mismatch');
380
+ }
109
381
  }
110
- if (a.pubkeys) {
111
- if (a.n !== undefined && a.n !== a.pubkeys.length)
382
+ if (this.#inputPubkeys) {
383
+ if (this.#inputN !== undefined && this.#inputN !== this.#inputPubkeys.length) {
112
384
  throw new TypeError('Pubkey count mismatch');
113
- o.n = a.pubkeys.length;
114
- if (o.n < o.m)
385
+ }
386
+ this.#n = this.#inputPubkeys.length;
387
+ this.#nComputed = true;
388
+ if (this.#m !== undefined && this.#n < this.#m) {
115
389
  throw new TypeError('Pubkey count cannot be less than m');
390
+ }
116
391
  }
117
- if (a.signatures) {
118
- if (a.signatures.length < o.m)
392
+ if (this.#inputSignatures) {
393
+ if (this.#m !== undefined && this.#inputSignatures.length < this.#m) {
119
394
  throw new TypeError('Not enough signatures provided');
120
- if (a.signatures.length > o.m)
395
+ }
396
+ if (this.#m !== undefined && this.#inputSignatures.length > this.#m) {
121
397
  throw new TypeError('Too many signatures provided');
398
+ }
122
399
  }
123
- if (a.input) {
124
- if (a.input[0] !== OPS.OP_0)
400
+ if (this.#inputInput) {
401
+ if (this.#inputInput[0] !== OPS.OP_0) {
125
402
  throw new TypeError('Input is invalid');
126
- if (o.signatures.length === 0 || !o.signatures.every(isAcceptableSignature))
403
+ }
404
+ const sigs = this.signatures;
405
+ if (!sigs || sigs.length === 0 || !sigs.every((s) => this.#isAcceptableSignature(s))) {
127
406
  throw new TypeError('Input has invalid signature(s)');
128
- if (a.signatures && !stacksEqual(a.signatures, o.signatures))
407
+ }
408
+ if (this.#inputSignatures && !stacksEqual(this.#inputSignatures, sigs)) {
129
409
  throw new TypeError('Signature mismatch');
130
- if (a.m !== undefined && a.m !== a.signatures.length)
410
+ }
411
+ if (this.#inputM !== undefined &&
412
+ this.#inputSignatures &&
413
+ this.#inputM !== this.#inputSignatures.length) {
131
414
  throw new TypeError('Signature count mismatch');
415
+ }
132
416
  }
133
417
  }
134
- return Object.assign(o, a);
135
418
  }
419
+ /**
420
+ * Creates a Pay-to-Multisig (P2MS) payment object.
421
+ *
422
+ * This is the legacy factory function for backwards compatibility.
423
+ * For new code, prefer using the P2MS class directly.
424
+ *
425
+ * @param a - The payment object containing the necessary data
426
+ * @param opts - Optional payment options
427
+ * @returns The P2MS payment object
428
+ * @throws {TypeError} If the required data is not provided or if the data is invalid
429
+ *
430
+ * @example
431
+ * ```typescript
432
+ * import { p2ms } from '@btc-vision/bitcoin';
433
+ *
434
+ * // Create a 2-of-3 multisig
435
+ * const payment = p2ms({ m: 2, pubkeys: [pubkey1, pubkey2, pubkey3] });
436
+ * ```
437
+ */
438
+ export function p2ms(a, opts) {
439
+ if (!a.input && !a.output && !(a.pubkeys && a.m !== undefined) && !a.signatures) {
440
+ throw new TypeError('Not enough data');
441
+ }
442
+ const instance = new P2MS({
443
+ m: a.m,
444
+ n: a.n,
445
+ pubkeys: a.pubkeys,
446
+ signatures: a.signatures,
447
+ output: a.output,
448
+ input: a.input,
449
+ network: a.network,
450
+ }, opts);
451
+ // Return a merged object for backwards compatibility
452
+ return Object.assign(instance.toPayment(), a);
453
+ }
454
+ //# sourceMappingURL=p2ms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"p2ms.js","sourceRoot":"","sources":["../../src/payments/p2ms.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAgB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EACH,OAAO,EAKP,WAAW,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAsC,WAAW,EAAE,MAAM,YAAY,CAAC;AAE7E,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;AAC5B,MAAM,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC,CAAC,WAAW;AAEhD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,IAAI;IACb,uBAAuB;IACvB,MAAM,CAAU,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IAExC,0BAA0B;IACjB,QAAQ,CAAU;IAClB,KAAK,CAAwB;IAEtC,gCAAgC;IAChC,OAAO,CAAsB;IAC7B,OAAO,CAAsB;IAC7B,aAAa,CAA4B;IACzC,gBAAgB,CAA4B;IAC5C,YAAY,CAA0B;IACtC,WAAW,CAA0B;IAErC,yBAAyB;IACzB,EAAE,CAAsB;IACxB,EAAE,CAAsB;IACxB,QAAQ,CAA4B;IACpC,WAAW,CAA4B;IACvC,OAAO,CAA0B;IACjC,MAAM,CAA0B;IAChC,QAAQ,CAA4B;IAEpC,cAAc;IACd,UAAU,GAAG,KAAK,CAAC;IACnB,UAAU,GAAG,KAAK,CAAC;IACnB,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