@btc-vision/transaction 1.5.1 → 1.5.2

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.
@@ -23,7 +23,6 @@ export declare abstract class SharedInteractionTransaction<T extends Transaction
23
23
  getContractSecret(): Buffer;
24
24
  getRndBytes(): Buffer;
25
25
  getPreimage(): Buffer;
26
- protected generateSecret(): Buffer;
27
26
  protected scriptSignerXOnlyPubKey(): Buffer;
28
27
  protected generateKeyPairFromSeed(): ECPairInterface;
29
28
  protected buildTransaction(): Promise<void>;
@@ -36,6 +36,7 @@ export interface SharedInteractionParameters extends ITransactionParameters {
36
36
  export interface IInteractionParameters extends SharedInteractionParameters {
37
37
  readonly calldata: Buffer;
38
38
  readonly to: string;
39
+ readonly contract?: string;
39
40
  }
40
41
  export interface IDeploymentParameters extends Omit<ITransactionParameters, 'to'> {
41
42
  readonly bytecode: Buffer;
@@ -1 +1 @@
1
- export declare const version = "1.4.0";
1
+ export declare const version = "1.5.2";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.4.0';
1
+ export const version = '1.5.2';
@@ -6,7 +6,13 @@ export class InteractionTransaction extends SharedInteractionTransaction {
6
6
  super(parameters);
7
7
  this.type = TransactionType.INTERACTION;
8
8
  this.tapLeafScript = null;
9
- this.contractSecret = this.generateSecret();
9
+ if (!parameters.contract) {
10
+ throw new Error('parameters.contract is required for interaction transaction.');
11
+ }
12
+ this.contractSecret = Buffer.from(parameters.contract.replace('0x', ''), 'hex');
13
+ if (this.contractSecret.length !== 32) {
14
+ throw new Error('Invalid contract secret length. Expected 32 bytes.');
15
+ }
10
16
  this.compiledTargetScript = this.calldataGenerator.compile(this.calldata, this.contractSecret, this.preimage, this.priorityFee, this.generateFeatures(parameters));
11
17
  this.scriptTree = this.getScriptTree();
12
18
  this.internalInit();
@@ -23,7 +23,6 @@ export declare abstract class SharedInteractionTransaction<T extends Transaction
23
23
  getContractSecret(): Buffer;
24
24
  getRndBytes(): Buffer;
25
25
  getPreimage(): Buffer;
26
- protected generateSecret(): Buffer;
27
26
  protected scriptSignerXOnlyPubKey(): Buffer;
28
27
  protected generateKeyPairFromSeed(): ECPairInterface;
29
28
  protected buildTransaction(): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { address, PaymentType, toXOnly } from '@btc-vision/bitcoin';
1
+ import { PaymentType, toXOnly } from '@btc-vision/bitcoin';
2
2
  import { MINIMUM_AMOUNT_CA, MINIMUM_AMOUNT_REWARD, TransactionBuilder } from './TransactionBuilder.js';
3
3
  import { CalldataGenerator } from '../../generators/builders/CalldataGenerator.js';
4
4
  import { Compressor } from '../../bytecode/Compressor.js';
@@ -48,14 +48,6 @@ export class SharedInteractionTransaction extends TransactionBuilder {
48
48
  getPreimage() {
49
49
  return this.preimage;
50
50
  }
51
- generateSecret() {
52
- if (!this.to)
53
- throw new Error('To address is required');
54
- if (this.to.startsWith('0x')) {
55
- throw new Error(`Legacy not support at this time. Reserved for future use.`);
56
- }
57
- return address.fromBech32(this.to).data;
58
- }
59
51
  scriptSignerXOnlyPubKey() {
60
52
  return toXOnly(Buffer.from(this.scriptSigner.publicKey));
61
53
  }
@@ -36,6 +36,7 @@ export interface SharedInteractionParameters extends ITransactionParameters {
36
36
  export interface IInteractionParameters extends SharedInteractionParameters {
37
37
  readonly calldata: Buffer;
38
38
  readonly to: string;
39
+ readonly contract?: string;
39
40
  }
40
41
  export interface IDeploymentParameters extends Omit<ITransactionParameters, 'to'> {
41
42
  readonly bytecode: Buffer;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.5.1",
4
+ "version": "1.5.2",
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.4.0';
1
+ export const version = '1.5.2';
@@ -26,7 +26,15 @@ export class InteractionTransaction extends SharedInteractionTransaction<Transac
26
26
  public constructor(parameters: IInteractionParameters) {
27
27
  super(parameters);
28
28
 
29
- this.contractSecret = this.generateSecret();
29
+ if (!parameters.contract) {
30
+ throw new Error('parameters.contract is required for interaction transaction.');
31
+ }
32
+
33
+ this.contractSecret = Buffer.from(parameters.contract.replace('0x', ''), 'hex');
34
+
35
+ if (this.contractSecret.length !== 32) {
36
+ throw new Error('Invalid contract secret length. Expected 32 bytes.');
37
+ }
30
38
 
31
39
  this.compiledTargetScript = this.calldataGenerator.compile(
32
40
  this.calldata,
@@ -1,4 +1,4 @@
1
- import { address, P2TRPayment, PaymentType, Psbt, PsbtInput, Signer, Taptree, toXOnly } from '@btc-vision/bitcoin';
1
+ import { P2TRPayment, PaymentType, Psbt, PsbtInput, Signer, Taptree, toXOnly } from '@btc-vision/bitcoin';
2
2
  import { ECPairInterface } from 'ecpair';
3
3
  import { MINIMUM_AMOUNT_CA, MINIMUM_AMOUNT_REWARD, TransactionBuilder } from './TransactionBuilder.js';
4
4
  import { TransactionType } from '../enums/TransactionType.js';
@@ -120,7 +120,8 @@ export abstract class SharedInteractionTransaction<
120
120
  * @returns {Buffer} The secret
121
121
  * @throws {Error} If the to address is invalid
122
122
  */
123
- protected generateSecret(): Buffer {
123
+
124
+ /*protected generateSecret(): Buffer {
124
125
  if (!this.to) throw new Error('To address is required');
125
126
 
126
127
  if (this.to.startsWith('0x')) {
@@ -128,7 +129,7 @@ export abstract class SharedInteractionTransaction<
128
129
  }
129
130
 
130
131
  return address.fromBech32(this.to).data;
131
- }
132
+ }*/
132
133
 
133
134
  /**
134
135
  * Get the internal pubkey as an x-only key
@@ -52,6 +52,7 @@ export interface IInteractionParameters extends SharedInteractionParameters {
52
52
  readonly calldata: Buffer;
53
53
 
54
54
  readonly to: string;
55
+ readonly contract?: string;
55
56
  }
56
57
 
57
58
  export interface IDeploymentParameters extends Omit<ITransactionParameters, 'to'> {