@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,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,107 @@
|
|
|
1
|
+
import bip32 from 'bip32';
|
|
2
|
+
import { address, initEccLib, networks, payments } from 'bitcoinjs-lib';
|
|
3
|
+
import { ECPairFactory } from 'ecpair';
|
|
4
|
+
import * as ecc from 'tiny-secp256k1';
|
|
5
|
+
initEccLib(ecc);
|
|
6
|
+
const BIP32Factory = typeof bip32 === 'function' ? bip32 : bip32.BIP32Factory;
|
|
7
|
+
export class EcKeyPair {
|
|
8
|
+
static BIP32 = BIP32Factory(ecc);
|
|
9
|
+
static ECPair = ECPairFactory(ecc);
|
|
10
|
+
static fromWIF(wif, network = networks.bitcoin) {
|
|
11
|
+
return this.ECPair.fromWIF(wif, network);
|
|
12
|
+
}
|
|
13
|
+
static fromPrivateKey(privateKey, network = networks.bitcoin) {
|
|
14
|
+
return this.ECPair.fromPrivateKey(privateKey, { network });
|
|
15
|
+
}
|
|
16
|
+
static fromPublicKey(publicKey, network = networks.bitcoin) {
|
|
17
|
+
return this.ECPair.fromPublicKey(publicKey, { network });
|
|
18
|
+
}
|
|
19
|
+
static generateMultiSigAddress(pubKeys, minimumSignatureRequired, network = networks.bitcoin) {
|
|
20
|
+
const publicKeys = this.verifyPubKeys(pubKeys, network);
|
|
21
|
+
const { address } = payments.p2wsh({
|
|
22
|
+
redeem: payments.p2ms({
|
|
23
|
+
m: minimumSignatureRequired,
|
|
24
|
+
pubkeys: publicKeys,
|
|
25
|
+
network: network,
|
|
26
|
+
}),
|
|
27
|
+
network: network,
|
|
28
|
+
});
|
|
29
|
+
if (!address) {
|
|
30
|
+
throw new Error('Failed to generate address');
|
|
31
|
+
}
|
|
32
|
+
return address;
|
|
33
|
+
}
|
|
34
|
+
static verifyPubKeys(pubKeys, network = networks.bitcoin) {
|
|
35
|
+
return pubKeys.map((pubKey) => {
|
|
36
|
+
const key = EcKeyPair.fromPublicKey(pubKey, network);
|
|
37
|
+
if (!key) {
|
|
38
|
+
throw new Error('Failed to regenerate key');
|
|
39
|
+
}
|
|
40
|
+
return key.publicKey;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
static getP2WPKHAddress(keyPair, network = networks.bitcoin) {
|
|
44
|
+
const res = payments.p2wpkh({ pubkey: keyPair.publicKey, network: network });
|
|
45
|
+
if (!res.address) {
|
|
46
|
+
throw new Error('Failed to generate wallet');
|
|
47
|
+
}
|
|
48
|
+
return res.address;
|
|
49
|
+
}
|
|
50
|
+
static generateWallet(network = networks.bitcoin) {
|
|
51
|
+
const keyPair = this.ECPair.makeRandom({
|
|
52
|
+
network: network,
|
|
53
|
+
});
|
|
54
|
+
const wallet = this.getP2WPKHAddress(keyPair, network);
|
|
55
|
+
if (!wallet) {
|
|
56
|
+
throw new Error('Failed to generate wallet');
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
address: wallet,
|
|
60
|
+
privateKey: keyPair.toWIF(),
|
|
61
|
+
publicKey: keyPair.publicKey.toString('hex'),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
static verifyContractAddress(contractAddress, network = networks.bitcoin) {
|
|
65
|
+
return !!address.toOutputScript(contractAddress, network);
|
|
66
|
+
}
|
|
67
|
+
static getLegacyAddress(keyPair, network = networks.bitcoin) {
|
|
68
|
+
const wallet = payments.p2pkh({ pubkey: keyPair.publicKey, network: network });
|
|
69
|
+
if (!wallet.address) {
|
|
70
|
+
throw new Error('Failed to generate wallet');
|
|
71
|
+
}
|
|
72
|
+
return wallet.address;
|
|
73
|
+
}
|
|
74
|
+
static generateRandomKeyPair(network = networks.bitcoin) {
|
|
75
|
+
return this.ECPair.makeRandom({
|
|
76
|
+
network: network,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
static fromSeed(seed, network = networks.bitcoin) {
|
|
80
|
+
return this.BIP32.fromSeed(seed, network);
|
|
81
|
+
}
|
|
82
|
+
static getTaprootAddress(keyPair, network = networks.bitcoin) {
|
|
83
|
+
const myXOnlyPubkey = keyPair.publicKey.slice(1, 33);
|
|
84
|
+
const output = Buffer.concat([
|
|
85
|
+
Buffer.from([0x51, 0x20]),
|
|
86
|
+
myXOnlyPubkey,
|
|
87
|
+
]);
|
|
88
|
+
return address.fromOutputScript(output, network);
|
|
89
|
+
}
|
|
90
|
+
static getTaprootAddressFromAddress(inAddr, network = networks.bitcoin) {
|
|
91
|
+
const { address } = payments.p2tr({
|
|
92
|
+
address: inAddr,
|
|
93
|
+
network: network,
|
|
94
|
+
});
|
|
95
|
+
if (!address) {
|
|
96
|
+
throw new Error(`Failed to generate sender address for transaction`);
|
|
97
|
+
}
|
|
98
|
+
return address;
|
|
99
|
+
}
|
|
100
|
+
static fromSeedKeyPair(seed, network = networks.bitcoin) {
|
|
101
|
+
const fromSeed = this.BIP32.fromSeed(seed, network);
|
|
102
|
+
const privKey = fromSeed.privateKey;
|
|
103
|
+
if (!privKey)
|
|
104
|
+
throw new Error('Failed to generate key pair');
|
|
105
|
+
return this.ECPair.fromPrivateKey(privKey, { network });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -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,30 @@
|
|
|
1
|
+
import { EcKeyPair } from './EcKeyPair.js';
|
|
2
|
+
import { networks } from 'bitcoinjs-lib';
|
|
3
|
+
export class Wallet {
|
|
4
|
+
network;
|
|
5
|
+
_keypair;
|
|
6
|
+
_p2wpkh;
|
|
7
|
+
_p2tr;
|
|
8
|
+
constructor(wallet, network = networks.bitcoin) {
|
|
9
|
+
this.network = network;
|
|
10
|
+
this._keypair = EcKeyPair.fromWIF(wallet.privateKey, this.network);
|
|
11
|
+
this._p2wpkh = EcKeyPair.getP2WPKHAddress(this._keypair, this.network);
|
|
12
|
+
this._p2tr = EcKeyPair.getTaprootAddress(this._keypair, this.network);
|
|
13
|
+
}
|
|
14
|
+
get keypair() {
|
|
15
|
+
if (!this._keypair)
|
|
16
|
+
throw new Error('Keypair not set');
|
|
17
|
+
return this._keypair;
|
|
18
|
+
}
|
|
19
|
+
get p2wpkh() {
|
|
20
|
+
return this._p2wpkh;
|
|
21
|
+
}
|
|
22
|
+
get p2tr() {
|
|
23
|
+
return this._p2tr;
|
|
24
|
+
}
|
|
25
|
+
get publicKey() {
|
|
26
|
+
if (!this.keypair)
|
|
27
|
+
throw new Error('Keypair not set');
|
|
28
|
+
return this.keypair.publicKey;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,13 @@
|
|
|
1
|
+
import { networks } from 'bitcoinjs-lib';
|
|
2
|
+
export class ContractBaseMetadata {
|
|
3
|
+
network;
|
|
4
|
+
constructor(network = networks.bitcoin) {
|
|
5
|
+
this.network = network;
|
|
6
|
+
}
|
|
7
|
+
static getAddress(network = networks.bitcoin) {
|
|
8
|
+
throw new Error('Method not implemented.');
|
|
9
|
+
}
|
|
10
|
+
getAddress() {
|
|
11
|
+
return this.address;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ContractMetadataManager: {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
2
|
+
import { Network } from 'bitcoinjs-lib';
|
|
3
|
+
export declare abstract class ContractBase {
|
|
4
|
+
protected network: Network;
|
|
5
|
+
protected abstract readonly address: Address;
|
|
6
|
+
protected constructor(network?: Network);
|
|
7
|
+
static getAddress(network?: Network): string;
|
|
8
|
+
getAddress(): Address;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { networks } from 'bitcoinjs-lib';
|
|
2
|
+
export class ContractBase {
|
|
3
|
+
network;
|
|
4
|
+
constructor(network = networks.bitcoin) {
|
|
5
|
+
this.network = network;
|
|
6
|
+
}
|
|
7
|
+
static getAddress(network = networks.bitcoin) {
|
|
8
|
+
throw new Error('Method not implemented.');
|
|
9
|
+
}
|
|
10
|
+
getAddress() {
|
|
11
|
+
return this.address;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -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,13 @@
|
|
|
1
|
+
import { networks } from 'bitcoinjs-lib';
|
|
2
|
+
export class ContractBaseMetadata {
|
|
3
|
+
network;
|
|
4
|
+
constructor(network = networks.bitcoin) {
|
|
5
|
+
this.network = network;
|
|
6
|
+
}
|
|
7
|
+
static getAddress(network = networks.bitcoin) {
|
|
8
|
+
throw new Error('Method not implemented.');
|
|
9
|
+
}
|
|
10
|
+
getAddress() {
|
|
11
|
+
return this.address;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -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,26 @@
|
|
|
1
|
+
import { networks } from 'bitcoinjs-lib';
|
|
2
|
+
import { ContractBaseMetadata } from '../ContractBaseMetadata.js';
|
|
3
|
+
export class wBTC extends ContractBaseMetadata {
|
|
4
|
+
network;
|
|
5
|
+
tokenName = 'Wrapped Bitcoin';
|
|
6
|
+
tokenSymbol = 'wBTC';
|
|
7
|
+
decimals = 8;
|
|
8
|
+
address;
|
|
9
|
+
constructor(network = networks.bitcoin) {
|
|
10
|
+
super(network);
|
|
11
|
+
this.network = network;
|
|
12
|
+
this.address = wBTC.getAddress(network);
|
|
13
|
+
}
|
|
14
|
+
static getAddress(network = networks.bitcoin) {
|
|
15
|
+
switch (network) {
|
|
16
|
+
case networks.bitcoin:
|
|
17
|
+
return 'bcrt1pcw0828yjrtlrc6mkp3lkq30j7wc7slsh7k7dyh53mrs4f8d74l6qumhqp4';
|
|
18
|
+
case networks.regtest:
|
|
19
|
+
return 'bcrt1pcw0828yjrtlrc6mkp3lkq30j7wc7slsh7k7dyh53mrs4f8d74l6qumhqp4';
|
|
20
|
+
case networks.testnet:
|
|
21
|
+
return 'tb1pq64lx73fwyrdp4asvl7xt5r5qvxvt9wy82x75taqtzvd64f58nasansurj';
|
|
22
|
+
default:
|
|
23
|
+
throw new Error(`Invalid network: ${network}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class NetworkConverter {
|
|
2
|
+
static toBitcoinJSNetwork(network) {
|
|
3
|
+
switch (network) {
|
|
4
|
+
case OPNetNetwork.Mainnet:
|
|
5
|
+
return networks.bitcoin;
|
|
6
|
+
case OPNetNetwork.Testnet:
|
|
7
|
+
return networks.testnet;
|
|
8
|
+
case OPNetNetwork.Regtest:
|
|
9
|
+
return networks.regtest;
|
|
10
|
+
default:
|
|
11
|
+
throw new Error(`Invalid network: ${network}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/opnet.d.ts
ADDED
|
@@ -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';
|
package/build/opnet.js
ADDED
|
@@ -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,15 @@
|
|
|
1
|
+
import { BitcoinNetwork } from '@btc-vision/bsi-common';
|
|
2
|
+
export const Regtest = {
|
|
3
|
+
wallet: {
|
|
4
|
+
address: 'bcrt1qfqsr3m7vjxheghcvw4ks0fryqxfq8qzjf8fxes',
|
|
5
|
+
publicKey: '020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c',
|
|
6
|
+
privateKey: 'cRCiYAgCBrU7hSaJBRuPqKVYXQqM5CKXbMfWHb25X4FDAWJ8Ai92',
|
|
7
|
+
},
|
|
8
|
+
config: {
|
|
9
|
+
BITCOIND_NETWORK: BitcoinNetwork.Regtest,
|
|
10
|
+
BITCOIND_HOST: '51.81.67.34',
|
|
11
|
+
BITCOIND_PORT: 9242,
|
|
12
|
+
BITCOIND_USERNAME: 'HJSiowseujhs',
|
|
13
|
+
BITCOIND_PASSWORD: 'YHEFHSDJ23JOIhjjef2ied9u290efu2930u90U',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { wBTC } from '../metadata/contracts/wBTC.js';
|
|
2
|
+
import { Wallet } from '../keypair/Wallet.js';
|
|
3
|
+
import { Regtest } from './Regtest.js';
|
|
4
|
+
import { UTXOManager } from '../utxo/UTXOManager.js';
|
|
5
|
+
import { networks } from 'bitcoinjs-lib';
|
|
6
|
+
import { TransactionFactory } from '../transaction/TransactionFactory.js';
|
|
7
|
+
import { BitcoinRPC } from '@btc-vision/bsi-bitcoin-rpc';
|
|
8
|
+
import { ABICoder, BinaryWriter } from '@btc-vision/bsi-binary';
|
|
9
|
+
const network = networks.regtest;
|
|
10
|
+
const rpc = new BitcoinRPC();
|
|
11
|
+
const wBtc = new wBTC(network);
|
|
12
|
+
const wallet = new Wallet(Regtest.wallet, network);
|
|
13
|
+
const utxoManager = new UTXOManager('http://localhost:9001');
|
|
14
|
+
const factory = new TransactionFactory();
|
|
15
|
+
const abiCoder = new ABICoder();
|
|
16
|
+
const transferSelector = Number(`0x` + abiCoder.encodeSelector('transfer'));
|
|
17
|
+
function getTransferToCalldata(to, amount) {
|
|
18
|
+
const addCalldata = new BinaryWriter();
|
|
19
|
+
addCalldata.writeSelector(transferSelector);
|
|
20
|
+
addCalldata.writeAddress(to);
|
|
21
|
+
addCalldata.writeU256(amount);
|
|
22
|
+
return Buffer.from(addCalldata.getBuffer());
|
|
23
|
+
}
|
|
24
|
+
const shouldMineBlock = true;
|
|
25
|
+
async function mineBlock() {
|
|
26
|
+
const ok = await rpc.generateToAddress(1, wallet.p2wpkh, 'default');
|
|
27
|
+
if (!ok) {
|
|
28
|
+
throw new Error('Could not mine block');
|
|
29
|
+
}
|
|
30
|
+
console.log(`Mined block`, ok);
|
|
31
|
+
return !!ok.length;
|
|
32
|
+
}
|
|
33
|
+
(async () => {
|
|
34
|
+
await rpc.init(Regtest.config);
|
|
35
|
+
const utxoSetting = {
|
|
36
|
+
address: wallet.p2wpkh,
|
|
37
|
+
minAmount: 10000n,
|
|
38
|
+
requestedAmount: 100000n,
|
|
39
|
+
};
|
|
40
|
+
const utxos = await utxoManager.fetchUTXO(utxoSetting);
|
|
41
|
+
console.log(`UTXOs:`, utxos);
|
|
42
|
+
if (!utxos) {
|
|
43
|
+
throw new Error('No UTXOs found');
|
|
44
|
+
}
|
|
45
|
+
const calldata = getTransferToCalldata(wBtc.getAddress(), 5000000n);
|
|
46
|
+
const interactionParameters = {
|
|
47
|
+
from: wallet.p2wpkh,
|
|
48
|
+
to: wBtc.getAddress(),
|
|
49
|
+
utxos: utxos,
|
|
50
|
+
signer: wallet.keypair,
|
|
51
|
+
network: network,
|
|
52
|
+
feeRate: 150,
|
|
53
|
+
priorityFee: 50000n,
|
|
54
|
+
calldata: calldata,
|
|
55
|
+
};
|
|
56
|
+
const finalTx = factory.signInteraction(interactionParameters);
|
|
57
|
+
const firstTxBroadcast = await rpc.sendRawTransaction({
|
|
58
|
+
hexstring: finalTx[0],
|
|
59
|
+
});
|
|
60
|
+
console.log(`First transaction broadcasted: ${firstTxBroadcast}`);
|
|
61
|
+
if (!firstTxBroadcast) {
|
|
62
|
+
throw new Error('Could not broadcast first transaction');
|
|
63
|
+
}
|
|
64
|
+
const secondTxBroadcast = await rpc.sendRawTransaction({
|
|
65
|
+
hexstring: finalTx[1],
|
|
66
|
+
});
|
|
67
|
+
console.log(`Second transaction broadcasted: ${secondTxBroadcast}`);
|
|
68
|
+
if (!secondTxBroadcast) {
|
|
69
|
+
throw new Error('Could not broadcast second transaction');
|
|
70
|
+
}
|
|
71
|
+
if (shouldMineBlock) {
|
|
72
|
+
await mineBlock();
|
|
73
|
+
}
|
|
74
|
+
})();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { networks } from 'bitcoinjs-lib';
|
|
2
|
+
export const Regtest = {
|
|
3
|
+
wallet: {
|
|
4
|
+
address: 'bcrt1qfqsr3m7vjxheghcvw4ks0fryqxfq8qzjf8fxes',
|
|
5
|
+
publicKey: '020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c',
|
|
6
|
+
privateKey: 'cRCiYAgCBrU7hSaJBRuPqKVYXQqM5CKXbMfWHb25X4FDAWJ8Ai92',
|
|
7
|
+
},
|
|
8
|
+
config: {
|
|
9
|
+
BITCOIND_NETWORK: networks.regtest,
|
|
10
|
+
BITCOIND_HOST: '51.81.67.34',
|
|
11
|
+
BITCOIND_PORT: 9242,
|
|
12
|
+
BITCOIND_USERNAME: 'HJSiowseujhs',
|
|
13
|
+
BITCOIND_PASSWORD: 'YHEFHSDJ23JOIhjjef2ied9u290efu2930u90U',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -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,22 @@
|
|
|
1
|
+
import { initEccLib } from 'bitcoinjs-lib';
|
|
2
|
+
import { tapTweakHash } from 'bitcoinjs-lib/src/payments/bip341.js';
|
|
3
|
+
import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
|
|
4
|
+
import * as ecc from 'tiny-secp256k1';
|
|
5
|
+
import { EcKeyPair } from '../keypair/EcKeyPair.js';
|
|
6
|
+
initEccLib(ecc);
|
|
7
|
+
export class TweakedSigner {
|
|
8
|
+
static tweakSigner(signer, opts = {}) {
|
|
9
|
+
let privateKey = signer.privateKey;
|
|
10
|
+
if (!privateKey) {
|
|
11
|
+
throw new Error('Private key is required for tweaking signer!');
|
|
12
|
+
}
|
|
13
|
+
if (signer.publicKey[0] === 3) {
|
|
14
|
+
privateKey = ecc.privateNegate(privateKey);
|
|
15
|
+
}
|
|
16
|
+
const tweakedPrivateKey = ecc.privateAdd(privateKey, tapTweakHash(toXOnly(signer.publicKey), opts.tweakHash));
|
|
17
|
+
if (!tweakedPrivateKey) {
|
|
18
|
+
throw new Error('Invalid tweaked private key!');
|
|
19
|
+
}
|
|
20
|
+
return EcKeyPair.fromPrivateKey(Buffer.from(tweakedPrivateKey), opts.network);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Logger } from '@btc-vision/bsi-common';
|
|
3
|
+
import { Network, Payment, Psbt, Signer, Transaction } from 'bitcoinjs-lib';
|
|
4
|
+
import { PsbtInputExtended, PsbtOutputExtended, UpdateInput } from './interfaces/Tap.js';
|
|
5
|
+
import { TransactionType } from './enums/TransactionType.js';
|
|
6
|
+
import { ITransactionParameters } from './interfaces/ITransactionParameters.js';
|
|
7
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
8
|
+
import { UTXO } from '../utxo/interfaces/IUTXO.js';
|
|
9
|
+
export declare abstract class TransactionBuilder<T extends TransactionType> extends Logger {
|
|
10
|
+
protected static readonly LOCK_LEAF_SCRIPT: Buffer;
|
|
11
|
+
protected static readonly MINIMUM_DUST: bigint;
|
|
12
|
+
abstract readonly type: T;
|
|
13
|
+
readonly logColor: string;
|
|
14
|
+
transactionFee: bigint;
|
|
15
|
+
protected readonly transaction: Psbt;
|
|
16
|
+
protected readonly inputs: PsbtInputExtended[];
|
|
17
|
+
protected readonly updateInputs: UpdateInput[];
|
|
18
|
+
protected readonly outputs: PsbtOutputExtended[];
|
|
19
|
+
protected feeOutput: PsbtOutputExtended | null;
|
|
20
|
+
protected signed: boolean;
|
|
21
|
+
protected tapData: Payment | null;
|
|
22
|
+
protected scriptData: Payment | null;
|
|
23
|
+
protected totalInputAmount: bigint;
|
|
24
|
+
protected readonly signer: Signer;
|
|
25
|
+
protected readonly network: Network;
|
|
26
|
+
protected readonly feeRate: number;
|
|
27
|
+
protected readonly priorityFee: bigint;
|
|
28
|
+
protected readonly utxos: UTXO[];
|
|
29
|
+
protected to: Address | null;
|
|
30
|
+
private _maximumFeeRate;
|
|
31
|
+
protected constructor(parameters: ITransactionParameters);
|
|
32
|
+
setDestinationAddress(address: Address): void;
|
|
33
|
+
setMaximumFeeRate(feeRate: number): void;
|
|
34
|
+
signTransaction(): string | null;
|
|
35
|
+
getTransaction(): Transaction;
|
|
36
|
+
getScriptAddress(): string;
|
|
37
|
+
getTapAddress(): string;
|
|
38
|
+
addInput(input: PsbtInputExtended): void;
|
|
39
|
+
addOutput(output: PsbtOutputExtended): void;
|
|
40
|
+
protected calculateTotalUTXOAmount(): bigint;
|
|
41
|
+
protected calculateTotalVOutAmount(): bigint;
|
|
42
|
+
protected addInputsFromUTXO(): void;
|
|
43
|
+
protected witnessStackToScriptWitness(witness: Buffer[]): Buffer;
|
|
44
|
+
protected internalInit(): void;
|
|
45
|
+
protected abstract buildTransaction(to?: Address): void;
|
|
46
|
+
protected generateScriptAddress(): Payment;
|
|
47
|
+
protected generateTapData(): Payment;
|
|
48
|
+
protected updateInput(input: UpdateInput): void;
|
|
49
|
+
protected getWitness(): Buffer;
|
|
50
|
+
protected getTapOutput(): Buffer;
|
|
51
|
+
protected getInputs(): PsbtInputExtended[];
|
|
52
|
+
protected getOutputs(): PsbtOutputExtended[];
|
|
53
|
+
protected verifyUTXOValidity(): void;
|
|
54
|
+
protected setFeeOutput(output: PsbtOutputExtended): void;
|
|
55
|
+
protected abstract getSignerKey(): Signer;
|
|
56
|
+
protected internalPubKeyToXOnly(): Buffer;
|
|
57
|
+
protected signInputs(transaction: Psbt): void;
|
|
58
|
+
private internalBuildTransaction;
|
|
59
|
+
private estimateTransactionFees;
|
|
60
|
+
}
|