@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,12 +1,9 @@
|
|
|
1
|
-
import { Network } from '
|
|
2
|
-
import { ECPairInterface } from 'ecpair';
|
|
1
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
3
2
|
export declare class Address extends Uint8Array {
|
|
4
3
|
#private;
|
|
5
|
-
private isP2TROnly;
|
|
6
4
|
constructor(bytes?: ArrayLike<number>);
|
|
7
|
-
|
|
8
|
-
get keyPair()
|
|
9
|
-
get tweakedBytes(): Uint8Array;
|
|
5
|
+
get originalPublicKey(): Uint8Array | undefined;
|
|
6
|
+
private get keyPair();
|
|
10
7
|
static dead(): Address;
|
|
11
8
|
static fromString(pubKey: string): Address;
|
|
12
9
|
static wrap(bytes: ArrayLike<number>): Address;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BIP32API, BIP32Interface } from 'bip32';
|
|
2
|
-
import { Network, Signer } from '
|
|
2
|
+
import { Network, Signer } from '@btc-vision/bitcoin';
|
|
3
3
|
import { ECPairAPI, ECPairInterface } from 'ecpair';
|
|
4
4
|
import { IWallet } from './interfaces/IWallet.js';
|
|
5
5
|
export declare class EcKeyPair {
|
|
@@ -14,7 +14,7 @@ export declare class EcKeyPair {
|
|
|
14
14
|
static tweakedPubKeyToAddress(tweakedPubKeyHex: string, network: Network): string;
|
|
15
15
|
static tweakedPubKeyBufferToAddress(tweakedPubKeyBuffer: Buffer | Uint8Array, network: Network): string;
|
|
16
16
|
static xOnlyTweakedPubKeyToAddress(tweakedPubKeyHex: string, network: Network): string;
|
|
17
|
-
static tweakPublicKey(compressedPubKeyHex: string):
|
|
17
|
+
static tweakPublicKey(compressedPubKeyHex: string | Buffer): Buffer;
|
|
18
18
|
static generateWallet(network?: Network): IWallet;
|
|
19
19
|
static verifyContractAddress(contractAddress: string, network?: Network): boolean;
|
|
20
20
|
static getLegacySegwitAddress(keyPair: ECPairInterface, network?: Network): string;
|
|
@@ -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;
|
|
@@ -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,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,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,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,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,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,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;
|
|
@@ -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;
|
|
@@ -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,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;
|
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.0.121";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.0.
|
|
1
|
+
export const version = '1.0.121';
|
|
@@ -67,8 +67,8 @@ export class BinaryWriter {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
writeAddress(value) {
|
|
70
|
-
|
|
71
|
-
this.writeBytes(
|
|
70
|
+
this.verifyAddress(value);
|
|
71
|
+
this.writeBytes(value);
|
|
72
72
|
}
|
|
73
73
|
writeStringWithLength(value) {
|
|
74
74
|
this.allocSafe(value.length + 2);
|
|
@@ -239,11 +239,10 @@ export class BinaryWriter {
|
|
|
239
239
|
this.writeSelector(selector);
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
|
-
|
|
243
|
-
if (pubKey.
|
|
242
|
+
verifyAddress(pubKey) {
|
|
243
|
+
if (pubKey.byteLength > ADDRESS_BYTE_LENGTH) {
|
|
244
244
|
throw new Error(`Address is too long ${pubKey.byteLength} > ${ADDRESS_BYTE_LENGTH} bytes`);
|
|
245
245
|
}
|
|
246
|
-
return pubKey.tweakedBytes;
|
|
247
246
|
}
|
|
248
247
|
resize(size) {
|
|
249
248
|
const buf = new Uint8Array(this.buffer.byteLength + size);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bech32, bech32m } from 'bech32';
|
|
2
|
-
import { initEccLib } from '
|
|
2
|
+
import { initEccLib } 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
|
initEccLib(ecc);
|
|
6
6
|
export class AddressGenerator {
|
|
7
7
|
static generatePKSH(sha256Hash, network) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { networks } from '
|
|
2
|
-
import { toXOnly } from '
|
|
1
|
+
import { networks } from '@btc-vision/bitcoin';
|
|
2
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
3
3
|
export class Generator {
|
|
4
4
|
constructor(senderPubKey, contractSaltPubKey, network = networks.bitcoin) {
|
|
5
5
|
this.network = networks.bitcoin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { crypto, networks, opcodes, script } from '
|
|
1
|
+
import { crypto, networks, opcodes, script } from '@btc-vision/bitcoin';
|
|
2
2
|
import { Compressor } from '../../bytecode/Compressor.js';
|
|
3
3
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
4
4
|
import { FeatureOpCodes } from '../Features.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Network } from '
|
|
1
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
2
2
|
import { Generator } from '../Generator.js';
|
|
3
3
|
export declare class DeploymentGenerator extends Generator {
|
|
4
4
|
constructor(senderPubKey: Buffer, contractSaltPubKey: Buffer, network?: Network);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { crypto, networks, opcodes, script } from '
|
|
1
|
+
import { crypto, networks, opcodes, script } from '@btc-vision/bitcoin';
|
|
2
2
|
import { Generator } from '../Generator.js';
|
|
3
3
|
export class DeploymentGenerator extends Generator {
|
|
4
4
|
constructor(senderPubKey, contractSaltPubKey, network = networks.bitcoin) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { networks, opcodes, script } from '
|
|
1
|
+
import { networks, opcodes, script } from '@btc-vision/bitcoin';
|
|
2
2
|
import { Compressor } from '../../bytecode/Compressor.js';
|
|
3
3
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
4
4
|
import { FeatureOpCodes } from '../Features.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { opcodes, script } from '
|
|
2
|
-
import { toXOnly } from '
|
|
1
|
+
import { opcodes, script } from '@btc-vision/bitcoin';
|
|
2
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
3
3
|
export class MultiSignGenerator {
|
|
4
4
|
static compile(vaultPublicKeys, minimumSignatures = 0, internal) {
|
|
5
5
|
if (minimumSignatures < 2) {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { Network } from '
|
|
2
|
-
import { ECPairInterface } from 'ecpair';
|
|
1
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
3
2
|
export declare class Address extends Uint8Array {
|
|
4
3
|
#private;
|
|
5
|
-
private isP2TROnly;
|
|
6
4
|
constructor(bytes?: ArrayLike<number>);
|
|
7
|
-
|
|
8
|
-
get keyPair()
|
|
9
|
-
get tweakedBytes(): Uint8Array;
|
|
5
|
+
get originalPublicKey(): Uint8Array | undefined;
|
|
6
|
+
private get keyPair();
|
|
10
7
|
static dead(): Address;
|
|
11
8
|
static fromString(pubKey: string): Address;
|
|
12
9
|
static wrap(bytes: ArrayLike<number>): Address;
|
package/build/keypair/Address.js
CHANGED
|
@@ -9,31 +9,35 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _Address_p2tr, _Address_network,
|
|
12
|
+
var _Address_p2tr, _Address_network, _Address_originalPublicKey, _Address_keyPair;
|
|
13
13
|
import { EcKeyPair } from './EcKeyPair.js';
|
|
14
14
|
import { ADDRESS_BYTE_LENGTH } from '../utils/types.js';
|
|
15
15
|
import { AddressVerificator } from './AddressVerificator.js';
|
|
16
|
-
import { toXOnly } from '
|
|
16
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
17
|
+
const hexPattern = /^[0-9a-fA-F]+$/;
|
|
18
|
+
const isHexadecimal = (input) => {
|
|
19
|
+
return hexPattern.test(input);
|
|
20
|
+
};
|
|
17
21
|
export class Address extends Uint8Array {
|
|
18
22
|
constructor(bytes) {
|
|
19
23
|
super(bytes?.length || ADDRESS_BYTE_LENGTH);
|
|
20
|
-
this.isP2TROnly = false;
|
|
21
24
|
_Address_p2tr.set(this, void 0);
|
|
22
25
|
_Address_network.set(this, void 0);
|
|
23
|
-
|
|
26
|
+
_Address_originalPublicKey.set(this, void 0);
|
|
27
|
+
_Address_keyPair.set(this, void 0);
|
|
24
28
|
if (!bytes) {
|
|
25
29
|
return;
|
|
26
30
|
}
|
|
27
31
|
this.set(bytes);
|
|
28
32
|
}
|
|
33
|
+
get originalPublicKey() {
|
|
34
|
+
return __classPrivateFieldGet(this, _Address_originalPublicKey, "f");
|
|
35
|
+
}
|
|
29
36
|
get keyPair() {
|
|
30
|
-
if (!this
|
|
37
|
+
if (!__classPrivateFieldGet(this, _Address_keyPair, "f")) {
|
|
31
38
|
throw new Error('Public key not set for address');
|
|
32
39
|
}
|
|
33
|
-
return this
|
|
34
|
-
}
|
|
35
|
-
get tweakedBytes() {
|
|
36
|
-
return __classPrivateFieldGet(this, _Address_tweakedBytes, "f") || this;
|
|
40
|
+
return __classPrivateFieldGet(this, _Address_keyPair, "f");
|
|
37
41
|
}
|
|
38
42
|
static dead() {
|
|
39
43
|
return Address.fromString('0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f');
|
|
@@ -45,6 +49,9 @@ export class Address extends Uint8Array {
|
|
|
45
49
|
if (pubKey.startsWith('0x')) {
|
|
46
50
|
pubKey = pubKey.slice(2);
|
|
47
51
|
}
|
|
52
|
+
if (!isHexadecimal(pubKey)) {
|
|
53
|
+
throw new Error('You must only pass public keys in hexadecimal format. If you have an address such as bc1q... you must convert it to a public key first. Please refer to await provider.getPublicKeyInfo("bc1q..."). If the public key associated with the address is not found, you must force the user to enter the destination public key. It looks like: 0x020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c.');
|
|
54
|
+
}
|
|
48
55
|
return new Address(Buffer.from(pubKey, 'hex'));
|
|
49
56
|
}
|
|
50
57
|
static wrap(bytes) {
|
|
@@ -57,24 +64,22 @@ export class Address extends Uint8Array {
|
|
|
57
64
|
return Buffer.from(this);
|
|
58
65
|
}
|
|
59
66
|
equals(a) {
|
|
60
|
-
const b = this
|
|
61
|
-
|
|
62
|
-
if (c.length !== b.length) {
|
|
67
|
+
const b = this;
|
|
68
|
+
if (a.length !== b.length) {
|
|
63
69
|
return false;
|
|
64
70
|
}
|
|
65
71
|
for (let i = 0; i < b.length; i++) {
|
|
66
|
-
if (b[i] !==
|
|
72
|
+
if (b[i] !== a[i]) {
|
|
67
73
|
return false;
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
return true;
|
|
71
77
|
}
|
|
72
78
|
lessThan(a) {
|
|
73
|
-
const b = this
|
|
74
|
-
const c = a.isP2TROnly ? a : __classPrivateFieldGet(a, _Address_tweakedBytes, "f");
|
|
79
|
+
const b = this;
|
|
75
80
|
for (let i = 0; i < 32; i++) {
|
|
76
81
|
const thisByte = b[i];
|
|
77
|
-
const aByte =
|
|
82
|
+
const aByte = a[i];
|
|
78
83
|
if (thisByte < aByte) {
|
|
79
84
|
return true;
|
|
80
85
|
}
|
|
@@ -85,11 +90,10 @@ export class Address extends Uint8Array {
|
|
|
85
90
|
return false;
|
|
86
91
|
}
|
|
87
92
|
greaterThan(a) {
|
|
88
|
-
const b = this
|
|
89
|
-
const c = a.isP2TROnly ? a : __classPrivateFieldGet(a, _Address_tweakedBytes, "f");
|
|
93
|
+
const b = this;
|
|
90
94
|
for (let i = 0; i < 32; i++) {
|
|
91
95
|
const thisByte = b[i];
|
|
92
|
-
const aByte =
|
|
96
|
+
const aByte = a[i];
|
|
93
97
|
if (thisByte > aByte) {
|
|
94
98
|
return true;
|
|
95
99
|
}
|
|
@@ -104,15 +108,15 @@ export class Address extends Uint8Array {
|
|
|
104
108
|
throw new Error(`Invalid public key length ${publicKey.length}`);
|
|
105
109
|
}
|
|
106
110
|
if (publicKey.length === 32) {
|
|
107
|
-
this.isP2TROnly = true;
|
|
108
111
|
const buf = Buffer.alloc(32);
|
|
109
112
|
buf.set(publicKey);
|
|
110
113
|
super.set(publicKey);
|
|
111
114
|
}
|
|
112
115
|
else {
|
|
113
|
-
this
|
|
114
|
-
__classPrivateFieldSet(this,
|
|
115
|
-
|
|
116
|
+
__classPrivateFieldSet(this, _Address_originalPublicKey, Uint8Array.from(publicKey), "f");
|
|
117
|
+
__classPrivateFieldSet(this, _Address_keyPair, EcKeyPair.fromPublicKey(__classPrivateFieldGet(this, _Address_originalPublicKey, "f")), "f");
|
|
118
|
+
const tweakedBytes = toXOnly(EcKeyPair.tweakPublicKey(Buffer.from(__classPrivateFieldGet(this, _Address_originalPublicKey, "f"))));
|
|
119
|
+
super.set(tweakedBytes);
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
isValid(network) {
|
|
@@ -137,7 +141,7 @@ export class Address extends Uint8Array {
|
|
|
137
141
|
if (__classPrivateFieldGet(this, _Address_p2tr, "f") && __classPrivateFieldGet(this, _Address_network, "f") === network) {
|
|
138
142
|
return __classPrivateFieldGet(this, _Address_p2tr, "f");
|
|
139
143
|
}
|
|
140
|
-
const p2trAddy = EcKeyPair.tweakedPubKeyBufferToAddress(this
|
|
144
|
+
const p2trAddy = EcKeyPair.tweakedPubKeyBufferToAddress(this, network);
|
|
141
145
|
if (p2trAddy) {
|
|
142
146
|
__classPrivateFieldSet(this, _Address_network, network, "f");
|
|
143
147
|
__classPrivateFieldSet(this, _Address_p2tr, p2trAddy, "f");
|
|
@@ -146,4 +150,4 @@ export class Address extends Uint8Array {
|
|
|
146
150
|
throw new Error('Public key not set');
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
|
-
_Address_p2tr = new WeakMap(), _Address_network = new WeakMap(),
|
|
153
|
+
_Address_p2tr = new WeakMap(), _Address_network = new WeakMap(), _Address_originalPublicKey = new WeakMap(), _Address_keyPair = new WeakMap();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BIP32API, BIP32Interface } from 'bip32';
|
|
2
|
-
import { Network, Signer } from '
|
|
2
|
+
import { Network, Signer } from '@btc-vision/bitcoin';
|
|
3
3
|
import { ECPairAPI, ECPairInterface } from 'ecpair';
|
|
4
4
|
import { IWallet } from './interfaces/IWallet.js';
|
|
5
5
|
export declare class EcKeyPair {
|
|
@@ -14,7 +14,7 @@ export declare class EcKeyPair {
|
|
|
14
14
|
static tweakedPubKeyToAddress(tweakedPubKeyHex: string, network: Network): string;
|
|
15
15
|
static tweakedPubKeyBufferToAddress(tweakedPubKeyBuffer: Buffer | Uint8Array, network: Network): string;
|
|
16
16
|
static xOnlyTweakedPubKeyToAddress(tweakedPubKeyHex: string, network: Network): string;
|
|
17
|
-
static tweakPublicKey(compressedPubKeyHex: string):
|
|
17
|
+
static tweakPublicKey(compressedPubKeyHex: string | Buffer): Buffer;
|
|
18
18
|
static generateWallet(network?: Network): IWallet;
|
|
19
19
|
static verifyContractAddress(contractAddress: string, network?: Network): boolean;
|
|
20
20
|
static getLegacySegwitAddress(keyPair: ECPairInterface, network?: Network): string;
|