@btc-vision/transaction 1.0.119 → 1.0.121
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/browser/_version.d.ts +1 -1
- package/browser/buffer/BinaryWriter.d.ts +1 -1
- package/browser/generators/AddressGenerator.d.ts +1 -1
- package/browser/generators/Generator.d.ts +1 -1
- package/browser/generators/builders/CalldataGenerator.d.ts +1 -1
- package/browser/generators/builders/CustomGenerator.d.ts +1 -1
- package/browser/generators/builders/DeploymentGenerator.d.ts +1 -1
- package/browser/generators/builders/LegacyCalldataGenerator.d.ts +1 -1
- package/browser/index.js +1 -1
- package/browser/keypair/Address.d.ts +3 -6
- package/browser/keypair/AddressVerificator.d.ts +1 -1
- package/browser/keypair/EcKeyPair.d.ts +2 -2
- package/browser/keypair/Wallet.d.ts +1 -1
- package/browser/metadata/ContractBaseMetadata.d.ts +1 -1
- package/browser/metadata/contracts/wBTC.d.ts +1 -1
- package/browser/signer/TweakedSigner.d.ts +1 -1
- package/browser/transaction/TransactionFactory.d.ts +1 -1
- package/browser/transaction/browser/BrowserSignerBase.d.ts +1 -1
- package/browser/transaction/browser/extensions/UnisatSigner.d.ts +1 -1
- package/browser/transaction/builders/CustomScriptTransaction.d.ts +1 -1
- package/browser/transaction/builders/DeploymentTransaction.d.ts +1 -1
- package/browser/transaction/builders/FundingTransaction.d.ts +1 -1
- package/browser/transaction/builders/InteractionTransaction.d.ts +1 -1
- package/browser/transaction/builders/MultiSignTransaction.d.ts +2 -2
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +2 -2
- package/browser/transaction/builders/TransactionBuilder.d.ts +1 -1
- package/browser/transaction/builders/UnwrapSegwitTransaction.d.ts +2 -2
- package/browser/transaction/builders/UnwrapTransaction.d.ts +2 -2
- package/browser/transaction/builders/WrapTransaction.d.ts +1 -1
- package/browser/transaction/interfaces/ITransactionParameters.d.ts +1 -1
- package/browser/transaction/interfaces/Tap.d.ts +1 -1
- package/browser/transaction/processor/PsbtTransaction.d.ts +1 -1
- package/browser/transaction/shared/P2TR_MS.d.ts +1 -1
- package/browser/transaction/shared/TweakedTransaction.d.ts +1 -1
- package/browser/utxo/OPNetLimitedProvider.d.ts +1 -1
- package/browser/verification/TapscriptVerificator.d.ts +2 -2
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/buffer/BinaryWriter.d.ts +1 -1
- package/build/buffer/BinaryWriter.js +4 -5
- package/build/generators/AddressGenerator.d.ts +1 -1
- package/build/generators/AddressGenerator.js +2 -2
- package/build/generators/Features.js +1 -1
- package/build/generators/Generator.d.ts +1 -1
- package/build/generators/Generator.js +2 -2
- package/build/generators/builders/CalldataGenerator.d.ts +1 -1
- package/build/generators/builders/CalldataGenerator.js +1 -1
- package/build/generators/builders/CustomGenerator.d.ts +1 -1
- package/build/generators/builders/CustomGenerator.js +1 -1
- package/build/generators/builders/DeploymentGenerator.d.ts +1 -1
- package/build/generators/builders/DeploymentGenerator.js +1 -1
- package/build/generators/builders/LegacyCalldataGenerator.d.ts +1 -1
- package/build/generators/builders/LegacyCalldataGenerator.js +1 -1
- package/build/generators/builders/MultiSignGenerator.js +2 -2
- package/build/keypair/Address.d.ts +3 -6
- package/build/keypair/Address.js +29 -25
- package/build/keypair/AddressVerificator.d.ts +1 -1
- package/build/keypair/AddressVerificator.js +1 -1
- package/build/keypair/EcKeyPair.d.ts +2 -2
- package/build/keypair/EcKeyPair.js +17 -10
- package/build/keypair/Wallet.d.ts +1 -1
- package/build/keypair/Wallet.js +3 -3
- package/build/metadata/ContractBaseMetadata.d.ts +1 -1
- package/build/metadata/ContractBaseMetadata.js +1 -1
- package/build/metadata/contracts/wBTC.d.ts +1 -1
- package/build/metadata/contracts/wBTC.js +1 -1
- package/build/signer/TweakedSigner.d.ts +1 -1
- package/build/signer/TweakedSigner.js +3 -3
- package/build/transaction/TransactionFactory.d.ts +1 -1
- package/build/transaction/browser/BrowserSignerBase.d.ts +1 -1
- package/build/transaction/browser/extensions/UnisatSigner.d.ts +1 -1
- package/build/transaction/browser/extensions/UnisatSigner.js +1 -1
- package/build/transaction/builders/CustomScriptTransaction.d.ts +1 -1
- package/build/transaction/builders/CustomScriptTransaction.js +2 -2
- package/build/transaction/builders/DeploymentTransaction.d.ts +1 -1
- package/build/transaction/builders/DeploymentTransaction.js +2 -2
- package/build/transaction/builders/FundingTransaction.d.ts +1 -1
- package/build/transaction/builders/InteractionTransaction.d.ts +1 -1
- package/build/transaction/builders/MultiSignTransaction.d.ts +2 -2
- package/build/transaction/builders/MultiSignTransaction.js +2 -2
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +2 -2
- package/build/transaction/builders/SharedInteractionTransaction.js +2 -2
- package/build/transaction/builders/TransactionBuilder.d.ts +1 -1
- package/build/transaction/builders/TransactionBuilder.js +2 -2
- package/build/transaction/builders/UnwrapSegwitTransaction.d.ts +2 -2
- package/build/transaction/builders/UnwrapSegwitTransaction.js +1 -1
- package/build/transaction/builders/UnwrapTransaction.d.ts +2 -2
- package/build/transaction/builders/UnwrapTransaction.js +2 -2
- package/build/transaction/builders/WrapTransaction.d.ts +1 -1
- package/build/transaction/interfaces/ITransactionParameters.d.ts +1 -1
- package/build/transaction/interfaces/Tap.d.ts +1 -1
- package/build/transaction/processor/PsbtTransaction.d.ts +1 -1
- package/build/transaction/processor/PsbtTransaction.js +1 -1
- package/build/transaction/shared/P2TR_MS.d.ts +1 -1
- package/build/transaction/shared/P2TR_MS.js +1 -1
- package/build/transaction/shared/TweakedTransaction.d.ts +1 -1
- package/build/transaction/shared/TweakedTransaction.js +3 -3
- package/build/utils/BitcoinUtils.js +1 -5
- package/build/utxo/OPNetLimitedProvider.d.ts +1 -1
- package/build/verification/TapscriptVerificator.d.ts +2 -2
- package/build/verification/TapscriptVerificator.js +2 -2
- package/gulpfile.js +1 -1
- package/package.json +21 -21
- package/src/_version.ts +1 -1
- package/src/buffer/BinaryWriter.ts +5 -6
- package/src/generators/AddressGenerator.ts +2 -2
- package/src/generators/Features.ts +1 -1
- package/src/generators/Generator.ts +2 -2
- package/src/generators/builders/CalldataGenerator.ts +2 -2
- package/src/generators/builders/CustomGenerator.ts +1 -1
- package/src/generators/builders/DeploymentGenerator.ts +1 -1
- package/src/generators/builders/LegacyCalldataGenerator.ts +1 -1
- package/src/generators/builders/MultiSignGenerator.ts +2 -2
- package/src/keypair/Address.ts +43 -40
- package/src/keypair/AddressVerificator.ts +1 -1
- package/src/keypair/EcKeyPair.ts +22 -14
- package/src/keypair/Wallet.ts +3 -6
- package/src/metadata/ContractBaseMetadata.ts +1 -1
- package/src/metadata/contracts/wBTC.ts +1 -1
- package/src/signer/TweakedSigner.ts +3 -3
- package/src/transaction/TransactionFactory.ts +2 -2
- package/src/transaction/browser/BrowserSignerBase.ts +1 -1
- package/src/transaction/browser/extensions/UnisatSigner.ts +1 -1
- package/src/transaction/builders/CustomScriptTransaction.ts +3 -3
- package/src/transaction/builders/DeploymentTransaction.ts +3 -3
- package/src/transaction/builders/FundingTransaction.ts +1 -1
- package/src/transaction/builders/InteractionTransaction.ts +1 -1
- package/src/transaction/builders/MultiSignTransaction.ts +3 -3
- package/src/transaction/builders/SharedInteractionTransaction.ts +3 -3
- package/src/transaction/builders/TransactionBuilder.ts +2 -2
- package/src/transaction/builders/UnwrapSegwitTransaction.ts +2 -2
- package/src/transaction/builders/UnwrapTransaction.ts +3 -3
- package/src/transaction/builders/WrapTransaction.ts +2 -2
- package/src/transaction/interfaces/ITransactionParameters.ts +1 -1
- package/src/transaction/interfaces/Tap.ts +1 -1
- package/src/transaction/processor/PsbtTransaction.ts +1 -1
- package/src/transaction/shared/P2TR_MS.ts +1 -1
- package/src/transaction/shared/TweakedTransaction.ts +3 -3
- package/src/utils/BitcoinUtils.ts +3 -7
- package/src/utxo/OPNetLimitedProvider.ts +1 -1
- package/src/verification/TapscriptVerificator.ts +3 -3
- package/webpack.config.js +1 -1
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
2
2
|
import bip32, { BIP32Factory } from 'bip32';
|
|
3
|
-
import { address, initEccLib, networks, payments } from '
|
|
4
|
-
import { toXOnly } from '
|
|
3
|
+
import { address, initEccLib, networks, payments } from '@btc-vision/bitcoin';
|
|
4
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
5
5
|
import { ECPairFactory } from 'ecpair';
|
|
6
|
-
import { CURVE, Point
|
|
7
|
-
import { taggedHash } from '
|
|
6
|
+
import { CURVE, ProjectivePoint as Point } from '@noble/secp256k1';
|
|
7
|
+
import { taggedHash } from '@btc-vision/bitcoin/src/crypto.js';
|
|
8
8
|
initEccLib(ecc);
|
|
9
9
|
const BIP32factory = typeof bip32 === 'function' ? bip32 : BIP32Factory;
|
|
10
10
|
if (!BIP32factory) {
|
|
11
11
|
throw new Error('Failed to load BIP32 library');
|
|
12
12
|
}
|
|
13
|
+
const mod = (a, b) => {
|
|
14
|
+
const result = a % b;
|
|
15
|
+
return result >= 0n ? result : result + b;
|
|
16
|
+
};
|
|
13
17
|
export class EcKeyPair {
|
|
14
18
|
static fromWIF(wif, network = networks.bitcoin) {
|
|
15
19
|
return this.ECPair.fromWIF(wif, network);
|
|
@@ -89,18 +93,21 @@ export class EcKeyPair {
|
|
|
89
93
|
return address;
|
|
90
94
|
}
|
|
91
95
|
static tweakPublicKey(compressedPubKeyHex) {
|
|
92
|
-
if (compressedPubKeyHex.startsWith('0x')) {
|
|
96
|
+
if (typeof compressedPubKeyHex === 'string' && compressedPubKeyHex.startsWith('0x')) {
|
|
93
97
|
compressedPubKeyHex = compressedPubKeyHex.slice(2);
|
|
94
98
|
}
|
|
99
|
+
if (typeof compressedPubKeyHex !== 'string') {
|
|
100
|
+
compressedPubKeyHex = compressedPubKeyHex.toString('hex');
|
|
101
|
+
}
|
|
95
102
|
let P = Point.fromHex(compressedPubKeyHex);
|
|
96
|
-
if (
|
|
103
|
+
if ((P.y & 1n) !== 0n) {
|
|
97
104
|
P = P.negate();
|
|
98
105
|
}
|
|
99
106
|
const x = P.toRawBytes(true).slice(1);
|
|
100
107
|
const tHash = taggedHash('TapTweak', Buffer.from(x));
|
|
101
|
-
const t =
|
|
102
|
-
const Q = P.add(Point.BASE.
|
|
103
|
-
return Q.
|
|
108
|
+
const t = mod(BigInt('0x' + Buffer.from(tHash).toString('hex')), CURVE.n);
|
|
109
|
+
const Q = P.add(Point.BASE.mul(t));
|
|
110
|
+
return Buffer.from(Q.toRawBytes(true));
|
|
104
111
|
}
|
|
105
112
|
static generateWallet(network = networks.bitcoin) {
|
|
106
113
|
const keyPair = this.ECPair.makeRandom({
|
|
@@ -176,7 +183,7 @@ export class EcKeyPair {
|
|
|
176
183
|
const privKey = fromSeed.privateKey;
|
|
177
184
|
if (!privKey)
|
|
178
185
|
throw new Error('Failed to generate key pair');
|
|
179
|
-
return this.ECPair.fromPrivateKey(privKey, { network });
|
|
186
|
+
return this.ECPair.fromPrivateKey(Buffer.from(privKey), { network });
|
|
180
187
|
}
|
|
181
188
|
}
|
|
182
189
|
EcKeyPair.BIP32 = BIP32factory(ecc);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IWallet } from './interfaces/IWallet.js';
|
|
2
2
|
import { ECPairInterface } from 'ecpair';
|
|
3
|
-
import { Network } from '
|
|
3
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
4
4
|
import { Address } from './Address.js';
|
|
5
5
|
export declare class Wallet {
|
|
6
6
|
readonly network: Network;
|
package/build/keypair/Wallet.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EcKeyPair } from './EcKeyPair.js';
|
|
2
|
-
import { networks } from '
|
|
3
|
-
import { toXOnly } from '
|
|
2
|
+
import { networks } from '@btc-vision/bitcoin';
|
|
3
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
4
4
|
import { Address } from './Address.js';
|
|
5
5
|
export class Wallet {
|
|
6
6
|
constructor(wallet, network = networks.bitcoin) {
|
|
@@ -10,7 +10,7 @@ export class Wallet {
|
|
|
10
10
|
this._p2tr = EcKeyPair.getTaprootAddress(this._keypair, this.network);
|
|
11
11
|
this._legacy = EcKeyPair.getLegacyAddress(this._keypair, this.network);
|
|
12
12
|
this._segwitLegacy = EcKeyPair.getLegacySegwitAddress(this._keypair, this.network);
|
|
13
|
-
this._tweakedKey =
|
|
13
|
+
this._tweakedKey = EcKeyPair.tweakPublicKey(this._keypair.publicKey.toString('hex'));
|
|
14
14
|
this._bufferPubKey = this._keypair.publicKey;
|
|
15
15
|
this._address = new Address(this._keypair.publicKey);
|
|
16
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { networks } from '
|
|
1
|
+
import { networks } from '@btc-vision/bitcoin';
|
|
2
2
|
import { ChainId } from '../../network/ChainId.js';
|
|
3
3
|
import { ContractBaseMetadata } from '../ContractBaseMetadata.js';
|
|
4
4
|
import { WBTC_ADDRESS_FRACTAL, WBTC_ADDRESS_REGTEST, WBTC_ADDRESS_TESTNET } from '../tokens.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
2
|
-
import { initEccLib } from '
|
|
3
|
-
import { tapTweakHash } from '
|
|
4
|
-
import { toXOnly } from '
|
|
2
|
+
import { initEccLib } from '@btc-vision/bitcoin';
|
|
3
|
+
import { tapTweakHash } from '@btc-vision/bitcoin/src/payments/bip341.js';
|
|
4
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
5
5
|
import { EcKeyPair } from '../keypair/EcKeyPair.js';
|
|
6
6
|
initEccLib(ecc);
|
|
7
7
|
export class TweakedSigner {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction } from '
|
|
1
|
+
import { Transaction } from '@btc-vision/bitcoin';
|
|
2
2
|
import { UTXO } from '../utxo/interfaces/IUTXO.js';
|
|
3
3
|
import { ICustomTransactionParameters } from './builders/CustomScriptTransaction.js';
|
|
4
4
|
import { FundingTransaction } from './builders/FundingTransaction.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { networks, Psbt } from '
|
|
1
|
+
import { networks, Psbt } from '@btc-vision/bitcoin';
|
|
2
2
|
import { EcKeyPair } from '../../../keypair/EcKeyPair.js';
|
|
3
3
|
import { CustomKeypair } from '../BrowserSignerBase.js';
|
|
4
4
|
import { UnisatNetwork } from '../types/Unisat.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
2
2
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
3
3
|
import { SharedInteractionParameters } from '../interfaces/ITransactionParameters.js';
|
|
4
|
-
import { Payment, Psbt, Stack } from '
|
|
4
|
+
import { Payment, Psbt, Stack } from '@btc-vision/bitcoin';
|
|
5
5
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
6
6
|
export interface ICustomTransactionParameters extends SharedInteractionParameters {
|
|
7
7
|
readonly script: (Buffer | Stack)[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
2
|
-
import { crypto as bitCrypto } from '
|
|
2
|
+
import { crypto as bitCrypto } from '@btc-vision/bitcoin';
|
|
3
3
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
4
4
|
import { CustomGenerator } from '../../generators/builders/CustomGenerator.js';
|
|
5
5
|
import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
|
|
6
6
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
7
7
|
import { AddressGenerator } from '../../generators/AddressGenerator.js';
|
|
8
|
-
import { toXOnly } from '
|
|
8
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
9
9
|
export class CustomScriptTransaction extends TransactionBuilder {
|
|
10
10
|
constructor(parameters) {
|
|
11
11
|
super(parameters);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
2
2
|
import { IDeploymentParameters } from '../interfaces/ITransactionParameters.js';
|
|
3
|
-
import { Payment, Psbt } from '
|
|
3
|
+
import { Payment, Psbt } from '@btc-vision/bitcoin';
|
|
4
4
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
5
5
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
6
6
|
import { Address } from '../../keypair/Address.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
2
|
-
import { crypto as bitCrypto } from '
|
|
2
|
+
import { crypto as bitCrypto } from '@btc-vision/bitcoin';
|
|
3
3
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
4
4
|
import { DeploymentGenerator } from '../../generators/builders/DeploymentGenerator.js';
|
|
5
|
-
import { toXOnly } from '
|
|
5
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
6
6
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
7
7
|
import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
|
|
8
8
|
import { Compressor } from '../../bytecode/Compressor.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
2
2
|
import { IFundingTransactionParameters } from '../interfaces/ITransactionParameters.js';
|
|
3
|
-
import { Signer } from '
|
|
3
|
+
import { Signer } from '@btc-vision/bitcoin';
|
|
4
4
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
5
5
|
import { ECPairInterface } from 'ecpair';
|
|
6
6
|
export declare class FundingTransaction extends TransactionBuilder<TransactionType.FUNDING> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Taptree } from '
|
|
1
|
+
import { Taptree } from '@btc-vision/bitcoin/src/types.js';
|
|
2
2
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
3
3
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
4
4
|
import { IInteractionParameters } from '../interfaces/ITransactionParameters.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Payment, Psbt, PsbtInput, Signer, TapScriptSig } from '
|
|
2
|
-
import { Taptree } from '
|
|
1
|
+
import { Payment, Psbt, PsbtInput, Signer, TapScriptSig } from '@btc-vision/bitcoin';
|
|
2
|
+
import { Taptree } from '@btc-vision/bitcoin/src/types.js';
|
|
3
3
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
4
4
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
5
5
|
import { ITransactionParameters } from '../interfaces/ITransactionParameters.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { crypto as bitcoinCrypto, opcodes, Psbt, script, } from '
|
|
1
|
+
import { crypto as bitcoinCrypto, opcodes, Psbt, script, } from '@btc-vision/bitcoin';
|
|
2
2
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
3
3
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
4
4
|
import { MultiSignGenerator } from '../../generators/builders/MultiSignGenerator.js';
|
|
5
|
-
import { toXOnly } from '
|
|
5
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
6
6
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
7
7
|
export class MultiSignTransaction extends TransactionBuilder {
|
|
8
8
|
constructor(parameters) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Payment, Psbt, PsbtInput, Signer } from '
|
|
2
|
-
import { Taptree } from '
|
|
1
|
+
import { Payment, Psbt, PsbtInput, Signer } from '@btc-vision/bitcoin';
|
|
2
|
+
import { Taptree } from '@btc-vision/bitcoin/src/types.js';
|
|
3
3
|
import { ECPairInterface } from 'ecpair';
|
|
4
4
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
5
5
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { address } from '
|
|
1
|
+
import { address } from '@btc-vision/bitcoin';
|
|
2
2
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
3
3
|
import { CalldataGenerator } from '../../generators/builders/CalldataGenerator.js';
|
|
4
4
|
import { Compressor } from '../../bytecode/Compressor.js';
|
|
5
5
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
6
6
|
import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
|
|
7
|
-
import { toXOnly } from '
|
|
7
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
8
8
|
export class SharedInteractionTransaction extends TransactionBuilder {
|
|
9
9
|
constructor(parameters) {
|
|
10
10
|
super(parameters);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Network, Psbt, PsbtInputExtended, PsbtOutputExtended, Signer, Transaction } from '
|
|
1
|
+
import { Network, Psbt, PsbtInputExtended, PsbtOutputExtended, Signer, Transaction } from '@btc-vision/bitcoin';
|
|
2
2
|
import { UpdateInput } from '../interfaces/Tap.js';
|
|
3
3
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
4
4
|
import { IFundingTransactionParameters, ITransactionParameters } from '../interfaces/ITransactionParameters.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { initEccLib, opcodes, Psbt, script, Transaction, } from '
|
|
2
|
-
import { varuint } from '
|
|
1
|
+
import { initEccLib, opcodes, Psbt, script, Transaction, } from '@btc-vision/bitcoin';
|
|
2
|
+
import { varuint } from '@btc-vision/bitcoin/src/bufferutils.js';
|
|
3
3
|
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
4
4
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
5
5
|
import { AddressVerificator } from '../../keypair/AddressVerificator.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Taptree } from '
|
|
1
|
+
import { Taptree } from '@btc-vision/bitcoin/src/types.js';
|
|
2
2
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
3
3
|
import { IUnwrapParameters } from '../interfaces/ITransactionParameters.js';
|
|
4
4
|
import { SharedInteractionTransaction } from './SharedInteractionTransaction.js';
|
|
5
|
-
import { Psbt } from '
|
|
5
|
+
import { Psbt } from '@btc-vision/bitcoin';
|
|
6
6
|
import { VaultUTXOs } from '../processor/PsbtTransaction.js';
|
|
7
7
|
export declare class UnwrapSegwitTransaction extends SharedInteractionTransaction<TransactionType.WBTC_UNWRAP> {
|
|
8
8
|
private static readonly UNWRAP_SELECTOR;
|
|
@@ -2,7 +2,7 @@ import { TransactionType } from '../enums/TransactionType.js';
|
|
|
2
2
|
import { SharedInteractionTransaction } from './SharedInteractionTransaction.js';
|
|
3
3
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
4
4
|
import { wBTC } from '../../metadata/contracts/wBTC.js';
|
|
5
|
-
import { payments } from '
|
|
5
|
+
import { payments } from '@btc-vision/bitcoin';
|
|
6
6
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
7
7
|
import { PsbtTransaction } from '../processor/PsbtTransaction.js';
|
|
8
8
|
import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Taptree } from '
|
|
1
|
+
import { Taptree } from '@btc-vision/bitcoin/src/types.js';
|
|
2
2
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
3
3
|
import { IUnwrapParameters } from '../interfaces/ITransactionParameters.js';
|
|
4
4
|
import { SharedInteractionTransaction } from './SharedInteractionTransaction.js';
|
|
5
|
-
import { Network, Payment, Psbt, PsbtInput } from '
|
|
5
|
+
import { Network, Payment, Psbt, PsbtInput } from '@btc-vision/bitcoin';
|
|
6
6
|
import { VaultUTXOs } from '../processor/PsbtTransaction.js';
|
|
7
7
|
export declare class UnwrapTransaction extends SharedInteractionTransaction<TransactionType.WBTC_UNWRAP> {
|
|
8
8
|
private static readonly UNWRAP_SELECTOR;
|
|
@@ -2,12 +2,12 @@ import { TransactionType } from '../enums/TransactionType.js';
|
|
|
2
2
|
import { SharedInteractionTransaction } from './SharedInteractionTransaction.js';
|
|
3
3
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
4
4
|
import { wBTC } from '../../metadata/contracts/wBTC.js';
|
|
5
|
-
import { payments, } from '
|
|
5
|
+
import { payments, } from '@btc-vision/bitcoin';
|
|
6
6
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
7
7
|
import { PsbtTransaction } from '../processor/PsbtTransaction.js';
|
|
8
8
|
import { MultiSignGenerator } from '../../generators/builders/MultiSignGenerator.js';
|
|
9
9
|
import { MultiSignTransaction } from './MultiSignTransaction.js';
|
|
10
|
-
import { toXOnly } from '
|
|
10
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
11
11
|
import { CalldataGenerator } from '../../generators/builders/CalldataGenerator.js';
|
|
12
12
|
import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
|
|
13
13
|
import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Taptree } from '
|
|
1
|
+
import { Taptree } from '@btc-vision/bitcoin/src/types.js';
|
|
2
2
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
3
3
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
4
4
|
import { IWrapParameters } from '../interfaces/ITransactionParameters.js';
|
|
@@ -4,7 +4,7 @@ import { ITweakedTransactionData } from '../shared/TweakedTransaction.js';
|
|
|
4
4
|
import { VaultUTXOs } from '../processor/PsbtTransaction.js';
|
|
5
5
|
import { ChainId } from '../../network/ChainId.js';
|
|
6
6
|
import { Address } from '../../keypair/Address.js';
|
|
7
|
-
import { PsbtOutputExtended } from '
|
|
7
|
+
import { PsbtOutputExtended } from '@btc-vision/bitcoin';
|
|
8
8
|
export interface ITransactionParameters extends ITweakedTransactionData {
|
|
9
9
|
readonly from?: string;
|
|
10
10
|
readonly to?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PsbtInput as _PsbtInput, PsbtInputUpdate as _PsbtInputUpdate, PsbtOutput as _PsbtOutput, TapBip32Derivation as _TapBip32Derivation, TapInternalKey as _TapInternalKey, TapKeySig as _TapKeySig, TapLeaf as _TapLeaf, TapLeafScript as _TapLeafScript, TapMerkleRoot as _TapMerkleRoot, TapScriptSig as _TapScriptSig, TapTree as _TapTree } from '
|
|
1
|
+
import { PsbtInput as _PsbtInput, PsbtInputUpdate as _PsbtInputUpdate, PsbtOutput as _PsbtOutput, TapBip32Derivation as _TapBip32Derivation, TapInternalKey as _TapInternalKey, TapKeySig as _TapKeySig, TapLeaf as _TapLeaf, TapLeafScript as _TapLeafScript, TapMerkleRoot as _TapMerkleRoot, TapScriptSig as _TapScriptSig, TapTree as _TapTree } from '@btc-vision/bitcoin';
|
|
2
2
|
export interface TapLeafScript {
|
|
3
3
|
readonly leafVersion: number;
|
|
4
4
|
readonly controlBlock: Buffer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Network, Psbt, PsbtInputExtended, PsbtOutputExtended, Signer, Transaction } from '
|
|
1
|
+
import { Network, Psbt, PsbtInputExtended, PsbtOutputExtended, Signer, Transaction } from '@btc-vision/bitcoin';
|
|
2
2
|
import { ITweakedTransactionData, TweakedTransaction } from '../shared/TweakedTransaction.js';
|
|
3
3
|
export interface PsbtTransactionData extends ITweakedTransactionData {
|
|
4
4
|
readonly psbt: Psbt;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@btc-vision/logger';
|
|
2
|
-
import { Network, Payment, Psbt, PsbtInput, PsbtInputExtended, Signer, Transaction } from '
|
|
2
|
+
import { Network, Payment, Psbt, PsbtInput, PsbtInputExtended, Signer, Transaction } from '@btc-vision/bitcoin';
|
|
3
3
|
import { ECPairInterface } from 'ecpair';
|
|
4
4
|
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
5
5
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Logger } from '@btc-vision/logger';
|
|
2
|
-
import { address as bitAddress, crypto as bitCrypto, getFinalScripts, opcodes, payments, script, } from '
|
|
2
|
+
import { address as bitAddress, crypto as bitCrypto, getFinalScripts, opcodes, payments, script, } from '@btc-vision/bitcoin';
|
|
3
3
|
import { TweakedSigner } from '../../signer/TweakedSigner.js';
|
|
4
|
-
import { toXOnly } from '
|
|
4
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
5
5
|
import { AddressTypes, AddressVerificator } from '../../keypair/AddressVerificator.js';
|
|
6
|
-
import { varuint } from '
|
|
6
|
+
import { varuint } from '@btc-vision/bitcoin/src/bufferutils.js';
|
|
7
7
|
export var TransactionSequence;
|
|
8
8
|
(function (TransactionSequence) {
|
|
9
9
|
TransactionSequence[TransactionSequence["REPLACE_BY_FEE"] = 4294967293] = "REPLACE_BY_FEE";
|
|
@@ -19,11 +19,7 @@ export class BitcoinUtils {
|
|
|
19
19
|
return Buffer.from(array);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
|
|
23
|
-
for (let i = 0; i < length; i++) {
|
|
24
|
-
randomValues.push(Math.floor(Math.random() * 256));
|
|
25
|
-
}
|
|
26
|
-
return Buffer.from(randomValues);
|
|
22
|
+
throw new Error('No secure random number generator available. Please upgrade your environment.');
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
static opnetHash(data) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Network } from '
|
|
1
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
2
2
|
import { Address, Wallet } from '../opnet.js';
|
|
3
3
|
import { UnwrapGeneration } from '../wbtc/UnwrapGeneration.js';
|
|
4
4
|
import { WrappedGeneration } from '../wbtc/WrappedGenerationParameters.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Network } from '
|
|
2
|
-
import { Taptree } from '
|
|
1
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
2
|
+
import { Taptree } from '@btc-vision/bitcoin/src/types.js';
|
|
3
3
|
export interface ContractAddressVerificationParams {
|
|
4
4
|
readonly deployerPubKey: Buffer;
|
|
5
5
|
readonly contractSaltPubKey: Buffer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { crypto as bitCrypto, networks, payments } from '
|
|
2
|
-
import { toXOnly } from '
|
|
1
|
+
import { crypto as bitCrypto, networks, payments } from '@btc-vision/bitcoin';
|
|
2
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
3
3
|
import { DeploymentGenerator } from '../generators/builders/DeploymentGenerator.js';
|
|
4
4
|
import { TransactionBuilder } from '../transaction/builders/TransactionBuilder.js';
|
|
5
5
|
import { Address } from '../keypair/Address.js';
|
package/gulpfile.js
CHANGED
|
@@ -3,7 +3,7 @@ import gulp from 'gulp';
|
|
|
3
3
|
import gulpcache from 'gulp-cached';
|
|
4
4
|
|
|
5
5
|
import gulpClean from 'gulp-clean';
|
|
6
|
-
import logger from 'gulp-logger';
|
|
6
|
+
import logger from 'gulp-logger-new';
|
|
7
7
|
import ts from 'gulp-typescript';
|
|
8
8
|
|
|
9
9
|
process.on('uncaughtException', function (err) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btc-vision/transaction",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.121",
|
|
5
5
|
"author": "BlobMaster41",
|
|
6
6
|
"description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
|
|
7
7
|
"engines": {
|
|
@@ -64,56 +64,56 @@
|
|
|
64
64
|
"docs": "typedoc --out docs --exclude 'src/tests/*.ts' --tsconfig tsconfig.json --readme README.md --name OPNet --plugin typedoc-material-theme --themeColor '#cb9820' --exclude src/tests/test.ts --exclude src/index.ts src"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@babel/core": "^7.
|
|
67
|
+
"@babel/core": "^7.26.0",
|
|
68
68
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
69
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
70
|
-
"@babel/preset-env": "^7.
|
|
71
|
-
"@babel/preset-flow": "^7.
|
|
72
|
-
"@babel/preset-react": "^7.
|
|
73
|
-
"@babel/preset-typescript": "^7.
|
|
74
|
-
"@types/node": "^22.
|
|
69
|
+
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
70
|
+
"@babel/preset-env": "^7.26.0",
|
|
71
|
+
"@babel/preset-flow": "^7.25.9",
|
|
72
|
+
"@babel/preset-react": "^7.25.9",
|
|
73
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
74
|
+
"@types/node": "^22.8.7",
|
|
75
75
|
"@types/sha.js": "^2.4.4",
|
|
76
|
-
"eslint": "^9.
|
|
76
|
+
"eslint": "^9.14.0",
|
|
77
77
|
"gulp": "^5.0.0",
|
|
78
78
|
"gulp-cached": "^1.1.1",
|
|
79
|
-
"gulp-logger": "^0.0.2",
|
|
80
79
|
"gulp-typescript": "^6.0.0-alpha.1",
|
|
81
80
|
"https-browserify": "^1.0.0",
|
|
82
81
|
"os-browserify": "^0.3.0",
|
|
83
|
-
"prettier": "^3.3.
|
|
82
|
+
"prettier": "^3.3.3",
|
|
84
83
|
"stream-browserify": "^3.0.0",
|
|
85
84
|
"stream-http": "^3.2.0",
|
|
86
|
-
"typedoc": "^0.26.
|
|
85
|
+
"typedoc": "^0.26.11",
|
|
87
86
|
"typedoc-material-theme": "^1.1.0",
|
|
88
|
-
"typescript-eslint": "^8.
|
|
89
|
-
"webpack": "^5.
|
|
87
|
+
"typescript-eslint": "^8.13.0",
|
|
88
|
+
"webpack": "^5.96.1",
|
|
90
89
|
"webpack-cli": "^5.1.4"
|
|
91
90
|
},
|
|
92
91
|
"dependencies": {
|
|
93
92
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
94
93
|
"@bitcoinerlab/secp256k1": "^1.1.1",
|
|
94
|
+
"@btc-vision/bitcoin": "^6.3.0",
|
|
95
95
|
"@btc-vision/bsi-bitcoin-rpc": "^1.0.29",
|
|
96
96
|
"@btc-vision/logger": "^1.0.6",
|
|
97
|
-
"@eslint/js": "^9.
|
|
98
|
-
"@noble/secp256k1": "^1.
|
|
97
|
+
"@eslint/js": "^9.14.0",
|
|
98
|
+
"@noble/secp256k1": "^2.1.0",
|
|
99
99
|
"assert": "^2.1.0",
|
|
100
|
-
"babel-loader": "^9.1
|
|
100
|
+
"babel-loader": "^9.2.1",
|
|
101
101
|
"babel-plugin-transform-import-meta": "^2.2.1",
|
|
102
102
|
"babel-preset-react": "^6.24.1",
|
|
103
103
|
"babelify": "^10.0.0",
|
|
104
104
|
"bech32": "^2.0.0",
|
|
105
105
|
"bignumber.js": "^9.1.2",
|
|
106
|
-
"bip32": "^
|
|
107
|
-
"bitcoinjs-lib": "github:btc-vision/bitcoinjs-lib",
|
|
106
|
+
"bip32": "^5.0.0-rc.0",
|
|
108
107
|
"browserify-zlib": "^0.2.0",
|
|
109
108
|
"buffer": "^6.0.3",
|
|
110
109
|
"ecpair": "^2.1.0",
|
|
111
110
|
"gulp-clean": "^0.4.0",
|
|
112
|
-
"gulp-eslint-new": "^2.
|
|
111
|
+
"gulp-eslint-new": "^2.4.0",
|
|
112
|
+
"gulp-logger-new": "^1.0.1",
|
|
113
113
|
"process": "^0.11.10",
|
|
114
114
|
"sha.js": "^2.4.11",
|
|
115
115
|
"ts-loader": "^9.5.1",
|
|
116
116
|
"ts-node": "^10.9.2",
|
|
117
|
-
"typescript": "^5.6.
|
|
117
|
+
"typescript": "^5.6.3"
|
|
118
118
|
}
|
|
119
119
|
}
|
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.121';
|
|
@@ -90,8 +90,9 @@ export class BinaryWriter {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
public writeAddress(value: Address): void {
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
this.verifyAddress(value);
|
|
94
|
+
|
|
95
|
+
this.writeBytes(value);
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
public writeStringWithLength(value: string): void {
|
|
@@ -305,14 +306,12 @@ export class BinaryWriter {
|
|
|
305
306
|
});
|
|
306
307
|
}
|
|
307
308
|
|
|
308
|
-
private
|
|
309
|
-
if (pubKey.
|
|
309
|
+
private verifyAddress(pubKey: Address): void {
|
|
310
|
+
if (pubKey.byteLength > ADDRESS_BYTE_LENGTH) {
|
|
310
311
|
throw new Error(
|
|
311
312
|
`Address is too long ${pubKey.byteLength} > ${ADDRESS_BYTE_LENGTH} bytes`,
|
|
312
313
|
);
|
|
313
314
|
}
|
|
314
|
-
|
|
315
|
-
return pubKey.tweakedBytes;
|
|
316
315
|
}
|
|
317
316
|
|
|
318
317
|
private resize(size: u32): void {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bech32, bech32m } from 'bech32';
|
|
2
|
-
import { initEccLib, Network } from '
|
|
2
|
+
import { initEccLib, Network } from '@btc-vision/bitcoin';
|
|
3
3
|
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
4
|
-
import { ripemd160 } from '
|
|
4
|
+
import { ripemd160 } from '@btc-vision/bitcoin/src/crypto.js';
|
|
5
5
|
|
|
6
6
|
initEccLib(ecc);
|
|
7
7
|
|