@btc-vision/transaction 1.0.118 → 1.0.120
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/event/NetEvent.d.ts +3 -3
- 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 +8 -0
- package/browser/index.js +1 -1
- package/browser/keypair/Address.d.ts +2 -1
- package/browser/keypair/AddressVerificator.d.ts +3 -4
- package/browser/keypair/EcKeyPair.d.ts +1 -1
- 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/opnet.d.ts +1 -0
- 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 +10 -1
- package/browser/utxo/OPNetLimitedProvider.d.ts +1 -1
- package/browser/utxo/interfaces/IUTXO.d.ts +3 -0
- package/browser/verification/TapscriptVerificator.d.ts +2 -2
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/event/NetEvent.d.ts +3 -3
- package/build/event/NetEvent.js +3 -3
- 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 +8 -0
- package/build/generators/builders/LegacyCalldataGenerator.js +75 -0
- package/build/generators/builders/MultiSignGenerator.js +2 -2
- package/build/keypair/Address.d.ts +2 -1
- package/build/keypair/Address.js +4 -1
- package/build/keypair/AddressVerificator.d.ts +3 -4
- package/build/keypair/AddressVerificator.js +14 -4
- package/build/keypair/EcKeyPair.d.ts +1 -1
- package/build/keypair/EcKeyPair.js +3 -3
- package/build/keypair/Wallet.d.ts +1 -1
- package/build/keypair/Wallet.js +2 -2
- 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/opnet.d.ts +1 -0
- package/build/opnet.js +1 -0
- 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 +3 -3
- 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 +10 -1
- package/build/transaction/shared/TweakedTransaction.js +95 -5
- package/build/utxo/OPNetLimitedProvider.d.ts +1 -1
- package/build/utxo/interfaces/IUTXO.d.ts +3 -0
- package/build/verification/TapscriptVerificator.d.ts +2 -2
- package/build/verification/TapscriptVerificator.js +2 -2
- package/package.json +2 -2
- package/src/_version.ts +1 -1
- package/src/event/NetEvent.ts +2 -2
- 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 +141 -0
- package/src/generators/builders/MultiSignGenerator.ts +2 -2
- package/src/keypair/Address.ts +10 -2
- package/src/keypair/AddressVerificator.ts +23 -4
- package/src/keypair/EcKeyPair.ts +3 -3
- package/src/keypair/Wallet.ts +2 -2
- package/src/metadata/ContractBaseMetadata.ts +1 -1
- package/src/metadata/contracts/wBTC.ts +1 -1
- package/src/opnet.ts +1 -0
- 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 +3 -3
- 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 +160 -5
- package/src/utxo/OPNetLimitedProvider.ts +1 -1
- package/src/utxo/interfaces/IUTXO.ts +3 -0
- package/src/verification/TapscriptVerificator.ts +3 -3
- package/webpack.config.js +1 -1
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) {
|
|
@@ -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';
|
package/build/opnet.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { version } from './_version.js';
|
|
|
2
2
|
export * from './bytecode/Compressor.js';
|
|
3
3
|
export * from './generators/Generator.js';
|
|
4
4
|
export * from './generators/builders/CalldataGenerator.js';
|
|
5
|
+
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
5
6
|
export * from './generators/builders/DeploymentGenerator.js';
|
|
6
7
|
export * from './generators/builders/CustomGenerator.js';
|
|
7
8
|
export * from './generators/builders/MultiSignGenerator.js';
|
package/build/opnet.js
CHANGED
|
@@ -2,6 +2,7 @@ export { version } from './_version.js';
|
|
|
2
2
|
export * from './bytecode/Compressor.js';
|
|
3
3
|
export * from './generators/Generator.js';
|
|
4
4
|
export * from './generators/builders/CalldataGenerator.js';
|
|
5
|
+
export * from './generators/builders/LegacyCalldataGenerator.js';
|
|
5
6
|
export * from './generators/builders/DeploymentGenerator.js';
|
|
6
7
|
export * from './generators/builders/CustomGenerator.js';
|
|
7
8
|
export * from './generators/builders/MultiSignGenerator.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';
|
|
@@ -343,4 +343,4 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
343
343
|
TransactionBuilder.LOCK_LEAF_SCRIPT = script.compile([
|
|
344
344
|
opcodes.OP_0,
|
|
345
345
|
]);
|
|
346
|
-
TransactionBuilder.MINIMUM_DUST =
|
|
346
|
+
TransactionBuilder.MINIMUM_DUST = 50n;
|
|
@@ -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';
|
|
@@ -54,5 +54,14 @@ export declare abstract class TweakedTransaction extends Logger {
|
|
|
54
54
|
protected internalInit(): void;
|
|
55
55
|
protected tweakSigner(): void;
|
|
56
56
|
protected getTweakedSigner(useTweakedHash?: boolean, signer?: Signer | ECPairInterface): ECPairInterface | undefined;
|
|
57
|
+
protected generateP2SHRedeemScript(customWitnessScript: Buffer): Buffer | undefined;
|
|
58
|
+
protected generateP2SHRedeemScriptLegacy(inputAddr: string): {
|
|
59
|
+
redeemScript: Buffer;
|
|
60
|
+
outputScript: Buffer;
|
|
61
|
+
} | undefined;
|
|
57
62
|
protected generatePsbtInputExtended(utxo: UTXO, i: number): PsbtInputExtended;
|
|
63
|
+
protected customFinalizerP2SH: (inputIndex: number, input: PsbtInput, scriptA: Buffer, isSegwit: boolean, isP2SH: boolean, isP2WSH: boolean) => {
|
|
64
|
+
finalScriptSig: Buffer | undefined;
|
|
65
|
+
finalScriptWitness: Buffer | undefined;
|
|
66
|
+
};
|
|
58
67
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Logger } from '@btc-vision/logger';
|
|
2
|
-
import { payments, } 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 '
|
|
5
|
-
import { AddressVerificator } from '../../keypair/AddressVerificator.js';
|
|
6
|
-
import { varuint } from '
|
|
4
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
5
|
+
import { AddressTypes, AddressVerificator } from '../../keypair/AddressVerificator.js';
|
|
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";
|
|
@@ -23,6 +23,21 @@ export class TweakedTransaction extends Logger {
|
|
|
23
23
|
this.isBrowser = false;
|
|
24
24
|
this.regenerated = false;
|
|
25
25
|
this.ignoreSignatureErrors = false;
|
|
26
|
+
this.customFinalizerP2SH = (inputIndex, input, scriptA, isSegwit, isP2SH, isP2WSH) => {
|
|
27
|
+
const inputDecoded = this.inputs[inputIndex];
|
|
28
|
+
if (isP2SH && input.partialSig && inputDecoded && inputDecoded.redeemScript) {
|
|
29
|
+
const signatures = input.partialSig.map((sig) => sig.signature);
|
|
30
|
+
const scriptSig = script.compile([
|
|
31
|
+
...signatures,
|
|
32
|
+
inputDecoded.redeemScript,
|
|
33
|
+
]);
|
|
34
|
+
return {
|
|
35
|
+
finalScriptSig: scriptSig,
|
|
36
|
+
finalScriptWitness: undefined,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return getFinalScripts(inputIndex, input, scriptA, isSegwit, isP2SH, isP2WSH);
|
|
40
|
+
};
|
|
26
41
|
this.signer = data.signer;
|
|
27
42
|
this.network = data.network;
|
|
28
43
|
this.nonWitnessUtxo = data.nonWitnessUtxo;
|
|
@@ -223,6 +238,7 @@ export class TweakedTransaction extends Logger {
|
|
|
223
238
|
}
|
|
224
239
|
await Promise.all(promises);
|
|
225
240
|
}
|
|
241
|
+
transaction.finalizeInput(0, this.customFinalizerP2SH);
|
|
226
242
|
try {
|
|
227
243
|
transaction.finalizeAllInputs();
|
|
228
244
|
this.finalized = true;
|
|
@@ -255,16 +271,90 @@ export class TweakedTransaction extends Logger {
|
|
|
255
271
|
}
|
|
256
272
|
return TweakedSigner.tweakSigner(signer, settings);
|
|
257
273
|
}
|
|
274
|
+
generateP2SHRedeemScript(customWitnessScript) {
|
|
275
|
+
const p2wsh = payments.p2wsh({
|
|
276
|
+
redeem: { output: customWitnessScript },
|
|
277
|
+
network: this.network,
|
|
278
|
+
});
|
|
279
|
+
const p2sh = payments.p2sh({
|
|
280
|
+
redeem: p2wsh,
|
|
281
|
+
network: this.network,
|
|
282
|
+
});
|
|
283
|
+
return p2sh.output;
|
|
284
|
+
}
|
|
285
|
+
generateP2SHRedeemScriptLegacy(inputAddr) {
|
|
286
|
+
const pubKeyHash = bitCrypto.hash160(this.signer.publicKey);
|
|
287
|
+
const redeemScript = script.compile([
|
|
288
|
+
opcodes.OP_DUP,
|
|
289
|
+
opcodes.OP_HASH160,
|
|
290
|
+
pubKeyHash,
|
|
291
|
+
opcodes.OP_EQUALVERIFY,
|
|
292
|
+
opcodes.OP_CHECKSIG,
|
|
293
|
+
]);
|
|
294
|
+
const redeemScriptHash = bitCrypto.hash160(redeemScript);
|
|
295
|
+
const outputScript = script.compile([
|
|
296
|
+
opcodes.OP_HASH160,
|
|
297
|
+
redeemScriptHash,
|
|
298
|
+
opcodes.OP_EQUAL,
|
|
299
|
+
]);
|
|
300
|
+
const p2wsh = payments.p2wsh({
|
|
301
|
+
redeem: { output: redeemScript },
|
|
302
|
+
network: this.network,
|
|
303
|
+
});
|
|
304
|
+
const p2sh = payments.p2sh({
|
|
305
|
+
redeem: p2wsh,
|
|
306
|
+
network: this.network,
|
|
307
|
+
});
|
|
308
|
+
const address = bitAddress.fromOutputScript(outputScript, this.network);
|
|
309
|
+
if (address === inputAddr && p2sh.redeem && p2sh.redeem.output) {
|
|
310
|
+
return {
|
|
311
|
+
redeemScript,
|
|
312
|
+
outputScript: p2sh.redeem.output,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
258
317
|
generatePsbtInputExtended(utxo, i) {
|
|
259
318
|
const input = {
|
|
260
319
|
hash: utxo.transactionId,
|
|
261
320
|
index: utxo.outputIndex,
|
|
321
|
+
sequence: this.sequence,
|
|
262
322
|
witnessUtxo: {
|
|
263
323
|
value: Number(utxo.value),
|
|
264
324
|
script: Buffer.from(utxo.scriptPubKey.hex, 'hex'),
|
|
265
325
|
},
|
|
266
|
-
sequence: this.sequence,
|
|
267
326
|
};
|
|
327
|
+
if (utxo.scriptPubKey.address) {
|
|
328
|
+
try {
|
|
329
|
+
const addressType = AddressVerificator.detectAddressType(utxo.scriptPubKey.address, this.network);
|
|
330
|
+
if (addressType === AddressTypes.P2SH_OR_P2SH_P2WPKH) {
|
|
331
|
+
const redeemScript = this.generateP2SHRedeemScriptLegacy(utxo.scriptPubKey.address);
|
|
332
|
+
if (!redeemScript) {
|
|
333
|
+
throw new Error('Failed to generate redeem script');
|
|
334
|
+
}
|
|
335
|
+
input.redeemScript = redeemScript.outputScript;
|
|
336
|
+
input.witnessScript = redeemScript.redeemScript;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
catch (e) {
|
|
340
|
+
this.error(`Failed to detect address type for ${utxo.scriptPubKey.address} - ${e}`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (utxo.nonWitnessUtxo) {
|
|
344
|
+
input.nonWitnessUtxo = Buffer.isBuffer(utxo.nonWitnessUtxo)
|
|
345
|
+
? utxo.nonWitnessUtxo
|
|
346
|
+
: Buffer.from(utxo.nonWitnessUtxo, 'hex');
|
|
347
|
+
}
|
|
348
|
+
if (utxo.redeemScript) {
|
|
349
|
+
input.redeemScript = Buffer.isBuffer(utxo.redeemScript)
|
|
350
|
+
? utxo.redeemScript
|
|
351
|
+
: Buffer.from(utxo.redeemScript, 'hex');
|
|
352
|
+
if (utxo.witnessScript) {
|
|
353
|
+
input.witnessScript = Buffer.isBuffer(utxo.witnessScript)
|
|
354
|
+
? utxo.witnessScript
|
|
355
|
+
: Buffer.from(utxo.witnessScript, 'hex');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
268
358
|
if (this.sighashTypes) {
|
|
269
359
|
const inputSign = TweakedTransaction.calculateSignHash(this.sighashTypes);
|
|
270
360
|
if (inputSign)
|
|
@@ -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';
|
|
@@ -4,6 +4,9 @@ export interface UTXO {
|
|
|
4
4
|
readonly outputIndex: number;
|
|
5
5
|
readonly value: bigint;
|
|
6
6
|
readonly scriptPubKey: ScriptPubKey;
|
|
7
|
+
redeemScript?: string | Buffer;
|
|
8
|
+
witnessScript?: string | Buffer;
|
|
9
|
+
nonWitnessUtxo?: string | Buffer;
|
|
7
10
|
}
|
|
8
11
|
export interface FetchUTXOParams {
|
|
9
12
|
readonly address: string;
|
|
@@ -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/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.120",
|
|
5
5
|
"author": "BlobMaster41",
|
|
6
6
|
"description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
|
|
7
7
|
"engines": {
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
94
94
|
"@bitcoinerlab/secp256k1": "^1.1.1",
|
|
95
|
+
"@btc-vision/bitcoin": "^6.3.0",
|
|
95
96
|
"@btc-vision/bsi-bitcoin-rpc": "^1.0.29",
|
|
96
97
|
"@btc-vision/logger": "^1.0.6",
|
|
97
98
|
"@eslint/js": "^9.10.0",
|
|
@@ -104,7 +105,6 @@
|
|
|
104
105
|
"bech32": "^2.0.0",
|
|
105
106
|
"bignumber.js": "^9.1.2",
|
|
106
107
|
"bip32": "^4.0.0",
|
|
107
|
-
"bitcoinjs-lib": "github:btc-vision/bitcoinjs-lib",
|
|
108
108
|
"browserify-zlib": "^0.2.0",
|
|
109
109
|
"buffer": "^6.0.3",
|
|
110
110
|
"ecpair": "^2.1.0",
|
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.120';
|
package/src/event/NetEvent.ts
CHANGED
|
@@ -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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Network, networks } from '
|
|
2
|
-
import { toXOnly } from '
|
|
1
|
+
import { Network, networks } from '@btc-vision/bitcoin';
|
|
2
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
3
3
|
|
|
4
4
|
/** Bitcoin Script Generator */
|
|
5
5
|
export abstract class Generator {
|