@btc-vision/bitcoin 6.4.10 → 6.5.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 (220) hide show
  1. package/.babelrc +13 -4
  2. package/.mocharc.json +13 -13
  3. package/.prettierrc.json +12 -12
  4. package/CHANGELOG.md +403 -403
  5. package/CONTRIBUTING.md +83 -83
  6. package/LICENSE +21 -21
  7. package/README.md +201 -201
  8. package/browser/chunks/crypto-C6FlKKmp.js +2006 -0
  9. package/browser/chunks/payments-BE4vwHhV.js +1045 -0
  10. package/browser/chunks/psbt-Dlosf9CT.js +3853 -0
  11. package/browser/chunks/script-COWGdiOo.js +318 -0
  12. package/browser/chunks/transaction-BiXwH2v4.js +421 -0
  13. package/browser/chunks/utils-BKmkTzNZ.js +759 -0
  14. package/browser/crypto/crypto.d.ts +1 -1
  15. package/browser/index.d.ts +7 -27
  16. package/browser/index.js +92 -2
  17. package/build/index.d.ts +7 -27
  18. package/build/index.js +2 -2
  19. package/cjs/package.json +3 -3
  20. package/gulpfile.js +42 -42
  21. package/package.json +153 -150
  22. package/src/bip66.ts +107 -107
  23. package/src/block.ts +233 -233
  24. package/src/bufferutils.ts +188 -188
  25. package/src/crypto.ts +108 -108
  26. package/src/ecc_lib.ts +94 -94
  27. package/src/hooks/AdvancedSignatureManager.ts +104 -104
  28. package/src/hooks/SignatureManager.ts +84 -84
  29. package/src/index.ts +83 -105
  30. package/src/merkle.ts +31 -31
  31. package/src/opcodes.ts +280 -280
  32. package/src/payments/bip341.ts +140 -140
  33. package/src/payments/embed.ts +61 -61
  34. package/src/payments/index.ts +172 -172
  35. package/src/payments/lazy.ts +28 -28
  36. package/src/payments/p2ms.ts +156 -156
  37. package/src/payments/p2op.ts +195 -195
  38. package/src/payments/p2pk.ts +93 -93
  39. package/src/payments/p2pkh.ts +214 -214
  40. package/src/payments/p2tr.ts +309 -309
  41. package/src/psbt/bip371.ts +441 -441
  42. package/src/push_data.ts +97 -97
  43. package/src/script.ts +247 -247
  44. package/src/script_number.ts +72 -72
  45. package/src/script_signature.ts +91 -91
  46. package/src/transaction.ts +656 -656
  47. package/test/address.spec.ts +155 -155
  48. package/test/bitcoin.core.spec.ts +212 -212
  49. package/test/block.spec.ts +171 -171
  50. package/test/bufferutils.spec.ts +450 -450
  51. package/test/crypto.spec.ts +49 -49
  52. package/test/fixtures/address.json +329 -329
  53. package/test/fixtures/block.json +148 -148
  54. package/test/fixtures/bufferutils.json +102 -102
  55. package/test/fixtures/core/README.md +26 -26
  56. package/test/fixtures/core/base58_encode_decode.json +50 -50
  57. package/test/fixtures/core/base58_keys_invalid.json +152 -152
  58. package/test/fixtures/core/base58_keys_valid.json +452 -452
  59. package/test/fixtures/core/blocks.json +27 -27
  60. package/test/fixtures/core/sig_canonical.json +7 -7
  61. package/test/fixtures/core/sig_noncanonical.json +33 -33
  62. package/test/fixtures/core/sighash.json +3505 -3505
  63. package/test/fixtures/core/tx_valid.json +2023 -2023
  64. package/test/fixtures/crypto.json +43 -43
  65. package/test/fixtures/ecdsa.json +217 -217
  66. package/test/fixtures/ecpair.json +141 -141
  67. package/test/fixtures/embed.json +108 -108
  68. package/test/fixtures/p2ms.json +434 -434
  69. package/test/fixtures/p2pk.json +179 -179
  70. package/test/fixtures/p2pkh.json +276 -276
  71. package/test/fixtures/p2sh.json +508 -508
  72. package/test/fixtures/p2tr.json +1198 -1198
  73. package/test/fixtures/p2wpkh.json +290 -290
  74. package/test/fixtures/p2wsh.json +489 -489
  75. package/test/fixtures/psbt.json +924 -924
  76. package/test/fixtures/script.json +465 -465
  77. package/test/fixtures/script_number.json +225 -225
  78. package/test/fixtures/signature.json +140 -140
  79. package/test/fixtures/transaction.json +916 -916
  80. package/test/integration/_regtest.ts +6 -6
  81. package/test/integration/addresses.spec.ts +142 -142
  82. package/test/integration/bip32.spec.ts +130 -130
  83. package/test/integration/blocks.spec.ts +28 -28
  84. package/test/integration/cltv.spec.ts +241 -241
  85. package/test/integration/csv.spec.ts +452 -452
  86. package/test/integration/payments.spec.ts +110 -110
  87. package/test/integration/taproot.spec.ts +663 -663
  88. package/test/integration/transactions.spec.ts +668 -668
  89. package/test/payments.spec.ts +114 -114
  90. package/test/payments.utils.ts +165 -165
  91. package/test/psbt.spec.ts +1285 -1285
  92. package/test/script.spec.ts +186 -186
  93. package/test/script_number.spec.ts +26 -26
  94. package/test/script_signature.spec.ts +66 -66
  95. package/test/transaction.spec.ts +337 -337
  96. package/test/ts-node-register.js +7 -7
  97. package/test/tsconfig.json +48 -48
  98. package/test/types.spec.ts +53 -53
  99. package/tsconfig.base.json +27 -27
  100. package/tsconfig.json +19 -19
  101. package/tsconfig.webpack.json +18 -18
  102. package/vite.config.browser.ts +93 -0
  103. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.ready +0 -0
  104. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.release-please-manifest.json +0 -3
  105. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CHANGELOG.md +0 -962
  106. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CONTRIBUTING.md +0 -34
  107. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/LICENSE +0 -24
  108. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/README.md +0 -273
  109. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/SECURITY.md +0 -2
  110. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/addon.gypi +0 -204
  111. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/bin/node-gyp.js +0 -138
  112. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/.release-please-manifest.json +0 -3
  113. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/LICENSE +0 -28
  114. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/ninja/build.ninja +0 -4
  115. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +0 -12
  116. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/GypVsCMake.md +0 -116
  117. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Hacking.md +0 -46
  118. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/InputFormatReference.md +0 -1080
  119. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/LanguageSpecification.md +0 -430
  120. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/README.md +0 -27
  121. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Testing.md +0 -450
  122. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/UserDocumentation.md +0 -965
  123. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp +0 -8
  124. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp.bat +0 -5
  125. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp_main.py +0 -45
  126. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -365
  127. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
  128. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1272
  129. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
  130. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
  131. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
  132. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
  133. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
  134. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -692
  135. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -711
  136. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -171
  137. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -169
  138. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -113
  139. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
  140. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  141. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -804
  142. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
  143. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1318
  144. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -127
  145. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
  146. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -461
  147. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
  148. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -57
  149. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2745
  150. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3976
  151. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
  152. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2964
  153. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -67
  154. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1391
  155. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
  156. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3115
  157. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
  158. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
  159. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1260
  160. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
  161. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
  162. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -373
  163. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1938
  164. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +0 -53
  165. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
  166. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3198
  167. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
  168. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +0 -3
  169. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +0 -177
  170. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +0 -23
  171. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +0 -15
  172. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +0 -108
  173. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +0 -252
  174. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +0 -83
  175. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +0 -359
  176. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +0 -61
  177. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +0 -192
  178. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/markers.py +0 -252
  179. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +0 -825
  180. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
  181. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +0 -90
  182. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +0 -1030
  183. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/tags.py +0 -553
  184. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/utils.py +0 -172
  185. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/version.py +0 -563
  186. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pyproject.toml +0 -120
  187. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/release-please-config.json +0 -11
  188. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/test_gyp.py +0 -261
  189. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/Find-VisualStudio.cs +0 -250
  190. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/build.js +0 -227
  191. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/clean.js +0 -15
  192. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/configure.js +0 -328
  193. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/create-config-gypi.js +0 -150
  194. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/download.js +0 -39
  195. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-node-directory.js +0 -63
  196. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-python.js +0 -310
  197. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-visualstudio.js +0 -590
  198. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/install.js +0 -415
  199. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/list.js +0 -26
  200. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/log.js +0 -168
  201. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/node-gyp.js +0 -188
  202. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/process-release.js +0 -146
  203. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/rebuild.js +0 -12
  204. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/remove.js +0 -43
  205. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/util.js +0 -81
  206. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/macOS_Catalina_acid_test.sh +0 -21
  207. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/package.json +0 -51
  208. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/release-please-config.json +0 -40
  209. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/src/win_delay_load_hook.cc +0 -39
  210. package/browser/index.js.LICENSE.txt +0 -14
  211. package/browser/ops.d.ts +0 -126
  212. package/build/ops.d.ts +0 -126
  213. package/build/ops.js +0 -127
  214. package/coverage/tmp/coverage-31752-1735543485354-0.json +0 -1
  215. package/coverage/tmp/coverage-59920-1735543484555-0.json +0 -1
  216. package/coverage/tmp/coverage-66252-1735543483919-0.json +0 -1
  217. package/coverage/tmp/coverage-68440-1735543485236-0.json +0 -1
  218. package/coverage/tmp/coverage-70588-1735543484426-0.json +0 -1
  219. package/coverage/tmp/coverage-79292-1735543485296-0.json +0 -1
  220. package/coverage/tmp/coverage-80212-1735543483980-0.json +0 -1
@@ -0,0 +1,421 @@
1
+ import { B as a, d as I, b as N, t as Z } from "./crypto-C6FlKKmp.js";
2
+ import { f as z, k as K, l as D, a as C, m as b, n as P, o as _, N as $, S as W, g as R, p as V, B as m, r as M, F as Q, q as J, h as tt } from "./utils-BKmkTzNZ.js";
3
+ import { c as et, d as st, o as it } from "./script-COWGdiOo.js";
4
+ const { typeforce: A } = K;
5
+ function p(f) {
6
+ const t = f.length;
7
+ return R(t) + t;
8
+ }
9
+ function rt(f) {
10
+ const t = f.length;
11
+ return R(t) + f.reduce((e, s) => e + p(s), 0);
12
+ }
13
+ const H = a.allocUnsafe(0), T = [], k = a.from(
14
+ "0000000000000000000000000000000000000000000000000000000000000000",
15
+ "hex"
16
+ ), F = a.from(
17
+ "0000000000000000000000000000000000000000000000000000000000000001",
18
+ "hex"
19
+ ), nt = a.from("ffffffffffffffff", "hex"), ot = {
20
+ script: H,
21
+ valueBuffer: nt
22
+ };
23
+ function ht(f) {
24
+ return f.value !== void 0;
25
+ }
26
+ class o {
27
+ constructor() {
28
+ this.version = 1, this.locktime = 0, this.ins = [], this.outs = [];
29
+ }
30
+ static {
31
+ this.DEFAULT_SEQUENCE = 4294967295;
32
+ }
33
+ static {
34
+ this.SIGHASH_DEFAULT = 0;
35
+ }
36
+ static {
37
+ this.SIGHASH_ALL = 1;
38
+ }
39
+ static {
40
+ this.SIGHASH_NONE = 2;
41
+ }
42
+ static {
43
+ this.SIGHASH_SINGLE = 3;
44
+ }
45
+ static {
46
+ this.SIGHASH_ANYONECANPAY = 128;
47
+ }
48
+ static {
49
+ this.SIGHASH_OUTPUT_MASK = 3;
50
+ }
51
+ static {
52
+ this.SIGHASH_INPUT_MASK = 128;
53
+ }
54
+ static {
55
+ this.ADVANCED_TRANSACTION_MARKER = 0;
56
+ }
57
+ static {
58
+ this.ADVANCED_TRANSACTION_FLAG = 1;
59
+ }
60
+ static {
61
+ this.TRUC_VERSION = 3;
62
+ }
63
+ static {
64
+ this.TRUC_MAX_VSIZE = 1e4;
65
+ }
66
+ static {
67
+ this.TRUC_CHILD_MAX_VSIZE = 1e3;
68
+ }
69
+ static fromBuffer(t, e) {
70
+ const s = new z(t), i = new o();
71
+ i.version = s.readInt32();
72
+ const n = s.readUInt8(), r = s.readUInt8();
73
+ let h = !1;
74
+ n === o.ADVANCED_TRANSACTION_MARKER && r === o.ADVANCED_TRANSACTION_FLAG ? h = !0 : s.offset -= 2;
75
+ const g = s.readVarInt();
76
+ for (let w = 0; w < g; ++w) {
77
+ const S = s.readSlice(32), U = s.readUInt32(), v = s.readVarSlice(), L = s.readUInt32();
78
+ i.ins.push({
79
+ hash: S,
80
+ index: U,
81
+ script: v,
82
+ sequence: L,
83
+ witness: T
84
+ });
85
+ }
86
+ const d = s.readVarInt();
87
+ for (let w = 0; w < d; ++w)
88
+ i.outs.push({
89
+ value: s.readUInt64(),
90
+ script: s.readVarSlice()
91
+ });
92
+ if (h) {
93
+ for (let w = 0; w < g; ++w)
94
+ i.ins[w].witness = s.readVector();
95
+ if (!i.hasWitnesses()) throw new Error("Transaction has superfluous witness data");
96
+ }
97
+ if (i.locktime = s.readUInt32(), e) return i;
98
+ if (s.offset !== t.length)
99
+ throw new Error("Transaction has unexpected data");
100
+ return i;
101
+ }
102
+ static fromHex(t) {
103
+ return o.fromBuffer(a.from(t, "hex"), !1);
104
+ }
105
+ static isCoinbaseHash(t) {
106
+ A(D, t);
107
+ for (let e = 0; e < 32; ++e)
108
+ if (t[e] !== 0) return !1;
109
+ return !0;
110
+ }
111
+ isCoinbase() {
112
+ return this.ins.length === 1 && o.isCoinbaseHash(this.ins[0].hash);
113
+ }
114
+ addInput(t, e, s, i) {
115
+ return A(
116
+ C(
117
+ D,
118
+ b,
119
+ P(b),
120
+ P(_)
121
+ ),
122
+ arguments
123
+ ), $(s) && (s = o.DEFAULT_SEQUENCE), this.ins.push({
124
+ hash: t,
125
+ index: e,
126
+ script: i || H,
127
+ sequence: s,
128
+ witness: T
129
+ }) - 1;
130
+ }
131
+ addOutput(t, e) {
132
+ return A(C(_, W), arguments), this.outs.push({
133
+ script: t,
134
+ value: e
135
+ }) - 1;
136
+ }
137
+ hasWitnesses() {
138
+ return this.ins.some((t) => t.witness.length !== 0);
139
+ }
140
+ weight() {
141
+ const t = this.byteLength(!1), e = this.byteLength(!0);
142
+ return t * 3 + e;
143
+ }
144
+ virtualSize() {
145
+ return Math.ceil(this.weight() / 4);
146
+ }
147
+ byteLength(t = !0) {
148
+ const e = t && this.hasWitnesses();
149
+ return (e ? 10 : 8) + R(this.ins.length) + R(this.outs.length) + this.ins.reduce((s, i) => s + 40 + p(i.script), 0) + this.outs.reduce((s, i) => s + 8 + p(i.script), 0) + (e ? this.ins.reduce((s, i) => s + rt(i.witness), 0) : 0);
150
+ }
151
+ clone() {
152
+ const t = new o();
153
+ return t.version = this.version, t.locktime = this.locktime, t.ins = this.ins.map((e) => ({
154
+ hash: e.hash,
155
+ index: e.index,
156
+ script: e.script,
157
+ sequence: e.sequence,
158
+ witness: e.witness
159
+ })), t.outs = this.outs.map((e) => ({
160
+ script: e.script,
161
+ value: e.value
162
+ })), t;
163
+ }
164
+ /**
165
+ * Hash transaction for signing a specific input.
166
+ *
167
+ * Bitcoin uses a different hash for each signed transaction input.
168
+ * This method copies the transaction, makes the necessary changes based on the
169
+ * hashType, and then hashes the result.
170
+ * This hash can then be used to sign the provided transaction input.
171
+ */
172
+ hashForSignature(t, e, s) {
173
+ if (A(
174
+ C(
175
+ b,
176
+ _,
177
+ /* types.UInt8 */
178
+ V
179
+ ),
180
+ arguments
181
+ ), t >= this.ins.length) return F;
182
+ const i = et(
183
+ st(e).filter((h) => h !== it.OP_CODESEPARATOR)
184
+ ), n = this.clone();
185
+ if ((s & 31) === o.SIGHASH_NONE)
186
+ n.outs = [], n.ins.forEach((h, g) => {
187
+ g !== t && (h.sequence = 0);
188
+ });
189
+ else if ((s & 31) === o.SIGHASH_SINGLE) {
190
+ if (t >= this.outs.length) return F;
191
+ n.outs.length = t + 1;
192
+ for (let h = 0; h < t; h++)
193
+ n.outs[h] = ot;
194
+ n.ins.forEach((h, g) => {
195
+ g !== t && (h.sequence = 0);
196
+ });
197
+ }
198
+ s & o.SIGHASH_ANYONECANPAY ? (n.ins = [n.ins[t]], n.ins[0].script = i) : (n.ins.forEach((h) => {
199
+ h.script = H;
200
+ }), n.ins[t].script = i);
201
+ const r = a.allocUnsafe(n.byteLength(!1) + 4);
202
+ return r.writeInt32LE(s, r.length - 4), n.__toBuffer(r, 0, !1), I(r);
203
+ }
204
+ hashForWitnessV1(t, e, s, i, n, r) {
205
+ if (A(
206
+ C(
207
+ b,
208
+ A.arrayOf(_),
209
+ A.arrayOf(W),
210
+ b
211
+ ),
212
+ arguments
213
+ ), s.length !== this.ins.length || e.length !== this.ins.length)
214
+ throw new Error("Must supply prevout script and value for all inputs");
215
+ const h = i === o.SIGHASH_DEFAULT ? o.SIGHASH_ALL : i & o.SIGHASH_OUTPUT_MASK, d = (i & o.SIGHASH_INPUT_MASK) === o.SIGHASH_ANYONECANPAY, w = h === o.SIGHASH_NONE, S = h === o.SIGHASH_SINGLE;
216
+ let U = H, v = H, L = H, O = H, G = H;
217
+ if (!d) {
218
+ let c = m.withCapacity(36 * this.ins.length);
219
+ this.ins.forEach((l) => {
220
+ c.writeSlice(l.hash), c.writeUInt32(l.index);
221
+ }), U = N(c.end()), c = m.withCapacity(8 * this.ins.length), s.forEach((l) => c.writeUInt64(l)), v = N(c.end()), c = m.withCapacity(
222
+ e.map(p).reduce((l, E) => l + E)
223
+ ), e.forEach((l) => c.writeVarSlice(l)), L = N(c.end()), c = m.withCapacity(4 * this.ins.length), this.ins.forEach((l) => c.writeUInt32(l.sequence)), O = N(c.end());
224
+ }
225
+ if (w || S) {
226
+ if (S && t < this.outs.length) {
227
+ const c = this.outs[t], l = m.withCapacity(8 + p(c.script));
228
+ l.writeUInt64(c.value), l.writeVarSlice(c.script), G = N(l.end());
229
+ }
230
+ } else {
231
+ if (!this.outs.length)
232
+ throw new Error("Add outputs to the transaction before signing.");
233
+ const c = this.outs.map((E) => 8 + p(E.script)).reduce((E, X) => E + X), l = m.withCapacity(c);
234
+ this.outs.forEach((E) => {
235
+ l.writeUInt64(E.value), l.writeVarSlice(E.script);
236
+ }), G = N(l.end());
237
+ }
238
+ const j = (n ? 2 : 0) + (r ? 1 : 0), x = 174 - (d ? 49 : 0) - (w ? 32 : 0) + (r ? 32 : 0) + (n ? 37 : 0), u = m.withCapacity(x);
239
+ if (u.writeUInt8(i), u.writeInt32(this.version), u.writeUInt32(this.locktime), u.writeSlice(U), u.writeSlice(v), u.writeSlice(L), u.writeSlice(O), w || S || u.writeSlice(G), u.writeUInt8(j), d) {
240
+ const c = this.ins[t];
241
+ u.writeSlice(c.hash), u.writeUInt32(c.index), u.writeUInt64(s[t]), u.writeVarSlice(e[t]), u.writeUInt32(c.sequence);
242
+ } else
243
+ u.writeUInt32(t);
244
+ if (r) {
245
+ const c = m.withCapacity(p(r));
246
+ c.writeVarSlice(r), u.writeSlice(N(c.end()));
247
+ }
248
+ return S && u.writeSlice(G), n && (u.writeSlice(n), u.writeUInt8(0), u.writeUInt32(4294967295)), Z(
249
+ "TapSighash",
250
+ a.concat([a.from([0]), u.end()])
251
+ );
252
+ }
253
+ hashForWitnessV0(t, e, s, i) {
254
+ A(C(b, _, W, b), arguments);
255
+ let n = a.from([]), r, h = k, g = k, d = k;
256
+ if (i & o.SIGHASH_ANYONECANPAY || (n = a.allocUnsafe(36 * this.ins.length), r = new m(n, 0), this.ins.forEach((S) => {
257
+ r.writeSlice(S.hash), r.writeUInt32(S.index);
258
+ }), g = I(n)), !(i & o.SIGHASH_ANYONECANPAY) && (i & 31) !== o.SIGHASH_SINGLE && (i & 31) !== o.SIGHASH_NONE && (n = a.allocUnsafe(4 * this.ins.length), r = new m(n, 0), this.ins.forEach((S) => {
259
+ r.writeUInt32(S.sequence);
260
+ }), d = I(n)), (i & 31) !== o.SIGHASH_SINGLE && (i & 31) !== o.SIGHASH_NONE) {
261
+ const S = this.outs.reduce((U, v) => U + 8 + p(v.script), 0);
262
+ n = a.allocUnsafe(S), r = new m(n, 0), this.outs.forEach((U) => {
263
+ r.writeUInt64(U.value), r.writeVarSlice(U.script);
264
+ }), h = I(n);
265
+ } else if ((i & 31) === o.SIGHASH_SINGLE && t < this.outs.length) {
266
+ const S = this.outs[t];
267
+ n = a.allocUnsafe(8 + p(S.script)), r = new m(n, 0), r.writeUInt64(S.value), r.writeVarSlice(S.script), h = I(n);
268
+ }
269
+ n = a.allocUnsafe(156 + p(e)), r = new m(n, 0);
270
+ const w = this.ins[t];
271
+ return r.writeInt32(this.version), r.writeSlice(g), r.writeSlice(d), r.writeSlice(w.hash), r.writeUInt32(w.index), r.writeVarSlice(e), r.writeUInt64(s), r.writeUInt32(w.sequence), r.writeSlice(h), r.writeUInt32(this.locktime), r.writeUInt32(i), I(n);
272
+ }
273
+ getHash(t) {
274
+ return t && this.isCoinbase() ? a.alloc(32, 0) : I(this.__toBuffer(void 0, void 0, t));
275
+ }
276
+ getId() {
277
+ return M(this.getHash(!1)).toString("hex");
278
+ }
279
+ toBuffer(t, e) {
280
+ return this.__toBuffer(t, e, !0);
281
+ }
282
+ toHex() {
283
+ return this.toBuffer(void 0, void 0).toString("hex");
284
+ }
285
+ setInputScript(t, e) {
286
+ A(C(V, _), arguments), this.ins[t].script = e;
287
+ }
288
+ setWitness(t, e) {
289
+ A(C(V, [_]), arguments), this.ins[t].witness = e;
290
+ }
291
+ __toBuffer(t, e, s = !1) {
292
+ t || (t = a.allocUnsafe(this.byteLength(s)));
293
+ const i = new m(t, e || 0);
294
+ i.writeInt32(this.version);
295
+ const n = s && this.hasWitnesses();
296
+ return n && (i.writeUInt8(o.ADVANCED_TRANSACTION_MARKER), i.writeUInt8(o.ADVANCED_TRANSACTION_FLAG)), i.writeVarInt(this.ins.length), this.ins.forEach((r) => {
297
+ i.writeSlice(r.hash), i.writeUInt32(r.index), i.writeVarSlice(r.script), i.writeUInt32(r.sequence);
298
+ }), i.writeVarInt(this.outs.length), this.outs.forEach((r) => {
299
+ ht(r) ? i.writeUInt64(r.value) : i.writeSlice(r.valueBuffer), i.writeVarSlice(r.script);
300
+ }), n && this.ins.forEach((r) => {
301
+ i.writeVector(r.witness);
302
+ }), i.writeUInt32(this.locktime), e !== void 0 ? t.slice(e, i.offset) : t;
303
+ }
304
+ }
305
+ const wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
306
+ __proto__: null,
307
+ Transaction: o
308
+ }, Symbol.toStringTag, { value: "Module" })), { typeforce: ct } = K, B = new TypeError("Cannot compute merkle root for zero transactions"), q = new TypeError("Cannot compute witness commit for non-segwit block");
309
+ class y {
310
+ constructor() {
311
+ this.version = 1, this.prevHash = void 0, this.merkleRoot = void 0, this.timestamp = 0, this.witnessCommit = void 0, this.bits = 0, this.nonce = 0, this.transactions = void 0;
312
+ }
313
+ static fromBuffer(t) {
314
+ if (t.length < 80) throw new Error("Buffer too small (< 80 bytes)");
315
+ const e = new z(t), s = new y();
316
+ if (s.version = e.readInt32(), s.prevHash = e.readSlice(32), s.merkleRoot = e.readSlice(32), s.timestamp = e.readUInt32(), s.bits = e.readUInt32(), s.nonce = e.readUInt32(), t.length === 80) return s;
317
+ const i = () => {
318
+ const h = o.fromBuffer(e.buffer.slice(e.offset), !0);
319
+ return e.offset += h.byteLength(), h;
320
+ }, n = e.readVarInt();
321
+ s.transactions = [];
322
+ for (let h = 0; h < n; ++h) {
323
+ const g = i();
324
+ s.transactions.push(g);
325
+ }
326
+ const r = s.getWitnessCommit();
327
+ return r && (s.witnessCommit = r), s;
328
+ }
329
+ static fromHex(t) {
330
+ return y.fromBuffer(a.from(t, "hex"));
331
+ }
332
+ static calculateTarget(t) {
333
+ const e = ((t & 4278190080) >> 24) - 3, s = t & 8388607, i = a.alloc(32, 0);
334
+ return i.writeUIntBE(s, 29 - e, 3), i;
335
+ }
336
+ static calculateMerkleRoot(t, e) {
337
+ if (ct([{ getHash: Q }], t), t.length === 0) throw B;
338
+ if (e && !Y(t)) throw q;
339
+ const s = t.map((n) => n.getHash(e)), i = J(s, I);
340
+ return e ? I(a.concat([i, t[0].ins[0].witness[0]])) : i;
341
+ }
342
+ getWitnessCommit() {
343
+ if (!Y(this.transactions)) return null;
344
+ const t = this.transactions[0].outs.filter(
345
+ (s) => s.script.slice(0, 6).equals(a.from("6a24aa21a9ed", "hex"))
346
+ ).map((s) => s.script.slice(6, 38));
347
+ if (t.length === 0) return null;
348
+ const e = t[t.length - 1];
349
+ return e instanceof a && e.length === 32 ? e : null;
350
+ }
351
+ hasWitnessCommit() {
352
+ return this.witnessCommit instanceof a && this.witnessCommit.length === 32 || this.getWitnessCommit() !== null;
353
+ }
354
+ hasWitness() {
355
+ return at(this.transactions);
356
+ }
357
+ weight() {
358
+ const t = this.byteLength(!1, !1), e = this.byteLength(!1, !0);
359
+ return t * 3 + e;
360
+ }
361
+ byteLength(t, e = !0) {
362
+ return t || !this.transactions ? 80 : 80 + R(this.transactions.length) + this.transactions.reduce((s, i) => s + i.byteLength(e), 0);
363
+ }
364
+ getHash() {
365
+ return I(this.toBuffer(!0));
366
+ }
367
+ getId() {
368
+ return M(this.getHash()).toString("hex");
369
+ }
370
+ getUTCDate() {
371
+ const t = /* @__PURE__ */ new Date(0);
372
+ return t.setUTCSeconds(this.timestamp), t;
373
+ }
374
+ // TODO: buffer, offset compatibility
375
+ toBuffer(t) {
376
+ const e = a.allocUnsafe(this.byteLength(t)), s = new m(e);
377
+ if (s.writeInt32(this.version), s.writeSlice(this.prevHash), s.writeSlice(this.merkleRoot), s.writeUInt32(this.timestamp), s.writeUInt32(this.bits), s.writeUInt32(this.nonce), t || !this.transactions) return e;
378
+ const i = tt(this.transactions.length, e, s.offset);
379
+ return s.offset += i.bytes, this.transactions.forEach((n) => {
380
+ const r = n.byteLength();
381
+ n.toBuffer(e, s.offset), s.offset += r;
382
+ }), e;
383
+ }
384
+ toHex(t) {
385
+ return this.toBuffer(t).toString("hex");
386
+ }
387
+ checkTxRoots() {
388
+ const t = this.hasWitnessCommit();
389
+ return !t && this.hasWitness() ? !1 : this.__checkMerkleRoot() && (t ? this.__checkWitnessCommit() : !0);
390
+ }
391
+ checkProofOfWork() {
392
+ const t = M(this.getHash()), e = y.calculateTarget(this.bits);
393
+ return t.compare(e) <= 0;
394
+ }
395
+ __checkMerkleRoot() {
396
+ if (!this.transactions) throw B;
397
+ const t = y.calculateMerkleRoot(this.transactions);
398
+ return this.merkleRoot.compare(t) === 0;
399
+ }
400
+ __checkWitnessCommit() {
401
+ if (!this.transactions) throw B;
402
+ if (!this.hasWitnessCommit()) throw q;
403
+ const t = y.calculateMerkleRoot(this.transactions, !0);
404
+ return this.witnessCommit.compare(t) === 0;
405
+ }
406
+ }
407
+ function Y(f) {
408
+ return f instanceof Array && f[0] && f[0].ins && f[0].ins instanceof Array && f[0].ins[0] && f[0].ins[0].witness && f[0].ins[0].witness instanceof Array && f[0].ins[0].witness.length > 0;
409
+ }
410
+ function at(f) {
411
+ return f instanceof Array && f.some(
412
+ (t) => typeof t == "object" && t.ins instanceof Array && t.ins.some(
413
+ (e) => typeof e == "object" && e.witness instanceof Array && e.witness.length > 0
414
+ )
415
+ );
416
+ }
417
+ export {
418
+ y as B,
419
+ o as T,
420
+ wt as a
421
+ };