@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.
Files changed (142) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/buffer/BinaryWriter.d.ts +1 -1
  3. package/browser/generators/AddressGenerator.d.ts +1 -1
  4. package/browser/generators/Generator.d.ts +1 -1
  5. package/browser/generators/builders/CalldataGenerator.d.ts +1 -1
  6. package/browser/generators/builders/CustomGenerator.d.ts +1 -1
  7. package/browser/generators/builders/DeploymentGenerator.d.ts +1 -1
  8. package/browser/generators/builders/LegacyCalldataGenerator.d.ts +1 -1
  9. package/browser/index.js +1 -1
  10. package/browser/keypair/Address.d.ts +3 -6
  11. package/browser/keypair/AddressVerificator.d.ts +1 -1
  12. package/browser/keypair/EcKeyPair.d.ts +2 -2
  13. package/browser/keypair/Wallet.d.ts +1 -1
  14. package/browser/metadata/ContractBaseMetadata.d.ts +1 -1
  15. package/browser/metadata/contracts/wBTC.d.ts +1 -1
  16. package/browser/signer/TweakedSigner.d.ts +1 -1
  17. package/browser/transaction/TransactionFactory.d.ts +1 -1
  18. package/browser/transaction/browser/BrowserSignerBase.d.ts +1 -1
  19. package/browser/transaction/browser/extensions/UnisatSigner.d.ts +1 -1
  20. package/browser/transaction/builders/CustomScriptTransaction.d.ts +1 -1
  21. package/browser/transaction/builders/DeploymentTransaction.d.ts +1 -1
  22. package/browser/transaction/builders/FundingTransaction.d.ts +1 -1
  23. package/browser/transaction/builders/InteractionTransaction.d.ts +1 -1
  24. package/browser/transaction/builders/MultiSignTransaction.d.ts +2 -2
  25. package/browser/transaction/builders/SharedInteractionTransaction.d.ts +2 -2
  26. package/browser/transaction/builders/TransactionBuilder.d.ts +1 -1
  27. package/browser/transaction/builders/UnwrapSegwitTransaction.d.ts +2 -2
  28. package/browser/transaction/builders/UnwrapTransaction.d.ts +2 -2
  29. package/browser/transaction/builders/WrapTransaction.d.ts +1 -1
  30. package/browser/transaction/interfaces/ITransactionParameters.d.ts +1 -1
  31. package/browser/transaction/interfaces/Tap.d.ts +1 -1
  32. package/browser/transaction/processor/PsbtTransaction.d.ts +1 -1
  33. package/browser/transaction/shared/P2TR_MS.d.ts +1 -1
  34. package/browser/transaction/shared/TweakedTransaction.d.ts +1 -1
  35. package/browser/utxo/OPNetLimitedProvider.d.ts +1 -1
  36. package/browser/verification/TapscriptVerificator.d.ts +2 -2
  37. package/build/_version.d.ts +1 -1
  38. package/build/_version.js +1 -1
  39. package/build/buffer/BinaryWriter.d.ts +1 -1
  40. package/build/buffer/BinaryWriter.js +4 -5
  41. package/build/generators/AddressGenerator.d.ts +1 -1
  42. package/build/generators/AddressGenerator.js +2 -2
  43. package/build/generators/Features.js +1 -1
  44. package/build/generators/Generator.d.ts +1 -1
  45. package/build/generators/Generator.js +2 -2
  46. package/build/generators/builders/CalldataGenerator.d.ts +1 -1
  47. package/build/generators/builders/CalldataGenerator.js +1 -1
  48. package/build/generators/builders/CustomGenerator.d.ts +1 -1
  49. package/build/generators/builders/CustomGenerator.js +1 -1
  50. package/build/generators/builders/DeploymentGenerator.d.ts +1 -1
  51. package/build/generators/builders/DeploymentGenerator.js +1 -1
  52. package/build/generators/builders/LegacyCalldataGenerator.d.ts +1 -1
  53. package/build/generators/builders/LegacyCalldataGenerator.js +1 -1
  54. package/build/generators/builders/MultiSignGenerator.js +2 -2
  55. package/build/keypair/Address.d.ts +3 -6
  56. package/build/keypair/Address.js +29 -25
  57. package/build/keypair/AddressVerificator.d.ts +1 -1
  58. package/build/keypair/AddressVerificator.js +1 -1
  59. package/build/keypair/EcKeyPair.d.ts +2 -2
  60. package/build/keypair/EcKeyPair.js +17 -10
  61. package/build/keypair/Wallet.d.ts +1 -1
  62. package/build/keypair/Wallet.js +3 -3
  63. package/build/metadata/ContractBaseMetadata.d.ts +1 -1
  64. package/build/metadata/ContractBaseMetadata.js +1 -1
  65. package/build/metadata/contracts/wBTC.d.ts +1 -1
  66. package/build/metadata/contracts/wBTC.js +1 -1
  67. package/build/signer/TweakedSigner.d.ts +1 -1
  68. package/build/signer/TweakedSigner.js +3 -3
  69. package/build/transaction/TransactionFactory.d.ts +1 -1
  70. package/build/transaction/browser/BrowserSignerBase.d.ts +1 -1
  71. package/build/transaction/browser/extensions/UnisatSigner.d.ts +1 -1
  72. package/build/transaction/browser/extensions/UnisatSigner.js +1 -1
  73. package/build/transaction/builders/CustomScriptTransaction.d.ts +1 -1
  74. package/build/transaction/builders/CustomScriptTransaction.js +2 -2
  75. package/build/transaction/builders/DeploymentTransaction.d.ts +1 -1
  76. package/build/transaction/builders/DeploymentTransaction.js +2 -2
  77. package/build/transaction/builders/FundingTransaction.d.ts +1 -1
  78. package/build/transaction/builders/InteractionTransaction.d.ts +1 -1
  79. package/build/transaction/builders/MultiSignTransaction.d.ts +2 -2
  80. package/build/transaction/builders/MultiSignTransaction.js +2 -2
  81. package/build/transaction/builders/SharedInteractionTransaction.d.ts +2 -2
  82. package/build/transaction/builders/SharedInteractionTransaction.js +2 -2
  83. package/build/transaction/builders/TransactionBuilder.d.ts +1 -1
  84. package/build/transaction/builders/TransactionBuilder.js +2 -2
  85. package/build/transaction/builders/UnwrapSegwitTransaction.d.ts +2 -2
  86. package/build/transaction/builders/UnwrapSegwitTransaction.js +1 -1
  87. package/build/transaction/builders/UnwrapTransaction.d.ts +2 -2
  88. package/build/transaction/builders/UnwrapTransaction.js +2 -2
  89. package/build/transaction/builders/WrapTransaction.d.ts +1 -1
  90. package/build/transaction/interfaces/ITransactionParameters.d.ts +1 -1
  91. package/build/transaction/interfaces/Tap.d.ts +1 -1
  92. package/build/transaction/processor/PsbtTransaction.d.ts +1 -1
  93. package/build/transaction/processor/PsbtTransaction.js +1 -1
  94. package/build/transaction/shared/P2TR_MS.d.ts +1 -1
  95. package/build/transaction/shared/P2TR_MS.js +1 -1
  96. package/build/transaction/shared/TweakedTransaction.d.ts +1 -1
  97. package/build/transaction/shared/TweakedTransaction.js +3 -3
  98. package/build/utils/BitcoinUtils.js +1 -5
  99. package/build/utxo/OPNetLimitedProvider.d.ts +1 -1
  100. package/build/verification/TapscriptVerificator.d.ts +2 -2
  101. package/build/verification/TapscriptVerificator.js +2 -2
  102. package/gulpfile.js +1 -1
  103. package/package.json +21 -21
  104. package/src/_version.ts +1 -1
  105. package/src/buffer/BinaryWriter.ts +5 -6
  106. package/src/generators/AddressGenerator.ts +2 -2
  107. package/src/generators/Features.ts +1 -1
  108. package/src/generators/Generator.ts +2 -2
  109. package/src/generators/builders/CalldataGenerator.ts +2 -2
  110. package/src/generators/builders/CustomGenerator.ts +1 -1
  111. package/src/generators/builders/DeploymentGenerator.ts +1 -1
  112. package/src/generators/builders/LegacyCalldataGenerator.ts +1 -1
  113. package/src/generators/builders/MultiSignGenerator.ts +2 -2
  114. package/src/keypair/Address.ts +43 -40
  115. package/src/keypair/AddressVerificator.ts +1 -1
  116. package/src/keypair/EcKeyPair.ts +22 -14
  117. package/src/keypair/Wallet.ts +3 -6
  118. package/src/metadata/ContractBaseMetadata.ts +1 -1
  119. package/src/metadata/contracts/wBTC.ts +1 -1
  120. package/src/signer/TweakedSigner.ts +3 -3
  121. package/src/transaction/TransactionFactory.ts +2 -2
  122. package/src/transaction/browser/BrowserSignerBase.ts +1 -1
  123. package/src/transaction/browser/extensions/UnisatSigner.ts +1 -1
  124. package/src/transaction/builders/CustomScriptTransaction.ts +3 -3
  125. package/src/transaction/builders/DeploymentTransaction.ts +3 -3
  126. package/src/transaction/builders/FundingTransaction.ts +1 -1
  127. package/src/transaction/builders/InteractionTransaction.ts +1 -1
  128. package/src/transaction/builders/MultiSignTransaction.ts +3 -3
  129. package/src/transaction/builders/SharedInteractionTransaction.ts +3 -3
  130. package/src/transaction/builders/TransactionBuilder.ts +2 -2
  131. package/src/transaction/builders/UnwrapSegwitTransaction.ts +2 -2
  132. package/src/transaction/builders/UnwrapTransaction.ts +3 -3
  133. package/src/transaction/builders/WrapTransaction.ts +2 -2
  134. package/src/transaction/interfaces/ITransactionParameters.ts +1 -1
  135. package/src/transaction/interfaces/Tap.ts +1 -1
  136. package/src/transaction/processor/PsbtTransaction.ts +1 -1
  137. package/src/transaction/shared/P2TR_MS.ts +1 -1
  138. package/src/transaction/shared/TweakedTransaction.ts +3 -3
  139. package/src/utils/BitcoinUtils.ts +3 -7
  140. package/src/utxo/OPNetLimitedProvider.ts +1 -1
  141. package/src/verification/TapscriptVerificator.ts +3 -3
  142. package/webpack.config.js +1 -1
@@ -1,12 +1,9 @@
1
- import { Network } from 'bitcoinjs-lib';
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
- private _keyPair;
8
- get keyPair(): ECPairInterface;
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,4 +1,4 @@
1
- import { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  export declare enum AddressTypes {
3
3
  P2PKH = "P2PKH",
4
4
  P2SH_OR_P2SH_P2WPKH = "P2SH_OR_P2SH-P2WPKH",
@@ -1,5 +1,5 @@
1
1
  import { BIP32API, BIP32Interface } from 'bip32';
2
- import { Network, Signer } from 'bitcoinjs-lib';
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): 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 'bitcoinjs-lib';
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 { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  export declare abstract class ContractBaseMetadata {
3
3
  protected network: Network;
4
4
  protected abstract readonly address: string;
@@ -1,4 +1,4 @@
1
- import { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  import { ChainId } from '../../network/ChainId.js';
3
3
  import { ContractBaseMetadata } from '../ContractBaseMetadata.js';
4
4
  export declare class wBTC extends ContractBaseMetadata {
@@ -1,4 +1,4 @@
1
- import { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  import { ECPairInterface } from 'ecpair';
3
3
  export interface TweakSettings {
4
4
  readonly network?: Network;
@@ -1,4 +1,4 @@
1
- import { Transaction } from 'bitcoinjs-lib';
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 { Network, Psbt, Signer } from 'bitcoinjs-lib';
1
+ import { Network, Psbt, Signer } from '@btc-vision/bitcoin';
2
2
  export declare abstract class CustomKeypair implements Signer {
3
3
  abstract network: Network;
4
4
  abstract publicKey: Buffer;
@@ -1,4 +1,4 @@
1
- import { Network, Psbt } from 'bitcoinjs-lib';
1
+ import { Network, Psbt } from '@btc-vision/bitcoin';
2
2
  import { CustomKeypair } from '../BrowserSignerBase.js';
3
3
  import { Unisat } from '../types/Unisat.js';
4
4
  declare global {
@@ -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 'bitcoinjs-lib';
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 'bitcoinjs-lib';
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 'bitcoinjs-lib';
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 'bitcoinjs-lib/src/types.js';
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 'bitcoinjs-lib';
2
- import { Taptree } from 'bitcoinjs-lib/src/types.js';
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 'bitcoinjs-lib';
2
- import { Taptree } from 'bitcoinjs-lib/src/types.js';
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 'bitcoinjs-lib';
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 'bitcoinjs-lib/src/types.js';
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 'bitcoinjs-lib';
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 'bitcoinjs-lib/src/types.js';
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 'bitcoinjs-lib';
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 'bitcoinjs-lib/src/types.js';
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 'bitcoinjs-lib';
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 'bitcoinjs-lib';
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 'bitcoinjs-lib';
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,4 +1,4 @@
1
- import { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  export declare class P2TR_MS {
3
3
  static generateMultiSigAddress(pubKeys: Buffer[], minimumSignatureRequired: number, network?: Network): string;
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import { Logger } from '@btc-vision/logger';
2
- import { Network, Payment, Psbt, PsbtInput, PsbtInputExtended, Signer, Transaction } from 'bitcoinjs-lib';
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 'bitcoinjs-lib';
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 'bitcoinjs-lib';
2
- import { Taptree } from 'bitcoinjs-lib/src/types.js';
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 +1 @@
1
- export declare const version = "1.0.119";
1
+ export declare const version = "1.0.121";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.0.119';
1
+ export const version = '1.0.121';
@@ -40,7 +40,7 @@ export declare class BinaryWriter {
40
40
  writeSelectorArray(value: Selector[]): void;
41
41
  private getChecksum;
42
42
  private writeMethodSelectorMap;
43
- private fromAddress;
43
+ private verifyAddress;
44
44
  private resize;
45
45
  private getDefaultBuffer;
46
46
  }
@@ -67,8 +67,8 @@ export class BinaryWriter {
67
67
  }
68
68
  }
69
69
  writeAddress(value) {
70
- const bytes = this.fromAddress(value);
71
- this.writeBytes(bytes);
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
- fromAddress(pubKey) {
243
- if (pubKey.tweakedBytes.byteLength > ADDRESS_BYTE_LENGTH) {
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,4 +1,4 @@
1
- import { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  export declare class AddressGenerator {
3
3
  static generatePKSH(sha256Hash: Buffer, network: Network): string;
4
4
  static generateTaprootAddress(pubKey: Buffer, network: {
@@ -1,7 +1,7 @@
1
1
  import { bech32, bech32m } from 'bech32';
2
- import { initEccLib } from 'bitcoinjs-lib';
2
+ import { initEccLib } from '@btc-vision/bitcoin';
3
3
  import * as ecc from '@bitcoinerlab/secp256k1';
4
- import { ripemd160 } from 'bitcoinjs-lib/src/crypto.js';
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,4 +1,4 @@
1
- import { opcodes } from 'bitcoinjs-lib';
1
+ import { opcodes } from '@btc-vision/bitcoin';
2
2
  export var Features;
3
3
  (function (Features) {
4
4
  Features[Features["UNWRAP"] = 0] = "UNWRAP";
@@ -1,4 +1,4 @@
1
- import { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  export declare abstract class Generator {
3
3
  static readonly DATA_CHUNK_SIZE: number;
4
4
  static readonly MAGIC: Buffer;
@@ -1,5 +1,5 @@
1
- import { networks } from 'bitcoinjs-lib';
2
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
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 { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  import { Features } from '../Features.js';
3
3
  import { Generator } from '../Generator.js';
4
4
  export declare class CalldataGenerator extends Generator {
@@ -1,4 +1,4 @@
1
- import { crypto, networks, opcodes, script } from 'bitcoinjs-lib';
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, Stack } from 'bitcoinjs-lib';
1
+ import { Network, Stack } from '@btc-vision/bitcoin';
2
2
  import { Generator } from '../Generator.js';
3
3
  export declare class CustomGenerator extends Generator {
4
4
  constructor(senderPubKey: Buffer, network?: Network);
@@ -1,4 +1,4 @@
1
- import { networks, script } from 'bitcoinjs-lib';
1
+ import { networks, script } from '@btc-vision/bitcoin';
2
2
  import { Generator } from '../Generator.js';
3
3
  export class CustomGenerator extends Generator {
4
4
  constructor(senderPubKey, network = networks.bitcoin) {
@@ -1,4 +1,4 @@
1
- import { Network } from 'bitcoinjs-lib';
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 'bitcoinjs-lib';
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 { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  import { Features } from '../Features.js';
3
3
  import { Generator } from '../Generator.js';
4
4
  export declare class LegacyCalldataGenerator extends Generator {
@@ -1,4 +1,4 @@
1
- import { networks, opcodes, script } from 'bitcoinjs-lib';
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 'bitcoinjs-lib';
2
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
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 'bitcoinjs-lib';
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
- private _keyPair;
8
- get keyPair(): ECPairInterface;
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;
@@ -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, _Address_tweakedBytes;
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 'bitcoinjs-lib/src/psbt/bip371.js';
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
- _Address_tweakedBytes.set(this, void 0);
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._keyPair) {
37
+ if (!__classPrivateFieldGet(this, _Address_keyPair, "f")) {
31
38
  throw new Error('Public key not set for address');
32
39
  }
33
- return this._keyPair;
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.isP2TROnly ? this : __classPrivateFieldGet(this, _Address_tweakedBytes, "f");
61
- const c = a.isP2TROnly ? a : __classPrivateFieldGet(a, _Address_tweakedBytes, "f");
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] !== c[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.isP2TROnly ? this : __classPrivateFieldGet(this, _Address_tweakedBytes, "f");
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 = c[i];
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.isP2TROnly ? this : __classPrivateFieldGet(this, _Address_tweakedBytes, "f");
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 = c[i];
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._keyPair = EcKeyPair.fromPublicKey(Uint8Array.from(publicKey));
114
- __classPrivateFieldSet(this, _Address_tweakedBytes, toXOnly(Buffer.from(EcKeyPair.tweakPublicKey(this._keyPair.publicKey.toString('hex')), 'hex')), "f");
115
- super.set(publicKey);
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.isP2TROnly ? this : __classPrivateFieldGet(this, _Address_tweakedBytes, "f"), network);
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(), _Address_tweakedBytes = new WeakMap();
153
+ _Address_p2tr = new WeakMap(), _Address_network = new WeakMap(), _Address_originalPublicKey = new WeakMap(), _Address_keyPair = new WeakMap();
@@ -1,4 +1,4 @@
1
- import { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  export declare enum AddressTypes {
3
3
  P2PKH = "P2PKH",
4
4
  P2SH_OR_P2SH_P2WPKH = "P2SH_OR_P2SH-P2WPKH",
@@ -1,4 +1,4 @@
1
- import { address, initEccLib } from 'bitcoinjs-lib';
1
+ import { address, initEccLib } from '@btc-vision/bitcoin';
2
2
  import * as ecc from '@bitcoinerlab/secp256k1';
3
3
  import { EcKeyPair } from './EcKeyPair.js';
4
4
  initEccLib(ecc);
@@ -1,5 +1,5 @@
1
1
  import { BIP32API, BIP32Interface } from 'bip32';
2
- import { Network, Signer } from 'bitcoinjs-lib';
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): 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;