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

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 (455) 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 +56 -9
  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 +12482 -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 +57 -10
  115. package/build/address.d.ts.map +1 -0
  116. package/build/address.js +80 -24
  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 +204 -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 +36 -9
  203. package/build/payments/bip341.d.ts.map +1 -0
  204. package/build/payments/bip341.js +35 -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 -152
  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 +429 -104
  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 +466 -144
  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 +113 -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 +411 -412
  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 +100 -36
  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 +175 -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 +66 -8
  332. package/scripts/bundle-ecc.ts +111 -0
  333. package/src/address.ts +81 -44
  334. package/src/bech32utils.ts +3 -3
  335. package/src/bip66.ts +34 -24
  336. package/src/block.ts +196 -84
  337. package/src/branded.ts +18 -0
  338. package/src/crypto.ts +64 -26
  339. package/src/ecc/context.ts +277 -0
  340. package/src/ecc/index.ts +14 -0
  341. package/src/ecc/types.ts +154 -0
  342. package/src/ecpair.d.ts +99 -0
  343. package/src/errors.ts +163 -0
  344. package/src/index.ts +113 -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 +34 -33
  355. package/src/payments/embed.ts +244 -41
  356. package/src/payments/index.ts +12 -10
  357. package/src/payments/p2ms.ts +490 -118
  358. package/src/payments/p2op.ts +431 -133
  359. package/src/payments/p2pk.ts +370 -72
  360. package/src/payments/p2pkh.ts +524 -130
  361. package/src/payments/p2sh.ts +572 -172
  362. package/src/payments/p2tr.ts +686 -194
  363. package/src/payments/p2wpkh.ts +484 -107
  364. package/src/payments/p2wsh.ts +526 -164
  365. package/src/payments/types.ts +80 -66
  366. package/src/psbt/bip371.ts +68 -51
  367. package/src/psbt/psbtutils.ts +39 -40
  368. package/src/psbt/types.ts +331 -0
  369. package/src/psbt/utils.ts +188 -0
  370. package/src/psbt/validation.ts +192 -0
  371. package/src/psbt.ts +566 -809
  372. package/src/pubkey.ts +22 -23
  373. package/src/push_data.ts +18 -16
  374. package/src/script.ts +82 -64
  375. package/src/script_number.ts +6 -6
  376. package/src/script_signature.ts +33 -36
  377. package/src/transaction.ts +458 -238
  378. package/src/types.ts +231 -100
  379. package/src/workers/WorkerSigningPool.node.ts +887 -0
  380. package/src/workers/WorkerSigningPool.ts +670 -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 +332 -0
  384. package/src/workers/signing-worker.ts +353 -0
  385. package/src/workers/types.ts +413 -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/vite.config.browser.ts +3 -42
  421. package/vitest.config.integration.ts +2 -0
  422. package/browser/bufferutils.d.ts +0 -34
  423. package/browser/chunks/crypto-BhCpKpek.js +0 -2033
  424. package/browser/chunks/payments-B1wlSccx.js +0 -1089
  425. package/browser/chunks/psbt-BCNk7JUx.js +0 -4055
  426. package/browser/chunks/script-DyPItFEl.js +0 -318
  427. package/browser/chunks/transaction-C_UbhMGn.js +0 -432
  428. package/browser/chunks/utils-DNZi-T5W.js +0 -761
  429. package/browser/ecc_lib.d.ts +0 -3
  430. package/browser/hooks/AdvancedSignatureManager.d.ts +0 -16
  431. package/browser/hooks/HookedSigner.d.ts +0 -4
  432. package/browser/hooks/SignatureManager.d.ts +0 -13
  433. package/browser/payments/lazy.d.ts +0 -2
  434. package/browser/typeforce.d.ts +0 -38
  435. package/build/bufferutils.d.ts +0 -34
  436. package/build/bufferutils.js +0 -141
  437. package/build/ecc_lib.d.ts +0 -3
  438. package/build/ecc_lib.js +0 -61
  439. package/build/hooks/AdvancedSignatureManager.d.ts +0 -16
  440. package/build/hooks/AdvancedSignatureManager.js +0 -52
  441. package/build/hooks/HookedSigner.d.ts +0 -4
  442. package/build/hooks/HookedSigner.js +0 -64
  443. package/build/hooks/SignatureManager.d.ts +0 -13
  444. package/build/hooks/SignatureManager.js +0 -45
  445. package/build/payments/lazy.d.ts +0 -2
  446. package/build/payments/lazy.js +0 -28
  447. package/build/tsconfig.tsbuildinfo +0 -1
  448. package/src/bufferutils.ts +0 -188
  449. package/src/ecc_lib.ts +0 -94
  450. package/src/hooks/AdvancedSignatureManager.ts +0 -104
  451. package/src/hooks/HookedSigner.ts +0 -108
  452. package/src/hooks/SignatureManager.ts +0 -84
  453. package/src/payments/lazy.ts +0 -28
  454. package/src/typeforce.d.ts +0 -38
  455. package/tsconfig.webpack.json +0 -18
@@ -1,21 +1,61 @@
1
- import { PartialSig, PsbtInput } from 'bip174/src/lib/interfaces.js';
2
- export declare const isP2MS: (script: Buffer) => boolean;
3
- export declare const isP2PK: (script: Buffer) => boolean;
4
- export declare const isP2PKH: (script: Buffer) => boolean;
5
- export declare const isP2WPKH: (script: Buffer) => boolean;
6
- export declare const isP2WSHScript: (script: Buffer) => boolean;
7
- export declare const isP2SHScript: (script: Buffer) => boolean;
8
- export declare const isP2TR: (script: Buffer) => boolean;
9
- export declare const isP2OP: (script: Buffer) => boolean;
10
- export declare const isP2A: (script: Buffer) => boolean;
11
- export declare function witnessStackToScriptWitness(witness: Buffer[]): Buffer;
12
- export declare function pubkeyPositionInScript(pubkey: Buffer, script: Buffer): number;
13
- export declare function pubkeyInScript(pubkey: Buffer, script: Buffer): boolean;
1
+ import type { PartialSig, PsbtInput } from 'bip174';
2
+ export declare const isP2MS: (script: Uint8Array) => boolean;
3
+ export declare const isP2PK: (script: Uint8Array) => boolean;
4
+ export declare const isP2PKH: (script: Uint8Array) => boolean;
5
+ export declare const isP2WPKH: (script: Uint8Array) => boolean;
6
+ export declare const isP2WSHScript: (script: Uint8Array) => boolean;
7
+ export declare const isP2SHScript: (script: Uint8Array) => boolean;
8
+ export declare const isP2TR: (script: Uint8Array) => boolean;
9
+ export declare const isP2OP: (script: Uint8Array) => boolean;
10
+ export declare const isP2A: (script: Uint8Array) => boolean;
11
+ /**
12
+ * Converts a witness stack to a script witness.
13
+ * @param witness The witness stack to convert.
14
+ * @returns The script witness as a Uint8Array.
15
+ */
16
+ export declare function witnessStackToScriptWitness(witness: Uint8Array[]): Uint8Array;
17
+ /**
18
+ * Finds the position of a public key in a script.
19
+ * @param pubkey The public key to search for.
20
+ * @param script The script to search in.
21
+ * @returns The index of the public key in the script, or -1 if not found.
22
+ * @throws {Error} If there is an unknown script error.
23
+ */
24
+ export declare function pubkeyPositionInScript(pubkey: Uint8Array, script: Uint8Array): number;
25
+ /**
26
+ * Checks if a public key is present in a script.
27
+ * @param pubkey The public key to check.
28
+ * @param script The script to search in.
29
+ * @returns A boolean indicating whether the public key is present in the script.
30
+ */
31
+ export declare function pubkeyInScript(pubkey: Uint8Array, script: Uint8Array): boolean;
32
+ /**
33
+ * Checks if an input contains a signature for a specific action.
34
+ * @param input - The input to check.
35
+ * @param action - The action to check for.
36
+ * @returns A boolean indicating whether the input contains a signature for the specified action.
37
+ */
14
38
  export declare function checkInputForSig(input: PsbtInput, action: string): boolean;
15
- type SignatureDecodeFunc = (buffer: Buffer) => {
16
- signature: Buffer;
39
+ type SignatureDecodeFunc = (buffer: Uint8Array) => {
40
+ signature: Uint8Array;
17
41
  hashType: number;
18
42
  };
19
- export declare function signatureBlocksAction(signature: Buffer, signatureDecodeFn: SignatureDecodeFunc, action: string): boolean;
43
+ /**
44
+ * Determines if a given action is allowed for a signature block.
45
+ * @param signature - The signature block.
46
+ * @param signatureDecodeFn - The function used to decode the signature.
47
+ * @param action - The action to be checked.
48
+ * @returns True if the action is allowed, false otherwise.
49
+ */
50
+ export declare function signatureBlocksAction(signature: Uint8Array, signatureDecodeFn: SignatureDecodeFunc, action: string): boolean;
51
+ /**
52
+ * Retrieves the partial signatures (Psigs) from the input's final scripts.
53
+ * Psigs are extracted from both the final scriptSig and final scriptWitness of the input.
54
+ * Only canonical script signatures are considered.
55
+ *
56
+ * @param input - The PsbtInput object representing the input.
57
+ * @returns An array of PartialSig objects containing the extracted Psigs.
58
+ */
20
59
  export declare function getPsigsFromInputFinalScripts(input: PsbtInput): PartialSig[];
21
60
  export {};
61
+ //# sourceMappingURL=psbtutils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"psbtutils.d.ts","sourceRoot":"","sources":["../../src/psbt/psbtutils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AA6BpD,eAAO,MAAM,MAAM,WAX2C,UAAU,KAAK,OAWjC,CAAC;AAC7C,eAAO,MAAM,MAAM,WAZ2C,UAAU,KAAK,OAYjC,CAAC;AAC7C,eAAO,MAAM,OAAO,WAb0C,UAAU,KAAK,OAa/B,CAAC;AAC/C,eAAO,MAAM,QAAQ,WAdyC,UAAU,KAAK,OAc7B,CAAC;AACjD,eAAO,MAAM,aAAa,WAfoC,UAAU,KAAK,OAezB,CAAC;AACrD,eAAO,MAAM,YAAY,WAhBqC,UAAU,KAAK,OAgB3B,CAAC;AACnD,eAAO,MAAM,MAAM,WAjB2C,UAAU,KAAK,OAiBjC,CAAC;AAC7C,eAAO,MAAM,MAAM,WAlB2C,UAAU,KAAK,OAkBjC,CAAC;AAC7C,eAAO,MAAM,KAAK,GAAI,QAAQ,UAAU,KAAG,OAQ1C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,CA2B7E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CA0CrF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAG1E;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK;IAC/C,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACjC,SAAS,EAAE,UAAU,EACrB,iBAAiB,EAAE,mBAAmB,EACtC,MAAM,EAAE,MAAM,GACf,OAAO,CAgBT;AAwBD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,CAa5E"}
@@ -1,4 +1,4 @@
1
- import * as varuint from 'bip174/src/lib/converter/varint.js';
1
+ import { varuint, concat, alloc, equals } from '../io/index.js';
2
2
  import { hash160 } from '../crypto.js';
3
3
  import { p2ms } from '../payments/p2ms.js';
4
4
  import { p2pk } from '../payments/p2pk.js';
@@ -32,21 +32,26 @@ export const isP2TR = isPaymentFactory(p2tr);
32
32
  export const isP2OP = isPaymentFactory(p2op);
33
33
  export const isP2A = (script) => {
34
34
  return (script.length === 4 &&
35
- script[0] === 0x51 &&
36
- script[1] === 0x02 &&
35
+ script[0] === 0x51 && // OP_1
36
+ script[1] === 0x02 && // push 2 bytes
37
37
  script[2] === 0x4e &&
38
38
  script[3] === 0x73);
39
39
  };
40
+ /**
41
+ * Converts a witness stack to a script witness.
42
+ * @param witness The witness stack to convert.
43
+ * @returns The script witness as a Uint8Array.
44
+ */
40
45
  export function witnessStackToScriptWitness(witness) {
41
- let buffer = Buffer.allocUnsafe(0);
46
+ const chunks = [];
42
47
  function writeSlice(slice) {
43
- buffer = Buffer.concat([buffer, Buffer.from(slice)]);
48
+ chunks.push(slice);
44
49
  }
45
50
  function writeVarInt(i) {
46
- const currentLen = buffer.length;
47
51
  const varintLen = varuint.encodingLength(i);
48
- buffer = Buffer.concat([buffer, Buffer.allocUnsafe(varintLen)]);
49
- varuint.encode(i, buffer, currentLen);
52
+ const buf = alloc(varintLen);
53
+ varuint.encode(i, buf, 0);
54
+ chunks.push(buf);
50
55
  }
51
56
  function writeVarSlice(slice) {
52
57
  writeVarInt(slice.length);
@@ -57,13 +62,22 @@ export function witnessStackToScriptWitness(witness) {
57
62
  vector.forEach(writeVarSlice);
58
63
  }
59
64
  writeVector(witness);
60
- return buffer;
65
+ return concat(chunks);
61
66
  }
67
+ /**
68
+ * Finds the position of a public key in a script.
69
+ * @param pubkey The public key to search for.
70
+ * @param script The script to search in.
71
+ * @returns The index of the public key in the script, or -1 if not found.
72
+ * @throws {Error} If there is an unknown script error.
73
+ */
62
74
  export function pubkeyPositionInScript(pubkey, script) {
63
75
  const decompiled = bscript.decompile(script);
64
76
  if (decompiled === null)
65
77
  throw new Error('Unknown script error');
78
+ // For P2PKH or P2PK
66
79
  const pubkeyHash = hash160(pubkey);
80
+ // For Taproot or some cases, we might also check the x-only
67
81
  const pubkeyXOnly = toXOnly(pubkey);
68
82
  const uncompressed = decompressPublicKey(pubkey);
69
83
  const pubkeyHybridHash = uncompressed?.hybrid ? hash160(uncompressed.hybrid) : undefined;
@@ -77,7 +91,7 @@ export function pubkeyPositionInScript(pubkey, script) {
77
91
  return true;
78
92
  if (pubkeysMatch(element, pubkeyXOnly))
79
93
  return true;
80
- if (element.equals(pubkeyHash)) {
94
+ if (equals(element, pubkeyHash)) {
81
95
  return true;
82
96
  }
83
97
  if (uncompressed) {
@@ -85,20 +99,40 @@ export function pubkeyPositionInScript(pubkey, script) {
85
99
  return true;
86
100
  if (pubkeysMatch(element, uncompressed.hybrid))
87
101
  return true;
88
- if ((pubkeyHybridHash && element.equals(pubkeyHybridHash)) ||
89
- (pubkeyUncompressedHash && element.equals(pubkeyUncompressedHash))) {
102
+ if ((pubkeyHybridHash && equals(element, pubkeyHybridHash)) ||
103
+ (pubkeyUncompressedHash && equals(element, pubkeyUncompressedHash))) {
90
104
  return true;
91
105
  }
92
106
  }
107
+ return false;
93
108
  });
94
109
  }
110
+ /**
111
+ * Checks if a public key is present in a script.
112
+ * @param pubkey The public key to check.
113
+ * @param script The script to search in.
114
+ * @returns A boolean indicating whether the public key is present in the script.
115
+ */
95
116
  export function pubkeyInScript(pubkey, script) {
96
117
  return pubkeyPositionInScript(pubkey, script) !== -1;
97
118
  }
119
+ /**
120
+ * Checks if an input contains a signature for a specific action.
121
+ * @param input - The input to check.
122
+ * @param action - The action to check for.
123
+ * @returns A boolean indicating whether the input contains a signature for the specified action.
124
+ */
98
125
  export function checkInputForSig(input, action) {
99
126
  const pSigs = extractPartialSigs(input);
100
127
  return pSigs.some((pSig) => signatureBlocksAction(pSig, bscript.signature.decode, action));
101
128
  }
129
+ /**
130
+ * Determines if a given action is allowed for a signature block.
131
+ * @param signature - The signature block.
132
+ * @param signatureDecodeFn - The function used to decode the signature.
133
+ * @param action - The action to be checked.
134
+ * @returns True if the action is allowed, false otherwise.
135
+ */
102
136
  export function signatureBlocksAction(signature, signatureDecodeFn, action) {
103
137
  const { hashType } = signatureDecodeFn(signature);
104
138
  const whitelist = [];
@@ -117,6 +151,16 @@ export function signatureBlocksAction(signature, signatureDecodeFn, action) {
117
151
  }
118
152
  return whitelist.indexOf(action) === -1;
119
153
  }
154
+ /**
155
+ * Extracts the signatures from a PsbtInput object.
156
+ * If the input has partial signatures, it returns an array of the signatures.
157
+ * If the input does not have partial signatures, it checks if it has a finalScriptSig or finalScriptWitness.
158
+ * If it does, it extracts the signatures from the final scripts and returns them.
159
+ * If none of the above conditions are met, it returns an empty array.
160
+ *
161
+ * @param input - The PsbtInput object from which to extract the signatures.
162
+ * @returns An array of signatures extracted from the PsbtInput object.
163
+ */
120
164
  function extractPartialSigs(input) {
121
165
  const { partialSig } = input;
122
166
  let pSigs;
@@ -128,17 +172,28 @@ function extractPartialSigs(input) {
128
172
  else {
129
173
  pSigs = partialSig;
130
174
  }
131
- return pSigs.map((p) => p.signature);
175
+ return pSigs.map((p) => new Uint8Array(p.signature));
132
176
  }
177
+ /**
178
+ * Retrieves the partial signatures (Psigs) from the input's final scripts.
179
+ * Psigs are extracted from both the final scriptSig and final scriptWitness of the input.
180
+ * Only canonical script signatures are considered.
181
+ *
182
+ * @param input - The PsbtInput object representing the input.
183
+ * @returns An array of PartialSig objects containing the extracted Psigs.
184
+ */
133
185
  export function getPsigsFromInputFinalScripts(input) {
134
- const scriptItems = !input.finalScriptSig ? [] : bscript.decompile(input.finalScriptSig) || [];
186
+ const scriptItems = !input.finalScriptSig
187
+ ? []
188
+ : bscript.decompile(new Uint8Array(input.finalScriptSig)) || [];
135
189
  const witnessItems = !input.finalScriptWitness
136
190
  ? []
137
- : bscript.decompile(input.finalScriptWitness) || [];
191
+ : bscript.decompile(new Uint8Array(input.finalScriptWitness)) || [];
138
192
  return scriptItems
139
193
  .concat(witnessItems)
140
194
  .filter((item) => {
141
- return Buffer.isBuffer(item) && bscript.isCanonicalScriptSignature(item);
195
+ return item instanceof Uint8Array && bscript.isCanonicalScriptSignature(item);
142
196
  })
143
197
  .map((sig) => ({ signature: sig }));
144
198
  }
199
+ //# sourceMappingURL=psbtutils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"psbtutils.js","sourceRoot":"","sources":["../../src/psbt/psbtutils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,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pB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACb,OAAO,IAAI,YAAY,UAAU,IAAI,OAAO,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAClF,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,GAAiB,EAAE,CAAC,CAAiB,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,249 @@
1
+ /**
2
+ * PSBT types and interfaces
3
+ * @packageDocumentation
4
+ */
5
+ import type { Psbt as PsbtBase, PsbtGlobal, PsbtInput, PsbtOutput } from 'bip174';
6
+ import type { Network } from '../networks.js';
7
+ import type { Transaction, TaprootHashCache } from '../transaction.js';
8
+ import type { Bytes32, PublicKey, Satoshi, Script, Signature, SchnorrSignature } from '../types.js';
9
+ /**
10
+ * Transaction input interface for PSBT.
11
+ */
12
+ export interface TransactionInput {
13
+ readonly hash: string | Bytes32;
14
+ readonly index: number;
15
+ readonly sequence?: number | undefined;
16
+ }
17
+ /**
18
+ * PSBT transaction input with Uint8Array hash.
19
+ */
20
+ export interface PsbtTxInput extends TransactionInput {
21
+ readonly hash: Bytes32;
22
+ }
23
+ /**
24
+ * Transaction output interface for PSBT.
25
+ */
26
+ export interface TransactionOutput {
27
+ readonly script: Script;
28
+ readonly value: Satoshi;
29
+ }
30
+ /**
31
+ * PSBT transaction output with optional address.
32
+ */
33
+ export interface PsbtTxOutput extends TransactionOutput {
34
+ readonly address: string | undefined;
35
+ }
36
+ /**
37
+ * Signature validation function type.
38
+ * msghash is 32 byte hash of preimage, signature is 64 byte compact signature (r,s 32 bytes each)
39
+ */
40
+ export type ValidateSigFunction = (pubkey: PublicKey, msghash: Bytes32, signature: Uint8Array) => boolean;
41
+ /**
42
+ * Extended PsbtBase interface with typed inputs and globalMap.
43
+ */
44
+ export interface PsbtBaseExtended extends Omit<PsbtBase, 'inputs'> {
45
+ readonly inputs: PsbtInput[];
46
+ readonly globalMap: PsbtGlobal;
47
+ }
48
+ /**
49
+ * Optional PSBT options.
50
+ */
51
+ export interface PsbtOptsOptional {
52
+ readonly network?: Network | undefined;
53
+ readonly maximumFeeRate?: number | undefined;
54
+ readonly version?: 1 | 2 | 3 | undefined;
55
+ }
56
+ /**
57
+ * Required PSBT options.
58
+ */
59
+ export interface PsbtOpts {
60
+ readonly network: Network;
61
+ maximumFeeRate: number;
62
+ }
63
+ /**
64
+ * Extended PSBT input with additional fields.
65
+ */
66
+ export interface PsbtInputExtended extends PsbtInput, TransactionInput {
67
+ readonly isPayToAnchor?: boolean | undefined;
68
+ }
69
+ /**
70
+ * Extended PSBT output - either address-based or script-based.
71
+ */
72
+ export type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
73
+ /**
74
+ * PSBT output with address.
75
+ */
76
+ export interface PsbtOutputExtendedAddress extends PsbtOutput {
77
+ readonly address: string;
78
+ readonly value: Satoshi;
79
+ }
80
+ /**
81
+ * PSBT output with script.
82
+ */
83
+ export interface PsbtOutputExtendedScript extends PsbtOutput {
84
+ readonly script: Script;
85
+ readonly value: Satoshi;
86
+ }
87
+ /**
88
+ * Base interface for HD signers.
89
+ */
90
+ interface HDSignerBase {
91
+ /**
92
+ * DER format compressed publicKey Uint8Array
93
+ */
94
+ readonly publicKey: PublicKey;
95
+ /**
96
+ * The first 4 bytes of the sha256-ripemd160 of the publicKey
97
+ */
98
+ readonly fingerprint: Uint8Array;
99
+ }
100
+ /**
101
+ * HD signer interface for synchronous signing.
102
+ */
103
+ export interface HDSigner extends HDSignerBase {
104
+ /**
105
+ * The path string must match /^m(\/\d+'?)+$/
106
+ * ex. m/44'/0'/0'/1/23 levels with ' must be hard derivations
107
+ */
108
+ derivePath(path: string): HDSigner;
109
+ /**
110
+ * Input hash (the "message digest") for the signature algorithm
111
+ * Return a 64 byte signature (32 byte r and 32 byte s in that order)
112
+ */
113
+ sign(hash: Bytes32): Uint8Array;
114
+ }
115
+ /**
116
+ * HD signer interface for asynchronous signing.
117
+ */
118
+ export interface HDSignerAsync extends HDSignerBase {
119
+ derivePath(path: string): HDSignerAsync;
120
+ sign(hash: Bytes32): Promise<Uint8Array>;
121
+ }
122
+ /**
123
+ * Alternative signer interface with lowR support.
124
+ */
125
+ export interface SignerAlternative {
126
+ readonly publicKey: PublicKey;
127
+ readonly lowR: boolean;
128
+ sign(hash: Bytes32, lowR?: boolean): Signature;
129
+ verify(hash: Bytes32, signature: Signature): boolean;
130
+ signSchnorr(hash: Bytes32): SchnorrSignature;
131
+ verifySchnorr(hash: Bytes32, signature: SchnorrSignature): boolean;
132
+ }
133
+ /**
134
+ * Basic signer interface for synchronous signing.
135
+ */
136
+ export interface Signer {
137
+ readonly publicKey: PublicKey;
138
+ readonly network?: Network | undefined;
139
+ sign(hash: Bytes32, lowR?: boolean): Signature;
140
+ signSchnorr?(hash: Bytes32): SchnorrSignature;
141
+ getPublicKey?(): PublicKey;
142
+ }
143
+ /**
144
+ * Basic signer interface for asynchronous signing.
145
+ */
146
+ export interface SignerAsync {
147
+ readonly publicKey: PublicKey;
148
+ readonly network?: Network | undefined;
149
+ sign(hash: Bytes32, lowR?: boolean): Promise<Signature>;
150
+ signSchnorr?(hash: Bytes32): Promise<SchnorrSignature>;
151
+ getPublicKey?(): PublicKey;
152
+ }
153
+ /**
154
+ * Minimal key pair interface for checking Taproot hashes.
155
+ * Only requires publicKey and optional signSchnorr presence check.
156
+ * Used by checkTaprootHashesForSig to accept broader key pair types (e.g., worker key pairs).
157
+ */
158
+ export interface TaprootHashCheckSigner {
159
+ readonly publicKey: Uint8Array;
160
+ signSchnorr?(hash: Uint8Array): Uint8Array | Promise<Uint8Array>;
161
+ }
162
+ /**
163
+ * Internal PSBT cache for computed values.
164
+ */
165
+ export interface PsbtCache {
166
+ nonWitnessUtxoTxCache: Transaction[];
167
+ nonWitnessUtxoBufCache: Uint8Array[];
168
+ txInCache: TxInCacheMap;
169
+ tx: Transaction;
170
+ feeRate?: number | undefined;
171
+ fee?: number | undefined;
172
+ extractedTx?: Transaction | undefined;
173
+ unsafeSignNonSegwit: boolean;
174
+ /** Cached flag: true if any input has signatures (avoids O(n) check) */
175
+ hasSignatures: boolean;
176
+ /** Cached prevOuts for Taproot signing (computed once) */
177
+ prevOuts?: readonly PrevOut[] | undefined;
178
+ /** Cached signing scripts */
179
+ signingScripts?: readonly Script[] | undefined;
180
+ /** Cached values */
181
+ values?: readonly Satoshi[] | undefined;
182
+ /** Cached intermediate hashes for Taproot sighash (computed once per PSBT) */
183
+ taprootHashCache?: TaprootHashCache | undefined;
184
+ }
185
+ /**
186
+ * Keys for cached numeric values in the transaction cache.
187
+ */
188
+ export type TxCacheNumberKey = 'feeRate' | 'fee';
189
+ /**
190
+ * Script types for classification.
191
+ */
192
+ export type ScriptType = 'witnesspubkeyhash' | 'pubkeyhash' | 'multisig' | 'pubkey' | 'nonstandard';
193
+ /**
194
+ * All possible script types including witness types.
195
+ * Note: P2WPKH can't be wrapped in P2WSH (already a witness program)
196
+ */
197
+ export type AllScriptType = 'witnesspubkeyhash' | 'pubkeyhash' | 'multisig' | 'pubkey' | 'nonstandard' | 'p2sh-witnesspubkeyhash' | 'p2sh-pubkeyhash' | 'p2sh-multisig' | 'p2sh-pubkey' | 'p2sh-nonstandard' | 'p2wsh-pubkeyhash' | 'p2wsh-multisig' | 'p2wsh-pubkey' | 'p2wsh-nonstandard' | 'p2sh-p2wsh-pubkeyhash' | 'p2sh-p2wsh-multisig' | 'p2sh-p2wsh-pubkey' | 'p2sh-p2wsh-nonstandard';
198
+ /**
199
+ * Return type for getScriptFromInput function.
200
+ */
201
+ export interface GetScriptReturn {
202
+ script: Script | null;
203
+ isSegwit: boolean;
204
+ isP2SH: boolean;
205
+ isP2WSH: boolean;
206
+ }
207
+ /**
208
+ * Index map for transaction input cache.
209
+ */
210
+ export interface TxInCacheMap {
211
+ readonly [index: string]: number;
212
+ }
213
+ /**
214
+ * Previous output data for signing.
215
+ */
216
+ export interface PrevOut {
217
+ readonly script: Script;
218
+ readonly value: Satoshi;
219
+ }
220
+ /**
221
+ * Result from getTaprootHashesForSig containing hash and optional leaf hash.
222
+ */
223
+ export interface TaprootHashResult {
224
+ readonly hash: Bytes32;
225
+ readonly leafHash?: Bytes32 | undefined;
226
+ }
227
+ /**
228
+ * Extended Taproot hash result with pubkey for validation.
229
+ */
230
+ export interface TaprootSigningHash {
231
+ readonly pubkey: PublicKey;
232
+ readonly hash: Bytes32;
233
+ readonly leafHash?: Bytes32 | undefined;
234
+ }
235
+ /**
236
+ * Function type for final scripts computation.
237
+ */
238
+ export type FinalScriptsFunc = (inputIndex: number, input: PsbtInput, script: Script, isSegwit: boolean, isP2SH: boolean, isP2WSH: boolean, canRunChecks: boolean) => {
239
+ finalScriptSig: Script | undefined;
240
+ finalScriptWitness: Uint8Array | undefined;
241
+ };
242
+ /**
243
+ * Function type for final Taproot scripts computation.
244
+ */
245
+ export type FinalTaprootScriptsFunc = (inputIndex: number, input: PsbtInput, tapLeafHashToFinalize?: Bytes32) => {
246
+ finalScriptWitness: Uint8Array | undefined;
247
+ };
248
+ export {};
249
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/psbt/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EACR,OAAO,EACP,SAAS,EACT,OAAO,EACP,MAAM,EACN,SAAS,EACT,gBAAgB,EACnB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAA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;GAEG;AACH,MAAM,WAAW,OAAO;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC3B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,KACpB;IACD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAClC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,EAChB,qBAAqB,CAAC,EAAE,OAAO,KAC9B;IACD,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9C,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * PSBT types and interfaces
3
+ * @packageDocumentation
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/psbt/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * PSBT utility functions
3
+ * @packageDocumentation
4
+ */
5
+ import type { ScriptType } from './types.js';
6
+ /**
7
+ * Converts a witness script buffer to an array of witness stack items.
8
+ * @param buffer - The witness script buffer
9
+ * @returns Array of witness stack items
10
+ */
11
+ export declare function scriptWitnessToWitnessStack(buffer: Uint8Array): Uint8Array[];
12
+ /**
13
+ * Converts a sighash type to a human-readable string.
14
+ * @param sighashType - The sighash type value
15
+ * @returns Human-readable sighash type string
16
+ */
17
+ export declare function sighashTypeToString(sighashType: number): string;
18
+ /**
19
+ * Compresses an uncompressed public key to compressed form.
20
+ * @param pubkey - The public key (33 or 65 bytes)
21
+ * @returns Compressed public key (33 bytes)
22
+ */
23
+ export declare function compressPubkey(pubkey: Uint8Array): Uint8Array;
24
+ /**
25
+ * Checks if a buffer looks like a public key.
26
+ * @param buf - The buffer to check
27
+ * @returns True if the buffer is a valid compressed public key format
28
+ */
29
+ export declare function isPubkeyLike(buf: Uint8Array): boolean;
30
+ /**
31
+ * Checks if a buffer looks like a signature.
32
+ * @param buf - The buffer to check
33
+ * @returns True if the buffer is a valid canonical signature format
34
+ */
35
+ export declare function isSigLike(buf: Uint8Array): boolean;
36
+ /**
37
+ * Classifies a script into a known script type.
38
+ * @param script - The script to classify
39
+ * @returns The script type
40
+ */
41
+ export declare function classifyScript(script: Uint8Array): ScriptType;
42
+ /**
43
+ * Creates an array of numbers from 0 to n-1.
44
+ * @param n - The length of the array
45
+ * @returns Array of numbers [0, 1, 2, ..., n-1]
46
+ */
47
+ export declare function range(n: number): number[];
48
+ /**
49
+ * Validates that a script is not P2WPKH or P2SH (invalid for P2WSH).
50
+ * @param script - The script to check
51
+ * @throws {Error} If the script is P2WPKH or P2SH
52
+ */
53
+ export declare function checkInvalidP2WSH(script: Uint8Array): void;
54
+ /**
55
+ * Extracts the meaningful script from a potentially wrapped script.
56
+ * Handles P2SH, P2WSH, and P2SH-P2WSH wrapping.
57
+ * @param script - The script to analyze
58
+ * @param index - The input/output index (for error messages)
59
+ * @param ioType - Whether this is an input or output
60
+ * @param redeemScript - Optional redeem script for P2SH
61
+ * @param witnessScript - Optional witness script for P2WSH
62
+ * @returns The meaningful script and its type
63
+ */
64
+ export declare function getMeaningfulScript(script: Uint8Array, index: number, ioType: 'input' | 'output', redeemScript?: Uint8Array, witnessScript?: Uint8Array): {
65
+ meaningfulScript: Uint8Array;
66
+ type: 'p2sh' | 'p2wsh' | 'p2sh-p2wsh' | 'raw';
67
+ };
68
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/psbt/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,CA0B5E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAe/D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAQ7D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAElD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAM7D;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAI1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,GAAG,QAAQ,EAC1B,YAAY,CAAC,EAAE,UAAU,EACzB,aAAa,CAAC,EAAE,UAAU,GAC3B;IACC,gBAAgB,EAAE,UAAU,CAAC;IAC7B,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,KAAK,CAAC;CACjD,CAkCA"}