@btc-vision/transaction 1.7.27 → 1.7.29

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 (122) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/btc-vision-bitcoin.js +1610 -1609
  3. package/browser/consensus/ConsensusConfig.d.ts +1 -5
  4. package/browser/consensus/IConsensusConfig.d.ts +6 -0
  5. package/browser/consensus/metadata/RoswellConsensus.d.ts +1 -1
  6. package/browser/epoch/interfaces/IChallengeSolution.d.ts +15 -1
  7. package/browser/generators/builders/CalldataGenerator.d.ts +2 -2
  8. package/browser/generators/builders/DeploymentGenerator.d.ts +2 -2
  9. package/browser/generators/builders/P2WDAGenerator.d.ts +2 -2
  10. package/browser/index.js +876 -1055
  11. package/browser/opnet.d.ts +7 -2
  12. package/browser/signer/AddressRotation.d.ts +2 -3
  13. package/browser/signer/IRotationSigner.d.ts +8 -0
  14. package/browser/transaction/TransactionFactory.d.ts +4 -27
  15. package/browser/transaction/browser/Web3Provider.d.ts +2 -25
  16. package/browser/transaction/builders/CancelTransaction.d.ts +1 -4
  17. package/browser/transaction/builders/ConsolidatedInteractionTransaction.d.ts +3 -3
  18. package/browser/transaction/builders/CustomScriptTransaction.d.ts +2 -8
  19. package/browser/transaction/builders/DeploymentTransaction.d.ts +3 -3
  20. package/browser/transaction/builders/InteractionTransactionP2WDA.d.ts +2 -2
  21. package/browser/transaction/builders/SharedInteractionTransaction.d.ts +3 -3
  22. package/browser/transaction/interfaces/ICancelTransactionParameters.d.ts +4 -0
  23. package/browser/transaction/interfaces/ICustomTransactionParameters.d.ts +8 -0
  24. package/browser/transaction/interfaces/ITransactionParameters.d.ts +6 -6
  25. package/browser/transaction/interfaces/ITransactionResponses.d.ts +26 -0
  26. package/browser/transaction/interfaces/ITweakedTransactionData.d.ts +17 -0
  27. package/browser/transaction/interfaces/IWeb3ProviderTypes.d.ts +24 -0
  28. package/browser/transaction/shared/TweakedTransaction.d.ts +2 -14
  29. package/browser/transaction/utils/WitnessUtils.d.ts +1 -0
  30. package/browser/utxo/OPNetLimitedProvider.d.ts +1 -1
  31. package/browser/utxo/interfaces/IUTXO.d.ts +2 -2
  32. package/browser/vendors.js +90 -90
  33. package/browser/verification/TapscriptVerificator.d.ts +2 -2
  34. package/build/_version.d.ts +1 -1
  35. package/build/_version.js +1 -1
  36. package/build/consensus/ConsensusConfig.d.ts +1 -5
  37. package/build/consensus/IConsensusConfig.d.ts +6 -0
  38. package/build/consensus/IConsensusConfig.js +1 -0
  39. package/build/consensus/metadata/RoswellConsensus.d.ts +1 -1
  40. package/build/epoch/interfaces/IChallengeSolution.d.ts +15 -1
  41. package/build/epoch/validator/EpochValidator.js +35 -3
  42. package/build/generators/builders/CalldataGenerator.d.ts +2 -2
  43. package/build/generators/builders/DeploymentGenerator.d.ts +2 -2
  44. package/build/generators/builders/P2WDAGenerator.d.ts +2 -2
  45. package/build/opnet.d.ts +7 -2
  46. package/build/opnet.js +7 -2
  47. package/build/signer/AddressRotation.d.ts +2 -3
  48. package/build/signer/IRotationSigner.d.ts +8 -0
  49. package/build/signer/IRotationSigner.js +1 -0
  50. package/build/transaction/TransactionFactory.d.ts +4 -27
  51. package/build/transaction/TransactionFactory.js +1 -1
  52. package/build/transaction/browser/Web3Provider.d.ts +2 -25
  53. package/build/transaction/builders/CancelTransaction.d.ts +1 -4
  54. package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts +3 -3
  55. package/build/transaction/builders/CustomScriptTransaction.d.ts +2 -8
  56. package/build/transaction/builders/DeploymentTransaction.d.ts +3 -3
  57. package/build/transaction/builders/InteractionTransactionP2WDA.d.ts +2 -2
  58. package/build/transaction/builders/SharedInteractionTransaction.d.ts +3 -3
  59. package/build/transaction/builders/TransactionBuilder.js +3 -21
  60. package/build/transaction/interfaces/ICancelTransactionParameters.d.ts +4 -0
  61. package/build/transaction/interfaces/ICancelTransactionParameters.js +1 -0
  62. package/build/transaction/interfaces/ICustomTransactionParameters.d.ts +8 -0
  63. package/build/transaction/interfaces/ICustomTransactionParameters.js +1 -0
  64. package/build/transaction/interfaces/ITransactionParameters.d.ts +6 -6
  65. package/build/transaction/interfaces/ITransactionResponses.d.ts +26 -0
  66. package/build/transaction/interfaces/ITransactionResponses.js +1 -0
  67. package/build/transaction/interfaces/ITweakedTransactionData.d.ts +17 -0
  68. package/build/transaction/interfaces/ITweakedTransactionData.js +1 -0
  69. package/build/transaction/interfaces/IWeb3ProviderTypes.d.ts +24 -0
  70. package/build/transaction/interfaces/IWeb3ProviderTypes.js +1 -0
  71. package/build/transaction/shared/TweakedTransaction.d.ts +2 -14
  72. package/build/transaction/shared/TweakedTransaction.js +3 -3
  73. package/build/transaction/utils/WitnessUtils.d.ts +1 -0
  74. package/build/transaction/utils/WitnessUtils.js +23 -0
  75. package/build/tsconfig.build.tsbuildinfo +1 -1
  76. package/build/utxo/OPNetLimitedProvider.d.ts +1 -1
  77. package/build/utxo/OPNetLimitedProvider.js +1 -1
  78. package/build/utxo/interfaces/IUTXO.d.ts +2 -2
  79. package/build/verification/TapscriptVerificator.d.ts +2 -2
  80. package/package.json +40 -20
  81. package/src/_version.ts +1 -1
  82. package/src/consensus/ConsensusConfig.ts +1 -28
  83. package/src/consensus/IConsensusConfig.ts +29 -0
  84. package/src/consensus/metadata/RoswellConsensus.ts +1 -1
  85. package/src/epoch/interfaces/IChallengeSolution.ts +13 -1
  86. package/src/epoch/validator/EpochValidator.ts +54 -3
  87. package/src/generators/builders/CalldataGenerator.ts +3 -3
  88. package/src/generators/builders/DeploymentGenerator.ts +3 -3
  89. package/src/generators/builders/P2WDAGenerator.ts +2 -2
  90. package/src/keypair/MessageSigner.ts +1 -1
  91. package/src/opnet.ts +7 -4
  92. package/src/signer/AddressRotation.ts +3 -4
  93. package/src/signer/IRotationSigner.ts +35 -0
  94. package/src/transaction/TransactionFactory.ts +14 -38
  95. package/src/transaction/browser/Web3Provider.ts +14 -78
  96. package/src/transaction/builders/CancelTransaction.ts +2 -11
  97. package/src/transaction/builders/ConsolidatedInteractionTransaction.ts +3 -3
  98. package/src/transaction/builders/CustomScriptTransaction.ts +1 -15
  99. package/src/transaction/builders/DeploymentTransaction.ts +3 -3
  100. package/src/transaction/builders/InteractionTransactionP2WDA.ts +3 -3
  101. package/src/transaction/builders/SharedInteractionTransaction.ts +3 -3
  102. package/src/transaction/builders/TransactionBuilder.ts +2 -28
  103. package/src/transaction/interfaces/ICancelTransactionParameters.ts +8 -0
  104. package/src/transaction/interfaces/ICustomTransactionParameters.ts +15 -0
  105. package/src/transaction/interfaces/ITransactionParameters.ts +6 -6
  106. package/src/transaction/interfaces/ITransactionResponses.ts +29 -0
  107. package/src/transaction/interfaces/ITweakedTransactionData.ts +24 -0
  108. package/src/transaction/interfaces/IWeb3ProviderTypes.ts +74 -0
  109. package/src/transaction/offline/TransactionReconstructor.ts +1 -1
  110. package/src/transaction/shared/TweakedTransaction.ts +6 -30
  111. package/src/transaction/utils/WitnessUtils.ts +36 -0
  112. package/src/utxo/OPNetLimitedProvider.ts +3 -1
  113. package/src/utxo/interfaces/IUTXO.ts +2 -2
  114. package/src/verification/TapscriptVerificator.ts +2 -2
  115. package/browser/metadata/tokens.d.ts +0 -39
  116. package/browser/transaction/processor/PsbtTransaction.d.ts +0 -25
  117. package/build/metadata/tokens.d.ts +0 -39
  118. package/build/metadata/tokens.js +0 -100
  119. package/build/transaction/processor/PsbtTransaction.d.ts +0 -25
  120. package/build/transaction/processor/PsbtTransaction.js +0 -80
  121. package/src/metadata/tokens.ts +0 -139
  122. package/src/transaction/processor/PsbtTransaction.ts +0 -179
@@ -1,82 +1,18 @@
1
- import {
2
- IDeploymentParameters,
3
- IInteractionParameters,
4
- } from '../interfaces/ITransactionParameters.js';
5
1
  import { UTXO } from '../../utxo/interfaces/IUTXO.js';
6
- import { CancelledTransaction, DeploymentResult, InteractionResponse } from '../TransactionFactory';
7
- import { ICustomTransactionParameters } from '../builders/CustomScriptTransaction.js';
8
- import { ICancelTransactionParameters } from '../builders/CancelTransaction.js';
9
- import { MLDSASecurityLevel } from '@btc-vision/bip32';
10
-
11
- export type InteractionParametersWithoutSigner = Omit<
12
- IInteractionParameters,
13
- 'signer' | 'challenge' | 'mldsaSigner'
14
- >;
15
-
16
- export type IDeploymentParametersWithoutSigner = Omit<
17
- IDeploymentParameters,
18
- 'signer' | 'network' | 'challenge' | 'mldsaSigner'
19
- >;
20
-
21
- export type ICustomTransactionWithoutSigner = Omit<
22
- ICustomTransactionParameters,
23
- 'signer' | 'challenge' | 'mldsaSigner'
24
- >;
25
-
26
- export type ICancelTransactionParametersWithoutSigner = Omit<
27
- ICancelTransactionParameters,
28
- 'signer' | 'challenge' | 'network' | 'mldsaSigner'
29
- >;
30
-
31
- export interface BroadcastTransactionOptions {
32
- raw: string;
33
- psbt: boolean;
34
- }
35
-
36
- export interface BroadcastedTransaction {
37
- /** Whether the transaction was successfully broadcasted. */
38
- readonly success: boolean;
39
-
40
- /**
41
- * The result of the broadcasted transaction.
42
- */
43
- readonly result?: string;
44
-
45
- /**
46
- * The error message if the transaction was not successfully broadcasted.
47
- */
48
- readonly error?: string;
49
-
50
- /**
51
- * The number of peers that the transaction was broadcasted to.
52
- */
53
- readonly peers?: number;
54
- }
55
-
56
- /**
57
- * ML-DSA signature result
58
- */
59
- export interface MLDSASignature {
60
- /**
61
- * The ML-DSA signature in hex format
62
- */
63
- readonly signature: string;
64
-
65
- /**
66
- * The ML-DSA public key used for signing in hex format
67
- */
68
- readonly publicKey: string;
69
-
70
- /**
71
- * The security level used (44, 65, or 87)
72
- */
73
- readonly securityLevel: MLDSASecurityLevel;
74
-
75
- /**
76
- * The message hash that was signed
77
- */
78
- readonly messageHash: string;
79
- }
2
+ import {
3
+ CancelledTransaction,
4
+ DeploymentResult,
5
+ InteractionResponse,
6
+ } from '../interfaces/ITransactionResponses.js';
7
+ import {
8
+ BroadcastedTransaction,
9
+ BroadcastTransactionOptions,
10
+ ICancelTransactionParametersWithoutSigner,
11
+ ICustomTransactionWithoutSigner,
12
+ IDeploymentParametersWithoutSigner,
13
+ InteractionParametersWithoutSigner,
14
+ MLDSASignature,
15
+ } from '../interfaces/IWeb3ProviderTypes.js';
80
16
 
81
17
  export interface Web3Provider {
82
18
  signInteraction(
@@ -2,19 +2,10 @@ import { TransactionType } from '../enums/TransactionType.js';
2
2
  import { P2TRPayment, PaymentType, Psbt, PsbtInput, Taptree } from '@btc-vision/bitcoin';
3
3
  import { TransactionBuilder } from './TransactionBuilder.js';
4
4
  import { TapLeafScript } from '../interfaces/Tap.js';
5
- import {
6
- ITransactionParameters,
7
- SharedInteractionParameters,
8
- } from '../interfaces/ITransactionParameters.js';
5
+ import { SharedInteractionParameters } from '../interfaces/ITransactionParameters.js';
6
+ import { ICancelTransactionParameters } from '../interfaces/ICancelTransactionParameters.js';
9
7
  import { UnisatSigner } from '../browser/extensions/UnisatSigner.js';
10
8
 
11
- export interface ICancelTransactionParameters extends Omit<
12
- ITransactionParameters,
13
- 'priorityFee' | 'gasSatFee'
14
- > {
15
- readonly compiledTargetScript: string | Buffer;
16
- }
17
-
18
9
  export class CancelTransaction extends TransactionBuilder<TransactionType.CANCEL> {
19
10
  public type: TransactionType.CANCEL = TransactionType.CANCEL;
20
11
 
@@ -14,7 +14,7 @@ import {
14
14
  } from '../interfaces/IConsolidatedTransactionParameters.js';
15
15
  import { IP2WSHAddress } from '../mineable/IP2WSHAddress.js';
16
16
  import { TimeLockGenerator } from '../mineable/TimelockGenerator.js';
17
- import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
17
+ import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
18
18
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
19
19
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
20
20
  import { Compressor } from '../../bytecode/Compressor.js';
@@ -77,7 +77,7 @@ export class ConsolidatedInteractionTransaction extends TransactionBuilder<Trans
77
77
  /** The compressed calldata (same as InteractionTransaction) */
78
78
  protected readonly calldata: Buffer;
79
79
  /** Challenge solution for epoch (same as InteractionTransaction) */
80
- protected readonly challenge: ChallengeSolution;
80
+ protected readonly challenge: IChallengeSolution;
81
81
  /** Epoch challenge P2WSH address (same as InteractionTransaction) */
82
82
  protected readonly epochChallenge: IP2WSHAddress;
83
83
  /** Script signer for interaction (same as InteractionTransaction) */
@@ -225,7 +225,7 @@ export class ConsolidatedInteractionTransaction extends TransactionBuilder<Trans
225
225
  /**
226
226
  * Get the challenge solution (same as InteractionTransaction).
227
227
  */
228
- public getChallenge(): ChallengeSolution {
228
+ public getChallenge(): IChallengeSolution {
229
229
  return this.challenge;
230
230
  }
231
231
 
@@ -6,32 +6,18 @@ import {
6
6
  Psbt,
7
7
  PsbtInput,
8
8
  Signer,
9
- Stack,
10
9
  Taptree,
11
10
  toXOnly,
12
11
  } from '@btc-vision/bitcoin';
13
12
  import { TransactionType } from '../enums/TransactionType.js';
14
13
  import { TapLeafScript } from '../interfaces/Tap.js';
15
- import { SharedInteractionParameters } from '../interfaces/ITransactionParameters.js';
16
14
  import { TransactionBuilder } from './TransactionBuilder.js';
17
15
  import { CustomGenerator } from '../../generators/builders/CustomGenerator.js';
18
16
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
19
17
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
20
18
  import { AddressGenerator } from '../../generators/AddressGenerator.js';
21
19
  import { ECPairInterface } from 'ecpair';
22
-
23
- export interface ICustomTransactionParameters extends Omit<
24
- SharedInteractionParameters,
25
- 'challenge'
26
- > {
27
- script: (Buffer | Stack)[];
28
- witnesses: Buffer[];
29
-
30
- /** optional Taproot annex payload (without the 0x50 prefix) */
31
- annex?: Buffer;
32
-
33
- to: string;
34
- }
20
+ import { ICustomTransactionParameters } from '../interfaces/ICustomTransactionParameters.js';
35
21
 
36
22
  /**
37
23
  * Class for interaction transactions
@@ -24,7 +24,7 @@ import { ECPairInterface } from 'ecpair';
24
24
  import { Address } from '../../keypair/Address.js';
25
25
  import { UnisatSigner } from '../browser/extensions/UnisatSigner.js';
26
26
  import { TimeLockGenerator } from '../mineable/TimelockGenerator.js';
27
- import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
27
+ import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
28
28
  import { Feature, FeaturePriority, Features } from '../../generators/Features.js';
29
29
  import { IP2WSHAddress } from '../mineable/IP2WSHAddress.js';
30
30
 
@@ -33,7 +33,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
33
33
 
34
34
  public type: TransactionType.DEPLOYMENT = TransactionType.DEPLOYMENT;
35
35
 
36
- protected readonly challenge: ChallengeSolution;
36
+ protected readonly challenge: IChallengeSolution;
37
37
  protected readonly epochChallenge: IP2WSHAddress;
38
38
 
39
39
  /**
@@ -210,7 +210,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
210
210
  * Get the contract bytecode
211
211
  * @returns {Buffer} The contract bytecode
212
212
  */
213
- public getChallenge(): ChallengeSolution {
213
+ public getChallenge(): IChallengeSolution {
214
214
  return this.challenge;
215
215
  }
216
216
 
@@ -9,7 +9,7 @@ import { P2WDAGenerator } from '../../generators/builders/P2WDAGenerator.js';
9
9
  import { Feature, FeaturePriority, Features } from '../../generators/Features.js';
10
10
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
11
11
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
12
- import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
12
+ import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
13
13
  import { ECPairInterface } from 'ecpair';
14
14
  import { P2WDADetector } from '../../p2wda/P2WDADetector.js';
15
15
  import { IP2WSHAddress } from '../mineable/IP2WSHAddress.js';
@@ -36,7 +36,7 @@ export class InteractionTransactionP2WDA extends TransactionBuilder<TransactionT
36
36
  private readonly contractAddress: string;
37
37
  private readonly contractSecret: Buffer;
38
38
  private readonly calldata: Buffer;
39
- private readonly challenge: ChallengeSolution;
39
+ private readonly challenge: IChallengeSolution;
40
40
  private readonly randomBytes: Buffer;
41
41
  private p2wdaGenerator: P2WDAGenerator;
42
42
  private scriptSigner: ECPairInterface;
@@ -131,7 +131,7 @@ export class InteractionTransactionP2WDA extends TransactionBuilder<TransactionT
131
131
  /**
132
132
  * Get the challenge (for compatibility if needed elsewhere)
133
133
  */
134
- public getChallenge(): ChallengeSolution {
134
+ public getChallenge(): IChallengeSolution {
135
135
  return this.challenge;
136
136
  }
137
137
 
@@ -9,7 +9,7 @@ import { EcKeyPair } from '../../keypair/EcKeyPair.js';
9
9
  import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
10
10
  import { UnisatSigner } from '../browser/extensions/UnisatSigner.js';
11
11
  import { TimeLockGenerator } from '../mineable/TimelockGenerator.js';
12
- import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
12
+ import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
13
13
  import { IP2WSHAddress } from '../mineable/IP2WSHAddress.js';
14
14
 
15
15
  /**
@@ -33,7 +33,7 @@ export abstract class SharedInteractionTransaction<
33
33
  protected abstract readonly compiledTargetScript: Buffer;
34
34
  protected abstract readonly scriptTree: Taptree;
35
35
 
36
- protected readonly challenge: ChallengeSolution;
36
+ protected readonly challenge: IChallengeSolution;
37
37
  protected readonly epochChallenge: IP2WSHAddress;
38
38
 
39
39
  protected calldataGenerator: CalldataGenerator;
@@ -118,7 +118,7 @@ export abstract class SharedInteractionTransaction<
118
118
  /**
119
119
  * Get the preimage
120
120
  */
121
- public getChallenge(): ChallengeSolution {
121
+ public getChallenge(): IChallengeSolution {
122
122
  return this.challenge;
123
123
  }
124
124
 
@@ -10,8 +10,8 @@ import bitcoin, {
10
10
  Signer,
11
11
  toXOnly,
12
12
  Transaction,
13
- varuint,
14
13
  } from '@btc-vision/bitcoin';
14
+ import { witnessStackToScriptWitness } from '../utils/WitnessUtils.js';
15
15
  import * as ecc from '@bitcoinerlab/secp256k1';
16
16
  import { UpdateInput } from '../interfaces/Tap.js';
17
17
  import { TransactionType } from '../enums/TransactionType.js';
@@ -232,33 +232,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
232
232
  * @returns {Buffer}
233
233
  */
234
234
  public static witnessStackToScriptWitness(witness: Buffer[]): Buffer {
235
- let buffer = Buffer.allocUnsafe(0);
236
-
237
- function writeSlice(slice: Buffer) {
238
- buffer = Buffer.concat([buffer, Buffer.from(slice)]);
239
- }
240
-
241
- function writeVarInt(i: number) {
242
- const currentLen = buffer.length;
243
- const varintLen = varuint.encodingLength(i);
244
-
245
- buffer = Buffer.concat([buffer, Buffer.allocUnsafe(varintLen)]);
246
- varuint.encode(i, buffer, currentLen);
247
- }
248
-
249
- function writeVarSlice(slice: Buffer) {
250
- writeVarInt(slice.length);
251
- writeSlice(slice);
252
- }
253
-
254
- function writeVector(vector: Buffer[]) {
255
- writeVarInt(vector.length);
256
- vector.forEach(writeVarSlice);
257
- }
258
-
259
- writeVector(witness);
260
-
261
- return buffer;
235
+ return witnessStackToScriptWitness(witness);
262
236
  }
263
237
 
264
238
  public addOPReturn(buffer: Buffer): void {
@@ -0,0 +1,8 @@
1
+ import { ITransactionParameters } from './ITransactionParameters.js';
2
+
3
+ export interface ICancelTransactionParameters extends Omit<
4
+ ITransactionParameters,
5
+ 'priorityFee' | 'gasSatFee'
6
+ > {
7
+ readonly compiledTargetScript: string | Buffer;
8
+ }
@@ -0,0 +1,15 @@
1
+ import { Stack } from '@btc-vision/bitcoin';
2
+ import { SharedInteractionParameters } from './ITransactionParameters.js';
3
+
4
+ export interface ICustomTransactionParameters extends Omit<
5
+ SharedInteractionParameters,
6
+ 'challenge'
7
+ > {
8
+ script: (Buffer | Stack)[];
9
+ witnesses: Buffer[];
10
+
11
+ /** optional Taproot annex payload (without the 0x50 prefix) */
12
+ annex?: Buffer;
13
+
14
+ to: string;
15
+ }
@@ -1,9 +1,9 @@
1
1
  import { UTXO } from '../../utxo/interfaces/IUTXO.js';
2
- import { ITweakedTransactionData } from '../shared/TweakedTransaction.js';
2
+ import { ITweakedTransactionData } from './ITweakedTransactionData.js';
3
3
  import { ChainId } from '../../network/ChainId.js';
4
4
  import { PsbtOutputExtended } from '@btc-vision/bitcoin';
5
- import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
6
- import { AddressRotationConfig } from '../../signer/AddressRotation.js';
5
+ import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
6
+ import { AddressRotationConfigBase } from '../../signer/IRotationSigner.js';
7
7
 
8
8
  export interface LoadedStorage {
9
9
  [key: string]: string[];
@@ -49,7 +49,7 @@ export interface ITransactionParameters extends ITweakedTransactionData {
49
49
  * When enabled, allows different signers to sign different UTXOs based on their addresses.
50
50
  * This supports proper Bitcoin privacy practices where each UTXO has its own key.
51
51
  */
52
- readonly addressRotation?: AddressRotationConfig;
52
+ readonly addressRotation?: AddressRotationConfigBase;
53
53
  }
54
54
 
55
55
  export interface IFundingTransactionParameters extends ITransactionParameters {
@@ -62,7 +62,7 @@ export interface SharedInteractionParameters extends ITransactionParameters {
62
62
  calldata?: Buffer;
63
63
  disableAutoRefund?: boolean;
64
64
 
65
- readonly challenge: ChallengeSolution;
65
+ readonly challenge: IChallengeSolution;
66
66
  readonly randomBytes?: Buffer;
67
67
 
68
68
  readonly loadedStorage?: LoadedStorage;
@@ -81,5 +81,5 @@ export interface IDeploymentParameters extends Omit<ITransactionParameters, 'to'
81
81
  readonly calldata?: Buffer;
82
82
 
83
83
  readonly randomBytes?: Buffer;
84
- readonly challenge: ChallengeSolution;
84
+ readonly challenge: IChallengeSolution;
85
85
  }
@@ -0,0 +1,29 @@
1
+ import { RawChallenge } from '../../epoch/interfaces/IChallengeSolution.js';
2
+ import { UTXO } from '../../utxo/interfaces/IUTXO.js';
3
+
4
+ export interface DeploymentResult {
5
+ readonly transaction: [string, string];
6
+ readonly contractAddress: string;
7
+ readonly contractPubKey: string;
8
+ readonly challenge: RawChallenge;
9
+ readonly utxos: UTXO[];
10
+ readonly inputUtxos: UTXO[];
11
+ }
12
+
13
+ export interface InteractionResponse {
14
+ readonly fundingTransaction: string | null;
15
+ readonly interactionTransaction: string;
16
+ readonly estimatedFees: bigint;
17
+ readonly nextUTXOs: UTXO[];
18
+ readonly fundingUTXOs: UTXO[];
19
+ readonly fundingInputUtxos: UTXO[];
20
+ readonly challenge: RawChallenge;
21
+ readonly interactionAddress: string | null;
22
+ readonly compiledTargetScript: string | null;
23
+ }
24
+
25
+ export interface CancelledTransaction {
26
+ readonly transaction: string;
27
+ readonly nextUTXOs: UTXO[];
28
+ readonly inputUtxos: UTXO[];
29
+ }
@@ -0,0 +1,24 @@
1
+ import { Network, Signer } from '@btc-vision/bitcoin';
2
+ import { ECPairInterface } from 'ecpair';
3
+ import { QuantumBIP32Interface } from '@btc-vision/bip32';
4
+ import { ChainId } from '../../network/ChainId.js';
5
+ import { AddressRotationConfigBase } from '../../signer/IRotationSigner.js';
6
+
7
+ export type SupportedTransactionVersion = 1 | 2 | 3;
8
+
9
+ export interface ITweakedTransactionData {
10
+ readonly mldsaSigner: QuantumBIP32Interface | null;
11
+ readonly signer: Signer | ECPairInterface;
12
+ readonly network: Network;
13
+ readonly chainId?: ChainId;
14
+ readonly nonWitnessUtxo?: Buffer;
15
+ readonly noSignatures?: boolean;
16
+ readonly unlockScript?: Buffer[];
17
+ readonly txVersion?: SupportedTransactionVersion;
18
+
19
+ /**
20
+ * Address rotation configuration for per-UTXO signing.
21
+ * When enabled, each UTXO can be signed by a different signer.
22
+ */
23
+ readonly addressRotation?: AddressRotationConfigBase;
24
+ }
@@ -0,0 +1,74 @@
1
+ import { IDeploymentParameters, IInteractionParameters } from './ITransactionParameters.js';
2
+ import { ICustomTransactionParameters } from './ICustomTransactionParameters.js';
3
+ import { ICancelTransactionParameters } from './ICancelTransactionParameters.js';
4
+ import { MLDSASecurityLevel } from '@btc-vision/bip32';
5
+
6
+ export type InteractionParametersWithoutSigner = Omit<
7
+ IInteractionParameters,
8
+ 'signer' | 'challenge' | 'mldsaSigner'
9
+ >;
10
+
11
+ export type IDeploymentParametersWithoutSigner = Omit<
12
+ IDeploymentParameters,
13
+ 'signer' | 'network' | 'challenge' | 'mldsaSigner'
14
+ >;
15
+
16
+ export type ICustomTransactionWithoutSigner = Omit<
17
+ ICustomTransactionParameters,
18
+ 'signer' | 'challenge' | 'mldsaSigner'
19
+ >;
20
+
21
+ export type ICancelTransactionParametersWithoutSigner = Omit<
22
+ ICancelTransactionParameters,
23
+ 'signer' | 'challenge' | 'network' | 'mldsaSigner'
24
+ >;
25
+
26
+ export interface BroadcastTransactionOptions {
27
+ raw: string;
28
+ psbt: boolean;
29
+ }
30
+
31
+ export interface BroadcastedTransaction {
32
+ /** Whether the transaction was successfully broadcasted. */
33
+ readonly success: boolean;
34
+
35
+ /**
36
+ * The result of the broadcasted transaction.
37
+ */
38
+ readonly result?: string;
39
+
40
+ /**
41
+ * The error message if the transaction was not successfully broadcasted.
42
+ */
43
+ readonly error?: string;
44
+
45
+ /**
46
+ * The number of peers that the transaction was broadcasted to.
47
+ */
48
+ readonly peers?: number;
49
+ }
50
+
51
+ /**
52
+ * ML-DSA signature result
53
+ */
54
+ export interface MLDSASignature {
55
+ /**
56
+ * The ML-DSA signature in hex format
57
+ */
58
+ readonly signature: string;
59
+
60
+ /**
61
+ * The ML-DSA public key used for signing in hex format
62
+ */
63
+ readonly publicKey: string;
64
+
65
+ /**
66
+ * The security level used (44, 65, or 87)
67
+ */
68
+ readonly securityLevel: MLDSASecurityLevel;
69
+
70
+ /**
71
+ * The message hash that was signed
72
+ */
73
+ readonly messageHash: string;
74
+ }
@@ -33,7 +33,7 @@ import {
33
33
  IInteractionParameters,
34
34
  ITransactionParameters,
35
35
  } from '../interfaces/ITransactionParameters.js';
36
- import { SupportedTransactionVersion } from '../shared/TweakedTransaction.js';
36
+ import { SupportedTransactionVersion } from '../interfaces/ITweakedTransactionData.js';
37
37
 
38
38
  /**
39
39
  * Options for reconstructing a transaction from serialized state
@@ -31,38 +31,15 @@ import { TweakedSigner, TweakSettings } from '../../signer/TweakedSigner.js';
31
31
  import { ECPairInterface } from 'ecpair';
32
32
  import { UTXO } from '../../utxo/interfaces/IUTXO.js';
33
33
  import { TapLeafScript } from '../interfaces/Tap.js';
34
- import { ChainId } from '../../network/ChainId.js';
35
34
  import { UnisatSigner } from '../browser/extensions/UnisatSigner.js';
36
- import {
37
- canSignNonTaprootInput,
38
- isTaprootInput,
39
- pubkeyInScript,
40
- } from '../../signer/SignerUtils.js';
41
- import { TransactionBuilder } from '../builders/TransactionBuilder.js';
35
+ import { canSignNonTaprootInput, isTaprootInput, pubkeyInScript, } from '../../signer/SignerUtils.js';
36
+ import { witnessStackToScriptWitness } from '../utils/WitnessUtils.js';
42
37
  import { Buffer } from 'buffer';
43
38
  import { P2WDADetector } from '../../p2wda/P2WDADetector.js';
44
39
  import { QuantumBIP32Interface } from '@btc-vision/bip32';
45
40
  import { MessageSigner } from '../../keypair/MessageSigner.js';
46
- import { AddressRotationConfig, RotationSigner, SignerMap } from '../../signer/AddressRotation.js';
47
-
48
- export type SupportedTransactionVersion = 1 | 2 | 3;
49
-
50
- export interface ITweakedTransactionData {
51
- readonly mldsaSigner: QuantumBIP32Interface | null;
52
- readonly signer: Signer | ECPairInterface | UnisatSigner;
53
- readonly network: Network;
54
- readonly chainId?: ChainId;
55
- readonly nonWitnessUtxo?: Buffer;
56
- readonly noSignatures?: boolean;
57
- readonly unlockScript?: Buffer[];
58
- readonly txVersion?: SupportedTransactionVersion;
59
-
60
- /**
61
- * Address rotation configuration for per-UTXO signing.
62
- * When enabled, each UTXO can be signed by a different signer.
63
- */
64
- readonly addressRotation?: AddressRotationConfig;
65
- }
41
+ import { RotationSigner, SignerMap } from '../../signer/AddressRotation.js';
42
+ import { ITweakedTransactionData, SupportedTransactionVersion, } from '../interfaces/ITweakedTransactionData.js';
66
43
 
67
44
  /**
68
45
  * The transaction sequence
@@ -1146,8 +1123,7 @@ export abstract class TweakedTransaction extends Logger {
1146
1123
  const witnessStack = [input.partialSig[0].signature, input.witnessScript];
1147
1124
  return {
1148
1125
  finalScriptSig: undefined,
1149
- finalScriptWitness:
1150
- TransactionBuilder.witnessStackToScriptWitness(witnessStack),
1126
+ finalScriptWitness: witnessStackToScriptWitness(witnessStack),
1151
1127
  };
1152
1128
  }
1153
1129
 
@@ -1191,7 +1167,7 @@ export abstract class TweakedTransaction extends Logger {
1191
1167
 
1192
1168
  return {
1193
1169
  finalScriptSig: undefined,
1194
- finalScriptWitness: TransactionBuilder.witnessStackToScriptWitness(witnessStack),
1170
+ finalScriptWitness: witnessStackToScriptWitness(witnessStack),
1195
1171
  };
1196
1172
  }
1197
1173
 
@@ -0,0 +1,36 @@
1
+ import { varuint } from '@btc-vision/bitcoin';
2
+
3
+ /**
4
+ * Convert witness stack to script witness buffer
5
+ * @param {Buffer[]} witness - The witness stack
6
+ * @returns {Buffer}
7
+ */
8
+ export function witnessStackToScriptWitness(witness: Buffer[]): Buffer {
9
+ let buffer = Buffer.allocUnsafe(0);
10
+
11
+ function writeSlice(slice: Buffer) {
12
+ buffer = Buffer.concat([buffer, Buffer.from(slice)]);
13
+ }
14
+
15
+ function writeVarInt(i: number) {
16
+ const currentLen = buffer.length;
17
+ const varintLen = varuint.encodingLength(i);
18
+
19
+ buffer = Buffer.concat([buffer, Buffer.allocUnsafe(varintLen)]);
20
+ varuint.encode(i, buffer, currentLen);
21
+ }
22
+
23
+ function writeVarSlice(slice: Buffer) {
24
+ writeVarInt(slice.length);
25
+ writeSlice(slice);
26
+ }
27
+
28
+ function writeVector(vector: Buffer[]) {
29
+ writeVarInt(vector.length);
30
+ vector.forEach(writeVarSlice);
31
+ }
32
+
33
+ writeVector(witness);
34
+
35
+ return buffer;
36
+ }
@@ -1,5 +1,7 @@
1
1
  import { Network } from '@btc-vision/bitcoin';
2
- import { IFundingTransactionParameters, TransactionFactory, Wallet } from '../opnet.js';
2
+ import { IFundingTransactionParameters } from '../transaction/interfaces/ITransactionParameters.js';
3
+ import { TransactionFactory } from '../transaction/TransactionFactory.js';
4
+ import { Wallet } from '../keypair/Wallet.js';
3
5
  import { BroadcastResponse } from './interfaces/BroadcastResponse.js';
4
6
  import {
5
7
  FetchUTXOParams,
@@ -1,5 +1,5 @@
1
1
  import { ScriptPubKey } from '@btc-vision/bitcoin-rpc';
2
- import { RotationSigner } from '../../signer/AddressRotation.js';
2
+ import { RotationSignerBase } from '../../signer/IRotationSigner.js';
3
3
 
4
4
  export interface UTXO {
5
5
  readonly transactionId: string;
@@ -16,7 +16,7 @@ export interface UTXO {
16
16
  * Used in address rotation mode where each UTXO may have its own signer.
17
17
  * If not provided, the signer will be resolved from the signerMap or the default signer.
18
18
  */
19
- signer?: RotationSigner;
19
+ signer?: RotationSignerBase;
20
20
  }
21
21
 
22
22
  export interface FetchUTXOParams {
@@ -10,7 +10,7 @@ import {
10
10
  toXOnly,
11
11
  } from '@btc-vision/bitcoin';
12
12
  import { DeploymentGenerator } from '../generators/builders/DeploymentGenerator.js';
13
- import { ChallengeSolution } from '../epoch/ChallengeSolution.js';
13
+ import { IChallengeSolution } from '../epoch/interfaces/IChallengeSolution.js';
14
14
  import { Feature, Features } from '../generators/Features.js';
15
15
 
16
16
  export interface ContractAddressVerificationParams {
@@ -18,7 +18,7 @@ export interface ContractAddressVerificationParams {
18
18
  readonly contractSaltPubKey: Buffer;
19
19
  readonly originalSalt: Buffer;
20
20
  readonly bytecode: Buffer;
21
- readonly challenge: ChallengeSolution;
21
+ readonly challenge: IChallengeSolution;
22
22
  readonly priorityFee: bigint;
23
23
  readonly features: Feature<Features>[];
24
24
  readonly calldata?: Buffer;