@btc-vision/transaction 1.0.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 (270) hide show
  1. package/.babelrc +7 -0
  2. package/.gitattributes +2 -0
  3. package/.github/workflows/node.js.yml +22 -0
  4. package/.idea/codeStyles/Project.xml +56 -0
  5. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  6. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  7. package/.idea/jsLibraryMappings.xml +6 -0
  8. package/.idea/modules.xml +8 -0
  9. package/.idea/prettier.xml +6 -0
  10. package/.idea/transaction.iml +16 -0
  11. package/.idea/vcs.xml +6 -0
  12. package/.prettierrc.json +12 -0
  13. package/CONTRIBUTING.md +71 -0
  14. package/LICENSE.md +16 -0
  15. package/README.md +213 -0
  16. package/browser/873e754d6c7c6e9361f1.module.wasm +0 -0
  17. package/browser/_version.d.ts +1 -0
  18. package/browser/bytecode/Compressor.d.ts +6 -0
  19. package/browser/crypto/crypto-browser.d.ts +40 -0
  20. package/browser/crypto/crypto.d.ts +2 -0
  21. package/browser/generators/Generator.d.ts +12 -0
  22. package/browser/generators/builders/CalldataGenerator.d.ts +8 -0
  23. package/browser/generators/builders/DeploymentGenerator.d.ts +7 -0
  24. package/browser/index.d.ts +3 -0
  25. package/browser/index.js +2 -0
  26. package/browser/index.js.LICENSE.txt +23 -0
  27. package/browser/keypair/EcKeyPair.d.ts +24 -0
  28. package/browser/keypair/Wallet.d.ts +16 -0
  29. package/browser/keypair/interfaces/IWallet.d.ts +5 -0
  30. package/browser/metadata/ContractBaseMetadata.d.ts +9 -0
  31. package/browser/metadata/ContractMetadataManager.d.ts +1 -0
  32. package/browser/metadata/contracts/wBTC.d.ts +12 -0
  33. package/browser/network/NetworkInformation.d.ts +6 -0
  34. package/browser/opnet.d.ts +22 -0
  35. package/browser/scripts/Regtest.d.ts +2 -0
  36. package/browser/scripts/test.d.ts +1 -0
  37. package/browser/signer/TweakedSigner.d.ts +9 -0
  38. package/browser/transaction/TransactionBuilder.d.ts +1 -0
  39. package/browser/transaction/TransactionFactory.d.ts +4 -0
  40. package/browser/transaction/builders/FundingTransaction.d.ts +11 -0
  41. package/browser/transaction/builders/InteractionTransaction.d.ts +47 -0
  42. package/browser/transaction/builders/TransactionBuilder.d.ts +64 -0
  43. package/browser/transaction/enums/TransactionType.d.ts +7 -0
  44. package/browser/transaction/interfaces/ITransactionParameters.d.ts +33 -0
  45. package/browser/transaction/interfaces/Tap.d.ts +22 -0
  46. package/browser/utils/BitcoinUtils.d.ts +5 -0
  47. package/browser/utxo/UTXOManager.d.ts +7 -0
  48. package/browser/utxo/interfaces/IUTXO.d.ts +19 -0
  49. package/build/Utils.d.ts +0 -0
  50. package/build/Utils.js +1 -0
  51. package/build/_version.d.ts +1 -0
  52. package/build/_version.js +1 -0
  53. package/build/bytecode/Compressor.d.ts +6 -0
  54. package/build/bytecode/Compressor.js +13 -0
  55. package/build/contracts/ContractMetadataManager.d.ts +0 -0
  56. package/build/contracts/ContractMetadataManager.js +1 -0
  57. package/build/crypto/crypto.d.ts +2 -0
  58. package/build/crypto/crypto.js +1 -0
  59. package/build/generators/Generator.d.ts +12 -0
  60. package/build/generators/Generator.js +25 -0
  61. package/build/generators/builders/CalldataGenerator.d.ts +8 -0
  62. package/build/generators/builders/CalldataGenerator.js +79 -0
  63. package/build/generators/builders/DeploymentGenerator.d.ts +7 -0
  64. package/build/generators/builders/DeploymentGenerator.js +38 -0
  65. package/build/index.d.ts +3 -0
  66. package/build/index.js +3 -0
  67. package/build/keypair/EcKeyPair.d.ts +24 -0
  68. package/build/keypair/EcKeyPair.js +107 -0
  69. package/build/keypair/Wallet.d.ts +16 -0
  70. package/build/keypair/Wallet.js +30 -0
  71. package/build/keypair/interfaces/GeneratedWallet.d.ts +5 -0
  72. package/build/keypair/interfaces/GeneratedWallet.js +1 -0
  73. package/build/keypair/interfaces/IWallet.d.ts +5 -0
  74. package/build/keypair/interfaces/IWallet.js +1 -0
  75. package/build/metadata/ContractBaseMetadata.d.ts +9 -0
  76. package/build/metadata/ContractBaseMetadata.js +13 -0
  77. package/build/metadata/ContractMetadataManager.d.ts +1 -0
  78. package/build/metadata/ContractMetadataManager.js +9 -0
  79. package/build/metadata/contracts/ContractBase.d.ts +9 -0
  80. package/build/metadata/contracts/ContractBase.js +13 -0
  81. package/build/metadata/contracts/ContractBaseMetadata.d.ts +9 -0
  82. package/build/metadata/contracts/ContractBaseMetadata.js +13 -0
  83. package/build/metadata/contracts/ContractMetadataManager.d.ts +0 -0
  84. package/build/metadata/contracts/ContractMetadataManager.js +1 -0
  85. package/build/metadata/contracts/wBTC.d.ts +12 -0
  86. package/build/metadata/contracts/wBTC.js +26 -0
  87. package/build/network/NetworkConverter.d.ts +0 -0
  88. package/build/network/NetworkConverter.js +14 -0
  89. package/build/network/NetworkInformation.d.ts +6 -0
  90. package/build/network/NetworkInformation.js +1 -0
  91. package/build/opnet.d.ts +22 -0
  92. package/build/opnet.js +22 -0
  93. package/build/scripts/Regtest.d.ts +2 -0
  94. package/build/scripts/Regtest.js +15 -0
  95. package/build/scripts/test.d.ts +1 -0
  96. package/build/scripts/test.js +74 -0
  97. package/build/signer/Regtest.d.ts +2 -0
  98. package/build/signer/Regtest.js +15 -0
  99. package/build/signer/TweakedSigner.d.ts +9 -0
  100. package/build/signer/TweakedSigner.js +22 -0
  101. package/build/transaction/TransactionBuilder.d.ts +60 -0
  102. package/build/transaction/TransactionBuilder.js +244 -0
  103. package/build/transaction/TransactionFactory.d.ts +4 -0
  104. package/build/transaction/TransactionFactory.js +32 -0
  105. package/build/transaction/builders/FundingTransaction.d.ts +11 -0
  106. package/build/transaction/builders/FundingTransaction.js +23 -0
  107. package/build/transaction/builders/GenericTransaction.d.ts +11 -0
  108. package/build/transaction/builders/GenericTransaction.js +23 -0
  109. package/build/transaction/builders/InteractionTransaction.d.ts +47 -0
  110. package/build/transaction/builders/InteractionTransaction.js +219 -0
  111. package/build/transaction/builders/TransactionBuilder.d.ts +64 -0
  112. package/build/transaction/builders/TransactionBuilder.js +288 -0
  113. package/build/transaction/enums/TransactionType.d.ts +7 -0
  114. package/build/transaction/enums/TransactionType.js +8 -0
  115. package/build/transaction/interfaces/ITransactionParameters.d.ts +33 -0
  116. package/build/transaction/interfaces/ITransactionParameters.js +1 -0
  117. package/build/transaction/interfaces/ITransactions.d.ts +32 -0
  118. package/build/transaction/interfaces/ITransactions.js +1 -0
  119. package/build/transaction/interfaces/Tap.d.ts +22 -0
  120. package/build/transaction/interfaces/Tap.js +1 -0
  121. package/build/utils/BitcoinUtils.d.ts +5 -0
  122. package/build/utils/BitcoinUtils.js +9 -0
  123. package/build/utxo/IUTXO.d.ts +0 -0
  124. package/build/utxo/IUTXO.js +1 -0
  125. package/build/utxo/UTXOManager.d.ts +7 -0
  126. package/build/utxo/UTXOManager.js +47 -0
  127. package/build/utxo/interfaces/IUTXO.d.ts +19 -0
  128. package/build/utxo/interfaces/IUTXO.js +1 -0
  129. package/cjs/_version.d.ts +1 -0
  130. package/cjs/_version.js +4 -0
  131. package/cjs/bytecode/Compressor.d.ts +6 -0
  132. package/cjs/bytecode/Compressor.js +20 -0
  133. package/cjs/crypto/crypto.d.ts +2 -0
  134. package/cjs/crypto/crypto.js +8 -0
  135. package/cjs/generators/Generator.d.ts +13 -0
  136. package/cjs/generators/Generator.js +31 -0
  137. package/cjs/generators/builders/CalldataGenerator.d.ts +8 -0
  138. package/cjs/generators/builders/CalldataGenerator.js +83 -0
  139. package/cjs/generators/builders/DeploymentGenerator.d.ts +7 -0
  140. package/cjs/generators/builders/DeploymentGenerator.js +42 -0
  141. package/cjs/index.d.ts +3 -0
  142. package/cjs/index.js +32 -0
  143. package/cjs/keypair/EcKeyPair.d.ts +24 -0
  144. package/cjs/keypair/EcKeyPair.js +137 -0
  145. package/cjs/keypair/Wallet.d.ts +16 -0
  146. package/cjs/keypair/Wallet.js +34 -0
  147. package/cjs/keypair/interfaces/IWallet.d.ts +5 -0
  148. package/cjs/keypair/interfaces/IWallet.js +2 -0
  149. package/cjs/metadata/ContractBaseMetadata.d.ts +9 -0
  150. package/cjs/metadata/ContractBaseMetadata.js +17 -0
  151. package/cjs/metadata/ContractMetadataManager.d.ts +0 -0
  152. package/cjs/metadata/ContractMetadataManager.js +1 -0
  153. package/cjs/metadata/contracts/wBTC.d.ts +12 -0
  154. package/cjs/metadata/contracts/wBTC.js +30 -0
  155. package/cjs/network/NetworkInformation.d.ts +6 -0
  156. package/cjs/network/NetworkInformation.js +2 -0
  157. package/cjs/opnet.d.ts +1 -0
  158. package/cjs/opnet.js +5 -0
  159. package/cjs/scripts/Regtest.d.ts +2 -0
  160. package/cjs/scripts/Regtest.js +18 -0
  161. package/cjs/scripts/test.d.ts +1 -0
  162. package/cjs/scripts/test.js +44 -0
  163. package/cjs/signer/TweakedSigner.d.ts +9 -0
  164. package/cjs/signer/TweakedSigner.js +49 -0
  165. package/cjs/transaction/TransactionBuilder.d.ts +0 -0
  166. package/cjs/transaction/TransactionBuilder.js +1 -0
  167. package/cjs/transaction/TransactionFactory.d.ts +4 -0
  168. package/cjs/transaction/TransactionFactory.js +33 -0
  169. package/cjs/transaction/builders/FundingTransaction.d.ts +11 -0
  170. package/cjs/transaction/builders/FundingTransaction.js +27 -0
  171. package/cjs/transaction/builders/InteractionTransaction.d.ts +45 -0
  172. package/cjs/transaction/builders/InteractionTransaction.js +214 -0
  173. package/cjs/transaction/builders/TransactionBuilder.d.ts +64 -0
  174. package/cjs/transaction/builders/TransactionBuilder.js +304 -0
  175. package/cjs/transaction/enums/TransactionType.d.ts +7 -0
  176. package/cjs/transaction/enums/TransactionType.js +11 -0
  177. package/cjs/transaction/interfaces/ITransactionParameters.d.ts +32 -0
  178. package/cjs/transaction/interfaces/ITransactionParameters.js +2 -0
  179. package/cjs/transaction/interfaces/Tap.d.ts +22 -0
  180. package/cjs/transaction/interfaces/Tap.js +2 -0
  181. package/cjs/utils/BitcoinUtils.d.ts +5 -0
  182. package/cjs/utils/BitcoinUtils.js +13 -0
  183. package/cjs/utxo/UTXOManager.d.ts +7 -0
  184. package/cjs/utxo/UTXOManager.js +51 -0
  185. package/cjs/utxo/interfaces/IUTXO.d.ts +19 -0
  186. package/cjs/utxo/interfaces/IUTXO.js +2 -0
  187. package/docs/.nojekyll +1 -0
  188. package/docs/assets/highlight.css +92 -0
  189. package/docs/assets/icons.js +15 -0
  190. package/docs/assets/icons.svg +1 -0
  191. package/docs/assets/main.js +59 -0
  192. package/docs/assets/material-style.css +247 -0
  193. package/docs/assets/navigation.js +1 -0
  194. package/docs/assets/search.js +1 -0
  195. package/docs/assets/style.css +1412 -0
  196. package/docs/classes/BitcoinUtils.html +183 -0
  197. package/docs/classes/CalldataGenerator.html +211 -0
  198. package/docs/classes/Compressor.html +185 -0
  199. package/docs/classes/ContractBaseMetadata.html +182 -0
  200. package/docs/classes/DeploymentGenerator.html +200 -0
  201. package/docs/classes/EcKeyPair.html +280 -0
  202. package/docs/classes/FundingTransaction.html +293 -0
  203. package/docs/classes/Generator.html +199 -0
  204. package/docs/classes/InteractionTransaction.html +365 -0
  205. package/docs/classes/TransactionBuilder.html +303 -0
  206. package/docs/classes/TransactionFactory.html +180 -0
  207. package/docs/classes/TweakedSigner.html +181 -0
  208. package/docs/classes/UTXOManager.html +187 -0
  209. package/docs/classes/Wallet.html +191 -0
  210. package/docs/classes/wBTC.html +189 -0
  211. package/docs/enums/TransactionType.html +179 -0
  212. package/docs/hierarchy.html +174 -0
  213. package/docs/index.html +237 -0
  214. package/docs/interfaces/FetchUTXOParams.html +178 -0
  215. package/docs/interfaces/IFundingTransactionParameters.html +182 -0
  216. package/docs/interfaces/IInteractionParameters.html +185 -0
  217. package/docs/interfaces/ITransactionDataContractDeployment.html +184 -0
  218. package/docs/interfaces/ITransactionDataContractInteractionWrap.html +186 -0
  219. package/docs/interfaces/ITransactionParameters.html +181 -0
  220. package/docs/interfaces/IWallet.html +181 -0
  221. package/docs/interfaces/NetworkInformation.html +176 -0
  222. package/docs/interfaces/PsbtInputExtended.html +194 -0
  223. package/docs/interfaces/PsbtOutputExtendedAddress.html +183 -0
  224. package/docs/interfaces/PsbtOutputExtendedScript.html +183 -0
  225. package/docs/interfaces/RawUTXOResponse.html +178 -0
  226. package/docs/interfaces/TapLeafScript.html +177 -0
  227. package/docs/interfaces/TweakSettings.html +179 -0
  228. package/docs/interfaces/UTXO.html +178 -0
  229. package/docs/interfaces/UpdateInput.html +175 -0
  230. package/docs/modules.html +208 -0
  231. package/docs/types/PsbtOutputExtended.html +174 -0
  232. package/docs/variables/version.html +174 -0
  233. package/gulpfile.js +152 -0
  234. package/jest.config.ts +52 -0
  235. package/package.json +116 -0
  236. package/src/_version.ts +1 -0
  237. package/src/bytecode/Compressor.ts +27 -0
  238. package/src/crypto/crypto-browser.js +71 -0
  239. package/src/crypto/crypto.ts +1 -0
  240. package/src/generators/Generator.ts +75 -0
  241. package/src/generators/builders/CalldataGenerator.ts +143 -0
  242. package/src/generators/builders/DeploymentGenerator.ts +63 -0
  243. package/src/index.ts +4 -0
  244. package/src/keypair/EcKeyPair.ts +265 -0
  245. package/src/keypair/Wallet.ts +75 -0
  246. package/src/keypair/interfaces/IWallet.ts +19 -0
  247. package/src/metadata/ContractBaseMetadata.ts +23 -0
  248. package/src/metadata/contracts/wBTC.ts +44 -0
  249. package/src/network/NetworkInformation.ts +7 -0
  250. package/src/opnet.ts +42 -0
  251. package/src/scripts/Regtest.ts +19 -0
  252. package/src/scripts/test.ts +98 -0
  253. package/src/signer/TweakedSigner.ts +57 -0
  254. package/src/transaction/TransactionFactory.ts +57 -0
  255. package/src/transaction/builders/FundingTransaction.ts +36 -0
  256. package/src/transaction/builders/InteractionTransaction.ts +439 -0
  257. package/src/transaction/builders/TransactionBuilder.ts +603 -0
  258. package/src/transaction/enums/TransactionType.ts +7 -0
  259. package/src/transaction/interfaces/ITransactionParameters.ts +41 -0
  260. package/src/transaction/interfaces/Tap.ts +26 -0
  261. package/src/utils/BitcoinUtils.ts +24 -0
  262. package/src/utxo/UTXOManager.ts +67 -0
  263. package/src/utxo/interfaces/IUTXO.ts +22 -0
  264. package/tests/TransactionBuilder.test.ts +58 -0
  265. package/tests/contracts/wbtc.wasm +0 -0
  266. package/tsconfig.base.json +43 -0
  267. package/tsconfig.cjs.json +9 -0
  268. package/tsconfig.json +8 -0
  269. package/tsconfig.webpack.json +11 -0
  270. package/webpack.config.js +77 -0
package/.babelrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "sourceType": "module",
3
+ "presets": [
4
+ "@babel/preset-react",
5
+ "@babel/preset-env"
6
+ ]
7
+ }
package/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,22 @@
1
+ name: Build Package CI
2
+ on:
3
+ push:
4
+ branches: [ "main" ]
5
+
6
+ jobs:
7
+ publish-gpr:
8
+
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - uses: actions/setup-node@v4
13
+ with:
14
+ node-version: 21.7.1
15
+ registry-url: https://npm.pkg.github.com/
16
+ scope: '@btc-vision'
17
+ - run: npm install
18
+ - run: npm run build
19
+ - run: npm publish
20
+ env:
21
+ NODE_AUTH_TOKEN: ${{secrets.BuildToken}}
22
+ NPM_TOKEN: ${{secrets.NpmToken}}
@@ -0,0 +1,56 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <HTMLCodeStyleSettings>
4
+ <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
5
+ </HTMLCodeStyleSettings>
6
+ <JSCodeStyleSettings version="0">
7
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
8
+ <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
9
+ <option name="USE_DOUBLE_QUOTES" value="false" />
10
+ <option name="FORCE_QUOTE_STYlE" value="true" />
11
+ <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
12
+ <option name="USE_EXPLICIT_JS_EXTENSION" value="TRUE" />
13
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
14
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
15
+ </JSCodeStyleSettings>
16
+ <TypeScriptCodeStyleSettings version="0">
17
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
18
+ <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
19
+ <option name="USE_DOUBLE_QUOTES" value="false" />
20
+ <option name="FORCE_QUOTE_STYlE" value="true" />
21
+ <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
22
+ <option name="USE_EXPLICIT_JS_EXTENSION" value="TRUE" />
23
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
24
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
25
+ </TypeScriptCodeStyleSettings>
26
+ <VueCodeStyleSettings>
27
+ <option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
28
+ <option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
29
+ </VueCodeStyleSettings>
30
+ <codeStyleSettings language="HTML">
31
+ <option name="SOFT_MARGINS" value="100" />
32
+ <indentOptions>
33
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
34
+ </indentOptions>
35
+ </codeStyleSettings>
36
+ <codeStyleSettings language="JSON">
37
+ <indentOptions>
38
+ <option name="INDENT_SIZE" value="4" />
39
+ </indentOptions>
40
+ </codeStyleSettings>
41
+ <codeStyleSettings language="JavaScript">
42
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="4" />
43
+ <option name="SOFT_MARGINS" value="100" />
44
+ </codeStyleSettings>
45
+ <codeStyleSettings language="TypeScript">
46
+ <option name="SOFT_MARGINS" value="100" />
47
+ </codeStyleSettings>
48
+ <codeStyleSettings language="Vue">
49
+ <option name="SOFT_MARGINS" value="100" />
50
+ <indentOptions>
51
+ <option name="INDENT_SIZE" value="4" />
52
+ <option name="TAB_SIZE" value="4" />
53
+ </indentOptions>
54
+ </codeStyleSettings>
55
+ </code_scheme>
56
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptLibraryMappings">
4
+ <includedPredefinedLibrary name="Node.js Core" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/transaction.iml" filepath="$PROJECT_DIR$/.idea/transaction.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="PrettierConfiguration">
4
+ <option name="myConfigurationMode" value="AUTOMATIC" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/browser" />
7
+ <excludeFolder url="file://$MODULE_DIR$/build" />
8
+ <excludeFolder url="file://$MODULE_DIR$/cjs" />
9
+ <excludeFolder url="file://$MODULE_DIR$/docs" />
10
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
11
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
12
+ </content>
13
+ <orderEntry type="inheritedJdk" />
14
+ <orderEntry type="sourceFolder" forTests="false" />
15
+ </component>
16
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,12 @@
1
+ {
2
+ "printWidth": 100,
3
+ "trailingComma": "all",
4
+ "tabWidth": 4,
5
+ "semi": true,
6
+ "singleQuote": true,
7
+ "quoteProps": "as-needed",
8
+ "bracketSpacing": true,
9
+ "bracketSameLine": true,
10
+ "arrowParens": "always",
11
+ "singleAttributePerLine": true
12
+ }
@@ -0,0 +1,71 @@
1
+ # Contributing Guidelines
2
+
3
+ Thank you for considering contributing to our project! Please take a moment to
4
+ review the following guidelines before submitting your contribution.
5
+
6
+ ## Pull Requests
7
+
8
+ When submitting a pull request, please make sure to follow these guidelines:
9
+
10
+ ### Before You Begin
11
+
12
+ 1. **Fork the repository**: If you haven't already, fork the repository to your
13
+ GitHub account.
14
+
15
+ 2. **Create a new branch**: Create a new branch for your feature or bug fix.
16
+ This helps keep the main branch clean and makes it easier to review your
17
+ changes.
18
+
19
+ 3. **Ensure your code is up-to-date**: Before starting work, make sure your
20
+ forked repository is up-to-date with the latest changes from the main
21
+ repository.
22
+
23
+ ### Making Changes
24
+
25
+ 1. **Follow coding conventions**: Make sure your code follows the existing
26
+ coding style and conventions used in the project.
27
+
28
+ 2. **Write descriptive commit messages**: Write clear and descriptive commit
29
+ messages that explain the purpose of your changes.
30
+
31
+ 3. **Test your changes**: Before submitting your pull request, make sure to test
32
+ your changes thoroughly to ensure they work as expected.
33
+
34
+ ### Submitting the Pull Request
35
+
36
+ 1. **Create a descriptive title**: Use a clear and descriptive title for your
37
+ pull request that summarizes the purpose of your changes.
38
+
39
+ 2. **Provide a detailed description**: Include a detailed description of the
40
+ changes you've made and any relevant context that reviewers should know.
41
+
42
+ 3. **Link related issues**: If your pull request addresses a specific issue,
43
+ make sure to reference it in the description using GitHub's issue linking
44
+ syntax (`#issue_number`).
45
+
46
+ 4. **Review and address feedback**: Be responsive to any feedback or comments
47
+ you receive on your pull request and make any necessary changes.
48
+
49
+ ## Issues
50
+
51
+ When submitting an issue, please provide as much information as possible to help
52
+ us understand and address the problem. Follow these guidelines when creating an
53
+ issue:
54
+
55
+ 1. **Use a descriptive title**: Use a clear and descriptive title that
56
+ summarizes the issue you're experiencing.
57
+
58
+ 2. **Provide detailed steps to reproduce**: Include detailed steps to reproduce
59
+ the issue, including any relevant code or configuration.
60
+
61
+ 3. **Include relevant information**: Provide any relevant information such as
62
+ error messages, screenshots, or logs that can help diagnose the problem.
63
+
64
+ 4. **Specify your environment**: If the issue is related to a specific
65
+ environment (e.g., operating system, browser), please specify it in your
66
+ issue description.
67
+
68
+ 5. **Check for existing issues**: Before submitting a new issue, please check if
69
+ a similar issue has already been reported to avoid duplicates.
70
+
71
+ Thank you for your contributions!
package/LICENSE.md ADDED
@@ -0,0 +1,16 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2025 to the user BlobMaster41 on GitHub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11
+ Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,213 @@
1
+ # OPNet - Transaction Builder
2
+
3
+ ![Bitcoin](https://img.shields.io/badge/Bitcoin-000?style=for-the-badge&logo=bitcoin&logoColor=white)
4
+ ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
5
+ ![NodeJS](https://img.shields.io/badge/Node%20js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)
6
+ ![NPM](https://img.shields.io/badge/npm-CB3837?style=for-the-badge&logo=npm&logoColor=white)
7
+ ![Gulp](https://img.shields.io/badge/GULP-%23CF4647.svg?style=for-the-badge&logo=gulp&logoColor=white)
8
+ ![ESLint](https://img.shields.io/badge/ESLint-4B3263?style=for-the-badge&logo=eslint&logoColor=white)
9
+
10
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
11
+
12
+ ## Introduction
13
+
14
+ The OPNet Transaction Builder library allows you to create and sign transactions for the OPNet network. Written in
15
+ TypeScript, this library provides a comprehensive set of functions to facilitate the creation, reading, and manipulation
16
+ of OPNet transactions, smart contracts, and other OPNet-related technologies.
17
+
18
+ ## Getting Started
19
+
20
+ ### Prerequisites
21
+
22
+ - Node.js version 16.x or higher
23
+ - npm (Node Package Manager)
24
+
25
+ ### Installation
26
+
27
+ ```shell
28
+ npm i @btc-vision/transaction
29
+ ```
30
+
31
+ ### Documentation
32
+
33
+ Documentation is available at [https://transaction.opnet.org](https://transaction.opnet.org) or in the `docs/` directory
34
+ of the repository.
35
+
36
+ #### Development
37
+
38
+ 1. Clone the repository:
39
+ ```bash
40
+ git clone https://github.com/btc-vision/transaction.git
41
+ ```
42
+ 2. Navigate to the repository directory:
43
+ ```bash
44
+ cd transaction
45
+ ```
46
+ 3. Install the required dependencies:
47
+ ```bash
48
+ npm i
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ Here's a basic example of how to use the OPNet Transaction Builder library to create and sign a transaction:
54
+ The following example demonstrates how to create a wBTC transfer transaction.
55
+
56
+ ### Import Statements
57
+
58
+ This section imports the necessary modules and libraries required for building and broadcasting transactions.
59
+
60
+ ```typescript
61
+ import {
62
+ TransactionFactory,
63
+ IInteractionParameters,
64
+ FetchUTXOParams,
65
+ UTXO,
66
+ UTXOManager,
67
+ Wallet,
68
+ wBTC
69
+ } from '@btc-vision/transaction';
70
+ import { networks } from 'bitcoinjs-lib';
71
+ import { BitcoinRPC } from '@btc-vision/bsi-bitcoin-rpc';
72
+ import { ABICoder, BinaryWriter } from '@btc-vision/bsi-binary';
73
+ ```
74
+
75
+ ### Setting Up configurations
76
+
77
+ We must provide the necessary configurations for the network, wallet, and RPC connection:
78
+
79
+ - The opnetNode variable is the URL of the OPNet node.
80
+ - The Testnet variable contains the wallet address, public key, and private key.
81
+ - The config variable inside the testnet object contains the network, host, port, username, and password for the RPC
82
+ connection.
83
+
84
+ ```typescript
85
+ const opnetNode: string = 'https://testnet.opnet.org';
86
+ const Testnet: NetworkInformation = {
87
+ wallet: {
88
+ address: '', // as BECH32
89
+ publicKey: '', // as HEX
90
+ privateKey: '', // as WIF
91
+ },
92
+
93
+ config: {
94
+ BITCOIND_NETWORK: BitcoinNetwork.TestNet, // Bitcoin network
95
+ BITCOIND_HOST: '', // Bitcoin RPC host
96
+ BITCOIND_PORT: 9242, // Bitcoin RPC port
97
+
98
+ BITCOIND_USERNAME: '', // Bitcoin RPC username
99
+ BITCOIND_PASSWORD: '', // Bitcoin RPC password
100
+ },
101
+ };
102
+ ```
103
+
104
+ ### Setting Up the Network and RPC
105
+
106
+ This section sets up the network, RPC, and wallet instances required for the transaction.
107
+
108
+ ```typescript
109
+ // Set up the network, RPC, and wallet
110
+ const network: networks.Network = networks.testnet; // Network
111
+ const rpc: BitcoinRPC = new BitcoinRPC();
112
+ const wBtc: wBTC = new wBTC(network); // wBTC metadata
113
+
114
+ const wallet: Wallet = new Wallet(Regtest.wallet, network); // Wallet
115
+ const utxoManager: UTXOManager = new UTXOManager(opnetNode); // UTXO manager
116
+
117
+ const factory: TransactionFactory = new TransactionFactory(); // Transaction factory
118
+ const abiCoder: ABICoder = new ABICoder();
119
+ const transferSelector = Number(`0x` + abiCoder.encodeSelector('transfer')); // Selector for the transfer function
120
+ ```
121
+
122
+ ### Creating Transfer Calldata
123
+
124
+ This section demonstrates how to create the calldata required for the `transfer` function.
125
+
126
+ ```typescript
127
+ // Function to create the transfer calldata
128
+ function getTransferToCalldata(to: string, amount: bigint): Buffer {
129
+ const addCalldata: BinaryWriter = new BinaryWriter();
130
+ addCalldata.writeSelector(transferSelector);
131
+ addCalldata.writeAddress(to);
132
+ addCalldata.writeU256(amount);
133
+ return Buffer.from(addCalldata.getBuffer());
134
+ }
135
+ ```
136
+
137
+ ### Initializing and Fetching UTXOs
138
+
139
+ This section initializes the RPC connection and fetches UTXOs for the wallet.
140
+
141
+ ```typescript
142
+
143
+ await rpc.init(Testnet.config); // Initialize the RPC connection
144
+
145
+ // Fetch UTXOs for the wallet
146
+ const utxoSetting: FetchUTXOParams = {
147
+ address: wallet.p2wpkh,
148
+ minAmount: 10000n,
149
+ requestedAmount: 100000n,
150
+ };
151
+
152
+ const utxos: UTXO[] = await utxoManager.fetchUTXO(utxoSetting);
153
+ console.log(`UTXOs:`, utxos);
154
+
155
+ if (!utxos.length) {
156
+ throw new Error('No UTXOs found');
157
+ }
158
+ ```
159
+
160
+ ### Preparing and Signing the Transaction
161
+
162
+ This section prepares the interaction parameters and signs the transaction.
163
+
164
+ ```typescript
165
+ // Prepare the interaction parameters for the transaction
166
+ const amountToSend: bigint = 5000000n; // Amount to send
167
+ const calldata: Buffer = getTransferToCalldata(wBtc.getAddress(), amountToSend);
168
+ const interactionParameters: IInteractionParameters = {
169
+ from: wallet.p2wpkh, // From address
170
+ to: wBtc.getAddress(), // To address
171
+ utxos: utxos, // UTXOs
172
+ signer: wallet.keypair, // Signer
173
+ network: network, // Network
174
+ feeRate: 150, // Fee rate (satoshi per byte)
175
+ priorityFee: 50000n, // Priority fee (opnet)
176
+ calldata: calldata, // Calldata
177
+ };
178
+
179
+ // Sign and broadcast the transaction
180
+ const finalTx = factory.signInteraction(interactionParameters);
181
+ ```
182
+
183
+ ### Broadcasting the Transaction
184
+
185
+ This section broadcasts the signed transaction to the network.
186
+
187
+ ```typescript
188
+ const firstTxBroadcast = await rpc.sendRawTransaction({ hexstring: finalTx[0] });
189
+ console.log(`First transaction broadcasted: ${firstTxBroadcast}`);
190
+
191
+ if (!firstTxBroadcast) {
192
+ throw new Error('Could not broadcast first transaction');
193
+ }
194
+
195
+ const secondTxBroadcast = await rpc.sendRawTransaction({ hexstring: finalTx[1] });
196
+ console.log(`Second transaction broadcasted: ${secondTxBroadcast}`);
197
+
198
+ if (!secondTxBroadcast) {
199
+ throw new Error('Could not broadcast second transaction');
200
+ }
201
+ ```
202
+
203
+ That's it! You have successfully created and broadcasted a transaction using OPNet.
204
+
205
+ ## Contribution
206
+
207
+ Contributions are welcome! Please read through the `CONTRIBUTING.md` file for guidelines on how to submit issues,
208
+ feature requests, and pull requests. We appreciate your input and encourage you to help us improve OPNet.
209
+
210
+ ## License
211
+
212
+ This project is open source and available under the [MIT License](LICENSE). If you have any suggestions or
213
+ contributions, please feel free to submit a pull request.
@@ -0,0 +1 @@
1
+ export declare const version = "1.0.0";
@@ -0,0 +1,6 @@
1
+ /// <reference types="node" />
2
+ export declare class Compressor {
3
+ private static readonly zlibOptions;
4
+ static compress(data: Uint8Array | Buffer): Buffer;
5
+ static decompress(data: Uint8Array | Buffer): Buffer;
6
+ }
@@ -0,0 +1,40 @@
1
+ export function createHash(algo: any): import("@noble/hashes/utils").Hash<{
2
+ A: number;
3
+ B: number;
4
+ C: number;
5
+ D: number;
6
+ E: number;
7
+ F: number;
8
+ G: number;
9
+ H: number;
10
+ get(): [number, number, number, number, number, number, number, number];
11
+ set(A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number): void;
12
+ process(view: DataView, offset: number): void;
13
+ roundClean(): void;
14
+ destroy(): void;
15
+ readonly blockLen: number;
16
+ outputLen: number;
17
+ readonly padOffset: number;
18
+ readonly isLE: boolean;
19
+ buffer: Uint8Array;
20
+ view: DataView;
21
+ finished: boolean;
22
+ length: number;
23
+ pos: number;
24
+ destroyed: boolean;
25
+ update(data: import("@noble/hashes/utils").Input): any;
26
+ digestInto(out: Uint8Array): void;
27
+ digest(): Uint8Array;
28
+ _cloneInto(to?: any | undefined): any;
29
+ clone(): any;
30
+ }> | import("@noble/hashes/utils").Hash<import("@noble/hashes/sha512").SHA512> | undefined;
31
+ export function createHmac(_algo: any, key: any): import("@noble/hashes/hmac").HMAC<any>;
32
+ export function pbkdf2Sync(password: any, salt: any, iterations: any, keylen: any, _algo: any): Uint8Array;
33
+ export function randomBytes(length: any): Uint8Array;
34
+ declare namespace _default {
35
+ export { createHash };
36
+ export { createHmac };
37
+ export { pbkdf2Sync };
38
+ export { randomBytes };
39
+ }
40
+ export default _default;
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export { createHash, createHmac, pbkdf2Sync, randomBytes } from 'crypto';
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { Network } from 'bitcoinjs-lib';
3
+ export declare abstract class Generator {
4
+ static readonly DATA_CHUNK_SIZE: number;
5
+ static readonly MAGIC: Buffer;
6
+ protected readonly senderPubKey: Buffer;
7
+ protected readonly contractSaltPubKey: Buffer;
8
+ protected readonly network: Network;
9
+ protected constructor(senderPubKey: Buffer, contractSaltPubKey: Buffer, network?: Network);
10
+ abstract compile(...args: unknown[]): Buffer;
11
+ protected splitBufferIntoChunks(buffer: Buffer, chunkSize?: number): Array<Buffer[]>;
12
+ }
@@ -0,0 +1,8 @@
1
+ /// <reference types="node" />
2
+ import { Network } from 'bitcoinjs-lib';
3
+ import { Generator } from '../Generator.js';
4
+ export declare class CalldataGenerator extends Generator {
5
+ constructor(senderPubKey: Buffer, contractSaltPubKey: Buffer, network?: Network);
6
+ compile(calldata: Buffer, contractSecret: Buffer, vaultPublicKeys?: Buffer[], minimumSignatures?: number): Buffer;
7
+ private getPubKeyAsBuffer;
8
+ }
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import { Network } from 'bitcoinjs-lib';
3
+ import { Generator } from '../Generator.js';
4
+ export declare class DeploymentGenerator extends Generator {
5
+ constructor(senderPubKey: Buffer, contractSaltPubKey: Buffer, network?: Network);
6
+ compile(contractBytecode: Buffer, contractSalt: Buffer): Buffer;
7
+ }
@@ -0,0 +1,3 @@
1
+ import * as opnet from './opnet.js';
2
+ export { opnet };
3
+ export * from './opnet.js';