@btc-vision/transaction 1.0.113 → 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 (134) 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 +1 -2
  15. package/browser/keypair/EcKeyPair.d.ts +9 -9
  16. package/browser/keypair/Wallet.d.ts +11 -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/transaction/TransactionFactory.d.ts +6 -6
  22. package/browser/transaction/browser/BrowserSignerBase.d.ts +3 -4
  23. package/browser/transaction/browser/extensions/UnisatSigner.d.ts +3 -4
  24. package/browser/transaction/browser/types/Unisat.d.ts +2 -3
  25. package/browser/transaction/builders/CustomScriptTransaction.d.ts +4 -5
  26. package/browser/transaction/builders/DeploymentTransaction.d.ts +4 -2
  27. package/browser/transaction/builders/MultiSignTransaction.d.ts +4 -5
  28. package/browser/transaction/builders/TransactionBuilder.d.ts +5 -6
  29. package/browser/transaction/builders/WrapTransaction.d.ts +2 -2
  30. package/browser/transaction/interfaces/ITransactionParameters.d.ts +6 -6
  31. package/browser/transaction/processor/PsbtTransaction.d.ts +3 -4
  32. package/browser/transaction/shared/P2TR_MS.d.ts +1 -2
  33. package/browser/utils/BufferHelper.d.ts +11 -0
  34. package/browser/utils/types.d.ts +12 -0
  35. package/browser/utxo/OPNetLimitedProvider.d.ts +1 -2
  36. package/build/_version.d.ts +1 -1
  37. package/build/_version.js +1 -1
  38. package/build/abi/ABICoder.d.ts +31 -0
  39. package/build/abi/ABICoder.js +137 -0
  40. package/build/buffer/BinaryReader.d.ts +37 -0
  41. package/build/buffer/BinaryReader.js +192 -0
  42. package/build/buffer/BinaryWriter.d.ts +46 -0
  43. package/build/buffer/BinaryWriter.js +258 -0
  44. package/build/deterministic/AddressMap.d.ts +10 -0
  45. package/build/deterministic/AddressMap.js +46 -0
  46. package/build/deterministic/AddressSet.d.ts +13 -0
  47. package/build/deterministic/AddressSet.js +44 -0
  48. package/build/deterministic/DeterministicMap.d.ts +17 -0
  49. package/build/deterministic/DeterministicMap.js +83 -0
  50. package/build/deterministic/DeterministicSet.d.ts +13 -0
  51. package/build/deterministic/DeterministicSet.js +46 -0
  52. package/build/deterministic/Map.d.ts +14 -0
  53. package/build/deterministic/Map.js +56 -0
  54. package/build/event/NetEvent.d.ts +5 -0
  55. package/build/event/NetEvent.js +6 -0
  56. package/build/generators/AddressGenerator.d.ts +3 -0
  57. package/build/generators/AddressGenerator.js +8 -1
  58. package/build/keypair/Address.d.ts +23 -0
  59. package/build/keypair/Address.js +129 -0
  60. package/build/keypair/AddressVerificator.d.ts +1 -2
  61. package/build/keypair/AddressVerificator.js +7 -2
  62. package/build/keypair/EcKeyPair.d.ts +9 -9
  63. package/build/keypair/EcKeyPair.js +9 -2
  64. package/build/keypair/Wallet.d.ts +11 -5
  65. package/build/keypair/Wallet.js +14 -1
  66. package/build/metadata/ContractBaseMetadata.d.ts +3 -4
  67. package/build/metadata/contracts/wBTC.d.ts +2 -3
  68. package/build/metadata/contracts/wBTC.js +4 -6
  69. package/build/metadata/tokens.d.ts +1 -1
  70. package/build/metadata/tokens.js +19 -15
  71. package/build/opnet.d.ts +11 -0
  72. package/build/opnet.js +11 -0
  73. package/build/transaction/TransactionFactory.d.ts +6 -6
  74. package/build/transaction/TransactionFactory.js +3 -2
  75. package/build/transaction/browser/BrowserSignerBase.d.ts +3 -4
  76. package/build/transaction/browser/extensions/UnisatSigner.d.ts +3 -4
  77. package/build/transaction/browser/types/Unisat.d.ts +2 -3
  78. package/build/transaction/builders/CustomScriptTransaction.d.ts +4 -5
  79. package/build/transaction/builders/DeploymentTransaction.d.ts +4 -2
  80. package/build/transaction/builders/DeploymentTransaction.js +6 -2
  81. package/build/transaction/builders/MultiSignTransaction.d.ts +4 -5
  82. package/build/transaction/builders/TransactionBuilder.d.ts +5 -6
  83. package/build/transaction/builders/UnwrapSegwitTransaction.js +2 -1
  84. package/build/transaction/builders/UnwrapTransaction.js +2 -1
  85. package/build/transaction/builders/WrapTransaction.d.ts +2 -2
  86. package/build/transaction/builders/WrapTransaction.js +5 -6
  87. package/build/transaction/interfaces/ITransactionParameters.d.ts +6 -6
  88. package/build/transaction/processor/PsbtTransaction.d.ts +3 -4
  89. package/build/transaction/shared/P2TR_MS.d.ts +1 -2
  90. package/build/utils/BufferHelper.d.ts +11 -0
  91. package/build/utils/BufferHelper.js +50 -0
  92. package/build/utils/types.d.ts +12 -0
  93. package/build/utils/types.js +1 -0
  94. package/build/utxo/OPNetLimitedProvider.d.ts +1 -2
  95. package/build/utxo/OPNetLimitedProvider.js +1 -1
  96. package/build/verification/TapscriptVerificator.js +3 -2
  97. package/package.json +3 -2
  98. package/src/_version.ts +1 -1
  99. package/src/abi/ABICoder.ts +158 -0
  100. package/src/buffer/BinaryReader.ts +260 -0
  101. package/src/buffer/BinaryWriter.ts +331 -0
  102. package/src/deterministic/AddressMap.ts +57 -0
  103. package/src/deterministic/AddressSet.ts +62 -0
  104. package/src/deterministic/DeterministicMap.ts +88 -0
  105. package/src/deterministic/DeterministicSet.ts +56 -0
  106. package/src/deterministic/Map.ts +66 -0
  107. package/src/event/NetEvent.ts +6 -0
  108. package/src/generators/AddressGenerator.ts +15 -1
  109. package/src/keypair/Address.ts +235 -0
  110. package/src/keypair/AddressVerificator.ts +9 -5
  111. package/src/keypair/EcKeyPair.ts +39 -37
  112. package/src/keypair/Wallet.ts +61 -12
  113. package/src/metadata/ContractBaseMetadata.ts +3 -4
  114. package/src/metadata/contracts/wBTC.ts +8 -9
  115. package/src/metadata/tokens.ts +21 -16
  116. package/src/opnet.ts +13 -0
  117. package/src/transaction/TransactionFactory.ts +11 -10
  118. package/src/transaction/browser/BrowserSignerBase.ts +3 -4
  119. package/src/transaction/browser/extensions/UnisatSigner.ts +6 -7
  120. package/src/transaction/browser/types/Unisat.ts +2 -3
  121. package/src/transaction/builders/CustomScriptTransaction.ts +4 -5
  122. package/src/transaction/builders/DeploymentTransaction.ts +17 -4
  123. package/src/transaction/builders/MultiSignTransaction.ts +4 -5
  124. package/src/transaction/builders/TransactionBuilder.ts +8 -9
  125. package/src/transaction/builders/UnwrapSegwitTransaction.ts +3 -1
  126. package/src/transaction/builders/UnwrapTransaction.ts +3 -17
  127. package/src/transaction/builders/WrapTransaction.ts +7 -8
  128. package/src/transaction/interfaces/ITransactionParameters.ts +7 -6
  129. package/src/transaction/processor/PsbtTransaction.ts +3 -4
  130. package/src/transaction/shared/P2TR_MS.ts +2 -3
  131. package/src/utils/BufferHelper.ts +71 -0
  132. package/src/utils/types.ts +19 -0
  133. package/src/utxo/OPNetLimitedProvider.ts +3 -8
  134. package/src/verification/TapscriptVerificator.ts +4 -2
@@ -1,26 +1,31 @@
1
- import { Address } from '@btc-vision/bsi-binary';
2
1
  import { ChainId } from '../network/ChainId.js';
2
+ import { Address } from '../keypair/Address.js';
3
+
4
+ function deadAddress(): Address {
5
+ return Address.dead();
6
+ }
3
7
 
4
8
  // Addresses Regtest
5
- export const FACTORY_ADDRESS_REGTEST: Address = 'bcrt1q9pf9fnpch9z2qrp5e3dgr2avzu3mypq3km2k40';
6
- export const POOL_ADDRESS_REGTEST: Address = 'bcrt1qg87nx9v9ln3qyadcn0llekzjn0hx8js46ztwky';
7
- export const WBTC_ADDRESS_REGTEST: Address = 'bcrt1qamv2ejattjgsc6k3yf3zqrp0wpuyedqgjmwx0v';
8
- export const MOTO_ADDRESS_REGTEST: Address = 'bcrt1qw8w4ejas2k22y54avv7hgrslg3cd0hme58h28r';
9
- export const ROUTER_ADDRESS_REGTEST: Address = 'bcrt1q9yd6mk324k0q4krmlxjky0pk65ul6hkf4u35e6';
9
+ export const FACTORY_ADDRESS_REGTEST: Address = deadAddress();
10
+
11
+ export const POOL_ADDRESS_REGTEST: Address = deadAddress();
12
+ export const WBTC_ADDRESS_REGTEST: Address = deadAddress();
13
+ export const MOTO_ADDRESS_REGTEST: Address = deadAddress();
14
+ export const ROUTER_ADDRESS_REGTEST: Address = deadAddress();
10
15
 
11
16
  // Addresses Testnet
12
- export const FACTORY_ADDRESS_TESTNET: Address = 'tb1qgev5kldhp5zvg6j8t9vl6x4phkrwn8nk9felxh';
13
- export const POOL_ADDRESS_TESTNET: Address = 'tb1q6a7yw353hjmresphupytw5vczpqxtg4yrupayk';
14
- export const WBTC_ADDRESS_TESTNET: Address = 'tb1qp28xna6pv47x6wflcplhu0a9hkld5shtvjx6xv';
15
- export const MOTO_ADDRESS_TESTNET: Address = 'tb1q4tyhf8hpu04qjj3qaag20knun0spctultxzakw';
16
- export const ROUTER_ADDRESS_TESTNET: Address = 'tb1qnh9mj95nnej25dwhjvvsppwmdm0myhxv7tllgt';
17
+ export const FACTORY_ADDRESS_TESTNET: Address = deadAddress();
18
+ export const POOL_ADDRESS_TESTNET: Address = deadAddress();
19
+ export const WBTC_ADDRESS_TESTNET: Address = deadAddress();
20
+ export const MOTO_ADDRESS_TESTNET: Address = deadAddress();
21
+ export const ROUTER_ADDRESS_TESTNET: Address = deadAddress();
17
22
 
18
23
  // Addresses Fractal
19
- export const FACTORY_ADDRESS_FRACTAL: Address = 'bc1qr4g85824m58wu0zffjtnf56n425fp0e8azhc7q';
20
- export const POOL_ADDRESS_FRACTAL: Address = 'bc1qv55cht4zzlt29ea7vdgwsedsn63a2sxtkgpv6h';
21
- export const WBTC_ADDRESS_FRACTAL: Address = 'bc1qdtzlucslvrvu4useyh9r69supqrw3w4xn9t4yv';
22
- export const MOTO_ADDRESS_FRACTAL: Address = 'bc1qfzq6w5uvgg5489egv0lj4shlqx4dagqt0ewdnu';
23
- export const ROUTER_ADDRESS_FRACTAL: Address = 'bc1q9w2zvmkzlezt2fu34u57y9vuw6rll5sp2090kn';
24
+ export const FACTORY_ADDRESS_FRACTAL: Address = deadAddress();
25
+ export const POOL_ADDRESS_FRACTAL: Address = deadAddress();
26
+ export const WBTC_ADDRESS_FRACTAL: Address = deadAddress();
27
+ export const MOTO_ADDRESS_FRACTAL: Address = deadAddress();
28
+ export const ROUTER_ADDRESS_FRACTAL: Address = deadAddress();
24
29
 
25
30
  export enum OPNetNetwork {
26
31
  Mainnet = 'mainnet',
package/src/opnet.ts CHANGED
@@ -73,6 +73,19 @@ export * from './consensus/ConsensusConfig.js';
73
73
  export * from './consensus/Consensus.js';
74
74
  export * from './consensus/metadata/RoswellConsensus.js';
75
75
 
76
+ /** Binary */
77
+ export * from './utils/BufferHelper.js';
78
+ export * from './utils/types.js';
79
+ export * from './keypair/Address.js';
80
+ export * from './event/NetEvent.js';
81
+ export * from './deterministic/DeterministicMap.js';
82
+ export * from './deterministic/DeterministicSet.js';
83
+ export * from './deterministic/AddressMap.js';
84
+ export * from './deterministic/AddressSet.js';
85
+ export * from './abi/ABICoder.js';
86
+ export * from './buffer/BinaryWriter.js';
87
+ export * from './buffer/BinaryReader.js';
88
+
76
89
  /** Custom signers */
77
90
  export * from './transaction/browser/BrowserSignerBase.js';
78
91
  export * from './transaction/browser/extensions/UnisatSigner.js';
@@ -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';
@@ -17,7 +16,7 @@ export interface ICustomTransactionParameters extends SharedInteractionParameter
17
16
  readonly script: (Buffer | Stack)[];
18
17
  readonly witnesses: Buffer[];
19
18
 
20
- readonly to: Address;
19
+ readonly to: string;
21
20
  }
22
21
 
23
22
  /**
@@ -31,7 +30,7 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
31
30
  * The contract address
32
31
  * @protected
33
32
  */
34
- protected readonly _scriptAddress: Address;
33
+ protected readonly _scriptAddress: string;
35
34
  /**
36
35
  * The tap leaf script
37
36
  * @private
@@ -113,14 +112,14 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
113
112
  /**
114
113
  * @description Get the contract address (PKSH)
115
114
  */
116
- public get scriptAddress(): Address {
115
+ public get scriptAddress(): string {
117
116
  return this._scriptAddress;
118
117
  }
119
118
 
120
119
  /**
121
120
  * @description Get the P2TR address
122
121
  */
123
- public get p2trAddress(): Address {
122
+ public get p2trAddress(): string {
124
123
  return this.to || this.getScriptAddress();
125
124
  }
126
125
 
@@ -10,10 +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';
16
14
  import { ECPairInterface } from 'ecpair';
15
+ import { Address } from '../../keypair/Address.js';
17
16
 
18
17
  export class DeploymentTransaction extends TransactionBuilder<TransactionType.DEPLOYMENT> {
19
18
  public static readonly MAXIMUM_CONTRACT_SIZE = 128 * 1024;
@@ -78,6 +77,12 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
78
77
  */
79
78
  private readonly contractSigner: Signer | ECPairInterface;
80
79
 
80
+ /**
81
+ * The contract public key
82
+ * @private
83
+ */
84
+ private readonly _contractPubKey: string;
85
+
81
86
  /**
82
87
  * The contract salt random bytes
83
88
  * @private
@@ -116,7 +121,15 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
116
121
 
117
122
  this.internalInit();
118
123
 
119
- 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;
120
133
  }
121
134
 
122
135
  /**
@@ -129,7 +142,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
129
142
  /**
130
143
  * @description Get the P2TR address
131
144
  */
132
- public get p2trAddress(): Address {
145
+ public get p2trAddress(): string {
133
146
  return this.to || this.getScriptAddress();
134
147
  }
135
148
 
@@ -6,7 +6,6 @@ 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';
@@ -19,9 +18,9 @@ export interface MultiSignParameters
19
18
  readonly from?: undefined;
20
19
  readonly to?: undefined;
21
20
  readonly psbt?: Psbt;
22
- readonly receiver: Address;
21
+ readonly receiver: string;
23
22
  readonly requestedAmount: bigint;
24
- readonly refundVault: Address;
23
+ readonly refundVault: string;
25
24
  }
26
25
 
27
26
  export interface MultiSignFromBase64Params extends Omit<MultiSignParameters, 'psbt'> {
@@ -62,8 +61,8 @@ export class MultiSignTransaction extends TransactionBuilder<TransactionType.MUL
62
61
  protected readonly originalInputCount: number = 0;
63
62
  protected readonly requestedAmount: bigint;
64
63
 
65
- protected readonly receiver: Address;
66
- protected readonly refundVault: Address;
64
+ protected readonly receiver: string;
65
+ protected readonly refundVault: string;
67
66
  /**
68
67
  * @description Sign hash types
69
68
  * @protected
@@ -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';
@@ -108,13 +107,13 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
108
107
  * @description The address where the transaction is sent to
109
108
  * @protected
110
109
  */
111
- protected to: Address | undefined;
110
+ protected to: string | undefined;
112
111
 
113
112
  /**
114
113
  * @description The address where the transaction is sent from
115
114
  * @protected
116
115
  */
117
- protected from: Address;
116
+ protected from: string;
118
117
 
119
118
  /**
120
119
  * @description The maximum fee rate of the transaction
@@ -163,7 +162,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
163
162
  from: string | undefined,
164
163
  keypair: ECPairInterface | Signer,
165
164
  network: Network,
166
- ): Address {
165
+ ): string {
167
166
  return from || EcKeyPair.getTaprootAddress(keypair, network);
168
167
  }
169
168
 
@@ -223,9 +222,9 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
223
222
 
224
223
  /**
225
224
  * Set the destination address of the transaction
226
- * @param {Address} address - The address to set
225
+ * @param {string} address - The address to set
227
226
  */
228
- public setDestinationAddress(address: Address): void {
227
+ public setDestinationAddress(address: string): void {
229
228
  this.to = address; // this.getScriptAddress()
230
229
  }
231
230
 
@@ -354,7 +353,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
354
353
  /**
355
354
  * Receiver address.
356
355
  * @public
357
- * @returns {Address} - The receiver address
356
+ * @returns {string} - The receiver address
358
357
  */
359
358
  public toAddress(): string | undefined {
360
359
  return this.to;
@@ -362,9 +361,9 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
362
361
 
363
362
  /**
364
363
  * @description Returns the script address
365
- * @returns {Address} - The script address
364
+ * @returns {string} - The script address
366
365
  */
367
- public address(): Address | undefined {
366
+ public address(): string | undefined {
368
367
  return this.tapData?.address;
369
368
  }
370
369
 
@@ -3,7 +3,6 @@ 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';
@@ -11,6 +10,9 @@ import { IWBTCUTXODocument, PsbtTransaction, VaultUTXOs } from '../processor/Psb
11
10
  import { PsbtInputExtended, PsbtOutputExtended } from '../interfaces/Tap.js';
12
11
  import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
13
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';
14
16
 
15
17
  const abiCoder: ABICoder = new ABICoder();
16
18
 
@@ -3,7 +3,6 @@ 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 { Network, Payment, payments, Psbt } from 'bitcoinjs-lib';
9
8
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
@@ -17,6 +16,9 @@ import { PsbtInput } from 'bip174/src/lib/interfaces.js';
17
16
  import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
18
17
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
19
18
  import { Features } from '../../generators/Features.js';
19
+ import { ABICoder } from '../../abi/ABICoder.js';
20
+ import { Selector } from '../../utils/types.js';
21
+ import { BinaryWriter } from '../../buffer/BinaryWriter.js';
20
22
 
21
23
  const abiCoder: ABICoder = new ABICoder();
22
24
  const numsPoint: Buffer = Buffer.from(
@@ -140,22 +142,6 @@ export class UnwrapTransaction extends SharedInteractionTransaction<TransactionT
140
142
  return Buffer.from(bufWriter.getBuffer());
141
143
  }
142
144
 
143
- /*public tweakScalarPoints(): Uint8Array {
144
- const key: Uint8Array = (this.signer as ECPairInterface).privateKey as Uint8Array;
145
- //const r = bitcoin.crypto.sha256(Buffer.from('WTF_IS_OP_NET!', 'utf-8'));
146
- const rG = ecc.pointMultiply(
147
- Buffer.from(this.internalPubKeyToXOnly()), //EcKeyPair.fromPrivateKey(r).publicKey.subarray(1)
148
- key,
149
- );
150
-
151
- if (!rG) throw new Error('Failed to tweak rG');
152
-
153
- const tweaked = ecc.pointAdd(this.numsPoint, rG);
154
- if (!tweaked) throw new Error('Failed to tweak rG');
155
-
156
- return Buffer.from(tweaked);
157
- }*/
158
-
159
145
  /**
160
146
  * @description Signs the transaction
161
147
  * @public
@@ -4,14 +4,15 @@ import { PsbtOutputExtendedAddress, TapLeafScript } from '../interfaces/Tap.js';
4
4
  import { IWrapParameters } from '../interfaces/ITransactionParameters.js';
5
5
  import { SharedInteractionTransaction } from './SharedInteractionTransaction.js';
6
6
  import { wBTC } from '../../metadata/contracts/wBTC.js';
7
- import { ABICoder, Address, BinaryWriter, Selector } from '@btc-vision/bsi-binary';
8
- import { TransactionBuilder } from './TransactionBuilder.js';
9
7
  import { WrappedGeneration } from '../../wbtc/WrappedGenerationParameters.js';
10
8
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
11
- import { AddressVerificator } from '../../keypair/AddressVerificator.js';
12
9
  import { Network } from 'bitcoinjs-lib';
13
10
  import { P2TR_MS } from '../shared/P2TR_MS.js';
14
11
  import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
12
+ import { Selector } from '../../utils/types.js';
13
+ import { ABICoder } from '../../abi/ABICoder.js';
14
+ import { BinaryWriter } from '../../buffer/BinaryWriter.js';
15
+ import { Address } from '../../keypair/Address.js';
15
16
 
16
17
  const abiCoder: ABICoder = new ABICoder();
17
18
 
@@ -31,7 +32,7 @@ export class WrapTransaction extends SharedInteractionTransaction<TransactionTyp
31
32
  * @private
32
33
  * @readonly
33
34
  */
34
- public readonly vault: Address;
35
+ public readonly vault: string;
35
36
 
36
37
  /**
37
38
  * The amount to wrap
@@ -91,9 +92,7 @@ export class WrapTransaction extends SharedInteractionTransaction<TransactionTyp
91
92
  );
92
93
  }
93
94
 
94
- const receiver: Address =
95
- parameters.receiver ||
96
- TransactionBuilder.getFrom(parameters.from, parameters.signer, parameters.network);
95
+ const receiver: Address = parameters.receiver || new Address(parameters.signer.publicKey);
97
96
 
98
97
  parameters.calldata = WrapTransaction.generateMintCalldata(
99
98
  parameters.amount,
@@ -146,7 +145,7 @@ export class WrapTransaction extends SharedInteractionTransaction<TransactionTyp
146
145
  if (!amount) throw new Error('Amount is required');
147
146
  if (!to) throw new Error('To address is required');
148
147
 
149
- if (!AddressVerificator.isValidP2TRAddress(to, network)) {
148
+ if (!to.isValid(network)) {
150
149
  throw new Error(
151
150
  `Oops! The address ${to} is not a valid P2TR address! If you wrap at this address, your funds will be lost!`,
152
151
  );
@@ -1,14 +1,15 @@
1
1
  import { UTXO } from '../../utxo/interfaces/IUTXO.js';
2
- import { Address } from '@btc-vision/bsi-binary';
3
2
  import { WrappedGeneration } from '../../wbtc/WrappedGenerationParameters.js';
4
3
  import { ITweakedTransactionData } from '../shared/TweakedTransaction.js';
5
4
  import { VaultUTXOs } from '../processor/PsbtTransaction.js';
6
5
  import { ChainId } from '../../network/ChainId.js';
7
6
  import { PsbtOutputExtended } from './Tap.js';
7
+ import { Address } from '../../keypair/Address.js';
8
8
 
9
9
  export interface ITransactionParameters extends ITweakedTransactionData {
10
- readonly from?: Address;
11
- readonly to?: Address;
10
+ readonly from?: string;
11
+ readonly to?: string;
12
+
12
13
  utxos: UTXO[];
13
14
 
14
15
  nonWitnessUtxo?: Buffer;
@@ -39,13 +40,13 @@ export interface IInteractionParameters
39
40
  extends Omit<SharedInteractionParameters, 'optionalOutputs'> {
40
41
  readonly calldata: Buffer;
41
42
 
42
- readonly to: Address;
43
+ readonly to: string;
43
44
  }
44
45
 
45
46
  export interface IWrapParameters extends Omit<SharedInteractionParameters, 'optionalOutputs'> {
46
- readonly to?: Address;
47
+ readonly to?: string;
48
+ readonly from: string;
47
49
 
48
- readonly from: Address;
49
50
  readonly amount: bigint;
50
51
  readonly receiver?: Address;
51
52
 
@@ -1,4 +1,3 @@
1
- import { Address } from '@btc-vision/bsi-binary';
2
1
  import { Network, Psbt, Signer, Transaction } from 'bitcoinjs-lib';
3
2
  import { PsbtInputExtended, PsbtOutputExtended } from '../interfaces/Tap.js';
4
3
  import { ITweakedTransactionData, TweakedTransaction } from '../shared/TweakedTransaction.js';
@@ -10,7 +9,7 @@ export interface PsbtTransactionData extends ITweakedTransactionData {
10
9
  }
11
10
 
12
11
  export interface IWBTCUTXODocument {
13
- readonly vault: Address;
12
+ readonly vault: string;
14
13
  readonly blockId: bigint;
15
14
 
16
15
  readonly hash: string;
@@ -21,8 +20,8 @@ export interface IWBTCUTXODocument {
21
20
  }
22
21
 
23
22
  export interface VaultUTXOs {
24
- readonly vault: Address;
25
- readonly publicKeys: Address[];
23
+ readonly vault: string;
24
+ readonly publicKeys: string[];
26
25
  readonly minimum: number;
27
26
  readonly utxos: IWBTCUTXODocument[];
28
27
  }
@@ -1,5 +1,4 @@
1
1
  import { Network, networks } from 'bitcoinjs-lib';
2
- import { Address } from '@btc-vision/bsi-binary';
3
2
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
4
3
  import { MultiSignParameters, MultiSignTransaction } from '../builders/MultiSignTransaction.js';
5
4
 
@@ -9,14 +8,14 @@ export class P2TR_MS {
9
8
  * @param {Buffer[]} pubKeys - The public keys to use
10
9
  * @param {number} minimumSignatureRequired - The minimum number of signatures required
11
10
  * @param {Network} network - The network to use
12
- * @returns {Address} - The generated address
11
+ * @returns {string} - The generated address
13
12
  * @throws {Error} - If the address cannot be generated
14
13
  */
15
14
  public static generateMultiSigAddress(
16
15
  pubKeys: Buffer[],
17
16
  minimumSignatureRequired: number,
18
17
  network: Network = networks.bitcoin,
19
- ): Address {
18
+ ): string {
20
19
  const publicKeys: Buffer[] = EcKeyPair.verifyPubKeys(pubKeys, network);
21
20
  if (publicKeys.length !== pubKeys.length) throw new Error(`Contains invalid public keys`);
22
21