@btc-vision/transaction 1.0.112 → 1.0.114

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 (150) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/abi/ABICoder.d.ts +31 -0
  3. package/browser/buffer/BinaryReader.d.ts +37 -0
  4. package/browser/buffer/BinaryWriter.d.ts +46 -0
  5. package/browser/deterministic/AddressMap.d.ts +10 -0
  6. package/browser/deterministic/AddressSet.d.ts +13 -0
  7. package/browser/deterministic/DeterministicMap.d.ts +17 -0
  8. package/browser/deterministic/DeterministicSet.d.ts +13 -0
  9. package/browser/deterministic/Map.d.ts +14 -0
  10. package/browser/event/NetEvent.d.ts +5 -0
  11. package/browser/generators/AddressGenerator.d.ts +3 -0
  12. package/browser/index.js +1 -1
  13. package/browser/keypair/Address.d.ts +23 -0
  14. package/browser/keypair/AddressVerificator.d.ts +15 -4
  15. package/browser/keypair/EcKeyPair.d.ts +15 -12
  16. package/browser/keypair/Wallet.d.ts +12 -5
  17. package/browser/metadata/ContractBaseMetadata.d.ts +3 -4
  18. package/browser/metadata/contracts/wBTC.d.ts +2 -3
  19. package/browser/metadata/tokens.d.ts +1 -1
  20. package/browser/opnet.d.ts +11 -0
  21. package/browser/signer/TweakedSigner.d.ts +2 -2
  22. package/browser/transaction/TransactionFactory.d.ts +6 -6
  23. package/browser/transaction/browser/BrowserSignerBase.d.ts +3 -4
  24. package/browser/transaction/browser/extensions/UnisatSigner.d.ts +3 -4
  25. package/browser/transaction/browser/types/Unisat.d.ts +2 -3
  26. package/browser/transaction/builders/CustomScriptTransaction.d.ts +4 -5
  27. package/browser/transaction/builders/DeploymentTransaction.d.ts +4 -2
  28. package/browser/transaction/builders/FundingTransaction.d.ts +2 -1
  29. package/browser/transaction/builders/MultiSignTransaction.d.ts +6 -6
  30. package/browser/transaction/builders/SharedInteractionTransaction.d.ts +1 -1
  31. package/browser/transaction/builders/TransactionBuilder.d.ts +6 -7
  32. package/browser/transaction/builders/WrapTransaction.d.ts +2 -2
  33. package/browser/transaction/interfaces/ITransactionParameters.d.ts +6 -6
  34. package/browser/transaction/processor/PsbtTransaction.d.ts +3 -4
  35. package/browser/transaction/shared/P2TR_MS.d.ts +1 -2
  36. package/browser/transaction/shared/TweakedTransaction.d.ts +8 -7
  37. package/browser/utils/BufferHelper.d.ts +11 -0
  38. package/browser/utils/types.d.ts +12 -0
  39. package/browser/utxo/OPNetLimitedProvider.d.ts +1 -2
  40. package/build/_version.d.ts +1 -1
  41. package/build/_version.js +1 -1
  42. package/build/abi/ABICoder.d.ts +31 -0
  43. package/build/abi/ABICoder.js +137 -0
  44. package/build/buffer/BinaryReader.d.ts +37 -0
  45. package/build/buffer/BinaryReader.js +192 -0
  46. package/build/buffer/BinaryWriter.d.ts +46 -0
  47. package/build/buffer/BinaryWriter.js +258 -0
  48. package/build/deterministic/AddressMap.d.ts +10 -0
  49. package/build/deterministic/AddressMap.js +46 -0
  50. package/build/deterministic/AddressSet.d.ts +13 -0
  51. package/build/deterministic/AddressSet.js +44 -0
  52. package/build/deterministic/DeterministicMap.d.ts +17 -0
  53. package/build/deterministic/DeterministicMap.js +83 -0
  54. package/build/deterministic/DeterministicSet.d.ts +13 -0
  55. package/build/deterministic/DeterministicSet.js +46 -0
  56. package/build/deterministic/Map.d.ts +14 -0
  57. package/build/deterministic/Map.js +56 -0
  58. package/build/event/NetEvent.d.ts +5 -0
  59. package/build/event/NetEvent.js +6 -0
  60. package/build/generators/AddressGenerator.d.ts +3 -0
  61. package/build/generators/AddressGenerator.js +8 -1
  62. package/build/keypair/Address.d.ts +23 -0
  63. package/build/keypair/Address.js +129 -0
  64. package/build/keypair/AddressVerificator.d.ts +15 -4
  65. package/build/keypair/AddressVerificator.js +79 -3
  66. package/build/keypair/EcKeyPair.d.ts +15 -12
  67. package/build/keypair/EcKeyPair.js +61 -9
  68. package/build/keypair/Wallet.d.ts +12 -5
  69. package/build/keypair/Wallet.js +19 -5
  70. package/build/metadata/ContractBaseMetadata.d.ts +3 -4
  71. package/build/metadata/contracts/wBTC.d.ts +2 -3
  72. package/build/metadata/contracts/wBTC.js +4 -6
  73. package/build/metadata/tokens.d.ts +1 -1
  74. package/build/metadata/tokens.js +19 -15
  75. package/build/opnet.d.ts +11 -0
  76. package/build/opnet.js +11 -0
  77. package/build/signer/TweakedSigner.d.ts +2 -2
  78. package/build/signer/TweakedSigner.js +1 -1
  79. package/build/transaction/TransactionFactory.d.ts +6 -6
  80. package/build/transaction/TransactionFactory.js +3 -2
  81. package/build/transaction/browser/BrowserSignerBase.d.ts +3 -4
  82. package/build/transaction/browser/extensions/UnisatSigner.d.ts +3 -4
  83. package/build/transaction/browser/types/Unisat.d.ts +2 -3
  84. package/build/transaction/builders/CustomScriptTransaction.d.ts +4 -5
  85. package/build/transaction/builders/CustomScriptTransaction.js +3 -3
  86. package/build/transaction/builders/DeploymentTransaction.d.ts +4 -2
  87. package/build/transaction/builders/DeploymentTransaction.js +10 -6
  88. package/build/transaction/builders/FundingTransaction.d.ts +2 -1
  89. package/build/transaction/builders/MultiSignTransaction.d.ts +6 -6
  90. package/build/transaction/builders/SharedInteractionTransaction.d.ts +1 -1
  91. package/build/transaction/builders/SharedInteractionTransaction.js +4 -4
  92. package/build/transaction/builders/TransactionBuilder.d.ts +6 -7
  93. package/build/transaction/builders/UnwrapSegwitTransaction.js +2 -1
  94. package/build/transaction/builders/UnwrapTransaction.js +4 -3
  95. package/build/transaction/builders/WrapTransaction.d.ts +2 -2
  96. package/build/transaction/builders/WrapTransaction.js +5 -6
  97. package/build/transaction/interfaces/ITransactionParameters.d.ts +6 -6
  98. package/build/transaction/processor/PsbtTransaction.d.ts +3 -4
  99. package/build/transaction/shared/P2TR_MS.d.ts +1 -2
  100. package/build/transaction/shared/TweakedTransaction.d.ts +8 -7
  101. package/build/transaction/shared/TweakedTransaction.js +1 -1
  102. package/build/utils/BufferHelper.d.ts +11 -0
  103. package/build/utils/BufferHelper.js +50 -0
  104. package/build/utils/types.d.ts +12 -0
  105. package/build/utils/types.js +1 -0
  106. package/build/utxo/OPNetLimitedProvider.d.ts +1 -2
  107. package/build/utxo/OPNetLimitedProvider.js +1 -1
  108. package/build/verification/TapscriptVerificator.js +3 -2
  109. package/package.json +4 -2
  110. package/src/_version.ts +1 -1
  111. package/src/abi/ABICoder.ts +158 -0
  112. package/src/buffer/BinaryReader.ts +260 -0
  113. package/src/buffer/BinaryWriter.ts +331 -0
  114. package/src/deterministic/AddressMap.ts +57 -0
  115. package/src/deterministic/AddressSet.ts +62 -0
  116. package/src/deterministic/DeterministicMap.ts +88 -0
  117. package/src/deterministic/DeterministicSet.ts +56 -0
  118. package/src/deterministic/Map.ts +66 -0
  119. package/src/event/NetEvent.ts +6 -0
  120. package/src/generators/AddressGenerator.ts +15 -1
  121. package/src/keypair/Address.ts +235 -0
  122. package/src/keypair/AddressVerificator.ts +149 -6
  123. package/src/keypair/EcKeyPair.ts +146 -47
  124. package/src/keypair/Wallet.ts +72 -15
  125. package/src/metadata/ContractBaseMetadata.ts +3 -4
  126. package/src/metadata/contracts/wBTC.ts +8 -9
  127. package/src/metadata/tokens.ts +21 -16
  128. package/src/opnet.ts +13 -0
  129. package/src/signer/TweakedSigner.ts +3 -2
  130. package/src/transaction/TransactionFactory.ts +11 -10
  131. package/src/transaction/browser/BrowserSignerBase.ts +3 -4
  132. package/src/transaction/browser/extensions/UnisatSigner.ts +6 -7
  133. package/src/transaction/browser/types/Unisat.ts +2 -3
  134. package/src/transaction/builders/CustomScriptTransaction.ts +10 -10
  135. package/src/transaction/builders/DeploymentTransaction.ts +23 -9
  136. package/src/transaction/builders/FundingTransaction.ts +2 -1
  137. package/src/transaction/builders/MultiSignTransaction.ts +10 -7
  138. package/src/transaction/builders/SharedInteractionTransaction.ts +5 -5
  139. package/src/transaction/builders/TransactionBuilder.ts +26 -17
  140. package/src/transaction/builders/UnwrapSegwitTransaction.ts +10 -4
  141. package/src/transaction/builders/UnwrapTransaction.ts +5 -19
  142. package/src/transaction/builders/WrapTransaction.ts +7 -13
  143. package/src/transaction/interfaces/ITransactionParameters.ts +7 -6
  144. package/src/transaction/processor/PsbtTransaction.ts +3 -4
  145. package/src/transaction/shared/P2TR_MS.ts +2 -3
  146. package/src/transaction/shared/TweakedTransaction.ts +12 -12
  147. package/src/utils/BufferHelper.ts +71 -0
  148. package/src/utils/types.ts +19 -0
  149. package/src/utxo/OPNetLimitedProvider.ts +3 -8
  150. package/src/verification/TapscriptVerificator.ts +4 -2
@@ -1,4 +1,3 @@
1
- import { Address } from '@btc-vision/bsi-binary';
2
1
  import { Psbt, Transaction } from 'bitcoinjs-lib';
3
2
  import { Output } from 'bitcoinjs-lib/src/transaction.js';
4
3
  import { currentConsensus, currentConsensusConfig } from '../consensus/ConsensusConfig.js';
@@ -30,17 +29,18 @@ import { PSBTTypes } from './psbt/PSBTTypes.js';
30
29
  export interface DeploymentResult {
31
30
  readonly transaction: [string, string];
32
31
 
33
- readonly contractAddress: Address;
34
- readonly p2trAddress: Address;
32
+ readonly contractAddress: string;
33
+ readonly contractPubKey: string;
34
+ readonly p2trAddress: string;
35
35
 
36
36
  readonly utxos: UTXO[];
37
37
  }
38
38
 
39
39
  export interface WrapResult {
40
40
  readonly transaction: [string, string];
41
- readonly vaultAddress: Address;
41
+ readonly vaultAddress: string;
42
42
  readonly amount: bigint;
43
- readonly receiverAddress: Address;
43
+ readonly receiverAddress: string;
44
44
  readonly utxos: UTXO[];
45
45
  }
46
46
 
@@ -277,7 +277,8 @@ export class TransactionFactory {
277
277
 
278
278
  return {
279
279
  transaction: [signedTransaction.toHex(), outTx.toHex()],
280
- contractAddress: finalTransaction.contractAddress,
280
+ contractAddress: finalTransaction.contractAddress.p2tr(deploymentParameters.network),
281
+ contractPubKey: finalTransaction.contractPubKey,
281
282
  p2trAddress: finalTransaction.p2trAddress,
282
283
  utxos: [refundUTXO],
283
284
  };
@@ -344,7 +345,7 @@ export class TransactionFactory {
344
345
  transaction: [signedTransaction.tx.toHex(), outTx.toHex()],
345
346
  vaultAddress: finalTransaction.vault,
346
347
  amount: finalTransaction.amount,
347
- receiverAddress: finalTransaction.receiver,
348
+ receiverAddress: finalTransaction.receiver.p2tr(wrapParameters.network),
348
349
  utxos: this.getUTXOAsTransaction(signedTransaction.tx, wrapParameters.from, 1),
349
350
  };
350
351
  }
@@ -522,12 +523,12 @@ export class TransactionFactory {
522
523
  * Get all new UTXOs of a generated transaction.
523
524
  * @param {TransactionBuilder<TransactionType>} original - The original transaction
524
525
  * @param {Transaction} tx - The transaction
525
- * @param {Address} to - The address to filter
526
+ * @param {string} to - The address to filter
526
527
  */
527
528
  public getAllNewUTXOs(
528
529
  original: TransactionBuilder<TransactionType>,
529
530
  tx: Transaction,
530
- to: Address,
531
+ to: string,
531
532
  ): UTXO[] {
532
533
  const outputs = original.getOutputs();
533
534
 
@@ -613,7 +614,7 @@ export class TransactionFactory {
613
614
  return params.priorityFee;
614
615
  }
615
616
 
616
- private getUTXOAsTransaction(tx: Transaction, to: Address, index: number): UTXO[] {
617
+ private getUTXOAsTransaction(tx: Transaction, to: string, index: number): UTXO[] {
617
618
  if (!tx.outs[index]) return [];
618
619
 
619
620
  const out: Output = tx.outs[index];
@@ -1,5 +1,4 @@
1
1
  import { Network, Psbt, Signer } from 'bitcoinjs-lib';
2
- import { Address } from '@btc-vision/bsi-binary';
3
2
 
4
3
  /**
5
4
  * Create a custom keypair.
@@ -10,10 +9,10 @@ export abstract class CustomKeypair implements Signer {
10
9
 
11
10
  public abstract publicKey: Buffer;
12
11
 
13
- public abstract addresses: Address[];
12
+ public abstract addresses: string[];
14
13
 
15
- public abstract p2tr: Address;
16
- public abstract p2wpkh: Address;
14
+ public abstract p2tr: string;
15
+ public abstract p2wpkh: string;
17
16
 
18
17
  protected constructor() {}
19
18
 
@@ -1,4 +1,3 @@
1
- import { Address } from '@btc-vision/bsi-binary';
2
1
  import { TapScriptSig } from 'bip174/src/lib/interfaces.js';
3
2
  import { Network, networks, Psbt } from 'bitcoinjs-lib';
4
3
  import { ECPairInterface } from 'ecpair';
@@ -24,9 +23,9 @@ export class UnisatSigner extends CustomKeypair {
24
23
  }
25
24
  }
26
25
 
27
- private _p2tr: Address | undefined;
26
+ private _p2tr: string | undefined;
28
27
 
29
- public get p2tr(): Address {
28
+ public get p2tr(): string {
30
29
  if (!this._p2tr) {
31
30
  throw new Error('P2TR address not set');
32
31
  }
@@ -34,9 +33,9 @@ export class UnisatSigner extends CustomKeypair {
34
33
  return this._p2tr;
35
34
  }
36
35
 
37
- private _p2wpkh: Address | undefined;
36
+ private _p2wpkh: string | undefined;
38
37
 
39
- public get p2wpkh(): Address {
38
+ public get p2wpkh(): string {
40
39
  if (!this._p2wpkh) {
41
40
  throw new Error('P2PKH address not set');
42
41
  }
@@ -44,9 +43,9 @@ export class UnisatSigner extends CustomKeypair {
44
43
  return this._p2wpkh;
45
44
  }
46
45
 
47
- private _addresses: Address[] | undefined;
46
+ private _addresses: string[] | undefined;
48
47
 
49
- public get addresses(): Address[] {
48
+ public get addresses(): string[] {
50
49
  if (!this._addresses) {
51
50
  throw new Error('Addresses not set');
52
51
  }
@@ -1,4 +1,3 @@
1
- import { Address } from '@btc-vision/bsi-binary';
2
1
  import { Web3Provider } from '../Web3Provider.js';
3
2
 
4
3
  export enum UnisatNetwork {
@@ -45,7 +44,7 @@ export interface ToSignInputPublicKey extends ToSignInputBase {
45
44
  }
46
45
 
47
46
  export interface ToSignInputAddress extends ToSignInputBase {
48
- readonly address: Address;
47
+ readonly address: string;
49
48
  }
50
49
 
51
50
  export type ToSignInput = ToSignInputPublicKey | ToSignInputAddress;
@@ -59,7 +58,7 @@ export interface Unisat {
59
58
  web3?: Web3Provider;
60
59
 
61
60
  sendBitcoin(
62
- toAddress: Address,
61
+ toAddress: string,
63
62
  satoshis: number,
64
63
  options: { feeRate: number; memo?: string; memos?: string[] },
65
64
  ): Promise<string>;
@@ -2,7 +2,6 @@ import { Taptree } from 'bitcoinjs-lib/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 { Address } from '@btc-vision/bsi-binary';
6
5
  import { crypto as bitCrypto, Payment, Psbt, Signer, Stack } from 'bitcoinjs-lib';
7
6
  import { TransactionBuilder } from './TransactionBuilder.js';
8
7
  import { CustomGenerator } from '../../generators/builders/CustomGenerator.js';
@@ -11,12 +10,13 @@ import { EcKeyPair } from '../../keypair/EcKeyPair.js';
11
10
  import { AddressGenerator } from '../../generators/AddressGenerator.js';
12
11
  import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
13
12
  import { PsbtInput } from 'bip174/src/lib/interfaces.js';
13
+ import { ECPairInterface } from 'ecpair';
14
14
 
15
15
  export interface ICustomTransactionParameters extends SharedInteractionParameters {
16
16
  readonly script: (Buffer | Stack)[];
17
17
  readonly witnesses: Buffer[];
18
18
 
19
- readonly to: Address;
19
+ readonly to: string;
20
20
  }
21
21
 
22
22
  /**
@@ -30,7 +30,7 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
30
30
  * The contract address
31
31
  * @protected
32
32
  */
33
- protected readonly _scriptAddress: Address;
33
+ protected readonly _scriptAddress: string;
34
34
  /**
35
35
  * The tap leaf script
36
36
  * @private
@@ -72,7 +72,7 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
72
72
  * The contract signer
73
73
  * @private
74
74
  */
75
- private readonly contractSigner: Signer;
75
+ private readonly contractSigner: Signer | ECPairInterface;
76
76
 
77
77
  /**
78
78
  * The contract salt random bytes
@@ -112,14 +112,14 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
112
112
  /**
113
113
  * @description Get the contract address (PKSH)
114
114
  */
115
- public get scriptAddress(): Address {
115
+ public get scriptAddress(): string {
116
116
  return this._scriptAddress;
117
117
  }
118
118
 
119
119
  /**
120
120
  * @description Get the P2TR address
121
121
  */
122
- public get p2trAddress(): Address {
122
+ public get p2trAddress(): string {
123
123
  return this.to || this.getScriptAddress();
124
124
  }
125
125
 
@@ -136,7 +136,7 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
136
136
  * @protected
137
137
  */
138
138
  protected contractSignerXOnlyPubKey(): Buffer {
139
- return toXOnly(this.contractSigner.publicKey);
139
+ return toXOnly(Buffer.from(this.contractSigner.publicKey));
140
140
  }
141
141
 
142
142
  /**
@@ -261,7 +261,7 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
261
261
  if (!this.tapLeafScript) {
262
262
  throw new Error('Tap leaf script is required');
263
263
  }
264
-
264
+
265
265
  const scriptSolution = this.witnesses;
266
266
  const witness = scriptSolution
267
267
  .concat(this.tapLeafScript.script)
@@ -277,10 +277,10 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
277
277
  * @private
278
278
  */
279
279
  private getPubKeys(): Buffer[] {
280
- const pubkeys = [this.signer.publicKey];
280
+ const pubkeys = [Buffer.from(this.signer.publicKey)];
281
281
 
282
282
  if (this.contractSigner) {
283
- pubkeys.push(this.contractSigner.publicKey);
283
+ pubkeys.push(Buffer.from(this.contractSigner.publicKey));
284
284
  }
285
285
 
286
286
  return pubkeys;
@@ -10,9 +10,9 @@ import { EcKeyPair } from '../../keypair/EcKeyPair.js';
10
10
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
11
11
  import { PsbtInput } from 'bip174/src/lib/interfaces.js';
12
12
  import { Compressor } from '../../bytecode/Compressor.js';
13
- import { AddressGenerator } from '../../generators/AddressGenerator.js';
14
- import { Address } from '@btc-vision/bsi-binary';
15
13
  import { SharedInteractionTransaction } from './SharedInteractionTransaction.js';
14
+ import { ECPairInterface } from 'ecpair';
15
+ import { Address } from '../../keypair/Address.js';
16
16
 
17
17
  export class DeploymentTransaction extends TransactionBuilder<TransactionType.DEPLOYMENT> {
18
18
  public static readonly MAXIMUM_CONTRACT_SIZE = 128 * 1024;
@@ -75,7 +75,13 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
75
75
  * The contract signer
76
76
  * @private
77
77
  */
78
- private readonly contractSigner: Signer;
78
+ private readonly contractSigner: Signer | ECPairInterface;
79
+
80
+ /**
81
+ * The contract public key
82
+ * @private
83
+ */
84
+ private readonly _contractPubKey: string;
79
85
 
80
86
  /**
81
87
  * The contract salt random bytes
@@ -100,7 +106,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
100
106
  this.contractSigner = EcKeyPair.fromSeedKeyPair(this.contractSeed, this.network);
101
107
 
102
108
  this.deploymentGenerator = new DeploymentGenerator(
103
- this.signer.publicKey,
109
+ Buffer.from(this.signer.publicKey),
104
110
  this.contractSignerXOnlyPubKey(),
105
111
  this.network,
106
112
  );
@@ -115,7 +121,15 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
115
121
 
116
122
  this.internalInit();
117
123
 
118
- this._contractAddress = AddressGenerator.generatePKSH(this.contractSeed, this.network);
124
+ this._contractPubKey = '0x' + this.contractSigner.publicKey.toString('hex');
125
+ this._contractAddress = new Address(this.contractSigner.publicKey); //AddressGenerator.generatePKSH(this.contractSeed, this.network);
126
+ }
127
+
128
+ /**
129
+ * Get the contract public key
130
+ */
131
+ public get contractPubKey(): string {
132
+ return this._contractPubKey;
119
133
  }
120
134
 
121
135
  /**
@@ -128,7 +142,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
128
142
  /**
129
143
  * @description Get the P2TR address
130
144
  */
131
- public get p2trAddress(): Address {
145
+ public get p2trAddress(): string {
132
146
  return this.to || this.getScriptAddress();
133
147
  }
134
148
 
@@ -145,7 +159,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
145
159
  * @protected
146
160
  */
147
161
  protected contractSignerXOnlyPubKey(): Buffer {
148
- return toXOnly(this.contractSigner.publicKey);
162
+ return toXOnly(Buffer.from(this.contractSigner.publicKey));
149
163
  }
150
164
 
151
165
  /**
@@ -323,10 +337,10 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
323
337
  * @private
324
338
  */
325
339
  private getPubKeys(): Buffer[] {
326
- const pubkeys = [this.signer.publicKey];
340
+ const pubkeys = [Buffer.from(this.signer.publicKey)];
327
341
 
328
342
  if (this.contractSigner) {
329
- pubkeys.push(this.contractSigner.publicKey);
343
+ pubkeys.push(Buffer.from(this.contractSigner.publicKey));
330
344
  }
331
345
 
332
346
  return pubkeys;
@@ -2,6 +2,7 @@ import { TransactionType } from '../enums/TransactionType.js';
2
2
  import { IFundingTransactionParameters } from '../interfaces/ITransactionParameters.js';
3
3
  import { Signer } from 'bitcoinjs-lib';
4
4
  import { TransactionBuilder } from './TransactionBuilder.js';
5
+ import { ECPairInterface } from 'ecpair';
5
6
 
6
7
  export class FundingTransaction extends TransactionBuilder<TransactionType.FUNDING> {
7
8
  public readonly type: TransactionType.FUNDING = TransactionType.FUNDING;
@@ -64,7 +65,7 @@ export class FundingTransaction extends TransactionBuilder<TransactionType.FUNDI
64
65
  }
65
66
  }
66
67
 
67
- protected override getSignerKey(): Signer {
68
+ protected override getSignerKey(): Signer | ECPairInterface {
68
69
  return this.signer;
69
70
  }
70
71
  }
@@ -6,10 +6,10 @@ import { TransactionType } from '../enums/TransactionType.js';
6
6
  import { ITransactionParameters } from '../interfaces/ITransactionParameters.js';
7
7
  import { MultiSignGenerator } from '../../generators/builders/MultiSignGenerator.js';
8
8
  import { PsbtInputExtended, PsbtOutputExtended } from '../interfaces/Tap.js';
9
- import { Address } from '@btc-vision/bsi-binary';
10
9
  import { UTXO } from '../../utxo/interfaces/IUTXO.js';
11
10
  import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
12
11
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
12
+ import { ECPairInterface } from 'ecpair';
13
13
 
14
14
  export interface MultiSignParameters
15
15
  extends Omit<ITransactionParameters, 'priorityFee' | 'signer'> {
@@ -18,9 +18,9 @@ export interface MultiSignParameters
18
18
  readonly from?: undefined;
19
19
  readonly to?: undefined;
20
20
  readonly psbt?: Psbt;
21
- readonly receiver: Address;
21
+ readonly receiver: string;
22
22
  readonly requestedAmount: bigint;
23
- readonly refundVault: Address;
23
+ readonly refundVault: string;
24
24
  }
25
25
 
26
26
  export interface MultiSignFromBase64Params extends Omit<MultiSignParameters, 'psbt'> {
@@ -61,8 +61,8 @@ export class MultiSignTransaction extends TransactionBuilder<TransactionType.MUL
61
61
  protected readonly originalInputCount: number = 0;
62
62
  protected readonly requestedAmount: bigint;
63
63
 
64
- protected readonly receiver: Address;
65
- protected readonly refundVault: Address;
64
+ protected readonly receiver: string;
65
+ protected readonly refundVault: string;
66
66
  /**
67
67
  * @description Sign hash types
68
68
  * @protected
@@ -172,7 +172,7 @@ export class MultiSignTransaction extends TransactionBuilder<TransactionType.MUL
172
172
  */
173
173
  public static signPartial(
174
174
  psbt: Psbt,
175
- signer: Signer,
175
+ signer: Signer | ECPairInterface,
176
176
  originalInputCount: number,
177
177
  minimums: number[],
178
178
  ): {
@@ -498,7 +498,10 @@ export class MultiSignTransaction extends TransactionBuilder<TransactionType.MUL
498
498
  * @returns {Promise<boolean>}
499
499
  * @throws {Error} - If something went wrong while building the transaction
500
500
  */
501
- protected override async internalBuildTransaction(transaction: Psbt, checkPartialSigs: boolean = false): Promise<boolean> {
501
+ protected override async internalBuildTransaction(
502
+ transaction: Psbt,
503
+ checkPartialSigs: boolean = false,
504
+ ): Promise<boolean> {
502
505
  const inputs: PsbtInputExtended[] = this.getInputs();
503
506
  const outputs: PsbtOutputExtended[] = this.getOutputs();
504
507
 
@@ -50,7 +50,7 @@ export abstract class SharedInteractionTransaction<
50
50
  * Script signer for the interaction
51
51
  * @protected
52
52
  */
53
- protected readonly scriptSigner: Signer;
53
+ protected readonly scriptSigner: Signer | ECPairInterface;
54
54
 
55
55
  /**
56
56
  * Disable auto refund
@@ -73,7 +73,7 @@ export abstract class SharedInteractionTransaction<
73
73
  this.scriptSigner = this.generateKeyPairFromSeed();
74
74
 
75
75
  this.calldataGenerator = new CalldataGenerator(
76
- this.signer.publicKey,
76
+ Buffer.from(this.signer.publicKey),
77
77
  this.scriptSignerXOnlyPubKey(),
78
78
  this.network,
79
79
  );
@@ -113,7 +113,7 @@ export abstract class SharedInteractionTransaction<
113
113
  * @returns {Buffer} The internal pubkey as an x-only key
114
114
  */
115
115
  protected scriptSignerXOnlyPubKey(): Buffer {
116
- return toXOnly(this.scriptSigner.publicKey);
116
+ return toXOnly(Buffer.from(this.scriptSigner.publicKey));
117
117
  }
118
118
 
119
119
  /**
@@ -362,10 +362,10 @@ export abstract class SharedInteractionTransaction<
362
362
  * @returns {Buffer[]} The public keys
363
363
  */
364
364
  private getPubKeys(): Buffer[] {
365
- const pubkeys = [this.signer.publicKey];
365
+ const pubkeys = [Buffer.from(this.signer.publicKey)];
366
366
 
367
367
  if (this.scriptSigner) {
368
- pubkeys.push(this.scriptSigner.publicKey);
368
+ pubkeys.push(Buffer.from(this.scriptSigner.publicKey));
369
369
  }
370
370
 
371
371
  return pubkeys;
@@ -8,7 +8,6 @@ import {
8
8
  ITransactionParameters,
9
9
  } from '../interfaces/ITransactionParameters.js';
10
10
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
11
- import { Address } from '@btc-vision/bsi-binary';
12
11
  import { UTXO } from '../../utxo/interfaces/IUTXO.js';
13
12
  import { ECPairInterface } from 'ecpair';
14
13
  import { AddressVerificator } from '../../keypair/AddressVerificator.js';
@@ -43,65 +42,79 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
43
42
  * @description Cost in satoshis of the transaction fee
44
43
  */
45
44
  public transactionFee: bigint = 0n;
45
+
46
46
  /**
47
47
  * @description The estimated fees of the transaction
48
48
  */
49
49
  public estimatedFees: bigint = 0n;
50
+
50
51
  /**
51
52
  * @param {ITransactionParameters} parameters - The transaction parameters
52
53
  */
53
-
54
54
  public optionalOutputs: PsbtOutputExtended[] | undefined;
55
+
55
56
  /**
56
57
  * @description The transaction itself.
57
58
  */
58
59
  protected transaction: Psbt;
60
+
59
61
  /**
60
62
  * @description Inputs to update later on.
61
63
  */
62
64
  protected readonly updateInputs: UpdateInput[] = [];
65
+
63
66
  /**
64
67
  * @description The outputs of the transaction
65
68
  */
66
69
  protected readonly outputs: PsbtOutputExtended[] = [];
70
+
67
71
  /**
68
72
  * @description Output that will be used to pay the fees
69
73
  */
70
74
  protected feeOutput: PsbtOutputExtended | null = null;
75
+
71
76
  /**
72
77
  * @description The total amount of satoshis in the inputs
73
78
  */
74
79
  protected totalInputAmount: bigint;
80
+
75
81
  /**
76
82
  * @description The signer of the transaction
77
83
  */
78
- protected readonly signer: Signer;
84
+ protected readonly signer: Signer | ECPairInterface;
85
+
79
86
  /**
80
87
  * @description The network where the transaction will be broadcasted
81
88
  */
82
89
  protected readonly network: Network;
90
+
83
91
  /**
84
92
  * @description The fee rate of the transaction
85
93
  */
86
94
  protected readonly feeRate: number;
95
+
87
96
  /**
88
97
  * @description The opnet priority fee of the transaction
89
98
  */
90
99
  protected priorityFee: bigint;
100
+
91
101
  /**
92
102
  * @description The utxos used in the transaction
93
103
  */
94
104
  protected utxos: UTXO[];
105
+
95
106
  /**
96
107
  * @description The address where the transaction is sent to
97
108
  * @protected
98
109
  */
99
- protected to: Address | undefined;
110
+ protected to: string | undefined;
111
+
100
112
  /**
101
113
  * @description The address where the transaction is sent from
102
114
  * @protected
103
115
  */
104
- protected from: Address;
116
+ protected from: string;
117
+
105
118
  /**
106
119
  * @description The maximum fee rate of the transaction
107
120
  */
@@ -131,11 +144,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
131
144
 
132
145
  this.optionalOutputs = parameters.optionalOutputs;
133
146
 
134
- this.from = TransactionBuilder.getFrom(
135
- parameters.from,
136
- this.signer as ECPairInterface,
137
- this.network,
138
- );
147
+ this.from = TransactionBuilder.getFrom(parameters.from, this.signer, this.network);
139
148
 
140
149
  this.totalInputAmount = this.calculateTotalUTXOAmount();
141
150
 
@@ -151,9 +160,9 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
151
160
 
152
161
  public static getFrom(
153
162
  from: string | undefined,
154
- keypair: ECPairInterface,
163
+ keypair: ECPairInterface | Signer,
155
164
  network: Network,
156
- ): Address {
165
+ ): string {
157
166
  return from || EcKeyPair.getTaprootAddress(keypair, network);
158
167
  }
159
168
 
@@ -213,9 +222,9 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
213
222
 
214
223
  /**
215
224
  * Set the destination address of the transaction
216
- * @param {Address} address - The address to set
225
+ * @param {string} address - The address to set
217
226
  */
218
- public setDestinationAddress(address: Address): void {
227
+ public setDestinationAddress(address: string): void {
219
228
  this.to = address; // this.getScriptAddress()
220
229
  }
221
230
 
@@ -344,7 +353,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
344
353
  /**
345
354
  * Receiver address.
346
355
  * @public
347
- * @returns {Address} - The receiver address
356
+ * @returns {string} - The receiver address
348
357
  */
349
358
  public toAddress(): string | undefined {
350
359
  return this.to;
@@ -352,9 +361,9 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
352
361
 
353
362
  /**
354
363
  * @description Returns the script address
355
- * @returns {Address} - The script address
364
+ * @returns {string} - The script address
356
365
  */
357
- public address(): Address | undefined {
366
+ public address(): string | undefined {
358
367
  return this.tapData?.address;
359
368
  }
360
369
 
@@ -3,13 +3,16 @@ 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
- import { ABICoder, BinaryWriter, Selector } from '@btc-vision/bsi-binary';
7
6
  import { wBTC } from '../../metadata/contracts/wBTC.js';
8
7
  import { payments, Psbt, Signer } from 'bitcoinjs-lib';
9
8
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
10
9
  import { IWBTCUTXODocument, PsbtTransaction, VaultUTXOs } from '../processor/PsbtTransaction.js';
11
10
  import { PsbtInputExtended, PsbtOutputExtended } from '../interfaces/Tap.js';
12
11
  import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
12
+ import { ECPairInterface } from 'ecpair';
13
+ import { Selector } from '../../utils/types.js';
14
+ import { ABICoder } from '../../abi/ABICoder.js';
15
+ import { BinaryWriter } from '../../buffer/BinaryWriter.js';
13
16
 
14
17
  const abiCoder: ABICoder = new ABICoder();
15
18
 
@@ -196,7 +199,10 @@ export class UnwrapSegwitTransaction extends SharedInteractionTransaction<Transa
196
199
  * @returns {Promise<boolean>}
197
200
  * @throws {Error} - If something went wrong while building the transaction
198
201
  */
199
- protected async internalBuildTransaction(transaction: Psbt, checkPartialSigs: boolean = false): Promise<boolean> {
202
+ protected async internalBuildTransaction(
203
+ transaction: Psbt,
204
+ checkPartialSigs: boolean = false,
205
+ ): Promise<boolean> {
200
206
  if (transaction.data.inputs.length === 0) {
201
207
  const inputs: PsbtInputExtended[] = this.getInputs();
202
208
  const outputs: PsbtOutputExtended[] = this.getOutputs();
@@ -300,12 +306,12 @@ export class UnwrapSegwitTransaction extends SharedInteractionTransaction<Transa
300
306
  /**
301
307
  * @description Add vault inputs to the transaction
302
308
  * @param {VaultUTXOs} vault The vault UTXOs
303
- * @param {Signer} [firstSigner] The first signer
309
+ * @param {Signer | ECPairInterface} [firstSigner] The first signer
304
310
  * @private
305
311
  */
306
312
  private async addVaultInputs(
307
313
  vault: VaultUTXOs,
308
- firstSigner: Signer = this.signer,
314
+ firstSigner: Signer | ECPairInterface = this.signer,
309
315
  ): Promise<void> {
310
316
  const p2wshOutput = this.generateMultiSignRedeemScript(vault.publicKeys, vault.minimum);
311
317
  for (const utxo of vault.utxos) {