@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.
- package/.babelrc +7 -0
- package/.gitattributes +2 -0
- package/.github/workflows/node.js.yml +22 -0
- package/.idea/codeStyles/Project.xml +56 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/transaction.iml +16 -0
- package/.idea/vcs.xml +6 -0
- package/.prettierrc.json +12 -0
- package/CONTRIBUTING.md +71 -0
- package/LICENSE.md +16 -0
- package/README.md +213 -0
- package/browser/873e754d6c7c6e9361f1.module.wasm +0 -0
- package/browser/_version.d.ts +1 -0
- package/browser/bytecode/Compressor.d.ts +6 -0
- package/browser/crypto/crypto-browser.d.ts +40 -0
- package/browser/crypto/crypto.d.ts +2 -0
- package/browser/generators/Generator.d.ts +12 -0
- package/browser/generators/builders/CalldataGenerator.d.ts +8 -0
- package/browser/generators/builders/DeploymentGenerator.d.ts +7 -0
- package/browser/index.d.ts +3 -0
- package/browser/index.js +2 -0
- package/browser/index.js.LICENSE.txt +23 -0
- package/browser/keypair/EcKeyPair.d.ts +24 -0
- package/browser/keypair/Wallet.d.ts +16 -0
- package/browser/keypair/interfaces/IWallet.d.ts +5 -0
- package/browser/metadata/ContractBaseMetadata.d.ts +9 -0
- package/browser/metadata/ContractMetadataManager.d.ts +1 -0
- package/browser/metadata/contracts/wBTC.d.ts +12 -0
- package/browser/network/NetworkInformation.d.ts +6 -0
- package/browser/opnet.d.ts +22 -0
- package/browser/scripts/Regtest.d.ts +2 -0
- package/browser/scripts/test.d.ts +1 -0
- package/browser/signer/TweakedSigner.d.ts +9 -0
- package/browser/transaction/TransactionBuilder.d.ts +1 -0
- package/browser/transaction/TransactionFactory.d.ts +4 -0
- package/browser/transaction/builders/FundingTransaction.d.ts +11 -0
- package/browser/transaction/builders/InteractionTransaction.d.ts +47 -0
- package/browser/transaction/builders/TransactionBuilder.d.ts +64 -0
- package/browser/transaction/enums/TransactionType.d.ts +7 -0
- package/browser/transaction/interfaces/ITransactionParameters.d.ts +33 -0
- package/browser/transaction/interfaces/Tap.d.ts +22 -0
- package/browser/utils/BitcoinUtils.d.ts +5 -0
- package/browser/utxo/UTXOManager.d.ts +7 -0
- package/browser/utxo/interfaces/IUTXO.d.ts +19 -0
- package/build/Utils.d.ts +0 -0
- package/build/Utils.js +1 -0
- package/build/_version.d.ts +1 -0
- package/build/_version.js +1 -0
- package/build/bytecode/Compressor.d.ts +6 -0
- package/build/bytecode/Compressor.js +13 -0
- package/build/contracts/ContractMetadataManager.d.ts +0 -0
- package/build/contracts/ContractMetadataManager.js +1 -0
- package/build/crypto/crypto.d.ts +2 -0
- package/build/crypto/crypto.js +1 -0
- package/build/generators/Generator.d.ts +12 -0
- package/build/generators/Generator.js +25 -0
- package/build/generators/builders/CalldataGenerator.d.ts +8 -0
- package/build/generators/builders/CalldataGenerator.js +79 -0
- package/build/generators/builders/DeploymentGenerator.d.ts +7 -0
- package/build/generators/builders/DeploymentGenerator.js +38 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +3 -0
- package/build/keypair/EcKeyPair.d.ts +24 -0
- package/build/keypair/EcKeyPair.js +107 -0
- package/build/keypair/Wallet.d.ts +16 -0
- package/build/keypair/Wallet.js +30 -0
- package/build/keypair/interfaces/GeneratedWallet.d.ts +5 -0
- package/build/keypair/interfaces/GeneratedWallet.js +1 -0
- package/build/keypair/interfaces/IWallet.d.ts +5 -0
- package/build/keypair/interfaces/IWallet.js +1 -0
- package/build/metadata/ContractBaseMetadata.d.ts +9 -0
- package/build/metadata/ContractBaseMetadata.js +13 -0
- package/build/metadata/ContractMetadataManager.d.ts +1 -0
- package/build/metadata/ContractMetadataManager.js +9 -0
- package/build/metadata/contracts/ContractBase.d.ts +9 -0
- package/build/metadata/contracts/ContractBase.js +13 -0
- package/build/metadata/contracts/ContractBaseMetadata.d.ts +9 -0
- package/build/metadata/contracts/ContractBaseMetadata.js +13 -0
- package/build/metadata/contracts/ContractMetadataManager.d.ts +0 -0
- package/build/metadata/contracts/ContractMetadataManager.js +1 -0
- package/build/metadata/contracts/wBTC.d.ts +12 -0
- package/build/metadata/contracts/wBTC.js +26 -0
- package/build/network/NetworkConverter.d.ts +0 -0
- package/build/network/NetworkConverter.js +14 -0
- package/build/network/NetworkInformation.d.ts +6 -0
- package/build/network/NetworkInformation.js +1 -0
- package/build/opnet.d.ts +22 -0
- package/build/opnet.js +22 -0
- package/build/scripts/Regtest.d.ts +2 -0
- package/build/scripts/Regtest.js +15 -0
- package/build/scripts/test.d.ts +1 -0
- package/build/scripts/test.js +74 -0
- package/build/signer/Regtest.d.ts +2 -0
- package/build/signer/Regtest.js +15 -0
- package/build/signer/TweakedSigner.d.ts +9 -0
- package/build/signer/TweakedSigner.js +22 -0
- package/build/transaction/TransactionBuilder.d.ts +60 -0
- package/build/transaction/TransactionBuilder.js +244 -0
- package/build/transaction/TransactionFactory.d.ts +4 -0
- package/build/transaction/TransactionFactory.js +32 -0
- package/build/transaction/builders/FundingTransaction.d.ts +11 -0
- package/build/transaction/builders/FundingTransaction.js +23 -0
- package/build/transaction/builders/GenericTransaction.d.ts +11 -0
- package/build/transaction/builders/GenericTransaction.js +23 -0
- package/build/transaction/builders/InteractionTransaction.d.ts +47 -0
- package/build/transaction/builders/InteractionTransaction.js +219 -0
- package/build/transaction/builders/TransactionBuilder.d.ts +64 -0
- package/build/transaction/builders/TransactionBuilder.js +288 -0
- package/build/transaction/enums/TransactionType.d.ts +7 -0
- package/build/transaction/enums/TransactionType.js +8 -0
- package/build/transaction/interfaces/ITransactionParameters.d.ts +33 -0
- package/build/transaction/interfaces/ITransactionParameters.js +1 -0
- package/build/transaction/interfaces/ITransactions.d.ts +32 -0
- package/build/transaction/interfaces/ITransactions.js +1 -0
- package/build/transaction/interfaces/Tap.d.ts +22 -0
- package/build/transaction/interfaces/Tap.js +1 -0
- package/build/utils/BitcoinUtils.d.ts +5 -0
- package/build/utils/BitcoinUtils.js +9 -0
- package/build/utxo/IUTXO.d.ts +0 -0
- package/build/utxo/IUTXO.js +1 -0
- package/build/utxo/UTXOManager.d.ts +7 -0
- package/build/utxo/UTXOManager.js +47 -0
- package/build/utxo/interfaces/IUTXO.d.ts +19 -0
- package/build/utxo/interfaces/IUTXO.js +1 -0
- package/cjs/_version.d.ts +1 -0
- package/cjs/_version.js +4 -0
- package/cjs/bytecode/Compressor.d.ts +6 -0
- package/cjs/bytecode/Compressor.js +20 -0
- package/cjs/crypto/crypto.d.ts +2 -0
- package/cjs/crypto/crypto.js +8 -0
- package/cjs/generators/Generator.d.ts +13 -0
- package/cjs/generators/Generator.js +31 -0
- package/cjs/generators/builders/CalldataGenerator.d.ts +8 -0
- package/cjs/generators/builders/CalldataGenerator.js +83 -0
- package/cjs/generators/builders/DeploymentGenerator.d.ts +7 -0
- package/cjs/generators/builders/DeploymentGenerator.js +42 -0
- package/cjs/index.d.ts +3 -0
- package/cjs/index.js +32 -0
- package/cjs/keypair/EcKeyPair.d.ts +24 -0
- package/cjs/keypair/EcKeyPair.js +137 -0
- package/cjs/keypair/Wallet.d.ts +16 -0
- package/cjs/keypair/Wallet.js +34 -0
- package/cjs/keypair/interfaces/IWallet.d.ts +5 -0
- package/cjs/keypair/interfaces/IWallet.js +2 -0
- package/cjs/metadata/ContractBaseMetadata.d.ts +9 -0
- package/cjs/metadata/ContractBaseMetadata.js +17 -0
- package/cjs/metadata/ContractMetadataManager.d.ts +0 -0
- package/cjs/metadata/ContractMetadataManager.js +1 -0
- package/cjs/metadata/contracts/wBTC.d.ts +12 -0
- package/cjs/metadata/contracts/wBTC.js +30 -0
- package/cjs/network/NetworkInformation.d.ts +6 -0
- package/cjs/network/NetworkInformation.js +2 -0
- package/cjs/opnet.d.ts +1 -0
- package/cjs/opnet.js +5 -0
- package/cjs/scripts/Regtest.d.ts +2 -0
- package/cjs/scripts/Regtest.js +18 -0
- package/cjs/scripts/test.d.ts +1 -0
- package/cjs/scripts/test.js +44 -0
- package/cjs/signer/TweakedSigner.d.ts +9 -0
- package/cjs/signer/TweakedSigner.js +49 -0
- package/cjs/transaction/TransactionBuilder.d.ts +0 -0
- package/cjs/transaction/TransactionBuilder.js +1 -0
- package/cjs/transaction/TransactionFactory.d.ts +4 -0
- package/cjs/transaction/TransactionFactory.js +33 -0
- package/cjs/transaction/builders/FundingTransaction.d.ts +11 -0
- package/cjs/transaction/builders/FundingTransaction.js +27 -0
- package/cjs/transaction/builders/InteractionTransaction.d.ts +45 -0
- package/cjs/transaction/builders/InteractionTransaction.js +214 -0
- package/cjs/transaction/builders/TransactionBuilder.d.ts +64 -0
- package/cjs/transaction/builders/TransactionBuilder.js +304 -0
- package/cjs/transaction/enums/TransactionType.d.ts +7 -0
- package/cjs/transaction/enums/TransactionType.js +11 -0
- package/cjs/transaction/interfaces/ITransactionParameters.d.ts +32 -0
- package/cjs/transaction/interfaces/ITransactionParameters.js +2 -0
- package/cjs/transaction/interfaces/Tap.d.ts +22 -0
- package/cjs/transaction/interfaces/Tap.js +2 -0
- package/cjs/utils/BitcoinUtils.d.ts +5 -0
- package/cjs/utils/BitcoinUtils.js +13 -0
- package/cjs/utxo/UTXOManager.d.ts +7 -0
- package/cjs/utxo/UTXOManager.js +51 -0
- package/cjs/utxo/interfaces/IUTXO.d.ts +19 -0
- package/cjs/utxo/interfaces/IUTXO.js +2 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +92 -0
- package/docs/assets/icons.js +15 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/material-style.css +247 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1412 -0
- package/docs/classes/BitcoinUtils.html +183 -0
- package/docs/classes/CalldataGenerator.html +211 -0
- package/docs/classes/Compressor.html +185 -0
- package/docs/classes/ContractBaseMetadata.html +182 -0
- package/docs/classes/DeploymentGenerator.html +200 -0
- package/docs/classes/EcKeyPair.html +280 -0
- package/docs/classes/FundingTransaction.html +293 -0
- package/docs/classes/Generator.html +199 -0
- package/docs/classes/InteractionTransaction.html +365 -0
- package/docs/classes/TransactionBuilder.html +303 -0
- package/docs/classes/TransactionFactory.html +180 -0
- package/docs/classes/TweakedSigner.html +181 -0
- package/docs/classes/UTXOManager.html +187 -0
- package/docs/classes/Wallet.html +191 -0
- package/docs/classes/wBTC.html +189 -0
- package/docs/enums/TransactionType.html +179 -0
- package/docs/hierarchy.html +174 -0
- package/docs/index.html +237 -0
- package/docs/interfaces/FetchUTXOParams.html +178 -0
- package/docs/interfaces/IFundingTransactionParameters.html +182 -0
- package/docs/interfaces/IInteractionParameters.html +185 -0
- package/docs/interfaces/ITransactionDataContractDeployment.html +184 -0
- package/docs/interfaces/ITransactionDataContractInteractionWrap.html +186 -0
- package/docs/interfaces/ITransactionParameters.html +181 -0
- package/docs/interfaces/IWallet.html +181 -0
- package/docs/interfaces/NetworkInformation.html +176 -0
- package/docs/interfaces/PsbtInputExtended.html +194 -0
- package/docs/interfaces/PsbtOutputExtendedAddress.html +183 -0
- package/docs/interfaces/PsbtOutputExtendedScript.html +183 -0
- package/docs/interfaces/RawUTXOResponse.html +178 -0
- package/docs/interfaces/TapLeafScript.html +177 -0
- package/docs/interfaces/TweakSettings.html +179 -0
- package/docs/interfaces/UTXO.html +178 -0
- package/docs/interfaces/UpdateInput.html +175 -0
- package/docs/modules.html +208 -0
- package/docs/types/PsbtOutputExtended.html +174 -0
- package/docs/variables/version.html +174 -0
- package/gulpfile.js +152 -0
- package/jest.config.ts +52 -0
- package/package.json +116 -0
- package/src/_version.ts +1 -0
- package/src/bytecode/Compressor.ts +27 -0
- package/src/crypto/crypto-browser.js +71 -0
- package/src/crypto/crypto.ts +1 -0
- package/src/generators/Generator.ts +75 -0
- package/src/generators/builders/CalldataGenerator.ts +143 -0
- package/src/generators/builders/DeploymentGenerator.ts +63 -0
- package/src/index.ts +4 -0
- package/src/keypair/EcKeyPair.ts +265 -0
- package/src/keypair/Wallet.ts +75 -0
- package/src/keypair/interfaces/IWallet.ts +19 -0
- package/src/metadata/ContractBaseMetadata.ts +23 -0
- package/src/metadata/contracts/wBTC.ts +44 -0
- package/src/network/NetworkInformation.ts +7 -0
- package/src/opnet.ts +42 -0
- package/src/scripts/Regtest.ts +19 -0
- package/src/scripts/test.ts +98 -0
- package/src/signer/TweakedSigner.ts +57 -0
- package/src/transaction/TransactionFactory.ts +57 -0
- package/src/transaction/builders/FundingTransaction.ts +36 -0
- package/src/transaction/builders/InteractionTransaction.ts +439 -0
- package/src/transaction/builders/TransactionBuilder.ts +603 -0
- package/src/transaction/enums/TransactionType.ts +7 -0
- package/src/transaction/interfaces/ITransactionParameters.ts +41 -0
- package/src/transaction/interfaces/Tap.ts +26 -0
- package/src/utils/BitcoinUtils.ts +24 -0
- package/src/utxo/UTXOManager.ts +67 -0
- package/src/utxo/interfaces/IUTXO.ts +22 -0
- package/tests/TransactionBuilder.test.ts +58 -0
- package/tests/contracts/wbtc.wasm +0 -0
- package/tsconfig.base.json +43 -0
- package/tsconfig.cjs.json +9 -0
- package/tsconfig.json +8 -0
- package/tsconfig.webpack.json +11 -0
- package/webpack.config.js +77 -0
package/.babelrc
ADDED
package/.gitattributes
ADDED
|
@@ -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,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,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
package/.prettierrc.json
ADDED
package/CONTRIBUTING.md
ADDED
|
@@ -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
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
[](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.
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "1.0.0";
|
|
@@ -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,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
|
+
}
|