@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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* The buffer module from node.js, for the browser.
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*!
|
|
9
|
+
* The buffer module from node.js, for the browser.
|
|
10
|
+
*
|
|
11
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
12
|
+
* @license MIT
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
16
|
+
|
|
17
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
18
|
+
|
|
19
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
20
|
+
|
|
21
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
22
|
+
|
|
23
|
+
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { BIP32Interface } from 'bip32';
|
|
3
|
+
import { Network } from 'bitcoinjs-lib';
|
|
4
|
+
import { ECPairInterface } from 'ecpair';
|
|
5
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
6
|
+
import { IWallet } from './interfaces/IWallet.js';
|
|
7
|
+
export declare class EcKeyPair {
|
|
8
|
+
static BIP32: any;
|
|
9
|
+
static ECPair: import("ecpair").ECPairAPI;
|
|
10
|
+
static fromWIF(wif: string, network?: Network): ECPairInterface;
|
|
11
|
+
static fromPrivateKey(privateKey: Buffer, network?: Network): ECPairInterface;
|
|
12
|
+
static fromPublicKey(publicKey: Buffer, network?: Network): ECPairInterface;
|
|
13
|
+
static generateMultiSigAddress(pubKeys: Buffer[], minimumSignatureRequired: number, network?: Network): Address;
|
|
14
|
+
static verifyPubKeys(pubKeys: Buffer[], network?: Network): Buffer[];
|
|
15
|
+
static getP2WPKHAddress(keyPair: ECPairInterface, network?: Network): Address;
|
|
16
|
+
static generateWallet(network?: Network): IWallet;
|
|
17
|
+
static verifyContractAddress(contractAddress: Address, network?: Network): boolean;
|
|
18
|
+
static getLegacyAddress(keyPair: ECPairInterface, network?: Network): Address;
|
|
19
|
+
static generateRandomKeyPair(network?: Network): ECPairInterface;
|
|
20
|
+
static fromSeed(seed: Buffer, network?: Network): BIP32Interface;
|
|
21
|
+
static getTaprootAddress(keyPair: ECPairInterface, network?: Network): Address;
|
|
22
|
+
static getTaprootAddressFromAddress(inAddr: Address, network?: Network): Address;
|
|
23
|
+
static fromSeedKeyPair(seed: Buffer, network?: Network): ECPairInterface;
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IWallet } from './interfaces/IWallet.js';
|
|
3
|
+
import { ECPairInterface } from 'ecpair';
|
|
4
|
+
import { Network } from 'bitcoinjs-lib';
|
|
5
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
6
|
+
export declare class Wallet {
|
|
7
|
+
readonly network: Network;
|
|
8
|
+
private readonly _keypair;
|
|
9
|
+
private readonly _p2wpkh;
|
|
10
|
+
private readonly _p2tr;
|
|
11
|
+
constructor(wallet: IWallet, network?: Network);
|
|
12
|
+
get keypair(): ECPairInterface;
|
|
13
|
+
get p2wpkh(): Address;
|
|
14
|
+
get p2tr(): Address;
|
|
15
|
+
get publicKey(): Buffer;
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { Network } from 'bitcoinjs-lib';
|
|
3
|
+
export declare abstract class ContractBaseMetadata {
|
|
4
|
+
protected network: Network;
|
|
5
|
+
protected abstract readonly address: Address;
|
|
6
|
+
protected constructor(network?: Network);
|
|
7
|
+
static getAddress(network?: Network): Address;
|
|
8
|
+
getAddress(): Address;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Network } from 'bitcoinjs-lib';
|
|
2
|
+
import { ContractBaseMetadata } from '../ContractBaseMetadata.js';
|
|
3
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
4
|
+
export declare class wBTC extends ContractBaseMetadata {
|
|
5
|
+
protected network: Network;
|
|
6
|
+
readonly tokenName: string;
|
|
7
|
+
readonly tokenSymbol: string;
|
|
8
|
+
readonly decimals: number;
|
|
9
|
+
protected readonly address: Address;
|
|
10
|
+
constructor(network?: Network);
|
|
11
|
+
static getAddress(network?: Network): Address;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { version } from './_version.js';
|
|
2
|
+
export * from './bytecode/Compressor.js';
|
|
3
|
+
export * from './generators/Generator.js';
|
|
4
|
+
export * from './generators/builders/CalldataGenerator.js';
|
|
5
|
+
export * from './generators/builders/DeploymentGenerator.js';
|
|
6
|
+
export * from './keypair/EcKeyPair.js';
|
|
7
|
+
export * from './keypair/Wallet.js';
|
|
8
|
+
export * from './keypair/interfaces/IWallet.js';
|
|
9
|
+
export * from './metadata/contracts/wBTC.js';
|
|
10
|
+
export * from './metadata/ContractBaseMetadata.js';
|
|
11
|
+
export * from './network/NetworkInformation.js';
|
|
12
|
+
export * from './signer/TweakedSigner.js';
|
|
13
|
+
export * from './transaction/TransactionFactory.js';
|
|
14
|
+
export * from './transaction/interfaces/ITransactionParameters.js';
|
|
15
|
+
export * from './transaction/interfaces/Tap.js';
|
|
16
|
+
export * from './transaction/enums/TransactionType.js';
|
|
17
|
+
export * from './transaction/builders/InteractionTransaction.js';
|
|
18
|
+
export * from './transaction/builders/FundingTransaction.js';
|
|
19
|
+
export * from './transaction/builders/TransactionBuilder.js';
|
|
20
|
+
export * from './utils/BitcoinUtils.js';
|
|
21
|
+
export * from './utxo/interfaces/IUTXO.js';
|
|
22
|
+
export * from './utxo/UTXOManager.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Network, Signer } from 'bitcoinjs-lib';
|
|
3
|
+
export interface TweakSettings {
|
|
4
|
+
readonly network?: Network;
|
|
5
|
+
tweakHash?: Buffer;
|
|
6
|
+
}
|
|
7
|
+
export declare class TweakedSigner {
|
|
8
|
+
static tweakSigner(signer: Signer, opts?: TweakSettings): Signer;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TransactionType } from '../enums/TransactionType.js';
|
|
2
|
+
import { IFundingTransactionParameters } from '../interfaces/ITransactionParameters.js';
|
|
3
|
+
import { Signer } from 'bitcoinjs-lib';
|
|
4
|
+
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
5
|
+
export declare class FundingTransaction extends TransactionBuilder<TransactionType.FUNDING> {
|
|
6
|
+
readonly type: TransactionType.FUNDING;
|
|
7
|
+
protected childTransactionRequiredFees: bigint;
|
|
8
|
+
constructor(parameters: IFundingTransactionParameters);
|
|
9
|
+
protected buildTransaction(): void;
|
|
10
|
+
protected getSignerKey(): Signer;
|
|
11
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PsbtInput } from 'bip174/src/lib/interfaces.js';
|
|
3
|
+
import { Payment, Psbt, Signer } from 'bitcoinjs-lib';
|
|
4
|
+
import { Taptree } from 'bitcoinjs-lib/src/types.js';
|
|
5
|
+
import { ECPairInterface } from 'ecpair';
|
|
6
|
+
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
7
|
+
import { TransactionType } from '../enums/TransactionType.js';
|
|
8
|
+
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
9
|
+
import { CalldataGenerator } from '../../generators/builders/CalldataGenerator.js';
|
|
10
|
+
import { IInteractionParameters } from '../interfaces/ITransactionParameters.js';
|
|
11
|
+
export declare class InteractionTransaction extends TransactionBuilder<TransactionType.INTERACTION> {
|
|
12
|
+
type: TransactionType.INTERACTION;
|
|
13
|
+
readonly randomBytes: Buffer;
|
|
14
|
+
protected targetScriptRedeem: Payment | null;
|
|
15
|
+
protected leftOverFundsScriptRedeem: Payment | null;
|
|
16
|
+
protected readonly compiledTargetScript: Buffer;
|
|
17
|
+
protected readonly scriptTree: Taptree;
|
|
18
|
+
protected tapLeafScript: TapLeafScript | null;
|
|
19
|
+
protected calldataGenerator: CalldataGenerator;
|
|
20
|
+
protected readonly calldata: Buffer;
|
|
21
|
+
protected readonly contractSecret: Buffer;
|
|
22
|
+
protected tweakedSigner?: Signer;
|
|
23
|
+
protected readonly scriptSigner: Signer;
|
|
24
|
+
protected readonly interactionPubKeys: Buffer[];
|
|
25
|
+
protected readonly minimumSignatures: number;
|
|
26
|
+
constructor(parameters: IInteractionParameters);
|
|
27
|
+
getContractSecret(): Buffer;
|
|
28
|
+
getRndBytes(): Buffer;
|
|
29
|
+
protected generateSecret(): Buffer;
|
|
30
|
+
protected tweakSigner(): void;
|
|
31
|
+
protected scriptSignerXOnlyPubKey(): Buffer;
|
|
32
|
+
protected generateKeyPairFromSeed(): ECPairInterface;
|
|
33
|
+
protected addInputsFromUTXO(): void;
|
|
34
|
+
protected buildTransaction(): void;
|
|
35
|
+
protected signInputs(transaction: Psbt): void;
|
|
36
|
+
protected getSignerKey(): Signer;
|
|
37
|
+
protected generateScriptAddress(): Payment;
|
|
38
|
+
protected generateTapData(): Payment;
|
|
39
|
+
protected getScriptSolution(input: PsbtInput): Buffer[];
|
|
40
|
+
private getPubKeys;
|
|
41
|
+
private customFinalizer;
|
|
42
|
+
private getTweakerHash;
|
|
43
|
+
private getTweakedSigner;
|
|
44
|
+
private generateRedeemScripts;
|
|
45
|
+
private getLeafScript;
|
|
46
|
+
private getScriptTree;
|
|
47
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Network, Payment, Psbt, Signer, Transaction } from 'bitcoinjs-lib';
|
|
3
|
+
import { PsbtInputExtended, PsbtOutputExtended, UpdateInput } from '../interfaces/Tap.js';
|
|
4
|
+
import { TransactionType } from '../enums/TransactionType.js';
|
|
5
|
+
import { IFundingTransactionParameters, ITransactionParameters } from '../interfaces/ITransactionParameters.js';
|
|
6
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
7
|
+
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
8
|
+
export declare abstract class TransactionBuilder<T extends TransactionType> {
|
|
9
|
+
protected static readonly LOCK_LEAF_SCRIPT: Buffer;
|
|
10
|
+
protected static readonly MINIMUM_DUST: bigint;
|
|
11
|
+
abstract readonly type: T;
|
|
12
|
+
readonly logColor: string;
|
|
13
|
+
transactionFee: bigint;
|
|
14
|
+
protected readonly transaction: Psbt;
|
|
15
|
+
protected readonly inputs: PsbtInputExtended[];
|
|
16
|
+
protected readonly updateInputs: UpdateInput[];
|
|
17
|
+
protected readonly outputs: PsbtOutputExtended[];
|
|
18
|
+
protected feeOutput: PsbtOutputExtended | null;
|
|
19
|
+
protected signed: boolean;
|
|
20
|
+
protected tapData: Payment | null;
|
|
21
|
+
protected scriptData: Payment | null;
|
|
22
|
+
protected totalInputAmount: bigint;
|
|
23
|
+
protected readonly signer: Signer;
|
|
24
|
+
protected readonly network: Network;
|
|
25
|
+
protected readonly feeRate: number;
|
|
26
|
+
protected readonly priorityFee: bigint;
|
|
27
|
+
protected utxos: UTXO[];
|
|
28
|
+
protected to: Address;
|
|
29
|
+
protected from: Address;
|
|
30
|
+
private _maximumFeeRate;
|
|
31
|
+
protected constructor(parameters: ITransactionParameters);
|
|
32
|
+
getFundingTransactionParameters(): IFundingTransactionParameters;
|
|
33
|
+
setDestinationAddress(address: Address): void;
|
|
34
|
+
setMaximumFeeRate(feeRate: number): void;
|
|
35
|
+
signTransaction(): Transaction;
|
|
36
|
+
getTransaction(): Transaction;
|
|
37
|
+
getScriptAddress(): string;
|
|
38
|
+
disableRBF(): void;
|
|
39
|
+
getTapAddress(): string;
|
|
40
|
+
addInput(input: PsbtInputExtended): void;
|
|
41
|
+
addOutput(output: PsbtOutputExtended): void;
|
|
42
|
+
protected addRefundOutput(amountSpent: bigint): void;
|
|
43
|
+
protected getTransactionOPNetFee(): bigint;
|
|
44
|
+
protected calculateTotalUTXOAmount(): bigint;
|
|
45
|
+
protected calculateTotalVOutAmount(): bigint;
|
|
46
|
+
protected addInputsFromUTXO(): void;
|
|
47
|
+
protected witnessStackToScriptWitness(witness: Buffer[]): Buffer;
|
|
48
|
+
protected internalInit(): void;
|
|
49
|
+
protected abstract buildTransaction(): void;
|
|
50
|
+
protected generateScriptAddress(): Payment;
|
|
51
|
+
protected generateTapData(): Payment;
|
|
52
|
+
protected updateInput(input: UpdateInput): void;
|
|
53
|
+
protected getWitness(): Buffer;
|
|
54
|
+
protected getTapOutput(): Buffer;
|
|
55
|
+
protected getInputs(): PsbtInputExtended[];
|
|
56
|
+
protected getOutputs(): PsbtOutputExtended[];
|
|
57
|
+
protected verifyUTXOValidity(): void;
|
|
58
|
+
protected setFeeOutput(output: PsbtOutputExtended): void;
|
|
59
|
+
protected abstract getSignerKey(): Signer;
|
|
60
|
+
protected internalPubKeyToXOnly(): Buffer;
|
|
61
|
+
protected signInputs(transaction: Psbt): void;
|
|
62
|
+
private internalBuildTransaction;
|
|
63
|
+
private estimateTransactionFees;
|
|
64
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Signer } from 'bitcoinjs-lib';
|
|
3
|
+
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
4
|
+
import { Network } from 'bitcoinjs-lib/src/networks.js';
|
|
5
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
6
|
+
export interface ITransactionParameters {
|
|
7
|
+
readonly from?: Address;
|
|
8
|
+
readonly to: Address;
|
|
9
|
+
utxos: UTXO[];
|
|
10
|
+
readonly signer: Signer;
|
|
11
|
+
readonly network: Network;
|
|
12
|
+
readonly feeRate: number;
|
|
13
|
+
readonly priorityFee: bigint;
|
|
14
|
+
}
|
|
15
|
+
export interface IFundingTransactionParameters extends ITransactionParameters {
|
|
16
|
+
readonly childTransactionRequiredFees: bigint;
|
|
17
|
+
}
|
|
18
|
+
export interface IInteractionParameters extends ITransactionParameters {
|
|
19
|
+
readonly calldata: Buffer;
|
|
20
|
+
readonly pubKeys?: Buffer[];
|
|
21
|
+
readonly minimumSignatures?: number;
|
|
22
|
+
readonly randomBytes?: Buffer;
|
|
23
|
+
}
|
|
24
|
+
export interface ITransactionDataContractInteractionWrap extends IInteractionParameters {
|
|
25
|
+
readonly amount: bigint;
|
|
26
|
+
readonly minimumSignatures: number;
|
|
27
|
+
readonly pubKeys: Buffer[];
|
|
28
|
+
}
|
|
29
|
+
export interface ITransactionDataContractDeployment extends ITransactionParameters {
|
|
30
|
+
readonly bytecode: Buffer;
|
|
31
|
+
readonly salt: Buffer;
|
|
32
|
+
readonly customSigner: Signer;
|
|
33
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PsbtInput, PsbtOutput } from 'bip174/src/lib/interfaces.js';
|
|
3
|
+
import { TransactionInput } from 'bitcoinjs-lib/src/psbt.js';
|
|
4
|
+
export interface TapLeafScript {
|
|
5
|
+
readonly leafVersion: number;
|
|
6
|
+
readonly controlBlock: Buffer;
|
|
7
|
+
readonly script: Buffer;
|
|
8
|
+
}
|
|
9
|
+
export interface UpdateInput {
|
|
10
|
+
tapLeafScript: TapLeafScript[];
|
|
11
|
+
}
|
|
12
|
+
export interface PsbtInputExtended extends PsbtInput, TransactionInput {
|
|
13
|
+
}
|
|
14
|
+
export interface PsbtOutputExtendedAddress extends PsbtOutput {
|
|
15
|
+
address: string;
|
|
16
|
+
value: number;
|
|
17
|
+
}
|
|
18
|
+
export interface PsbtOutputExtendedScript extends PsbtOutput {
|
|
19
|
+
script: Buffer;
|
|
20
|
+
value: number;
|
|
21
|
+
}
|
|
22
|
+
export type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ScriptPubKey } from '@btc-vision/bsi-bitcoin-rpc';
|
|
2
|
+
export interface UTXO {
|
|
3
|
+
readonly transactionId: string;
|
|
4
|
+
readonly outputIndex: number;
|
|
5
|
+
readonly value: bigint;
|
|
6
|
+
readonly scriptPubKey: ScriptPubKey;
|
|
7
|
+
}
|
|
8
|
+
export interface FetchUTXOParams {
|
|
9
|
+
readonly address: string;
|
|
10
|
+
readonly minAmount: bigint;
|
|
11
|
+
readonly requestedAmount: bigint;
|
|
12
|
+
readonly optimized?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface RawUTXOResponse {
|
|
15
|
+
readonly transactionId: string;
|
|
16
|
+
readonly outputIndex: number;
|
|
17
|
+
readonly value: string;
|
|
18
|
+
readonly scriptPubKey: ScriptPubKey;
|
|
19
|
+
}
|
package/build/Utils.d.ts
ADDED
|
File without changes
|
package/build/Utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "1.0.0";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const version = '1.0.0';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import zlib from 'zlib';
|
|
2
|
+
export class Compressor {
|
|
3
|
+
static zlibOptions = {
|
|
4
|
+
level: zlib.constants.Z_MAX_LEVEL,
|
|
5
|
+
maxOutputLength: 1024 * 1024 * 16,
|
|
6
|
+
};
|
|
7
|
+
static compress(data) {
|
|
8
|
+
return zlib.gzipSync(data, Compressor.zlibOptions);
|
|
9
|
+
}
|
|
10
|
+
static decompress(data) {
|
|
11
|
+
return zlib.gunzipSync(data, Compressor.zlibOptions);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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,25 @@
|
|
|
1
|
+
import { networks } from 'bitcoinjs-lib';
|
|
2
|
+
export class Generator {
|
|
3
|
+
static DATA_CHUNK_SIZE = 512;
|
|
4
|
+
static MAGIC = Buffer.from('bsi', 'utf-8');
|
|
5
|
+
senderPubKey;
|
|
6
|
+
contractSaltPubKey;
|
|
7
|
+
network = networks.bitcoin;
|
|
8
|
+
constructor(senderPubKey, contractSaltPubKey, network = networks.bitcoin) {
|
|
9
|
+
this.senderPubKey = senderPubKey;
|
|
10
|
+
this.contractSaltPubKey = contractSaltPubKey;
|
|
11
|
+
this.network = network;
|
|
12
|
+
}
|
|
13
|
+
splitBufferIntoChunks(buffer, chunkSize = Generator.DATA_CHUNK_SIZE) {
|
|
14
|
+
const chunks = [];
|
|
15
|
+
for (let i = 0; i < buffer.length; i += chunkSize) {
|
|
16
|
+
const dataLength = Math.min(chunkSize, buffer.length - i);
|
|
17
|
+
const buf2 = Buffer.alloc(dataLength);
|
|
18
|
+
for (let j = 0; j < dataLength; j++) {
|
|
19
|
+
buf2.writeUInt8(buffer[i + j], j);
|
|
20
|
+
}
|
|
21
|
+
chunks.push([buf2]);
|
|
22
|
+
}
|
|
23
|
+
return chunks;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -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,79 @@
|
|
|
1
|
+
import { crypto, networks, opcodes, script } from 'bitcoinjs-lib';
|
|
2
|
+
import { Compressor } from '../../bytecode/Compressor.js';
|
|
3
|
+
import { Generator } from '../Generator.js';
|
|
4
|
+
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
5
|
+
export class CalldataGenerator extends Generator {
|
|
6
|
+
constructor(senderPubKey, contractSaltPubKey, network = networks.bitcoin) {
|
|
7
|
+
super(senderPubKey, contractSaltPubKey, network);
|
|
8
|
+
}
|
|
9
|
+
compile(calldata, contractSecret, vaultPublicKeys = [], minimumSignatures = 0) {
|
|
10
|
+
const dataChunks = this.splitBufferIntoChunks(calldata);
|
|
11
|
+
if (!dataChunks.length)
|
|
12
|
+
throw new Error('No data chunks found');
|
|
13
|
+
let compiledData = [
|
|
14
|
+
this.senderPubKey,
|
|
15
|
+
opcodes.OP_CHECKSIGVERIFY,
|
|
16
|
+
this.contractSaltPubKey,
|
|
17
|
+
opcodes.OP_CHECKSIGVERIFY,
|
|
18
|
+
opcodes.OP_HASH160,
|
|
19
|
+
crypto.hash160(this.senderPubKey),
|
|
20
|
+
opcodes.OP_EQUALVERIFY,
|
|
21
|
+
opcodes.OP_HASH160,
|
|
22
|
+
crypto.hash160(contractSecret),
|
|
23
|
+
opcodes.OP_EQUALVERIFY,
|
|
24
|
+
opcodes.OP_DEPTH,
|
|
25
|
+
opcodes.OP_1,
|
|
26
|
+
opcodes.OP_NUMEQUAL,
|
|
27
|
+
opcodes.OP_IF,
|
|
28
|
+
Generator.MAGIC,
|
|
29
|
+
];
|
|
30
|
+
if (vaultPublicKeys.length > 0) {
|
|
31
|
+
const pubKeyBuffer = this.getPubKeyAsBuffer(vaultPublicKeys);
|
|
32
|
+
const pubKeyDataChunks = this.splitBufferIntoChunks(pubKeyBuffer);
|
|
33
|
+
compiledData = compiledData.concat(...[
|
|
34
|
+
opcodes.OP_0,
|
|
35
|
+
...pubKeyDataChunks,
|
|
36
|
+
]);
|
|
37
|
+
if (minimumSignatures) {
|
|
38
|
+
if (minimumSignatures > 255) {
|
|
39
|
+
throw new Error('Minimum signatures cannot exceed 255');
|
|
40
|
+
}
|
|
41
|
+
const minSigBuffer = Buffer.alloc(2);
|
|
42
|
+
minSigBuffer.writeUint16LE(minimumSignatures, 0);
|
|
43
|
+
compiledData = compiledData.concat(...[
|
|
44
|
+
opcodes.OP_1,
|
|
45
|
+
minSigBuffer,
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new Error('Minimum signatures must be provided');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
compiledData = compiledData.concat(...[opcodes.OP_1NEGATE, ...dataChunks, opcodes.OP_ELSE, opcodes.OP_1, opcodes.OP_ENDIF]);
|
|
53
|
+
const asm = compiledData.flat();
|
|
54
|
+
const compiled = script.compile(asm);
|
|
55
|
+
const decompiled = script.decompile(compiled);
|
|
56
|
+
if (!decompiled) {
|
|
57
|
+
throw new Error('Failed to decompile script??');
|
|
58
|
+
}
|
|
59
|
+
return compiled;
|
|
60
|
+
}
|
|
61
|
+
getPubKeyAsBuffer(witnessKeys) {
|
|
62
|
+
let finalBuffer = Buffer.alloc(0);
|
|
63
|
+
for (let pubKey of witnessKeys) {
|
|
64
|
+
const key = EcKeyPair.fromPublicKey(pubKey, this.network);
|
|
65
|
+
if (!key.compressed) {
|
|
66
|
+
throw new Error('Public key must be compressed');
|
|
67
|
+
}
|
|
68
|
+
if (pubKey.byteLength !== 33) {
|
|
69
|
+
throw new Error(`Public key must be 33 bytes, got ${pubKey.byteLength} bytes.`);
|
|
70
|
+
}
|
|
71
|
+
finalBuffer = Buffer.concat([finalBuffer, pubKey]);
|
|
72
|
+
}
|
|
73
|
+
const compressed = Compressor.compress(finalBuffer);
|
|
74
|
+
if (compressed.byteLength >= finalBuffer.byteLength) {
|
|
75
|
+
return finalBuffer;
|
|
76
|
+
}
|
|
77
|
+
return compressed;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -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,38 @@
|
|
|
1
|
+
import { crypto, networks, opcodes, script } from 'bitcoinjs-lib';
|
|
2
|
+
import { Generator } from '../Generator.js';
|
|
3
|
+
export class DeploymentGenerator extends Generator {
|
|
4
|
+
constructor(senderPubKey, contractSaltPubKey, network = networks.bitcoin) {
|
|
5
|
+
super(senderPubKey, contractSaltPubKey, network);
|
|
6
|
+
}
|
|
7
|
+
compile(contractBytecode, contractSalt) {
|
|
8
|
+
const dataChunks = this.splitBufferIntoChunks(contractBytecode);
|
|
9
|
+
const asm = [
|
|
10
|
+
this.senderPubKey,
|
|
11
|
+
opcodes.OP_CHECKSIGVERIFY,
|
|
12
|
+
this.contractSaltPubKey,
|
|
13
|
+
opcodes.OP_CHECKSIGVERIFY,
|
|
14
|
+
opcodes.OP_HASH160,
|
|
15
|
+
crypto.hash160(this.senderPubKey),
|
|
16
|
+
opcodes.OP_EQUALVERIFY,
|
|
17
|
+
opcodes.OP_HASH256,
|
|
18
|
+
crypto.hash256(contractSalt),
|
|
19
|
+
opcodes.OP_EQUALVERIFY,
|
|
20
|
+
opcodes.OP_DEPTH,
|
|
21
|
+
opcodes.OP_1,
|
|
22
|
+
opcodes.OP_NUMEQUAL,
|
|
23
|
+
opcodes.OP_IF,
|
|
24
|
+
Generator.MAGIC,
|
|
25
|
+
opcodes.OP_1NEGATE,
|
|
26
|
+
...dataChunks,
|
|
27
|
+
opcodes.OP_ELSE,
|
|
28
|
+
opcodes.OP_1,
|
|
29
|
+
opcodes.OP_ENDIF,
|
|
30
|
+
].flat();
|
|
31
|
+
const compiled = script.compile(asm);
|
|
32
|
+
const decompiled = script.decompile(compiled);
|
|
33
|
+
if (!decompiled) {
|
|
34
|
+
throw new Error('Failed to decompile script??');
|
|
35
|
+
}
|
|
36
|
+
return compiled;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED