@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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.7.27",
4
+ "version": "1.7.29",
5
5
  "author": "BlobMaster41",
6
6
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
7
7
  "engines": {
@@ -12,73 +12,90 @@
12
12
  "browser": {
13
13
  "types": "./browser/index.d.ts",
14
14
  "import": "./browser/index.js",
15
- "require": "./browser/index.js"
15
+ "require": "./browser/index.js",
16
+ "default": "./browser/index.js"
16
17
  },
17
18
  "node": {
18
19
  "types": "./build/index.d.ts",
19
20
  "import": "./build/index.js",
20
- "require": "./build/index.js"
21
+ "require": "./build/index.js",
22
+ "default": "./build/index.js"
21
23
  },
22
24
  "types": "./build/index.d.ts",
23
25
  "import": "./build/index.js",
24
- "require": "./build/index.js"
26
+ "require": "./build/index.js",
27
+ "default": "./build/index.js"
25
28
  },
26
29
  "./browser": {
27
30
  "import": "./browser/index.js",
28
31
  "require": "./browser/index.js",
29
- "types": "./browser/index.d.ts"
32
+ "types": "./browser/index.d.ts",
33
+ "default": "./browser/index.js"
30
34
  },
31
35
  "./browser/noble-curves": {
32
36
  "import": "./browser/noble-curves.js",
33
- "require": "./browser/noble-curves.js"
37
+ "require": "./browser/noble-curves.js",
38
+ "default": "./browser/noble-curves.js"
34
39
  },
35
40
  "./browser/noble-hashes": {
36
41
  "import": "./browser/noble-hashes.js",
37
- "require": "./browser/noble-hashes.js"
42
+ "require": "./browser/noble-hashes.js",
43
+ "default": "./browser/noble-hashes.js"
38
44
  },
39
45
  "./browser/btc-vision-bitcoin": {
40
46
  "import": "./browser/btc-vision-bitcoin.js",
41
- "require": "./browser/btc-vision-bitcoin.js"
47
+ "require": "./browser/btc-vision-bitcoin.js",
48
+ "default": "./browser/btc-vision-bitcoin.js"
42
49
  },
43
50
  "./browser/btc-vision-bip32": {
44
51
  "import": "./browser/btc-vision-bip32.js",
45
- "require": "./browser/btc-vision-bip32.js"
52
+ "require": "./browser/btc-vision-bip32.js",
53
+ "default": "./browser/btc-vision-bip32.js"
46
54
  },
47
55
  "./browser/btc-vision-post-quantum": {
48
56
  "import": "./browser/btc-vision-post-quantum.js",
49
- "require": "./browser/btc-vision-post-quantum.js"
57
+ "require": "./browser/btc-vision-post-quantum.js",
58
+ "default": "./browser/btc-vision-post-quantum.js"
50
59
  },
51
60
  "./browser/btc-vision-logger": {
52
61
  "import": "./browser/btc-vision-logger.js",
53
- "require": "./browser/btc-vision-logger.js"
62
+ "require": "./browser/btc-vision-logger.js",
63
+ "default": "./browser/btc-vision-logger.js"
54
64
  },
55
65
  "./browser/valibot": {
56
66
  "import": "./browser/valibot.js",
57
- "require": "./browser/valibot.js"
67
+ "require": "./browser/valibot.js",
68
+ "default": "./browser/valibot.js"
58
69
  },
59
70
  "./browser/pako": {
60
71
  "import": "./browser/pako.js",
61
- "require": "./browser/pako.js"
72
+ "require": "./browser/pako.js",
73
+ "default": "./browser/pako.js"
62
74
  },
63
75
  "./browser/bip39": {
64
76
  "import": "./browser/bip39.js",
65
- "require": "./browser/bip39.js"
77
+ "require": "./browser/bip39.js",
78
+ "default": "./browser/bip39.js"
66
79
  },
67
80
  "./browser/bitcoin-utils": {
68
81
  "import": "./browser/bitcoin-utils.js",
69
- "require": "./browser/bitcoin-utils.js"
82
+ "require": "./browser/bitcoin-utils.js",
83
+ "default": "./browser/bitcoin-utils.js"
70
84
  },
71
85
  "./browser/scure-base": {
72
86
  "import": "./browser/scure-base.js",
73
- "require": "./browser/scure-base.js"
87
+ "require": "./browser/scure-base.js",
88
+ "default": "./browser/scure-base.js"
74
89
  },
75
90
  "./browser/polyfills": {
76
91
  "import": "./browser/polyfills.js",
77
- "require": "./browser/polyfills.js"
92
+ "require": "./browser/polyfills.js",
93
+ "default": "./browser/polyfills.js"
78
94
  },
79
95
  "./browser/vendors": {
80
96
  "import": "./browser/vendors.js",
81
- "require": "./browser/vendors.js"
97
+ "require": "./browser/vendors.js",
98
+ "default": "./browser/vendors.js"
82
99
  }
83
100
  },
84
101
  "browser": {
@@ -126,7 +143,9 @@
126
143
  "test": "npm run build && vitest run",
127
144
  "test:watch": "npm run build && vitest",
128
145
  "test:ui": "npm run build && vitest --ui",
129
- "test:coverage": "npm run build && vitest run --coverage"
146
+ "test:coverage": "npm run build && vitest run --coverage",
147
+ "check:circular": "madge --circular --extensions ts,tsx src/",
148
+ "prebuild": "npm run check:circular"
130
149
  },
131
150
  "devDependencies": {
132
151
  "@babel/core": "^7.28.5",
@@ -143,6 +162,7 @@
143
162
  "@vitest/ui": "^4.0.8",
144
163
  "eslint": "^9.39.1",
145
164
  "https-browserify": "^1.0.0",
165
+ "madge": "^8.0.0",
146
166
  "os-browserify": "^0.3.0",
147
167
  "prettier": "^3.6.2",
148
168
  "stream-browserify": "^3.0.0",
@@ -159,7 +179,7 @@
159
179
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
160
180
  "@bitcoinerlab/secp256k1": "^1.2.0",
161
181
  "@btc-vision/bip32": "^6.0.3",
162
- "@btc-vision/bitcoin": "^6.5.2",
182
+ "@btc-vision/bitcoin": "^6.5.4",
163
183
  "@btc-vision/bitcoin-rpc": "^1.0.6",
164
184
  "@btc-vision/logger": "^1.0.8",
165
185
  "@btc-vision/post-quantum": "^0.5.3",
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.7.27';
1
+ export const version = '1.7.28';
@@ -1,34 +1,7 @@
1
1
  import { Consensus } from './Consensus.js';
2
+ import { ConsensusConfig } from './IConsensusConfig.js';
2
3
  import { RoswellConsensus } from './metadata/RoswellConsensus.js';
3
4
 
4
- export interface ConsensusConfig<T extends Consensus> {
5
- // The consensus type.
6
- readonly CONSENSUS: T;
7
-
8
- // The consensus name.
9
- readonly CONSENSUS_NAME: string;
10
-
11
- // The block height at which this consensus was enabled.
12
- readonly ENABLED_AT_BLOCK: bigint;
13
-
14
- /** WBTC vaults */
15
- // Defines the minimum amount that can be consolidated in a single transaction.
16
- //readonly VAULT_MINIMUM_AMOUNT: bigint;
17
-
18
- // Defines the requested minimum acceptance for joining UTXOs when an unwrap is being done.
19
- // If the consolidate output going back to the vault is lower than this amount, the transaction will be rejected.
20
- // User must pay for the consolidation, this help the network by having fewer UTXOs.
21
- //readonly VAULT_NETWORK_CONSOLIDATION_ACCEPTANCE: bigint;
22
-
23
- // Everytime an user wrap bitcoin, he prepays the fees for the consolidation at a maximum fee rate of the following determined value.
24
- // If the fees are lower, the user will be refunded the difference.
25
- // If the fees are higher, the user must pay the difference.
26
- //readonly UNWRAP_CONSOLIDATION_PREPAID_FEES: bigint;
27
-
28
- // The maximum fee rate for the consolidation.
29
- //readonly UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT: bigint;
30
- }
31
-
32
5
  export const OPNetConsensusConfig: { [key in Consensus]?: ConsensusConfig<key> } = {
33
6
  [Consensus.Roswell]: RoswellConsensus,
34
7
  };
@@ -0,0 +1,29 @@
1
+ import { Consensus } from './Consensus.js';
2
+
3
+ export interface ConsensusConfig<T extends Consensus> {
4
+ // The consensus type.
5
+ readonly CONSENSUS: T;
6
+
7
+ // The consensus name.
8
+ readonly CONSENSUS_NAME: string;
9
+
10
+ // The block height at which this consensus was enabled.
11
+ readonly ENABLED_AT_BLOCK: bigint;
12
+
13
+ /** WBTC vaults */
14
+ // Defines the minimum amount that can be consolidated in a single transaction.
15
+ //readonly VAULT_MINIMUM_AMOUNT: bigint;
16
+
17
+ // Defines the requested minimum acceptance for joining UTXOs when an unwrap is being done.
18
+ // If the consolidate output going back to the vault is lower than this amount, the transaction will be rejected.
19
+ // User must pay for the consolidation, this help the network by having fewer UTXOs.
20
+ //readonly VAULT_NETWORK_CONSOLIDATION_ACCEPTANCE: bigint;
21
+
22
+ // Everytime an user wrap bitcoin, he prepays the fees for the consolidation at a maximum fee rate of the following determined value.
23
+ // If the fees are lower, the user will be refunded the difference.
24
+ // If the fees are higher, the user must pay the difference.
25
+ //readonly UNWRAP_CONSOLIDATION_PREPAID_FEES: bigint;
26
+
27
+ // The maximum fee rate for the consolidation.
28
+ //readonly UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT: bigint;
29
+ }
@@ -1,4 +1,4 @@
1
- import { ConsensusConfig } from '../ConsensusConfig.js';
1
+ import { ConsensusConfig } from '../IConsensusConfig.js';
2
2
  import { Consensus } from '../Consensus.js';
3
3
 
4
4
  export const RoswellConsensus: ConsensusConfig<Consensus.Roswell> = {
@@ -18,6 +18,16 @@ export interface IChallengeSolution {
18
18
  readonly graffiti: Buffer;
19
19
  readonly difficulty: number;
20
20
  readonly verification: IChallengeVerification;
21
+
22
+ verifySubmissionSignature(): boolean;
23
+ getSubmission(): IChallengeSubmission | undefined;
24
+ toRaw(): RawChallenge;
25
+ verify(): boolean;
26
+ toBuffer(): Buffer;
27
+ toHex(): string;
28
+ calculateSolution(): Buffer;
29
+ checkDifficulty(minDifficulty: number): { valid: boolean; difficulty: number };
30
+ getMiningTargetBlock(): bigint | null;
21
31
  }
22
32
 
23
33
  export interface RawChallengeVerification {
@@ -41,8 +51,10 @@ export interface RawChallengeSubmission {
41
51
  export interface IChallengeSubmission {
42
52
  readonly publicKey: Address;
43
53
  readonly solution: Buffer;
44
- readonly graffiti?: Buffer;
54
+ readonly graffiti: Buffer | undefined;
45
55
  readonly signature: Buffer;
56
+ readonly epochNumber: bigint;
57
+ verifySignature(): boolean;
46
58
  }
47
59
 
48
60
  export interface RawChallenge {
@@ -1,6 +1,7 @@
1
1
  import { IChallengeSolution, RawChallenge } from '../interfaces/IChallengeSolution.js';
2
- import { ChallengeSolution } from '../ChallengeSolution.js';
3
2
  import { crypto } from '@btc-vision/bitcoin';
3
+ import { Address } from '../../keypair/Address.js';
4
+ import { stringToBuffer } from '../../utils/StringToBuffer.js';
4
5
 
5
6
  export class EpochValidator {
6
7
  private static readonly BLOCKS_PER_EPOCH: bigint = 5n;
@@ -131,8 +132,58 @@ export class EpochValidator {
131
132
  * Validate epoch winner from raw data
132
133
  */
133
134
  public static validateEpochWinner(epochData: RawChallenge): boolean {
134
- const preimage = new ChallengeSolution(epochData);
135
- return this.verifySolution(preimage);
135
+ try {
136
+ const epochNumber = BigInt(epochData.epochNumber);
137
+ const publicKey = Address.fromString(
138
+ epochData.mldsaPublicKey,
139
+ epochData.legacyPublicKey,
140
+ );
141
+ const solution = stringToBuffer(epochData.solution);
142
+ const salt = stringToBuffer(epochData.salt);
143
+ const difficulty = epochData.difficulty;
144
+
145
+ const verification = {
146
+ epochHash: stringToBuffer(epochData.verification.epochHash),
147
+ epochRoot: stringToBuffer(epochData.verification.epochRoot),
148
+ targetHash: stringToBuffer(epochData.verification.targetHash),
149
+ targetChecksum: stringToBuffer(epochData.verification.targetChecksum),
150
+ startBlock: BigInt(epochData.verification.startBlock),
151
+ endBlock: BigInt(epochData.verification.endBlock),
152
+ proofs: Object.freeze(epochData.verification.proofs.map((p) => stringToBuffer(p))),
153
+ };
154
+
155
+ const calculatedPreimage = this.calculatePreimage(
156
+ verification.targetChecksum,
157
+ publicKey.toBuffer(),
158
+ salt,
159
+ );
160
+
161
+ const computedSolution = this.sha1(calculatedPreimage);
162
+ const computedSolutionBuffer = this.uint8ArrayToBuffer(computedSolution);
163
+
164
+ if (!computedSolutionBuffer.equals(solution)) {
165
+ return false;
166
+ }
167
+
168
+ const matchingBits = this.countMatchingBits(
169
+ computedSolutionBuffer,
170
+ verification.targetHash,
171
+ );
172
+
173
+ if (matchingBits !== difficulty) {
174
+ return false;
175
+ }
176
+
177
+ const expectedStartBlock = epochNumber * this.BLOCKS_PER_EPOCH;
178
+ const expectedEndBlock = expectedStartBlock + this.BLOCKS_PER_EPOCH - 1n;
179
+
180
+ return !(
181
+ verification.startBlock !== expectedStartBlock ||
182
+ verification.endBlock !== expectedEndBlock
183
+ );
184
+ } catch {
185
+ return false;
186
+ }
136
187
  }
137
188
 
138
189
  /**
@@ -4,7 +4,7 @@ import { Compressor } from '../../bytecode/Compressor.js';
4
4
  import { EcKeyPair } from '../../keypair/EcKeyPair.js';
5
5
  import { Feature, Features } from '../Features.js';
6
6
  import { Generator } from '../Generator.js';
7
- import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
7
+ import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
8
8
  import { BinaryWriter } from '../../buffer/BinaryWriter.js';
9
9
 
10
10
  /**
@@ -58,7 +58,7 @@ export class CalldataGenerator extends Generator {
58
58
  * Compile an interaction bitcoin script
59
59
  * @param {Buffer} calldata - The calldata to use
60
60
  * @param {Buffer} contractSecret - The contract secret
61
- * @param {ChallengeSolution} challenge
61
+ * @param {IChallengeSolution} challenge
62
62
  * @param maxPriority - Amount of satoshis to spend max on priority fee
63
63
  * @param {Feature<Features>[]} featuresRaw - The features to use
64
64
  * @returns {Buffer} - The compiled script
@@ -67,7 +67,7 @@ export class CalldataGenerator extends Generator {
67
67
  public compile(
68
68
  calldata: Buffer,
69
69
  contractSecret: Buffer,
70
- challenge: ChallengeSolution,
70
+ challenge: IChallengeSolution,
71
71
  maxPriority: bigint,
72
72
  featuresRaw: Feature<Features>[] = [],
73
73
  ): Buffer {
@@ -1,7 +1,7 @@
1
1
  import { crypto, Network, networks, opcodes, script } from '@btc-vision/bitcoin';
2
2
  import { Generator } from '../Generator.js';
3
3
  import { Feature, Features } from '../Features.js';
4
- import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
4
+ import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
5
5
  import { BinaryWriter } from '../../buffer/BinaryWriter.js';
6
6
 
7
7
  export const OPNET_DEPLOYMENT_VERSION = 0x00;
@@ -29,7 +29,7 @@ export class DeploymentGenerator extends Generator {
29
29
  public compile(
30
30
  contractBytecode: Buffer,
31
31
  contractSalt: Buffer,
32
- challenge: ChallengeSolution,
32
+ challenge: IChallengeSolution,
33
33
  maxPriority: bigint,
34
34
  calldata?: Buffer,
35
35
  features?: Feature<Features>[],
@@ -59,7 +59,7 @@ export class DeploymentGenerator extends Generator {
59
59
  private getAsm(
60
60
  contractBytecode: Buffer,
61
61
  contractSalt: Buffer,
62
- challenge: ChallengeSolution,
62
+ challenge: IChallengeSolution,
63
63
  maxPriority: bigint,
64
64
  calldata?: Buffer,
65
65
  featuresRaw?: Feature<Features>[],
@@ -2,7 +2,7 @@ import { Network, networks } from '@btc-vision/bitcoin';
2
2
  import { BinaryWriter } from '../../buffer/BinaryWriter.js';
3
3
  import { Feature, Features } from '../Features.js';
4
4
  import { Generator } from '../Generator.js';
5
- import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
5
+ import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
6
6
 
7
7
  /**
8
8
  * @category Generators
@@ -62,7 +62,7 @@ export class P2WDAGenerator extends Generator {
62
62
  public compile(
63
63
  calldata: Buffer,
64
64
  contractSecret: Buffer,
65
- challenge: ChallengeSolution,
65
+ challenge: IChallengeSolution,
66
66
  maxPriority: bigint,
67
67
  featuresRaw: Feature<Features>[] = [],
68
68
  ): Buffer {
@@ -5,7 +5,7 @@ import { TweakedSigner } from '../signer/TweakedSigner.js';
5
5
  import { EcKeyPair } from './EcKeyPair.js';
6
6
  import { MLDSASecurityLevel, QuantumBIP32Interface } from '@btc-vision/bip32';
7
7
  import { isOPWallet, OPWallet } from '../transaction/browser/types/OPWallet.js';
8
- import { MLDSASignature } from '../transaction/browser/Web3Provider.js';
8
+ import { MLDSASignature } from '../transaction/interfaces/IWeb3ProviderTypes.js';
9
9
 
10
10
  export interface SignedMessage {
11
11
  readonly signature: Uint8Array;
package/src/opnet.ts CHANGED
@@ -55,12 +55,18 @@ export * from './network/ChainId.js';
55
55
 
56
56
  /** Signer */
57
57
  export * from './signer/TweakedSigner.js';
58
+ export * from './signer/IRotationSigner.js';
58
59
  export * from './signer/AddressRotation.js';
59
60
 
60
61
  /** Transaction */
61
62
  export * from './transaction/enums/TransactionType.js';
62
63
  export * from './transaction/interfaces/ITransactionParameters.js';
63
64
  export * from './transaction/interfaces/IConsolidatedTransactionParameters.js';
65
+ export * from './transaction/interfaces/ITransactionResponses.js';
66
+ export * from './transaction/interfaces/IWeb3ProviderTypes.js';
67
+ export * from './transaction/interfaces/ICancelTransactionParameters.js';
68
+ export * from './transaction/interfaces/ICustomTransactionParameters.js';
69
+ export * from './transaction/interfaces/ITweakedTransactionData.js';
64
70
  export * from './transaction/interfaces/Tap.js';
65
71
  export * from './transaction/TransactionFactory.js';
66
72
 
@@ -100,9 +106,6 @@ export * from './utils/lengths.js';
100
106
  export * from './utxo/interfaces/IUTXO.js';
101
107
  export * from './utxo/OPNetLimitedProvider.js';
102
108
 
103
- /** Processor */
104
- export * from './transaction/processor/PsbtTransaction.js';
105
-
106
109
  /** Shared */
107
110
  export * from './transaction/psbt/PSBTTypes.js';
108
111
  export * from './transaction/shared/TweakedTransaction.js';
@@ -112,6 +115,7 @@ export * from './transaction/shared/P2TR_MS.js';
112
115
 
113
116
  /** Consensus */
114
117
  export * from './consensus/Consensus.js';
118
+ export * from './consensus/IConsensusConfig.js';
115
119
  export * from './consensus/ConsensusConfig.js';
116
120
  export * from './consensus/metadata/RoswellConsensus.js';
117
121
 
@@ -136,7 +140,6 @@ export * from './transaction/browser/types/Unisat.js';
136
140
  export * from './transaction/browser/types/Xverse.js';
137
141
  export * from './transaction/browser/types/OPWallet.js';
138
142
 
139
- export * from './metadata/tokens.js';
140
143
  export * from './transaction/browser/Web3Provider.js';
141
144
 
142
145
  export * from './keypair/Secp256k1PointDeriver.js';
@@ -1,11 +1,10 @@
1
- import { Signer } from '@btc-vision/bitcoin';
2
- import { ECPairInterface } from 'ecpair';
1
+ import { RotationSignerBase } from './IRotationSigner.js';
3
2
  import { UnisatSigner } from '../transaction/browser/extensions/UnisatSigner.js';
4
3
 
5
4
  /**
6
- * Supported signer types for address rotation
5
+ * Supported signer types for address rotation (includes browser signers)
7
6
  */
8
- export type RotationSigner = Signer | ECPairInterface | UnisatSigner;
7
+ export type RotationSigner = RotationSignerBase | UnisatSigner;
9
8
 
10
9
  /**
11
10
  * Map of addresses to their respective signers for address rotation mode.
@@ -0,0 +1,35 @@
1
+ import { Signer } from '@btc-vision/bitcoin';
2
+ import { ECPairInterface } from 'ecpair';
3
+
4
+ /**
5
+ * Base signer type for address rotation.
6
+ * This is the minimal interface required for UTXO signing.
7
+ * UnisatSigner extends this through the CustomKeypair base class.
8
+ */
9
+ export type RotationSignerBase = Signer | ECPairInterface;
10
+
11
+ /**
12
+ * Map of addresses to their respective signers for address rotation mode.
13
+ * Each UTXO address can have its own dedicated signer.
14
+ */
15
+ export type SignerMapBase = Map<string, RotationSignerBase>;
16
+
17
+ /**
18
+ * Configuration for address rotation mode (base version without browser signers).
19
+ * When enabled, each UTXO can be signed by a different signer based on its address.
20
+ */
21
+ export interface AddressRotationConfigBase {
22
+ /**
23
+ * Whether address rotation mode is enabled.
24
+ * When true, the signerMap will be used to find the appropriate signer for each UTXO.
25
+ * When false, the default single signer will be used for all inputs.
26
+ */
27
+ readonly enabled: boolean;
28
+
29
+ /**
30
+ * Map of addresses to their respective signers.
31
+ * The key is the address (from UTXO.scriptPubKey.address).
32
+ * The value is the signer that controls that address.
33
+ */
34
+ readonly signerMap: SignerMapBase;
35
+ }
@@ -1,10 +1,7 @@
1
1
  import { Transaction, TxOutput } from '@btc-vision/bitcoin';
2
2
  import { currentConsensus } from '../consensus/ConsensusConfig.js';
3
3
  import { UTXO } from '../utxo/interfaces/IUTXO.js';
4
- import {
5
- CustomScriptTransaction,
6
- ICustomTransactionParameters,
7
- } from './builders/CustomScriptTransaction.js';
4
+ import { CustomScriptTransaction } from './builders/CustomScriptTransaction.js';
8
5
  import { DeploymentTransaction } from './builders/DeploymentTransaction.js';
9
6
  import { FundingTransaction } from './builders/FundingTransaction.js';
10
7
  import { InteractionTransaction } from './builders/InteractionTransaction.js';
@@ -22,26 +19,23 @@ import {
22
19
  ICustomTransactionWithoutSigner,
23
20
  IDeploymentParametersWithoutSigner,
24
21
  InteractionParametersWithoutSigner,
25
- } from './browser/Web3Provider.js';
22
+ } from './interfaces/IWeb3ProviderTypes.js';
26
23
  import { WindowWithWallets } from './browser/extensions/UnisatSigner.js';
27
- import { RawChallenge } from '../epoch/interfaces/IChallengeSolution.js';
24
+ import { IChallengeSolution, RawChallenge } from '../epoch/interfaces/IChallengeSolution.js';
28
25
  import { P2WDADetector } from '../p2wda/P2WDADetector.js';
29
26
  import { InteractionTransactionP2WDA } from './builders/InteractionTransactionP2WDA.js';
30
- import { ChallengeSolution } from '../epoch/ChallengeSolution.js';
31
27
  import { Address } from '../keypair/Address.js';
32
28
  import { BitcoinUtils } from '../utils/BitcoinUtils.js';
33
- import { CancelTransaction, ICancelTransactionParameters } from './builders/CancelTransaction.js';
29
+ import { CancelTransaction } from './builders/CancelTransaction.js';
34
30
  import { ConsolidatedInteractionTransaction } from './builders/ConsolidatedInteractionTransaction.js';
35
31
  import { IConsolidatedInteractionParameters } from './interfaces/IConsolidatedTransactionParameters.js';
36
-
37
- export interface DeploymentResult {
38
- readonly transaction: [string, string];
39
- readonly contractAddress: string;
40
- readonly contractPubKey: string;
41
- readonly challenge: RawChallenge;
42
- readonly utxos: UTXO[];
43
- readonly inputUtxos: UTXO[];
44
- }
32
+ import {
33
+ CancelledTransaction,
34
+ DeploymentResult,
35
+ InteractionResponse,
36
+ } from './interfaces/ITransactionResponses.js';
37
+ import { ICancelTransactionParameters } from './interfaces/ICancelTransactionParameters.js';
38
+ import { ICustomTransactionParameters } from './interfaces/ICustomTransactionParameters.js';
45
39
 
46
40
  export interface FundingTransactionResponse {
47
41
  readonly tx: Transaction;
@@ -58,28 +52,10 @@ export interface BitcoinTransferBase {
58
52
  readonly inputUtxos: UTXO[];
59
53
  }
60
54
 
61
- export interface InteractionResponse {
62
- readonly fundingTransaction: string | null;
63
- readonly interactionTransaction: string;
64
- readonly estimatedFees: bigint;
65
- readonly nextUTXOs: UTXO[];
66
- readonly fundingUTXOs: UTXO[];
67
- readonly fundingInputUtxos: UTXO[];
68
- readonly challenge: RawChallenge;
69
- readonly interactionAddress: string | null;
70
- readonly compiledTargetScript: string | null;
71
- }
72
-
73
55
  export interface BitcoinTransferResponse extends BitcoinTransferBase {
74
56
  readonly original: FundingTransaction;
75
57
  }
76
58
 
77
- export interface CancelledTransaction {
78
- readonly transaction: string;
79
- readonly nextUTXOs: UTXO[];
80
- readonly inputUtxos: UTXO[];
81
- }
82
-
83
59
  /**
84
60
  * Response from signConsolidatedInteraction.
85
61
  * Contains both setup and reveal transactions for the CHCT system.
@@ -835,7 +811,7 @@ export class TransactionFactory {
835
811
  * @param {new (params: P) => T} TransactionClass - The transaction class constructor
836
812
  * @param {(tx: T) => Promise<bigint>} calculateAmount - Function to calculate required amount
837
813
  * @param {string} debugPrefix - Prefix for debug logging
838
- * @returns {Promise<{finalTransaction: T, estimatedAmount: bigint, challenge: ChallengeSolution | null}>} - The final transaction and estimated amount
814
+ * @returns {Promise<{finalTransaction: T, estimatedAmount: bigint, challenge: IChallengeSolution | null}>} - The final transaction and estimated amount
839
815
  */
840
816
  private async iterateFundingAmount<
841
817
  T extends InteractionTransaction | DeploymentTransaction | CustomScriptTransaction,
@@ -848,7 +824,7 @@ export class TransactionFactory {
848
824
  ): Promise<{
849
825
  finalTransaction: T;
850
826
  estimatedAmount: bigint;
851
- challenge: ChallengeSolution | null;
827
+ challenge: IChallengeSolution | null;
852
828
  }> {
853
829
  const randomBytes =
854
830
  'randomBytes' in params
@@ -861,7 +837,7 @@ export class TransactionFactory {
861
837
  let previousAmount = 0n;
862
838
  let iterations = 0;
863
839
  let finalPreTransaction: T | null = null;
864
- let challenge: ChallengeSolution | null = null;
840
+ let challenge: IChallengeSolution | null = null;
865
841
 
866
842
  while (iterations < this.MAX_ITERATIONS && estimatedFundingAmount !== previousAmount) {
867
843
  previousAmount = estimatedFundingAmount;