@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.
Files changed (146) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/event/NetEvent.d.ts +3 -3
  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 +8 -0
  9. package/browser/index.js +1 -1
  10. package/browser/keypair/Address.d.ts +2 -1
  11. package/browser/keypair/AddressVerificator.d.ts +3 -4
  12. package/browser/keypair/EcKeyPair.d.ts +1 -1
  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/opnet.d.ts +1 -0
  17. package/browser/signer/TweakedSigner.d.ts +1 -1
  18. package/browser/transaction/TransactionFactory.d.ts +1 -1
  19. package/browser/transaction/browser/BrowserSignerBase.d.ts +1 -1
  20. package/browser/transaction/browser/extensions/UnisatSigner.d.ts +1 -1
  21. package/browser/transaction/builders/CustomScriptTransaction.d.ts +1 -1
  22. package/browser/transaction/builders/DeploymentTransaction.d.ts +1 -1
  23. package/browser/transaction/builders/FundingTransaction.d.ts +1 -1
  24. package/browser/transaction/builders/InteractionTransaction.d.ts +1 -1
  25. package/browser/transaction/builders/MultiSignTransaction.d.ts +2 -2
  26. package/browser/transaction/builders/SharedInteractionTransaction.d.ts +2 -2
  27. package/browser/transaction/builders/TransactionBuilder.d.ts +1 -1
  28. package/browser/transaction/builders/UnwrapSegwitTransaction.d.ts +2 -2
  29. package/browser/transaction/builders/UnwrapTransaction.d.ts +2 -2
  30. package/browser/transaction/builders/WrapTransaction.d.ts +1 -1
  31. package/browser/transaction/interfaces/ITransactionParameters.d.ts +1 -1
  32. package/browser/transaction/interfaces/Tap.d.ts +1 -1
  33. package/browser/transaction/processor/PsbtTransaction.d.ts +1 -1
  34. package/browser/transaction/shared/P2TR_MS.d.ts +1 -1
  35. package/browser/transaction/shared/TweakedTransaction.d.ts +10 -1
  36. package/browser/utxo/OPNetLimitedProvider.d.ts +1 -1
  37. package/browser/utxo/interfaces/IUTXO.d.ts +3 -0
  38. package/browser/verification/TapscriptVerificator.d.ts +2 -2
  39. package/build/_version.d.ts +1 -1
  40. package/build/_version.js +1 -1
  41. package/build/event/NetEvent.d.ts +3 -3
  42. package/build/event/NetEvent.js +3 -3
  43. package/build/generators/AddressGenerator.d.ts +1 -1
  44. package/build/generators/AddressGenerator.js +2 -2
  45. package/build/generators/Features.js +1 -1
  46. package/build/generators/Generator.d.ts +1 -1
  47. package/build/generators/Generator.js +2 -2
  48. package/build/generators/builders/CalldataGenerator.d.ts +1 -1
  49. package/build/generators/builders/CalldataGenerator.js +1 -1
  50. package/build/generators/builders/CustomGenerator.d.ts +1 -1
  51. package/build/generators/builders/CustomGenerator.js +1 -1
  52. package/build/generators/builders/DeploymentGenerator.d.ts +1 -1
  53. package/build/generators/builders/DeploymentGenerator.js +1 -1
  54. package/build/generators/builders/LegacyCalldataGenerator.d.ts +8 -0
  55. package/build/generators/builders/LegacyCalldataGenerator.js +75 -0
  56. package/build/generators/builders/MultiSignGenerator.js +2 -2
  57. package/build/keypair/Address.d.ts +2 -1
  58. package/build/keypair/Address.js +4 -1
  59. package/build/keypair/AddressVerificator.d.ts +3 -4
  60. package/build/keypair/AddressVerificator.js +14 -4
  61. package/build/keypair/EcKeyPair.d.ts +1 -1
  62. package/build/keypair/EcKeyPair.js +3 -3
  63. package/build/keypair/Wallet.d.ts +1 -1
  64. package/build/keypair/Wallet.js +2 -2
  65. package/build/metadata/ContractBaseMetadata.d.ts +1 -1
  66. package/build/metadata/ContractBaseMetadata.js +1 -1
  67. package/build/metadata/contracts/wBTC.d.ts +1 -1
  68. package/build/metadata/contracts/wBTC.js +1 -1
  69. package/build/opnet.d.ts +1 -0
  70. package/build/opnet.js +1 -0
  71. package/build/signer/TweakedSigner.d.ts +1 -1
  72. package/build/signer/TweakedSigner.js +3 -3
  73. package/build/transaction/TransactionFactory.d.ts +1 -1
  74. package/build/transaction/browser/BrowserSignerBase.d.ts +1 -1
  75. package/build/transaction/browser/extensions/UnisatSigner.d.ts +1 -1
  76. package/build/transaction/browser/extensions/UnisatSigner.js +1 -1
  77. package/build/transaction/builders/CustomScriptTransaction.d.ts +1 -1
  78. package/build/transaction/builders/CustomScriptTransaction.js +2 -2
  79. package/build/transaction/builders/DeploymentTransaction.d.ts +1 -1
  80. package/build/transaction/builders/DeploymentTransaction.js +2 -2
  81. package/build/transaction/builders/FundingTransaction.d.ts +1 -1
  82. package/build/transaction/builders/InteractionTransaction.d.ts +1 -1
  83. package/build/transaction/builders/MultiSignTransaction.d.ts +2 -2
  84. package/build/transaction/builders/MultiSignTransaction.js +2 -2
  85. package/build/transaction/builders/SharedInteractionTransaction.d.ts +2 -2
  86. package/build/transaction/builders/SharedInteractionTransaction.js +2 -2
  87. package/build/transaction/builders/TransactionBuilder.d.ts +1 -1
  88. package/build/transaction/builders/TransactionBuilder.js +3 -3
  89. package/build/transaction/builders/UnwrapSegwitTransaction.d.ts +2 -2
  90. package/build/transaction/builders/UnwrapSegwitTransaction.js +1 -1
  91. package/build/transaction/builders/UnwrapTransaction.d.ts +2 -2
  92. package/build/transaction/builders/UnwrapTransaction.js +2 -2
  93. package/build/transaction/builders/WrapTransaction.d.ts +1 -1
  94. package/build/transaction/interfaces/ITransactionParameters.d.ts +1 -1
  95. package/build/transaction/interfaces/Tap.d.ts +1 -1
  96. package/build/transaction/processor/PsbtTransaction.d.ts +1 -1
  97. package/build/transaction/processor/PsbtTransaction.js +1 -1
  98. package/build/transaction/shared/P2TR_MS.d.ts +1 -1
  99. package/build/transaction/shared/P2TR_MS.js +1 -1
  100. package/build/transaction/shared/TweakedTransaction.d.ts +10 -1
  101. package/build/transaction/shared/TweakedTransaction.js +95 -5
  102. package/build/utxo/OPNetLimitedProvider.d.ts +1 -1
  103. package/build/utxo/interfaces/IUTXO.d.ts +3 -0
  104. package/build/verification/TapscriptVerificator.d.ts +2 -2
  105. package/build/verification/TapscriptVerificator.js +2 -2
  106. package/package.json +2 -2
  107. package/src/_version.ts +1 -1
  108. package/src/event/NetEvent.ts +2 -2
  109. package/src/generators/AddressGenerator.ts +2 -2
  110. package/src/generators/Features.ts +1 -1
  111. package/src/generators/Generator.ts +2 -2
  112. package/src/generators/builders/CalldataGenerator.ts +2 -2
  113. package/src/generators/builders/CustomGenerator.ts +1 -1
  114. package/src/generators/builders/DeploymentGenerator.ts +1 -1
  115. package/src/generators/builders/LegacyCalldataGenerator.ts +141 -0
  116. package/src/generators/builders/MultiSignGenerator.ts +2 -2
  117. package/src/keypair/Address.ts +10 -2
  118. package/src/keypair/AddressVerificator.ts +23 -4
  119. package/src/keypair/EcKeyPair.ts +3 -3
  120. package/src/keypair/Wallet.ts +2 -2
  121. package/src/metadata/ContractBaseMetadata.ts +1 -1
  122. package/src/metadata/contracts/wBTC.ts +1 -1
  123. package/src/opnet.ts +1 -0
  124. package/src/signer/TweakedSigner.ts +3 -3
  125. package/src/transaction/TransactionFactory.ts +2 -2
  126. package/src/transaction/browser/BrowserSignerBase.ts +1 -1
  127. package/src/transaction/browser/extensions/UnisatSigner.ts +1 -1
  128. package/src/transaction/builders/CustomScriptTransaction.ts +3 -3
  129. package/src/transaction/builders/DeploymentTransaction.ts +3 -3
  130. package/src/transaction/builders/FundingTransaction.ts +1 -1
  131. package/src/transaction/builders/InteractionTransaction.ts +1 -1
  132. package/src/transaction/builders/MultiSignTransaction.ts +3 -3
  133. package/src/transaction/builders/SharedInteractionTransaction.ts +3 -3
  134. package/src/transaction/builders/TransactionBuilder.ts +3 -3
  135. package/src/transaction/builders/UnwrapSegwitTransaction.ts +2 -2
  136. package/src/transaction/builders/UnwrapTransaction.ts +3 -3
  137. package/src/transaction/builders/WrapTransaction.ts +2 -2
  138. package/src/transaction/interfaces/ITransactionParameters.ts +1 -1
  139. package/src/transaction/interfaces/Tap.ts +1 -1
  140. package/src/transaction/processor/PsbtTransaction.ts +1 -1
  141. package/src/transaction/shared/P2TR_MS.ts +1 -1
  142. package/src/transaction/shared/TweakedTransaction.ts +160 -5
  143. package/src/utxo/OPNetLimitedProvider.ts +1 -1
  144. package/src/utxo/interfaces/IUTXO.ts +3 -0
  145. package/src/verification/TapscriptVerificator.ts +3 -3
  146. package/webpack.config.js +1 -1
@@ -1,4 +1,4 @@
1
- import { crypto, Network, networks, opcodes, script } from 'bitcoinjs-lib';
1
+ import { crypto, Network, networks, opcodes, script } from '@btc-vision/bitcoin';
2
2
  import { ECPairInterface } from 'ecpair';
3
3
  import { Compressor } from '../../bytecode/Compressor.js';
4
4
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
@@ -99,7 +99,7 @@ export class CalldataGenerator extends Generator {
99
99
 
100
100
  Generator.MAGIC,
101
101
  ];
102
-
102
+
103
103
  // write pub keys, when requested.
104
104
  if (vaultPublicKeys.length > 0) {
105
105
  const pubKeyBuffer = CalldataGenerator.getPubKeyAsBuffer(vaultPublicKeys, this.network);
@@ -1,4 +1,4 @@
1
- import { Network, networks, script, Stack } from 'bitcoinjs-lib';
1
+ import { Network, networks, script, Stack } from '@btc-vision/bitcoin';
2
2
  import { Generator } from '../Generator.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { crypto, Network, networks, opcodes, script } from 'bitcoinjs-lib';
1
+ import { crypto, Network, networks, opcodes, script } from '@btc-vision/bitcoin';
2
2
  import { Generator } from '../Generator.js';
3
3
 
4
4
  export class DeploymentGenerator extends Generator {
@@ -0,0 +1,141 @@
1
+ import { Network, networks, opcodes, script } from '@btc-vision/bitcoin';
2
+ import { ECPairInterface } from 'ecpair';
3
+ import { Compressor } from '../../bytecode/Compressor.js';
4
+ import { EcKeyPair } from '../../keypair/EcKeyPair.js';
5
+ import { FeatureOpCodes, Features } from '../Features.js';
6
+ import { Generator } from '../Generator.js';
7
+
8
+ /**
9
+ * Class to generate bitcoin script for interaction transactions
10
+ */
11
+ export class LegacyCalldataGenerator extends Generator {
12
+ constructor(senderPubKey: Buffer, network: Network = networks.bitcoin) {
13
+ super(senderPubKey, Buffer.alloc(0), network);
14
+ }
15
+
16
+ /**
17
+ * Get the public key as a buffer
18
+ * @param {Buffer[]} witnessKeys - The public keys
19
+ * @param {Network} network - The network to use
20
+ * @private
21
+ * @returns {Buffer} - The public key as a buffer
22
+ */
23
+ public static getPubKeyAsBuffer(witnessKeys: Buffer[], network: Network): Buffer {
24
+ let finalBuffer: Buffer = Buffer.alloc(0);
25
+
26
+ for (const pubKey of witnessKeys) {
27
+ const key: ECPairInterface = EcKeyPair.fromPublicKey(pubKey, network);
28
+
29
+ if (!key.compressed) {
30
+ throw new Error('Public key must be compressed');
31
+ }
32
+
33
+ if (pubKey.byteLength !== 33) {
34
+ throw new Error(`Public key must be 33 bytes, got ${pubKey.byteLength} bytes.`);
35
+ }
36
+
37
+ finalBuffer = Buffer.concat([finalBuffer, pubKey]);
38
+ }
39
+
40
+ // compress the public keys
41
+ const compressed: Buffer = Compressor.compress(finalBuffer);
42
+ if (compressed.byteLength >= finalBuffer.byteLength) {
43
+ // we ensure that the user pays the smallest amount of fees. [micro-optimization]
44
+ return finalBuffer;
45
+ }
46
+
47
+ // if compressed is smaller, return compressed.
48
+ return compressed;
49
+ }
50
+
51
+ /**
52
+ * Compile an interaction bitcoin script
53
+ * @param {Buffer} calldata - The calldata to use
54
+ * @param {Buffer} contractSecret - The contract secret
55
+ * @param {number[]} [features=[]] - The features to use (optional)
56
+ * @param {Buffer[]} [vaultPublicKeys=[]] - The public keys of the vault (optional)
57
+ * @param {number} [minimumSignatures=0] - The minimum number of signatures (optional)
58
+ * @returns {Buffer} - The compiled script
59
+ * @throws {Error} - If something goes wrong
60
+ */
61
+ public compile(
62
+ calldata: Buffer,
63
+ contractSecret: Buffer,
64
+ features: Features[] = [],
65
+ vaultPublicKeys: Buffer[] = [],
66
+ minimumSignatures: number = 0,
67
+ ): Buffer {
68
+ const dataChunks: Buffer[][] = this.splitBufferIntoChunks(calldata);
69
+ if (!dataChunks.length) throw new Error('No data chunks found');
70
+
71
+ let compiledData = [
72
+ this.senderPubKey,
73
+ opcodes.OP_CHECKSIGVERIFY,
74
+
75
+ contractSecret,
76
+ opcodes.OP_TOALTSTACK,
77
+
78
+ opcodes.OP_DEPTH,
79
+ opcodes.OP_1,
80
+ opcodes.OP_NUMEQUAL,
81
+ opcodes.OP_IF,
82
+
83
+ Generator.MAGIC,
84
+ ];
85
+
86
+ // write pub keys, when requested.
87
+ if (vaultPublicKeys.length > 0) {
88
+ const pubKeyBuffer = LegacyCalldataGenerator.getPubKeyAsBuffer(
89
+ vaultPublicKeys,
90
+ this.network,
91
+ );
92
+ const pubKeyDataChunks: Buffer[][] = this.splitBufferIntoChunks(pubKeyBuffer);
93
+
94
+ compiledData = compiledData.concat(
95
+ ...[
96
+ opcodes.OP_0, // provide opnet public keys
97
+ ...pubKeyDataChunks,
98
+ ],
99
+ );
100
+
101
+ if (minimumSignatures) {
102
+ // verify that the minimum is not greater than 255
103
+ if (minimumSignatures > 255) {
104
+ throw new Error('Minimum signatures cannot exceed 255');
105
+ }
106
+
107
+ // we use a 2 bytes buffer even if we limit to 255 so it does not use an opcode for the number
108
+ const minSigBuffer = Buffer.alloc(2);
109
+ minSigBuffer.writeUint16LE(minimumSignatures, 0);
110
+
111
+ compiledData = compiledData.concat(
112
+ ...[
113
+ opcodes.OP_1, // provide minimum signatures
114
+ minSigBuffer,
115
+ ],
116
+ );
117
+ } else {
118
+ throw new Error('Minimum signatures must be provided');
119
+ }
120
+ }
121
+
122
+ const featureOpcodes = features.map((feature) => FeatureOpCodes[feature]); // Get the opcodes for the features
123
+
124
+ // Write calldata
125
+ compiledData = compiledData.concat(
126
+ ...featureOpcodes,
127
+ ...[opcodes.OP_1NEGATE, ...dataChunks, opcodes.OP_ELSE, opcodes.OP_1, opcodes.OP_ENDIF],
128
+ );
129
+
130
+ const asm = compiledData.flat();
131
+ const compiled = script.compile(asm);
132
+
133
+ /** Verify the validity of the script */
134
+ const decompiled = script.decompile(compiled);
135
+ if (!decompiled) {
136
+ throw new Error('Failed to decompile script??');
137
+ }
138
+
139
+ return compiled;
140
+ }
141
+ }
@@ -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
 
4
4
  /**
5
5
  * Generate a bitcoin script for a multisign interaction
@@ -1,9 +1,9 @@
1
- import { Network } from 'bitcoinjs-lib';
1
+ import { Network } from '@btc-vision/bitcoin';
2
2
  import { EcKeyPair } from './EcKeyPair.js';
3
3
  import { ECPairInterface } from 'ecpair';
4
4
  import { ADDRESS_BYTE_LENGTH } from '../utils/types.js';
5
5
  import { AddressVerificator } from './AddressVerificator.js';
6
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
6
+ import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
7
7
 
8
8
  export class Address extends Uint8Array {
9
9
  private isP2TROnly: boolean = false;
@@ -82,6 +82,14 @@ export class Address extends Uint8Array {
82
82
  return '0x' + Buffer.from(this).toString('hex');
83
83
  }
84
84
 
85
+ /**
86
+ * Converts the address to a buffer
87
+ * @returns {Buffer} The buffer
88
+ */
89
+ public toBuffer(): Buffer {
90
+ return Buffer.from(this);
91
+ }
92
+
85
93
  public equals(a: Address): boolean {
86
94
  const b = this.isP2TROnly ? this : (this.#tweakedBytes as Uint8Array);
87
95
  const c = a.isP2TROnly ? a : (a.#tweakedBytes as Uint8Array);
@@ -1,4 +1,4 @@
1
- import { address, initEccLib, Network } from 'bitcoinjs-lib';
1
+ import { address, initEccLib, Network } from '@btc-vision/bitcoin';
2
2
  import * as ecc from '@bitcoinerlab/secp256k1';
3
3
  import { EcKeyPair } from './EcKeyPair.js';
4
4
 
@@ -6,8 +6,6 @@ initEccLib(ecc);
6
6
 
7
7
  export enum AddressTypes {
8
8
  P2PKH = 'P2PKH',
9
- P2SH = 'P2SH',
10
- P2SH_P2WPKH = 'P2SH-P2WPKH',
11
9
  P2SH_OR_P2SH_P2WPKH = 'P2SH_OR_P2SH-P2WPKH',
12
10
  P2PK = 'P2PK',
13
11
  P2TR = 'P2TR',
@@ -125,6 +123,27 @@ export class AddressVerificator {
125
123
  return false; // Not a valid public key
126
124
  }
127
125
 
126
+ /**
127
+ * Checks if the address requires a redeem script to spend funds.
128
+ * @param {string} addy - The address to check.
129
+ * @param {Network} network - The network to validate against.
130
+ * @returns {boolean} - True if the address requires a redeem script, false otherwise.
131
+ */
132
+ public static requireRedeemScript(addy: string, network: Network): boolean {
133
+ try {
134
+ // First, try to decode as a Base58Check address (P2PKH, P2SH, or P2SH-P2WPKH)
135
+ const decodedBase58 = address.fromBase58Check(addy);
136
+
137
+ if (decodedBase58.version === network.pubKeyHash) {
138
+ return false;
139
+ }
140
+
141
+ return decodedBase58.version === network.scriptHash;
142
+ } catch {
143
+ return false;
144
+ }
145
+ }
146
+
128
147
  /**
129
148
  * Validates if a given Bitcoin address is of the specified type and network.
130
149
  * - P2PKH (Legacy address starting with '1' for mainnet or 'm/n' for testnet)
@@ -138,7 +157,7 @@ export class AddressVerificator {
138
157
  * @param network - The Bitcoin network to validate against (mainnet, testnet, etc.).
139
158
  * @returns - The type of the valid Bitcoin address, or null if invalid.
140
159
  */
141
- public static validateBitcoinAddress(addy: string, network: Network): AddressTypes | null {
160
+ public static detectAddressType(addy: string, network: Network): AddressTypes | null {
142
161
  if (AddressVerificator.isValidPublicKey(addy, network)) {
143
162
  return AddressTypes.P2PK;
144
163
  }
@@ -1,11 +1,11 @@
1
1
  import * as ecc from '@bitcoinerlab/secp256k1';
2
2
  import bip32, { BIP32API, BIP32Factory, BIP32Interface } from 'bip32';
3
- import { address, initEccLib, Network, networks, payments, Signer } from 'bitcoinjs-lib';
4
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
3
+ import { address, initEccLib, Network, networks, payments, Signer } from '@btc-vision/bitcoin';
4
+ import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
5
5
  import { ECPairAPI, ECPairFactory, ECPairInterface } from 'ecpair';
6
6
  import { IWallet } from './interfaces/IWallet.js';
7
7
  import { CURVE, Point, utils } from '@noble/secp256k1';
8
- import { taggedHash } from 'bitcoinjs-lib/src/crypto.js';
8
+ import { taggedHash } from '@btc-vision/bitcoin/src/crypto.js';
9
9
 
10
10
  initEccLib(ecc);
11
11
 
@@ -1,8 +1,8 @@
1
1
  import { IWallet } from './interfaces/IWallet.js';
2
2
  import { ECPairInterface } from 'ecpair';
3
3
  import { EcKeyPair } from './EcKeyPair.js';
4
- import { Network, networks } from 'bitcoinjs-lib';
5
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
4
+ import { Network, networks } from '@btc-vision/bitcoin';
5
+ import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
6
6
  import { Address } from './Address.js';
7
7
 
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { Network, networks } from 'bitcoinjs-lib';
1
+ import { Network, networks } from '@btc-vision/bitcoin';
2
2
 
3
3
  export abstract class ContractBaseMetadata {
4
4
  protected abstract readonly address: string;
@@ -1,4 +1,4 @@
1
- import { Network, networks } from 'bitcoinjs-lib';
1
+ import { Network, 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/src/opnet.ts CHANGED
@@ -6,6 +6,7 @@ export * from './bytecode/Compressor.js';
6
6
  /** Generators */
7
7
  export * from './generators/Generator.js';
8
8
  export * from './generators/builders/CalldataGenerator.js';
9
+ export * from './generators/builders/LegacyCalldataGenerator.js';
9
10
  export * from './generators/builders/DeploymentGenerator.js';
10
11
  export * from './generators/builders/CustomGenerator.js';
11
12
  export * from './generators/builders/MultiSignGenerator.js';
@@ -1,7 +1,7 @@
1
1
  import * as ecc from '@bitcoinerlab/secp256k1';
2
- import { initEccLib, Network, Signer } from 'bitcoinjs-lib';
3
- import { tapTweakHash } from 'bitcoinjs-lib/src/payments/bip341.js';
4
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
2
+ import { initEccLib, Network, Signer } 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 { ECPairInterface } from 'ecpair';
6
6
  import { EcKeyPair } from '../keypair/EcKeyPair.js';
7
7
 
@@ -1,5 +1,5 @@
1
- import { Psbt, Transaction } from 'bitcoinjs-lib';
2
- import { Output } from 'bitcoinjs-lib/src/transaction.js';
1
+ import { Psbt, Transaction } from '@btc-vision/bitcoin';
2
+ import { Output } from '@btc-vision/bitcoin/src/transaction.js';
3
3
  import { currentConsensus, currentConsensusConfig } from '../consensus/ConsensusConfig.js';
4
4
  import { wBTC } from '../metadata/contracts/wBTC.js';
5
5
  import { UTXO } from '../utxo/interfaces/IUTXO.js';
@@ -1,4 +1,4 @@
1
- import { Network, Psbt, Signer } from 'bitcoinjs-lib';
1
+ import { Network, Psbt, Signer } from '@btc-vision/bitcoin';
2
2
 
3
3
  /**
4
4
  * Create a custom keypair.
@@ -1,4 +1,4 @@
1
- import { Network, networks, Psbt, TapScriptSig } from 'bitcoinjs-lib';
1
+ import { Network, networks, Psbt, TapScriptSig } from '@btc-vision/bitcoin';
2
2
  import { ECPairInterface } from 'ecpair';
3
3
  import { EcKeyPair } from '../../../keypair/EcKeyPair.js';
4
4
  import { CustomKeypair } from '../BrowserSignerBase.js';
@@ -1,14 +1,14 @@
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 { SharedInteractionParameters } from '../interfaces/ITransactionParameters.js';
5
- import { crypto as bitCrypto, Payment, Psbt, PsbtInput, Signer, Stack } from 'bitcoinjs-lib';
5
+ import { crypto as bitCrypto, Payment, Psbt, PsbtInput, Signer, Stack } from '@btc-vision/bitcoin';
6
6
  import { TransactionBuilder } from './TransactionBuilder.js';
7
7
  import { CustomGenerator } from '../../generators/builders/CustomGenerator.js';
8
8
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
9
9
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
10
10
  import { AddressGenerator } from '../../generators/AddressGenerator.js';
11
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
11
+ import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
12
12
  import { ECPairInterface } from 'ecpair';
13
13
 
14
14
  export interface ICustomTransactionParameters extends SharedInteractionParameters {
@@ -1,11 +1,11 @@
1
1
  import { TransactionType } from '../enums/TransactionType.js';
2
2
  import { IDeploymentParameters } from '../interfaces/ITransactionParameters.js';
3
- import { crypto as bitCrypto, Payment, Psbt, PsbtInput, Signer } from 'bitcoinjs-lib';
3
+ import { crypto as bitCrypto, Payment, Psbt, PsbtInput, Signer } from '@btc-vision/bitcoin';
4
4
  import { TransactionBuilder } from './TransactionBuilder.js';
5
- import { Taptree } from 'bitcoinjs-lib/src/types.js';
5
+ import { Taptree } from '@btc-vision/bitcoin/src/types.js';
6
6
  import { TapLeafScript } from '../interfaces/Tap.js';
7
7
  import { DeploymentGenerator } from '../../generators/builders/DeploymentGenerator.js';
8
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
8
+ import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
9
9
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
10
10
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
11
11
  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 'bitcoinjs-lib';
3
+ import { Signer } from '@btc-vision/bitcoin';
4
4
  import { TransactionBuilder } from './TransactionBuilder.js';
5
5
  import { ECPairInterface } from 'ecpair';
6
6
 
@@ -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';
@@ -9,14 +9,14 @@ import {
9
9
  script,
10
10
  Signer,
11
11
  TapScriptSig,
12
- } from 'bitcoinjs-lib';
13
- import { Taptree } from 'bitcoinjs-lib/src/types.js';
12
+ } from '@btc-vision/bitcoin';
13
+ import { Taptree } from '@btc-vision/bitcoin/src/types.js';
14
14
  import { TransactionBuilder } from './TransactionBuilder.js';
15
15
  import { TransactionType } from '../enums/TransactionType.js';
16
16
  import { ITransactionParameters } from '../interfaces/ITransactionParameters.js';
17
17
  import { MultiSignGenerator } from '../../generators/builders/MultiSignGenerator.js';
18
18
  import { UTXO } from '../../utxo/interfaces/IUTXO.js';
19
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
19
+ import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
20
20
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
21
21
  import { ECPairInterface } from 'ecpair';
22
22
 
@@ -1,5 +1,5 @@
1
- import { address, Payment, Psbt, PsbtInput, Signer } from 'bitcoinjs-lib';
2
- import { Taptree } from 'bitcoinjs-lib/src/types.js';
1
+ import { address, 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';
@@ -8,7 +8,7 @@ import { SharedInteractionParameters } from '../interfaces/ITransactionParameter
8
8
  import { Compressor } from '../../bytecode/Compressor.js';
9
9
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
10
10
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
11
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
11
+ import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
12
12
 
13
13
  /**
14
14
  * Shared interaction transaction
@@ -8,8 +8,8 @@ import {
8
8
  script,
9
9
  Signer,
10
10
  Transaction,
11
- } from 'bitcoinjs-lib';
12
- import { varuint } from 'bitcoinjs-lib/src/bufferutils.js';
11
+ } from '@btc-vision/bitcoin';
12
+ import { varuint } from '@btc-vision/bitcoin/src/bufferutils.js';
13
13
  import * as ecc from '@bitcoinerlab/secp256k1';
14
14
  import { UpdateInput } from '../interfaces/Tap.js';
15
15
  import { TransactionType } from '../enums/TransactionType.js';
@@ -37,7 +37,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
37
37
  //opcodes.OP_VERIFY, - verify that this is not needed.
38
38
  ]);
39
39
 
40
- public static readonly MINIMUM_DUST: bigint = 330n;
40
+ public static readonly MINIMUM_DUST: bigint = 50n;
41
41
 
42
42
  public abstract readonly type: T;
43
43
  public readonly logColor: string = '#785def';
@@ -1,10 +1,10 @@
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
5
  import { TransactionBuilder } from './TransactionBuilder.js';
6
6
  import { wBTC } from '../../metadata/contracts/wBTC.js';
7
- import { payments, Psbt, PsbtInputExtended, PsbtOutputExtended, Signer } from 'bitcoinjs-lib';
7
+ import { payments, Psbt, PsbtInputExtended, PsbtOutputExtended, Signer } from '@btc-vision/bitcoin';
8
8
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
9
9
  import { IWBTCUTXODocument, PsbtTransaction, VaultUTXOs } from '../processor/PsbtTransaction.js';
10
10
  import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
@@ -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 { IUnwrapParameters } from '../interfaces/ITransactionParameters.js';
4
4
  import { SharedInteractionTransaction } from './SharedInteractionTransaction.js';
@@ -12,12 +12,12 @@ import {
12
12
  PsbtInput,
13
13
  PsbtInputExtended,
14
14
  PsbtOutputExtended,
15
- } from 'bitcoinjs-lib';
15
+ } from '@btc-vision/bitcoin';
16
16
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
17
17
  import { IWBTCUTXODocument, PsbtTransaction, VaultUTXOs } from '../processor/PsbtTransaction.js';
18
18
  import { MultiSignGenerator } from '../../generators/builders/MultiSignGenerator.js';
19
19
  import { MultiSignTransaction } from './MultiSignTransaction.js';
20
- import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
20
+ import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
21
21
  import { CalldataGenerator } from '../../generators/builders/CalldataGenerator.js';
22
22
  import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
23
23
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
@@ -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';
@@ -6,7 +6,7 @@ import { SharedInteractionTransaction } from './SharedInteractionTransaction.js'
6
6
  import { wBTC } from '../../metadata/contracts/wBTC.js';
7
7
  import { WrappedGeneration } from '../../wbtc/WrappedGenerationParameters.js';
8
8
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
9
- import { Network, PsbtOutputExtendedAddress } from 'bitcoinjs-lib';
9
+ import { Network, PsbtOutputExtendedAddress } from '@btc-vision/bitcoin';
10
10
  import { P2TR_MS } from '../shared/P2TR_MS.js';
11
11
  import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
12
12
  import { Selector } from '../../utils/types.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
 
9
9
  export interface ITransactionParameters extends ITweakedTransactionData {
10
10
  readonly from?: string;
@@ -10,7 +10,7 @@ import {
10
10
  TapMerkleRoot as _TapMerkleRoot,
11
11
  TapScriptSig as _TapScriptSig,
12
12
  TapTree as _TapTree,
13
- } from 'bitcoinjs-lib';
13
+ } from '@btc-vision/bitcoin';
14
14
 
15
15
  export interface TapLeafScript {
16
16
  readonly leafVersion: number;
@@ -5,7 +5,7 @@ import {
5
5
  PsbtOutputExtended,
6
6
  Signer,
7
7
  Transaction,
8
- } from 'bitcoinjs-lib';
8
+ } from '@btc-vision/bitcoin';
9
9
  import { ITweakedTransactionData, TweakedTransaction } from '../shared/TweakedTransaction.js';
10
10
 
11
11
  export interface PsbtTransactionData extends ITweakedTransactionData {
@@ -1,4 +1,4 @@
1
- import { Network, networks } from 'bitcoinjs-lib';
1
+ import { Network, networks } from '@btc-vision/bitcoin';
2
2
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
3
3
  import { MultiSignParameters, MultiSignTransaction } from '../builders/MultiSignTransaction.js';
4
4