@btc-vision/bitcoin 6.3.2 → 6.3.4

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 (144) hide show
  1. package/.gitattributes +2 -2
  2. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.ready +0 -0
  3. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.release-please-manifest.json +3 -0
  4. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CHANGELOG.md +962 -0
  5. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CONTRIBUTING.md +34 -0
  6. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/LICENSE +24 -0
  7. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/README.md +273 -0
  8. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/SECURITY.md +2 -0
  9. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/addon.gypi +204 -0
  10. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/bin/node-gyp.js +138 -0
  11. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/.release-please-manifest.json +3 -0
  12. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/LICENSE +28 -0
  13. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/ninja/build.ninja +4 -0
  14. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +12 -0
  15. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/GypVsCMake.md +116 -0
  16. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Hacking.md +46 -0
  17. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/InputFormatReference.md +1080 -0
  18. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/LanguageSpecification.md +430 -0
  19. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/README.md +27 -0
  20. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Testing.md +450 -0
  21. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/UserDocumentation.md +965 -0
  22. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp +8 -0
  23. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp.bat +5 -0
  24. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp_main.py +45 -0
  25. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +365 -0
  26. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
  27. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1272 -0
  28. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1547 -0
  29. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
  30. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +153 -0
  31. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +271 -0
  32. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +574 -0
  33. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +692 -0
  34. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common.py +711 -0
  35. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +171 -0
  36. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +169 -0
  37. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +113 -0
  38. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
  39. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  40. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +804 -0
  41. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1173 -0
  42. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1318 -0
  43. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +127 -0
  44. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +103 -0
  45. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +461 -0
  46. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +89 -0
  47. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +57 -0
  48. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2745 -0
  49. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3976 -0
  50. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
  51. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2964 -0
  52. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +67 -0
  53. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1391 -0
  54. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +25 -0
  55. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input.py +3115 -0
  56. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +98 -0
  57. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +771 -0
  58. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1260 -0
  59. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
  60. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
  61. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +373 -0
  62. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1938 -0
  63. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +53 -0
  64. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +302 -0
  65. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3198 -0
  66. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +65 -0
  67. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +3 -0
  68. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +177 -0
  69. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +23 -0
  70. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +15 -0
  71. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +108 -0
  72. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +252 -0
  73. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +83 -0
  74. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +359 -0
  75. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +61 -0
  76. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +192 -0
  77. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/markers.py +252 -0
  78. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +825 -0
  79. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
  80. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +90 -0
  81. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +1030 -0
  82. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/tags.py +553 -0
  83. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/utils.py +172 -0
  84. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/version.py +563 -0
  85. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pyproject.toml +120 -0
  86. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/release-please-config.json +11 -0
  87. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/test_gyp.py +261 -0
  88. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/Find-VisualStudio.cs +250 -0
  89. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/build.js +227 -0
  90. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/clean.js +15 -0
  91. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/configure.js +328 -0
  92. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/create-config-gypi.js +150 -0
  93. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/download.js +39 -0
  94. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-node-directory.js +63 -0
  95. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-python.js +310 -0
  96. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-visualstudio.js +590 -0
  97. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/install.js +415 -0
  98. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/list.js +26 -0
  99. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/log.js +168 -0
  100. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/node-gyp.js +188 -0
  101. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/process-release.js +146 -0
  102. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/rebuild.js +12 -0
  103. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/remove.js +43 -0
  104. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/util.js +81 -0
  105. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/macOS_Catalina_acid_test.sh +21 -0
  106. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/package.json +51 -0
  107. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/release-please-config.json +40 -0
  108. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/src/win_delay_load_hook.cc +39 -0
  109. package/browser/index.js +1 -1
  110. package/browser/payments/index.d.ts +2 -0
  111. package/browser/psbt.d.ts +3 -3
  112. package/build/payments/index.d.ts +2 -0
  113. package/build/payments/p2pkh.js +52 -10
  114. package/build/payments/p2sh.js +2 -1
  115. package/build/psbt/psbtutils.d.ts +1 -1
  116. package/build/psbt/psbtutils.js +22 -7
  117. package/build/psbt.d.ts +3 -3
  118. package/build/psbt.js +9 -7
  119. package/coverage/tmp/coverage-31752-1735543485354-0.json +1 -0
  120. package/coverage/tmp/coverage-59920-1735543484555-0.json +1 -0
  121. package/coverage/tmp/coverage-66252-1735543483919-0.json +1 -0
  122. package/coverage/tmp/coverage-68440-1735543485236-0.json +1 -0
  123. package/coverage/tmp/coverage-70588-1735543484426-0.json +1 -0
  124. package/coverage/tmp/coverage-79292-1735543485296-0.json +1 -0
  125. package/coverage/tmp/coverage-80212-1735543483980-0.json +1 -0
  126. package/eslint.config.js +56 -56
  127. package/package.json +1 -1
  128. package/src/address.ts +211 -211
  129. package/src/crypto/crypto-browser.js +75 -75
  130. package/src/crypto/crypto.ts +1 -1
  131. package/src/hooks/HookedSigner.ts +108 -108
  132. package/src/index.ts +86 -86
  133. package/src/networks.ts +235 -235
  134. package/src/payments/embed.ts +55 -55
  135. package/src/payments/index.ts +4 -0
  136. package/src/payments/lazy.ts +28 -28
  137. package/src/payments/p2pk.ts +85 -85
  138. package/src/payments/p2pkh.ts +210 -149
  139. package/src/payments/p2sh.ts +206 -205
  140. package/src/psbt/bip371.ts +441 -441
  141. package/src/psbt/psbtutils.ts +315 -299
  142. package/src/psbt.ts +2187 -2174
  143. package/src/types.ts +122 -122
  144. package/webpack.config.js +79 -79
package/eslint.config.js CHANGED
@@ -1,56 +1,56 @@
1
- // @ts-check
2
-
3
- import eslint from '@eslint/js';
4
- import tseslint from 'typescript-eslint';
5
-
6
- export default tseslint.config(
7
- eslint.configs.recommended,
8
- ...tseslint.configs.strictTypeChecked,
9
- {
10
- languageOptions: {
11
- parserOptions: {
12
- projectService: true,
13
- tsconfigDirName: import.meta.dirname,
14
- },
15
- },
16
- rules: {
17
- 'no-undef': 'off',
18
- '@typescript-eslint/no-unused-vars': 'off',
19
- 'no-empty': 'off',
20
- '@typescript-eslint/restrict-template-expressions': 'off',
21
- '@typescript-eslint/only-throw-error': 'off',
22
- '@typescript-eslint/no-unnecessary-condition': 'off',
23
- '@typescript-eslint/unbound-method': 'warn',
24
- '@typescript-eslint/no-confusing-void-expression': 'off',
25
- '@typescript-eslint/no-extraneous-class': 'off',
26
- 'no-async-promise-executor': 'off',
27
- '@typescript-eslint/no-misused-promises': 'off',
28
- '@typescript-eslint/no-unnecessary-type-parameters': 'off',
29
- '@typescript-eslint/no-duplicate-enum-values': 'off',
30
- 'prefer-spread': 'off',
31
- '@typescript-eslint/no-empty-object-type': 'off',
32
- /** TO FIX */
33
- '@typescript-eslint/no-unsafe-call': 'warn',
34
- '@typescript-eslint/no-unsafe-assignment': 'warn',
35
- 'prefer-rest-params': 'warn',
36
- '@typescript-eslint/restrict-plus-operands': 'warn',
37
- '@typescript-eslint/no-unsafe-member-access': 'warn',
38
- '@typescript-eslint/no-unsafe-return': 'warn',
39
- '@typescript-eslint/no-require-imports': 'warn',
40
- '@typescript-eslint/no-explicit-any': 'warn',
41
- '@typescript-eslint/no-unsafe-argument': 'warn',
42
- '@typescript-eslint/no-unnecessary-type-assertion': 'warn',
43
- '@typescript-eslint/no-non-null-assertion': 'warn',
44
- '@typescript-eslint/no-invalid-void-type': 'warn',
45
- '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
46
- '@typescript-eslint/no-unnecessary-template-expression': 'warn',
47
- 'no-case-declarations': 'warn',
48
- '@typescript-eslint/ban-ts-comment': 'warn',
49
- '@typescript-eslint/no-deprecated': 'warn',
50
- },
51
- },
52
- {
53
- files: ['**/*.js'],
54
- ...tseslint.configs.disableTypeChecked,
55
- },
56
- );
1
+ // @ts-check
2
+
3
+ import eslint from '@eslint/js';
4
+ import tseslint from 'typescript-eslint';
5
+
6
+ export default tseslint.config(
7
+ eslint.configs.recommended,
8
+ ...tseslint.configs.strictTypeChecked,
9
+ {
10
+ languageOptions: {
11
+ parserOptions: {
12
+ projectService: true,
13
+ tsconfigDirName: import.meta.dirname,
14
+ },
15
+ },
16
+ rules: {
17
+ 'no-undef': 'off',
18
+ '@typescript-eslint/no-unused-vars': 'off',
19
+ 'no-empty': 'off',
20
+ '@typescript-eslint/restrict-template-expressions': 'off',
21
+ '@typescript-eslint/only-throw-error': 'off',
22
+ '@typescript-eslint/no-unnecessary-condition': 'off',
23
+ '@typescript-eslint/unbound-method': 'warn',
24
+ '@typescript-eslint/no-confusing-void-expression': 'off',
25
+ '@typescript-eslint/no-extraneous-class': 'off',
26
+ 'no-async-promise-executor': 'off',
27
+ '@typescript-eslint/no-misused-promises': 'off',
28
+ '@typescript-eslint/no-unnecessary-type-parameters': 'off',
29
+ '@typescript-eslint/no-duplicate-enum-values': 'off',
30
+ 'prefer-spread': 'off',
31
+ '@typescript-eslint/no-empty-object-type': 'off',
32
+ /** TO FIX */
33
+ '@typescript-eslint/no-unsafe-call': 'warn',
34
+ '@typescript-eslint/no-unsafe-assignment': 'warn',
35
+ 'prefer-rest-params': 'warn',
36
+ '@typescript-eslint/restrict-plus-operands': 'warn',
37
+ '@typescript-eslint/no-unsafe-member-access': 'warn',
38
+ '@typescript-eslint/no-unsafe-return': 'warn',
39
+ '@typescript-eslint/no-require-imports': 'warn',
40
+ '@typescript-eslint/no-explicit-any': 'warn',
41
+ '@typescript-eslint/no-unsafe-argument': 'warn',
42
+ '@typescript-eslint/no-unnecessary-type-assertion': 'warn',
43
+ '@typescript-eslint/no-non-null-assertion': 'warn',
44
+ '@typescript-eslint/no-invalid-void-type': 'warn',
45
+ '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
46
+ '@typescript-eslint/no-unnecessary-template-expression': 'warn',
47
+ 'no-case-declarations': 'warn',
48
+ '@typescript-eslint/ban-ts-comment': 'warn',
49
+ '@typescript-eslint/no-deprecated': 'warn',
50
+ },
51
+ },
52
+ {
53
+ files: ['**/*.js'],
54
+ ...tseslint.configs.disableTypeChecked,
55
+ },
56
+ );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/bitcoin",
3
3
  "type": "module",
4
- "version": "6.3.2",
4
+ "version": "6.3.4",
5
5
  "description": "Client-side Bitcoin JavaScript library",
6
6
  "engines": {
7
7
  "node": ">=16.0.0"
package/src/address.ts CHANGED
@@ -1,211 +1,211 @@
1
- /**
2
- * bitcoin address decode and encode tools, include base58、bech32 and output script
3
- *
4
- * networks support bitcoin、bitcoin testnet and bitcoin regtest
5
- *
6
- * addresses support P2PKH、P2SH、P2WPKH、P2WSH、P2TR and so on
7
- *
8
- * @packageDocumentation
9
- */
10
- import { bech32, bech32m } from 'bech32';
11
- import * as bs58check from 'bs58check';
12
- import { payments } from './index.js';
13
- import * as networks from './networks.js';
14
- import { Network } from './networks.js';
15
- import * as bscript from './script.js';
16
- import { Hash160bit, tuple, typeforce, UInt8 } from './types.js';
17
-
18
- /** base58check decode result */
19
- export interface Base58CheckResult {
20
- /** address hash */
21
- hash: Buffer;
22
- /** address version: 0x00 for P2PKH, 0x05 for P2SH */
23
- version: number;
24
- }
25
-
26
- /** bech32 decode result */
27
- export interface Bech32Result {
28
- /** address version: 0x00 for P2WPKH、P2WSH, 0x01 for P2TR*/
29
- version: number;
30
- /** address prefix: bc for P2WPKH、P2WSH、P2TR */
31
- prefix: string;
32
- /** address data:20 bytes for P2WPKH, 32 bytes for P2WSH、P2TR */
33
- data: Buffer;
34
- }
35
-
36
- const FUTURE_SEGWIT_MAX_SIZE: number = 40;
37
- const FUTURE_SEGWIT_MIN_SIZE: number = 2;
38
- const FUTURE_SEGWIT_MAX_VERSION: number = 16;
39
- const FUTURE_SEGWIT_MIN_VERSION: number = 2;
40
- const FUTURE_SEGWIT_VERSION_DIFF: number = 0x50;
41
- const FUTURE_SEGWIT_VERSION_WARNING: string =
42
- 'WARNING: Sending to a future segwit version address can lead to loss of funds. ' +
43
- 'End users MUST be warned carefully in the GUI and asked if they wish to proceed ' +
44
- 'with caution. Wallets should verify the segwit version from the output of fromBech32, ' +
45
- 'then decide when it is safe to use which version of segwit.';
46
-
47
- function _toFutureSegwitAddress(output: Buffer, network: Network): string {
48
- const data = output.slice(2);
49
-
50
- if (data.length < FUTURE_SEGWIT_MIN_SIZE || data.length > FUTURE_SEGWIT_MAX_SIZE)
51
- throw new TypeError('Invalid program length for segwit address');
52
-
53
- const version = output[0] - FUTURE_SEGWIT_VERSION_DIFF;
54
-
55
- if (version < FUTURE_SEGWIT_MIN_VERSION || version > FUTURE_SEGWIT_MAX_VERSION)
56
- throw new TypeError('Invalid version for segwit address');
57
-
58
- if (output[1] !== data.length) throw new TypeError('Invalid script for segwit address');
59
-
60
- console.warn(FUTURE_SEGWIT_VERSION_WARNING);
61
-
62
- return toBech32(data, version, network.bech32);
63
- }
64
-
65
- /**
66
- * decode address with base58 specification, return address version and address hash if valid
67
- */
68
- export function fromBase58Check(address: string): Base58CheckResult {
69
- const payload = Buffer.from(bs58check.default.decode(address));
70
-
71
- // TODO: 4.0.0, move to "toOutputScript"
72
- if (payload.length < 21) throw new TypeError(address + ' is too short');
73
- if (payload.length > 21) throw new TypeError(address + ' is too long');
74
-
75
- const version = payload.readUInt8(0);
76
- const hash = payload.slice(1);
77
-
78
- return { version, hash };
79
- }
80
-
81
- /**
82
- * decode address with bech32 specification, return address version、address prefix and address data if valid
83
- */
84
- export function fromBech32(address: string): Bech32Result {
85
- let result;
86
- let version;
87
- try {
88
- result = bech32.decode(address);
89
- } catch (e) {}
90
-
91
- if (result) {
92
- version = result.words[0];
93
- if (version !== 0) throw new TypeError(address + ' uses wrong encoding');
94
- } else {
95
- result = bech32m.decode(address);
96
- version = result.words[0];
97
- if (version === 0) throw new TypeError(address + ' uses wrong encoding');
98
- }
99
-
100
- const data = bech32.fromWords(result.words.slice(1));
101
-
102
- return {
103
- version,
104
- prefix: result.prefix,
105
- data: Buffer.from(data),
106
- };
107
- }
108
-
109
- /**
110
- * encode address hash to base58 address with version
111
- */
112
- export function toBase58Check(hash: Buffer, version: number): string {
113
- typeforce(tuple(Hash160bit, UInt8), arguments);
114
-
115
- const payload = Buffer.allocUnsafe(21);
116
- payload.writeUInt8(version, 0);
117
- hash.copy(payload, 1);
118
-
119
- return bs58check.default.encode(payload);
120
- }
121
-
122
- /**
123
- * encode address hash to bech32 address with version and prefix
124
- */
125
- export function toBech32(data: Buffer, version: number, prefix: string): string {
126
- const words = bech32.toWords(data);
127
- words.unshift(version);
128
-
129
- return version === 0 ? bech32.encode(prefix, words) : bech32m.encode(prefix, words);
130
- }
131
-
132
- /**
133
- * decode address from output script with network, return address if matched
134
- */
135
- export function fromOutputScript(output: Buffer, network?: Network): string {
136
- // TODO: Network
137
- network = network || networks.bitcoin;
138
-
139
- try {
140
- return payments.p2pkh({ output, network }).address as string;
141
- } catch (e) {}
142
- try {
143
- return payments.p2sh({ output, network }).address as string;
144
- } catch (e) {}
145
- try {
146
- return payments.p2wpkh({ output, network }).address as string;
147
- } catch (e) {}
148
- try {
149
- return payments.p2wsh({ output, network }).address as string;
150
- } catch (e) {}
151
- try {
152
- return payments.p2tr({ output, network }).address as string;
153
- } catch (e) {}
154
- try {
155
- return _toFutureSegwitAddress(output, network);
156
- } catch (e) {}
157
-
158
- throw new Error(bscript.toASM(output) + ' has no matching Address');
159
- }
160
-
161
- /**
162
- * encodes address to output script with network, return output script if address matched
163
- */
164
- export function toOutputScript(address: string, network?: Network): Buffer {
165
- network = network || networks.bitcoin;
166
-
167
- let decodeBase58: Base58CheckResult | undefined;
168
- let decodeBech32: Bech32Result | undefined;
169
- try {
170
- decodeBase58 = fromBase58Check(address);
171
- } catch (e) {}
172
-
173
- if (decodeBase58) {
174
- if (decodeBase58.version === network.pubKeyHash)
175
- return payments.p2pkh({ hash: decodeBase58.hash }).output as Buffer;
176
- if (decodeBase58.version === network.scriptHash)
177
- return payments.p2sh({ hash: decodeBase58.hash }).output as Buffer;
178
- } else {
179
- try {
180
- decodeBech32 = fromBech32(address);
181
- } catch (e) {}
182
-
183
- if (decodeBech32) {
184
- if (decodeBech32.prefix !== network.bech32)
185
- throw new Error(address + ' has an invalid prefix');
186
- if (decodeBech32.version === 0) {
187
- if (decodeBech32.data.length === 20)
188
- return payments.p2wpkh({ hash: decodeBech32.data }).output as Buffer;
189
- if (decodeBech32.data.length === 32)
190
- return payments.p2wsh({ hash: decodeBech32.data }).output as Buffer;
191
- } else if (decodeBech32.version === 1) {
192
- if (decodeBech32.data.length === 32)
193
- return payments.p2tr({ pubkey: decodeBech32.data }).output as Buffer;
194
- } else if (
195
- decodeBech32.version >= FUTURE_SEGWIT_MIN_VERSION &&
196
- decodeBech32.version <= FUTURE_SEGWIT_MAX_VERSION &&
197
- decodeBech32.data.length >= FUTURE_SEGWIT_MIN_SIZE &&
198
- decodeBech32.data.length <= FUTURE_SEGWIT_MAX_SIZE
199
- ) {
200
- console.warn(FUTURE_SEGWIT_VERSION_WARNING);
201
-
202
- return bscript.compile([
203
- decodeBech32.version + FUTURE_SEGWIT_VERSION_DIFF,
204
- decodeBech32.data,
205
- ]);
206
- }
207
- }
208
- }
209
-
210
- return Buffer.from(address, 'hex');
211
- }
1
+ /**
2
+ * bitcoin address decode and encode tools, include base58、bech32 and output script
3
+ *
4
+ * networks support bitcoin、bitcoin testnet and bitcoin regtest
5
+ *
6
+ * addresses support P2PKH、P2SH、P2WPKH、P2WSH、P2TR and so on
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { bech32, bech32m } from 'bech32';
11
+ import * as bs58check from 'bs58check';
12
+ import { payments } from './index.js';
13
+ import * as networks from './networks.js';
14
+ import { Network } from './networks.js';
15
+ import * as bscript from './script.js';
16
+ import { Hash160bit, tuple, typeforce, UInt8 } from './types.js';
17
+
18
+ /** base58check decode result */
19
+ export interface Base58CheckResult {
20
+ /** address hash */
21
+ hash: Buffer;
22
+ /** address version: 0x00 for P2PKH, 0x05 for P2SH */
23
+ version: number;
24
+ }
25
+
26
+ /** bech32 decode result */
27
+ export interface Bech32Result {
28
+ /** address version: 0x00 for P2WPKH、P2WSH, 0x01 for P2TR*/
29
+ version: number;
30
+ /** address prefix: bc for P2WPKH、P2WSH、P2TR */
31
+ prefix: string;
32
+ /** address data:20 bytes for P2WPKH, 32 bytes for P2WSH、P2TR */
33
+ data: Buffer;
34
+ }
35
+
36
+ const FUTURE_SEGWIT_MAX_SIZE: number = 40;
37
+ const FUTURE_SEGWIT_MIN_SIZE: number = 2;
38
+ const FUTURE_SEGWIT_MAX_VERSION: number = 16;
39
+ const FUTURE_SEGWIT_MIN_VERSION: number = 2;
40
+ const FUTURE_SEGWIT_VERSION_DIFF: number = 0x50;
41
+ const FUTURE_SEGWIT_VERSION_WARNING: string =
42
+ 'WARNING: Sending to a future segwit version address can lead to loss of funds. ' +
43
+ 'End users MUST be warned carefully in the GUI and asked if they wish to proceed ' +
44
+ 'with caution. Wallets should verify the segwit version from the output of fromBech32, ' +
45
+ 'then decide when it is safe to use which version of segwit.';
46
+
47
+ function _toFutureSegwitAddress(output: Buffer, network: Network): string {
48
+ const data = output.slice(2);
49
+
50
+ if (data.length < FUTURE_SEGWIT_MIN_SIZE || data.length > FUTURE_SEGWIT_MAX_SIZE)
51
+ throw new TypeError('Invalid program length for segwit address');
52
+
53
+ const version = output[0] - FUTURE_SEGWIT_VERSION_DIFF;
54
+
55
+ if (version < FUTURE_SEGWIT_MIN_VERSION || version > FUTURE_SEGWIT_MAX_VERSION)
56
+ throw new TypeError('Invalid version for segwit address');
57
+
58
+ if (output[1] !== data.length) throw new TypeError('Invalid script for segwit address');
59
+
60
+ console.warn(FUTURE_SEGWIT_VERSION_WARNING);
61
+
62
+ return toBech32(data, version, network.bech32);
63
+ }
64
+
65
+ /**
66
+ * decode address with base58 specification, return address version and address hash if valid
67
+ */
68
+ export function fromBase58Check(address: string): Base58CheckResult {
69
+ const payload = Buffer.from(bs58check.default.decode(address));
70
+
71
+ // TODO: 4.0.0, move to "toOutputScript"
72
+ if (payload.length < 21) throw new TypeError(address + ' is too short');
73
+ if (payload.length > 21) throw new TypeError(address + ' is too long');
74
+
75
+ const version = payload.readUInt8(0);
76
+ const hash = payload.slice(1);
77
+
78
+ return { version, hash };
79
+ }
80
+
81
+ /**
82
+ * decode address with bech32 specification, return address version、address prefix and address data if valid
83
+ */
84
+ export function fromBech32(address: string): Bech32Result {
85
+ let result;
86
+ let version;
87
+ try {
88
+ result = bech32.decode(address);
89
+ } catch (e) {}
90
+
91
+ if (result) {
92
+ version = result.words[0];
93
+ if (version !== 0) throw new TypeError(address + ' uses wrong encoding');
94
+ } else {
95
+ result = bech32m.decode(address);
96
+ version = result.words[0];
97
+ if (version === 0) throw new TypeError(address + ' uses wrong encoding');
98
+ }
99
+
100
+ const data = bech32.fromWords(result.words.slice(1));
101
+
102
+ return {
103
+ version,
104
+ prefix: result.prefix,
105
+ data: Buffer.from(data),
106
+ };
107
+ }
108
+
109
+ /**
110
+ * encode address hash to base58 address with version
111
+ */
112
+ export function toBase58Check(hash: Buffer, version: number): string {
113
+ typeforce(tuple(Hash160bit, UInt8), arguments);
114
+
115
+ const payload = Buffer.allocUnsafe(21);
116
+ payload.writeUInt8(version, 0);
117
+ hash.copy(payload, 1);
118
+
119
+ return bs58check.default.encode(payload);
120
+ }
121
+
122
+ /**
123
+ * encode address hash to bech32 address with version and prefix
124
+ */
125
+ export function toBech32(data: Buffer, version: number, prefix: string): string {
126
+ const words = bech32.toWords(data);
127
+ words.unshift(version);
128
+
129
+ return version === 0 ? bech32.encode(prefix, words) : bech32m.encode(prefix, words);
130
+ }
131
+
132
+ /**
133
+ * decode address from output script with network, return address if matched
134
+ */
135
+ export function fromOutputScript(output: Buffer, network?: Network): string {
136
+ // TODO: Network
137
+ network = network || networks.bitcoin;
138
+
139
+ try {
140
+ return payments.p2pkh({ output, network }).address as string;
141
+ } catch (e) {}
142
+ try {
143
+ return payments.p2sh({ output, network }).address as string;
144
+ } catch (e) {}
145
+ try {
146
+ return payments.p2wpkh({ output, network }).address as string;
147
+ } catch (e) {}
148
+ try {
149
+ return payments.p2wsh({ output, network }).address as string;
150
+ } catch (e) {}
151
+ try {
152
+ return payments.p2tr({ output, network }).address as string;
153
+ } catch (e) {}
154
+ try {
155
+ return _toFutureSegwitAddress(output, network);
156
+ } catch (e) {}
157
+
158
+ throw new Error(bscript.toASM(output) + ' has no matching Address');
159
+ }
160
+
161
+ /**
162
+ * encodes address to output script with network, return output script if address matched
163
+ */
164
+ export function toOutputScript(address: string, network?: Network): Buffer {
165
+ network = network || networks.bitcoin;
166
+
167
+ let decodeBase58: Base58CheckResult | undefined;
168
+ let decodeBech32: Bech32Result | undefined;
169
+ try {
170
+ decodeBase58 = fromBase58Check(address);
171
+ } catch (e) {}
172
+
173
+ if (decodeBase58) {
174
+ if (decodeBase58.version === network.pubKeyHash)
175
+ return payments.p2pkh({ hash: decodeBase58.hash }).output as Buffer;
176
+ if (decodeBase58.version === network.scriptHash)
177
+ return payments.p2sh({ hash: decodeBase58.hash }).output as Buffer;
178
+ } else {
179
+ try {
180
+ decodeBech32 = fromBech32(address);
181
+ } catch (e) {}
182
+
183
+ if (decodeBech32) {
184
+ if (decodeBech32.prefix !== network.bech32)
185
+ throw new Error(address + ' has an invalid prefix');
186
+ if (decodeBech32.version === 0) {
187
+ if (decodeBech32.data.length === 20)
188
+ return payments.p2wpkh({ hash: decodeBech32.data }).output as Buffer;
189
+ if (decodeBech32.data.length === 32)
190
+ return payments.p2wsh({ hash: decodeBech32.data }).output as Buffer;
191
+ } else if (decodeBech32.version === 1) {
192
+ if (decodeBech32.data.length === 32)
193
+ return payments.p2tr({ pubkey: decodeBech32.data }).output as Buffer;
194
+ } else if (
195
+ decodeBech32.version >= FUTURE_SEGWIT_MIN_VERSION &&
196
+ decodeBech32.version <= FUTURE_SEGWIT_MAX_VERSION &&
197
+ decodeBech32.data.length >= FUTURE_SEGWIT_MIN_SIZE &&
198
+ decodeBech32.data.length <= FUTURE_SEGWIT_MAX_SIZE
199
+ ) {
200
+ console.warn(FUTURE_SEGWIT_VERSION_WARNING);
201
+
202
+ return bscript.compile([
203
+ decodeBech32.version + FUTURE_SEGWIT_VERSION_DIFF,
204
+ decodeBech32.data,
205
+ ]);
206
+ }
207
+ }
208
+ }
209
+
210
+ return Buffer.from(address, 'hex');
211
+ }