@btc-vision/transaction 1.6.0 → 1.6.1

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 (32) hide show
  1. package/browser/_version.d.ts +1 -1
  2. package/browser/epoch/validator/EpochValidator.d.ts +2 -2
  3. package/browser/generators/builders/DeploymentGenerator.d.ts +1 -1
  4. package/browser/generators/builders/LegacyCalldataGenerator.d.ts +1 -1
  5. package/browser/index.js +1 -1
  6. package/browser/transaction/TransactionFactory.d.ts +2 -2
  7. package/browser/transaction/builders/DeploymentTransaction.d.ts +1 -1
  8. package/browser/utxo/OPNetLimitedProvider.d.ts +0 -4
  9. package/build/_version.d.ts +1 -1
  10. package/build/_version.js +1 -1
  11. package/build/epoch/ChallengeSolution.js +1 -1
  12. package/build/epoch/validator/EpochValidator.d.ts +2 -2
  13. package/build/epoch/validator/EpochValidator.js +8 -8
  14. package/build/generators/builders/DeploymentGenerator.d.ts +1 -1
  15. package/build/generators/builders/DeploymentGenerator.js +5 -5
  16. package/build/generators/builders/LegacyCalldataGenerator.d.ts +1 -1
  17. package/build/generators/builders/LegacyCalldataGenerator.js +2 -2
  18. package/build/transaction/TransactionFactory.d.ts +2 -2
  19. package/build/transaction/TransactionFactory.js +2 -2
  20. package/build/transaction/builders/DeploymentTransaction.d.ts +1 -1
  21. package/build/transaction/builders/DeploymentTransaction.js +4 -4
  22. package/build/utxo/OPNetLimitedProvider.d.ts +0 -4
  23. package/build/utxo/OPNetLimitedProvider.js +0 -7
  24. package/package.json +1 -1
  25. package/src/_version.ts +1 -1
  26. package/src/epoch/ChallengeSolution.ts +7 -7
  27. package/src/epoch/validator/EpochValidator.ts +9 -9
  28. package/src/generators/builders/DeploymentGenerator.ts +6 -6
  29. package/src/generators/builders/LegacyCalldataGenerator.ts +3 -3
  30. package/src/transaction/TransactionFactory.ts +4 -4
  31. package/src/transaction/builders/DeploymentTransaction.ts +5 -5
  32. package/src/utxo/OPNetLimitedProvider.ts +0 -17
@@ -11,7 +11,7 @@ export interface DeploymentResult {
11
11
  readonly transaction: [string, string];
12
12
  readonly contractAddress: string;
13
13
  readonly contractPubKey: string;
14
- readonly preimage: RawChallenge;
14
+ readonly challenge: RawChallenge;
15
15
  readonly utxos: UTXO[];
16
16
  }
17
17
  export interface FundingTransactionResponse {
@@ -30,7 +30,7 @@ export interface InteractionResponse {
30
30
  readonly interactionTransaction: string;
31
31
  readonly estimatedFees: bigint;
32
32
  readonly nextUTXOs: UTXO[];
33
- readonly preimage: RawChallenge;
33
+ readonly challenge: RawChallenge;
34
34
  }
35
35
  export interface BitcoinTransferResponse extends BitcoinTransferBase {
36
36
  readonly original: FundingTransaction;
@@ -9,7 +9,7 @@ import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
9
9
  export declare class DeploymentTransaction extends TransactionBuilder<TransactionType.DEPLOYMENT> {
10
10
  static readonly MAXIMUM_CONTRACT_SIZE: number;
11
11
  type: TransactionType.DEPLOYMENT;
12
- protected readonly preimage: ChallengeSolution;
12
+ protected readonly challenge: ChallengeSolution;
13
13
  protected readonly epochChallenge: ITimeLockOutput;
14
14
  protected readonly _contractAddress: Address;
15
15
  protected tapLeafScript: TapLeafScript | null;
@@ -7,9 +7,6 @@ export interface WalletUTXOs {
7
7
  readonly pending: RawUTXOResponse[];
8
8
  readonly spentTransactions: RawUTXOResponse[];
9
9
  }
10
- export interface PreimageData {
11
- readonly preimage: Buffer;
12
- }
13
10
  export declare class OPNetLimitedProvider {
14
11
  private readonly opnetAPIUrl;
15
12
  private readonly utxoPath;
@@ -18,7 +15,6 @@ export declare class OPNetLimitedProvider {
18
15
  fetchUTXO(settings: FetchUTXOParams): Promise<UTXO[]>;
19
16
  fetchUTXOMultiAddr(settings: FetchUTXOParamsMultiAddress): Promise<UTXO[]>;
20
17
  broadcastTransaction(transaction: string, psbt: boolean): Promise<BroadcastResponse | undefined>;
21
- getPreimage(): Promise<PreimageData | undefined>;
22
18
  splitUTXOs(wallet: Wallet, network: Network, splitInputsInto: number, amountPerUTXO: bigint): Promise<BroadcastResponse | {
23
19
  error: string;
24
20
  }>;
@@ -1 +1 @@
1
- export declare const version = "1.6.0";
1
+ export declare const version = "1.6.1";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.6.0';
1
+ export const version = '1.6.1';
@@ -66,7 +66,7 @@ export class ChallengeSolution {
66
66
  return this.submission;
67
67
  }
68
68
  async verify() {
69
- return EpochValidator.validatePreimage(this);
69
+ return EpochValidator.validateChallengeSolution(this);
70
70
  }
71
71
  toBuffer() {
72
72
  return this.solution;
@@ -7,10 +7,10 @@ export declare class EpochValidator {
7
7
  static sha1(data: Uint8Array): Promise<Uint8Array>;
8
8
  static calculatePreimage(checksumRoot: Buffer, publicKey: Buffer, salt: Buffer): Buffer;
9
9
  static countMatchingBits(hash1: Buffer, hash2: Buffer): number;
10
- static verifySolution(preimage: IChallengeSolution, log?: boolean): Promise<boolean>;
10
+ static verifySolution(challenge: IChallengeSolution, log?: boolean): Promise<boolean>;
11
11
  static getMiningTargetBlock(epochNumber: bigint): bigint | null;
12
12
  static validateEpochWinner(epochData: RawChallenge): Promise<boolean>;
13
- static validatePreimage(preimage: IChallengeSolution): Promise<boolean>;
13
+ static validateChallengeSolution(challenge: IChallengeSolution): Promise<boolean>;
14
14
  static calculateSolution(targetChecksum: Buffer, publicKey: Buffer, salt: Buffer): Promise<Buffer>;
15
15
  static checkDifficulty(solution: Buffer, targetHash: Buffer, minDifficulty: number): {
16
16
  valid: boolean;
@@ -45,20 +45,20 @@ export class EpochValidator {
45
45
  }
46
46
  return matchingBits;
47
47
  }
48
- static async verifySolution(preimage, log = false) {
48
+ static async verifySolution(challenge, log = false) {
49
49
  try {
50
- const verification = preimage.verification;
51
- const calculatedPreimage = this.calculatePreimage(verification.targetChecksum, preimage.publicKey.toBuffer(), preimage.salt);
50
+ const verification = challenge.verification;
51
+ const calculatedPreimage = this.calculatePreimage(verification.targetChecksum, challenge.publicKey.toBuffer(), challenge.salt);
52
52
  const computedSolution = await this.sha1(this.bufferToUint8Array(calculatedPreimage));
53
53
  const computedSolutionBuffer = this.uint8ArrayToBuffer(computedSolution);
54
- if (!computedSolutionBuffer.equals(preimage.solution)) {
54
+ if (!computedSolutionBuffer.equals(challenge.solution)) {
55
55
  return false;
56
56
  }
57
57
  const matchingBits = this.countMatchingBits(computedSolutionBuffer, verification.targetHash);
58
- if (matchingBits !== preimage.difficulty) {
58
+ if (matchingBits !== challenge.difficulty) {
59
59
  return false;
60
60
  }
61
- const expectedStartBlock = preimage.epochNumber * this.BLOCKS_PER_EPOCH;
61
+ const expectedStartBlock = challenge.epochNumber * this.BLOCKS_PER_EPOCH;
62
62
  const expectedEndBlock = expectedStartBlock + this.BLOCKS_PER_EPOCH - 1n;
63
63
  return !(verification.startBlock !== expectedStartBlock ||
64
64
  verification.endBlock !== expectedEndBlock);
@@ -79,8 +79,8 @@ export class EpochValidator {
79
79
  const preimage = new ChallengeSolution(epochData);
80
80
  return await this.verifySolution(preimage);
81
81
  }
82
- static async validatePreimage(preimage) {
83
- return await this.verifySolution(preimage);
82
+ static async validateChallengeSolution(challenge) {
83
+ return await this.verifySolution(challenge);
84
84
  }
85
85
  static async calculateSolution(targetChecksum, publicKey, salt) {
86
86
  const preimage = this.calculatePreimage(targetChecksum, publicKey, salt);
@@ -6,6 +6,6 @@ export declare const OPNET_DEPLOYMENT_VERSION = 0;
6
6
  export declare const versionBuffer: Buffer<ArrayBuffer>;
7
7
  export declare class DeploymentGenerator extends Generator {
8
8
  constructor(senderPubKey: Buffer, contractSaltPubKey: Buffer, network?: Network);
9
- compile(contractBytecode: Buffer, contractSalt: Buffer, preimage: ChallengeSolution, maxPriority: bigint, calldata?: Buffer, features?: Feature<Features>[]): Buffer;
9
+ compile(contractBytecode: Buffer, contractSalt: Buffer, challenge: ChallengeSolution, maxPriority: bigint, calldata?: Buffer, features?: Feature<Features>[]): Buffer;
10
10
  private getAsm;
11
11
  }
@@ -6,8 +6,8 @@ export class DeploymentGenerator extends Generator {
6
6
  constructor(senderPubKey, contractSaltPubKey, network = networks.bitcoin) {
7
7
  super(senderPubKey, contractSaltPubKey, network);
8
8
  }
9
- compile(contractBytecode, contractSalt, preimage, maxPriority, calldata, features) {
10
- const asm = this.getAsm(contractBytecode, contractSalt, preimage, maxPriority, calldata, features);
9
+ compile(contractBytecode, contractSalt, challenge, maxPriority, calldata, features) {
10
+ const asm = this.getAsm(contractBytecode, contractSalt, challenge, maxPriority, calldata, features);
11
11
  const compiled = script.compile(asm);
12
12
  const decompiled = script.decompile(compiled);
13
13
  if (!decompiled) {
@@ -15,7 +15,7 @@ export class DeploymentGenerator extends Generator {
15
15
  }
16
16
  return compiled;
17
17
  }
18
- getAsm(contractBytecode, contractSalt, preimage, maxPriority, calldata, features) {
18
+ getAsm(contractBytecode, contractSalt, challenge, maxPriority, calldata, features) {
19
19
  if (!this.contractSaltPubKey)
20
20
  throw new Error('Contract salt public key not set');
21
21
  const dataChunks = this.splitBufferIntoChunks(contractBytecode);
@@ -33,9 +33,9 @@ export class DeploymentGenerator extends Generator {
33
33
  const compiledData = [
34
34
  this.getHeader(maxPriority, featuresList),
35
35
  opcodes.OP_TOALTSTACK,
36
- preimage.publicKey.originalPublicKeyBuffer(),
36
+ challenge.publicKey.originalPublicKeyBuffer(),
37
37
  opcodes.OP_TOALTSTACK,
38
- preimage.solution,
38
+ challenge.solution,
39
39
  opcodes.OP_TOALTSTACK,
40
40
  this.xSenderPubKey,
41
41
  opcodes.OP_DUP,
@@ -4,5 +4,5 @@ import { Feature, Features } from '../Features.js';
4
4
  export declare class LegacyCalldataGenerator extends Generator {
5
5
  constructor(senderPubKey: Buffer, network?: Network);
6
6
  static getPubKeyAsBuffer(witnessKeys: Buffer[], network: Network): Buffer;
7
- compile(calldata: Buffer, contractSecret: Buffer, preimage: Buffer, maxPriority: bigint, features?: Feature<Features>[]): Buffer;
7
+ compile(calldata: Buffer, contractSecret: Buffer, challenge: Buffer, maxPriority: bigint, features?: Feature<Features>[]): Buffer;
8
8
  }
@@ -24,7 +24,7 @@ export class LegacyCalldataGenerator extends Generator {
24
24
  }
25
25
  return compressed;
26
26
  }
27
- compile(calldata, contractSecret, preimage, maxPriority, features = []) {
27
+ compile(calldata, contractSecret, challenge, maxPriority, features = []) {
28
28
  const dataChunks = this.splitBufferIntoChunks(calldata);
29
29
  if (!dataChunks.length)
30
30
  throw new Error('No data chunks found');
@@ -39,7 +39,7 @@ export class LegacyCalldataGenerator extends Generator {
39
39
  let compiledData = [
40
40
  this.getHeader(maxPriority, featuresList),
41
41
  opcodes.OP_TOALTSTACK,
42
- preimage,
42
+ challenge,
43
43
  opcodes.OP_TOALTSTACK,
44
44
  this.senderPubKey,
45
45
  opcodes.OP_DUP,
@@ -11,7 +11,7 @@ export interface DeploymentResult {
11
11
  readonly transaction: [string, string];
12
12
  readonly contractAddress: string;
13
13
  readonly contractPubKey: string;
14
- readonly preimage: RawChallenge;
14
+ readonly challenge: RawChallenge;
15
15
  readonly utxos: UTXO[];
16
16
  }
17
17
  export interface FundingTransactionResponse {
@@ -30,7 +30,7 @@ export interface InteractionResponse {
30
30
  readonly interactionTransaction: string;
31
31
  readonly estimatedFees: bigint;
32
32
  readonly nextUTXOs: UTXO[];
33
- readonly preimage: RawChallenge;
33
+ readonly challenge: RawChallenge;
34
34
  }
35
35
  export interface BitcoinTransferResponse extends BitcoinTransferBase {
36
36
  readonly original: FundingTransaction;
@@ -133,7 +133,7 @@ export class TransactionFactory {
133
133
  interactionTransaction: outTx.toHex(),
134
134
  estimatedFees: preTransaction.estimatedFees,
135
135
  nextUTXOs: this.getUTXOAsTransaction(signedTransaction.tx, interactionParameters.from, 1),
136
- preimage: preTransaction.getPreimage().toRaw(),
136
+ challenge: preTransaction.getPreimage().toRaw(),
137
137
  };
138
138
  }
139
139
  async signDeployment(deploymentParameters) {
@@ -211,7 +211,7 @@ export class TransactionFactory {
211
211
  contractAddress: finalTransaction.getContractAddress(),
212
212
  contractPubKey: finalTransaction.contractPubKey,
213
213
  utxos: [refundUTXO],
214
- preimage: preTransaction.getPreimage().toRaw(),
214
+ challenge: preTransaction.getPreimage().toRaw(),
215
215
  };
216
216
  }
217
217
  async createBTCTransfer(parameters) {
@@ -9,7 +9,7 @@ import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
9
9
  export declare class DeploymentTransaction extends TransactionBuilder<TransactionType.DEPLOYMENT> {
10
10
  static readonly MAXIMUM_CONTRACT_SIZE: number;
11
11
  type: TransactionType.DEPLOYMENT;
12
- protected readonly preimage: ChallengeSolution;
12
+ protected readonly challenge: ChallengeSolution;
13
13
  protected readonly epochChallenge: ITimeLockOutput;
14
14
  protected readonly _contractAddress: Address;
15
15
  protected tapLeafScript: TapLeafScript | null;
@@ -45,12 +45,12 @@ export class DeploymentTransaction extends TransactionBuilder {
45
45
  if (!parameters.challenge)
46
46
  throw new Error('Challenge solution is required');
47
47
  this.randomBytes = parameters.randomBytes || BitcoinUtils.rndBytes();
48
- this.preimage = parameters.challenge;
49
- this.epochChallenge = TimeLockGenerator.generateTimeLockAddress(this.preimage.publicKey.originalPublicKeyBuffer(), this.network);
48
+ this.challenge = parameters.challenge;
49
+ this.epochChallenge = TimeLockGenerator.generateTimeLockAddress(this.challenge.publicKey.originalPublicKeyBuffer(), this.network);
50
50
  this.contractSeed = this.getContractSeed();
51
51
  this.contractSigner = EcKeyPair.fromSeedKeyPair(this.contractSeed, this.network);
52
52
  this.deploymentGenerator = new DeploymentGenerator(Buffer.from(this.signer.publicKey), this.contractSignerXOnlyPubKey(), this.network);
53
- this.compiledTargetScript = this.deploymentGenerator.compile(this.bytecode, this.randomBytes, this.preimage, this.priorityFee, this.calldata, this.generateFeatures(parameters));
53
+ this.compiledTargetScript = this.deploymentGenerator.compile(this.bytecode, this.randomBytes, this.challenge, this.priorityFee, this.calldata, this.generateFeatures(parameters));
54
54
  this.scriptTree = this.getScriptTree();
55
55
  this.internalInit();
56
56
  this._contractPubKey = '0x' + this.contractSeed.toString('hex');
@@ -69,7 +69,7 @@ export class DeploymentTransaction extends TransactionBuilder {
69
69
  return this.randomBytes;
70
70
  }
71
71
  getPreimage() {
72
- return this.preimage;
72
+ return this.challenge;
73
73
  }
74
74
  getContractAddress() {
75
75
  if (this._computedAddress) {
@@ -7,9 +7,6 @@ export interface WalletUTXOs {
7
7
  readonly pending: RawUTXOResponse[];
8
8
  readonly spentTransactions: RawUTXOResponse[];
9
9
  }
10
- export interface PreimageData {
11
- readonly preimage: Buffer;
12
- }
13
10
  export declare class OPNetLimitedProvider {
14
11
  private readonly opnetAPIUrl;
15
12
  private readonly utxoPath;
@@ -18,7 +15,6 @@ export declare class OPNetLimitedProvider {
18
15
  fetchUTXO(settings: FetchUTXOParams): Promise<UTXO[]>;
19
16
  fetchUTXOMultiAddr(settings: FetchUTXOParamsMultiAddress): Promise<UTXO[]>;
20
17
  broadcastTransaction(transaction: string, psbt: boolean): Promise<BroadcastResponse | undefined>;
21
- getPreimage(): Promise<PreimageData | undefined>;
22
18
  splitUTXOs(wallet: Wallet, network: Network, splitInputsInto: number, amountPerUTXO: bigint): Promise<BroadcastResponse | {
23
19
  error: string;
24
20
  }>;
@@ -103,13 +103,6 @@ export class OPNetLimitedProvider {
103
103
  }
104
104
  return result;
105
105
  }
106
- async getPreimage() {
107
- const result = await this.rpcMethod('btc_preimage', []);
108
- if (!result) {
109
- return;
110
- }
111
- return result;
112
- }
113
106
  async splitUTXOs(wallet, network, splitInputsInto, amountPerUTXO) {
114
107
  const utxoSetting = {
115
108
  addresses: [wallet.p2wpkh, wallet.p2tr],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "1.6.1",
5
5
  "author": "BlobMaster41",
6
6
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
7
7
  "engines": {
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.6.0';
1
+ export const version = '1.6.1';
@@ -115,16 +115,16 @@ export class ChallengeSolution implements IChallengeSolution {
115
115
  }
116
116
 
117
117
  /**
118
- * Verify this preimage
119
- * @returns {Promise<boolean>} True if the preimage is valid
118
+ * Verify this challenge
119
+ * @returns {Promise<boolean>} True if the challenge is valid
120
120
  */
121
121
  public async verify(): Promise<boolean> {
122
- return EpochValidator.validatePreimage(this);
122
+ return EpochValidator.validateChallengeSolution(this);
123
123
  }
124
124
 
125
125
  /**
126
- * Get the preimage buffer (alias for solution)
127
- * @returns {Buffer} The solution/preimage as a buffer
126
+ * Get the preimage challenge
127
+ * @returns {Buffer} The solution/challenge as a buffer
128
128
  */
129
129
  public toBuffer(): Buffer {
130
130
  return this.solution;
@@ -162,7 +162,7 @@ export class ChallengeSolution implements IChallengeSolution {
162
162
  }
163
163
 
164
164
  /**
165
- * Calculate the expected solution hash for this preimage
165
+ * Calculate the expected solution hash for this challenge
166
166
  * @returns {Promise<Buffer>} The calculated solution hash
167
167
  */
168
168
  public async calculateSolution(): Promise<Buffer> {
@@ -174,7 +174,7 @@ export class ChallengeSolution implements IChallengeSolution {
174
174
  }
175
175
 
176
176
  /**
177
- * Check if the preimage meets a specific difficulty requirement
177
+ * Check if the challenge meets a specific difficulty requirement
178
178
  * @param {number} minDifficulty The minimum difficulty required
179
179
  * @returns {Promise<{valid: boolean; difficulty: number}>} Validation result
180
180
  */
@@ -79,21 +79,21 @@ export class EpochValidator {
79
79
  * Verify an epoch solution using IPreimage
80
80
  */
81
81
  public static async verifySolution(
82
- preimage: IChallengeSolution,
82
+ challenge: IChallengeSolution,
83
83
  log: boolean = false,
84
84
  ): Promise<boolean> {
85
85
  try {
86
- const verification = preimage.verification;
86
+ const verification = challenge.verification;
87
87
  const calculatedPreimage = this.calculatePreimage(
88
88
  verification.targetChecksum,
89
- preimage.publicKey.toBuffer(),
90
- preimage.salt,
89
+ challenge.publicKey.toBuffer(),
90
+ challenge.salt,
91
91
  );
92
92
 
93
93
  const computedSolution = await this.sha1(this.bufferToUint8Array(calculatedPreimage));
94
94
  const computedSolutionBuffer = this.uint8ArrayToBuffer(computedSolution);
95
95
 
96
- if (!computedSolutionBuffer.equals(preimage.solution)) {
96
+ if (!computedSolutionBuffer.equals(challenge.solution)) {
97
97
  return false;
98
98
  }
99
99
 
@@ -102,11 +102,11 @@ export class EpochValidator {
102
102
  verification.targetHash,
103
103
  );
104
104
 
105
- if (matchingBits !== preimage.difficulty) {
105
+ if (matchingBits !== challenge.difficulty) {
106
106
  return false;
107
107
  }
108
108
 
109
- const expectedStartBlock = preimage.epochNumber * this.BLOCKS_PER_EPOCH;
109
+ const expectedStartBlock = challenge.epochNumber * this.BLOCKS_PER_EPOCH;
110
110
  const expectedEndBlock = expectedStartBlock + this.BLOCKS_PER_EPOCH - 1n;
111
111
 
112
112
  return !(
@@ -142,8 +142,8 @@ export class EpochValidator {
142
142
  /**
143
143
  * Validate epoch winner from Preimage instance
144
144
  */
145
- public static async validatePreimage(preimage: IChallengeSolution): Promise<boolean> {
146
- return await this.verifySolution(preimage);
145
+ public static async validateChallengeSolution(challenge: IChallengeSolution): Promise<boolean> {
146
+ return await this.verifySolution(challenge);
147
147
  }
148
148
 
149
149
  /**
@@ -19,7 +19,7 @@ export class DeploymentGenerator extends Generator {
19
19
  * Compile a bitcoin script representing a contract deployment
20
20
  * @param {Buffer} contractBytecode - The contract bytecode
21
21
  * @param {Buffer} contractSalt - The contract salt
22
- * @param {ChallengeSolution} preimage - The preimage for reward
22
+ * @param {ChallengeSolution} challenge - The challenge for reward
23
23
  * @param {bigint} maxPriority - The maximum priority for the contract
24
24
  * @param {Buffer} [calldata] - The calldata to be passed to the contract
25
25
  * @param {Feature<Features>[]} [features] - Optional features to include in the script
@@ -28,7 +28,7 @@ export class DeploymentGenerator extends Generator {
28
28
  public compile(
29
29
  contractBytecode: Buffer,
30
30
  contractSalt: Buffer,
31
- preimage: ChallengeSolution,
31
+ challenge: ChallengeSolution,
32
32
  maxPriority: bigint,
33
33
  calldata?: Buffer,
34
34
  features?: Feature<Features>[],
@@ -36,7 +36,7 @@ export class DeploymentGenerator extends Generator {
36
36
  const asm = this.getAsm(
37
37
  contractBytecode,
38
38
  contractSalt,
39
- preimage,
39
+ challenge,
40
40
  maxPriority,
41
41
  calldata,
42
42
  features,
@@ -57,7 +57,7 @@ export class DeploymentGenerator extends Generator {
57
57
  private getAsm(
58
58
  contractBytecode: Buffer,
59
59
  contractSalt: Buffer,
60
- preimage: ChallengeSolution,
60
+ challenge: ChallengeSolution,
61
61
  maxPriority: bigint,
62
62
  calldata?: Buffer,
63
63
  features?: Feature<Features>[],
@@ -85,10 +85,10 @@ export class DeploymentGenerator extends Generator {
85
85
  opcodes.OP_TOALTSTACK,
86
86
 
87
87
  // CHALLENGE PREIMAGE FOR REWARD,
88
- preimage.publicKey.originalPublicKeyBuffer(),
88
+ challenge.publicKey.originalPublicKeyBuffer(),
89
89
  opcodes.OP_TOALTSTACK,
90
90
 
91
- preimage.solution,
91
+ challenge.solution,
92
92
  opcodes.OP_TOALTSTACK,
93
93
 
94
94
  this.xSenderPubKey,
@@ -52,7 +52,7 @@ export class LegacyCalldataGenerator extends Generator {
52
52
  * Compile an interaction bitcoin script
53
53
  * @param {Buffer} calldata - The calldata to use
54
54
  * @param {Buffer} contractSecret - The contract secret
55
- * @param {Buffer} preimage - The preimage to use
55
+ * @param {Buffer} challenge - The challenge to use
56
56
  * @param {bigint} maxPriority - The maximum priority
57
57
  * @param {number[]} [features=[]] - The features to use (optional)
58
58
  * @returns {Buffer} - The compiled script
@@ -61,7 +61,7 @@ export class LegacyCalldataGenerator extends Generator {
61
61
  public compile(
62
62
  calldata: Buffer,
63
63
  contractSecret: Buffer,
64
- preimage: Buffer,
64
+ challenge: Buffer,
65
65
  maxPriority: bigint,
66
66
  features: Feature<Features>[] = [],
67
67
  ): Buffer {
@@ -83,7 +83,7 @@ export class LegacyCalldataGenerator extends Generator {
83
83
  opcodes.OP_TOALTSTACK,
84
84
 
85
85
  // CHALLENGE PREIMAGE FOR REWARD,
86
- preimage,
86
+ challenge,
87
87
  opcodes.OP_TOALTSTACK,
88
88
 
89
89
  this.senderPubKey,
@@ -29,7 +29,7 @@ export interface DeploymentResult {
29
29
 
30
30
  readonly contractAddress: string;
31
31
  readonly contractPubKey: string;
32
- readonly preimage: RawChallenge;
32
+ readonly challenge: RawChallenge;
33
33
 
34
34
  readonly utxos: UTXO[];
35
35
  }
@@ -52,7 +52,7 @@ export interface InteractionResponse {
52
52
  readonly interactionTransaction: string;
53
53
  readonly estimatedFees: bigint;
54
54
  readonly nextUTXOs: UTXO[];
55
- readonly preimage: RawChallenge;
55
+ readonly challenge: RawChallenge;
56
56
  }
57
57
 
58
58
  export interface BitcoinTransferResponse extends BitcoinTransferBase {
@@ -253,7 +253,7 @@ export class TransactionFactory {
253
253
  interactionParameters.from,
254
254
  1,
255
255
  ), // always 1
256
- preimage: preTransaction.getPreimage().toRaw(),
256
+ challenge: preTransaction.getPreimage().toRaw(),
257
257
  };
258
258
  }
259
259
 
@@ -358,7 +358,7 @@ export class TransactionFactory {
358
358
  contractAddress: finalTransaction.getContractAddress(), //finalTransaction.contractAddress.p2tr(deploymentParameters.network),
359
359
  contractPubKey: finalTransaction.contractPubKey,
360
360
  utxos: [refundUTXO],
361
- preimage: preTransaction.getPreimage().toRaw(),
361
+ challenge: preTransaction.getPreimage().toRaw(),
362
362
  };
363
363
  }
364
364
 
@@ -36,7 +36,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
36
36
 
37
37
  public type: TransactionType.DEPLOYMENT = TransactionType.DEPLOYMENT;
38
38
 
39
- protected readonly preimage: ChallengeSolution;
39
+ protected readonly challenge: ChallengeSolution;
40
40
  protected readonly epochChallenge: ITimeLockOutput;
41
41
 
42
42
  /**
@@ -128,10 +128,10 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
128
128
  if (!parameters.challenge) throw new Error('Challenge solution is required');
129
129
 
130
130
  this.randomBytes = parameters.randomBytes || BitcoinUtils.rndBytes();
131
- this.preimage = parameters.challenge;
131
+ this.challenge = parameters.challenge;
132
132
 
133
133
  this.epochChallenge = TimeLockGenerator.generateTimeLockAddress(
134
- this.preimage.publicKey.originalPublicKeyBuffer(),
134
+ this.challenge.publicKey.originalPublicKeyBuffer(),
135
135
  this.network,
136
136
  );
137
137
 
@@ -147,7 +147,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
147
147
  this.compiledTargetScript = this.deploymentGenerator.compile(
148
148
  this.bytecode,
149
149
  this.randomBytes,
150
- this.preimage,
150
+ this.challenge,
151
151
  this.priorityFee,
152
152
  this.calldata,
153
153
  this.generateFeatures(parameters),
@@ -195,7 +195,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
195
195
  * @returns {Buffer} The contract bytecode
196
196
  */
197
197
  public getPreimage(): ChallengeSolution {
198
- return this.preimage;
198
+ return this.challenge;
199
199
  }
200
200
 
201
201
  public getContractAddress(): string {
@@ -14,10 +14,6 @@ export interface WalletUTXOs {
14
14
  readonly spentTransactions: RawUTXOResponse[];
15
15
  }
16
16
 
17
- export interface PreimageData {
18
- readonly preimage: Buffer;
19
- }
20
-
21
17
  /**
22
18
  * Allows to fetch UTXO data from any OPNET node
23
19
  */
@@ -181,19 +177,6 @@ export class OPNetLimitedProvider {
181
177
  return result as BroadcastResponse;
182
178
  }
183
179
 
184
- /**
185
- * Fetches the preimage from the OPNET node
186
- * @returns {Promise<PreimageData | undefined>} - The preimage fetched
187
- */
188
- public async getPreimage(): Promise<PreimageData | undefined> {
189
- const result = await this.rpcMethod('btc_preimage', []);
190
- if (!result) {
191
- return;
192
- }
193
-
194
- return result as PreimageData;
195
- }
196
-
197
180
  /**
198
181
  * Splits UTXOs into smaller UTXOs
199
182
  * @param {Wallet} wallet - The wallet to split UTXOs