@btc-vision/transaction 1.1.10 → 1.1.12

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.
@@ -18,5 +18,6 @@ export declare class Address extends Uint8Array {
18
18
  p2pkh(network: Network): string;
19
19
  p2shp2wpkh(network: Network): string;
20
20
  toString(): string;
21
+ toJSON(): string;
21
22
  p2tr(network: Network): string;
22
23
  }
@@ -1,9 +1,13 @@
1
1
  import { ECPairInterface } from 'ecpair';
2
2
  import { Network } from '@btc-vision/bitcoin';
3
+ export interface SignedMessage {
4
+ readonly signature: Uint8Array;
5
+ readonly message: Uint8Array;
6
+ }
3
7
  declare class MessageSignerBase {
4
8
  sha256(message: Buffer | Uint8Array): Buffer;
5
- tweakAndSignMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string, network: Network): Uint8Array;
6
- signMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string): Uint8Array;
9
+ tweakAndSignMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string, network: Network): SignedMessage;
10
+ signMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string): SignedMessage;
7
11
  verifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
8
12
  tweakAndVerifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
9
13
  }
@@ -22,7 +22,7 @@ export interface SharedInteractionParameters extends ITransactionParameters {
22
22
  disableAutoRefund?: boolean;
23
23
  readonly randomBytes?: Buffer;
24
24
  }
25
- export interface IInteractionParameters extends Omit<SharedInteractionParameters, 'optionalOutputs'> {
25
+ export interface IInteractionParameters extends SharedInteractionParameters {
26
26
  readonly calldata: Buffer;
27
27
  readonly to: string;
28
28
  }
@@ -1 +1 @@
1
- export declare const version = "1.1.10";
1
+ export declare const version = "1.1.12";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.1.10';
1
+ export const version = '1.1.12';
@@ -18,5 +18,6 @@ export declare class Address extends Uint8Array {
18
18
  p2pkh(network: Network): string;
19
19
  p2shp2wpkh(network: Network): string;
20
20
  toString(): string;
21
+ toJSON(): string;
21
22
  p2tr(network: Network): string;
22
23
  }
@@ -133,6 +133,9 @@ export class Address extends Uint8Array {
133
133
  toString() {
134
134
  return this.toHex();
135
135
  }
136
+ toJSON() {
137
+ return this.toHex();
138
+ }
136
139
  p2tr(network) {
137
140
  if (__classPrivateFieldGet(this, _Address_p2tr, "f") && __classPrivateFieldGet(this, _Address_network, "f") === network) {
138
141
  return __classPrivateFieldGet(this, _Address_p2tr, "f");
@@ -1,9 +1,13 @@
1
1
  import { ECPairInterface } from 'ecpair';
2
2
  import { Network } from '@btc-vision/bitcoin';
3
+ export interface SignedMessage {
4
+ readonly signature: Uint8Array;
5
+ readonly message: Uint8Array;
6
+ }
3
7
  declare class MessageSignerBase {
4
8
  sha256(message: Buffer | Uint8Array): Buffer;
5
- tweakAndSignMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string, network: Network): Uint8Array;
6
- signMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string): Uint8Array;
9
+ tweakAndSignMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string, network: Network): SignedMessage;
10
+ signMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string): SignedMessage;
7
11
  verifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
8
12
  tweakAndVerifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
9
13
  }
@@ -21,7 +21,10 @@ class MessageSignerBase {
21
21
  throw new Error('Private key not found in keypair.');
22
22
  }
23
23
  const hashedMessage = this.sha256(message);
24
- return ecc.signSchnorr(hashedMessage, keypair.privateKey);
24
+ return {
25
+ signature: ecc.signSchnorr(hashedMessage, keypair.privateKey),
26
+ message: hashedMessage,
27
+ };
25
28
  }
26
29
  verifySignature(publicKey, message, signature) {
27
30
  if (typeof message === 'string') {
@@ -22,7 +22,7 @@ export interface SharedInteractionParameters extends ITransactionParameters {
22
22
  disableAutoRefund?: boolean;
23
23
  readonly randomBytes?: Buffer;
24
24
  }
25
- export interface IInteractionParameters extends Omit<SharedInteractionParameters, 'optionalOutputs'> {
25
+ export interface IInteractionParameters extends SharedInteractionParameters {
26
26
  readonly calldata: Buffer;
27
27
  readonly to: string;
28
28
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.1.10",
4
+ "version": "1.1.12",
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.1.10';
1
+ export const version = '1.1.12';
@@ -228,6 +228,13 @@ export class Address extends Uint8Array {
228
228
  public toString(): string {
229
229
  return this.toHex();
230
230
  }
231
+
232
+ /**
233
+ * Convert the address to a JSON string
234
+ */
235
+ public toJSON(): string {
236
+ return this.toHex();
237
+ }
231
238
 
232
239
  /**
233
240
  * Get the address in p2tr format
@@ -5,6 +5,11 @@ import { TweakedSigner } from '../signer/TweakedSigner.js';
5
5
  import { EcKeyPair } from './EcKeyPair.js';
6
6
  import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
7
7
 
8
+ export interface SignedMessage {
9
+ readonly signature: Uint8Array;
10
+ readonly message: Uint8Array;
11
+ }
12
+
8
13
  class MessageSignerBase {
9
14
  public sha256(message: Buffer | Uint8Array): Buffer {
10
15
  return crypto.sha256(Buffer.from(message));
@@ -21,7 +26,7 @@ class MessageSignerBase {
21
26
  keypair: ECPairInterface,
22
27
  message: Uint8Array | Buffer | string,
23
28
  network: Network,
24
- ): Uint8Array {
29
+ ): SignedMessage {
25
30
  const tweaked = TweakedSigner.tweakSigner(keypair, {
26
31
  network,
27
32
  });
@@ -39,7 +44,7 @@ class MessageSignerBase {
39
44
  public signMessage(
40
45
  keypair: ECPairInterface,
41
46
  message: Uint8Array | Buffer | string,
42
- ): Uint8Array {
47
+ ): SignedMessage {
43
48
  if (typeof message === 'string') {
44
49
  message = Buffer.from(message, 'utf-8');
45
50
  }
@@ -49,7 +54,10 @@ class MessageSignerBase {
49
54
  }
50
55
 
51
56
  const hashedMessage = this.sha256(message);
52
- return ecc.signSchnorr(hashedMessage, keypair.privateKey);
57
+ return {
58
+ signature: ecc.signSchnorr(hashedMessage, keypair.privateKey),
59
+ message: hashedMessage,
60
+ };
53
61
  }
54
62
 
55
63
  /**
@@ -33,8 +33,7 @@ export interface SharedInteractionParameters extends ITransactionParameters {
33
33
  readonly randomBytes?: Buffer;
34
34
  }
35
35
 
36
- export interface IInteractionParameters
37
- extends Omit<SharedInteractionParameters, 'optionalOutputs'> {
36
+ export interface IInteractionParameters extends SharedInteractionParameters {
38
37
  readonly calldata: Buffer;
39
38
 
40
39
  readonly to: string;