@btc-vision/transaction 1.1.9 → 1.1.11

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.
@@ -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
  }
@@ -1 +1 @@
1
- export declare const version = "1.1.9";
1
+ export declare const version = "1.1.11";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.1.9';
1
+ export const version = '1.1.11';
@@ -131,9 +131,6 @@ export class Address extends Uint8Array {
131
131
  return EcKeyPair.getLegacySegwitAddress(this.keyPair, network);
132
132
  }
133
133
  toString() {
134
- if (__classPrivateFieldGet(this, _Address_p2tr, "f")) {
135
- return __classPrivateFieldGet(this, _Address_p2tr, "f");
136
- }
137
134
  return this.toHex();
138
135
  }
139
136
  p2tr(network) {
@@ -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') {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.1.9",
4
+ "version": "1.1.11",
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.9';
1
+ export const version = '1.1.11';
@@ -184,7 +184,7 @@ export class Address extends Uint8Array {
184
184
  const tweakedBytes = toXOnly(
185
185
  EcKeyPair.tweakPublicKey(Buffer.from(this.#originalPublicKey)),
186
186
  );
187
-
187
+
188
188
  super.set(tweakedBytes);
189
189
  }
190
190
  }
@@ -226,10 +226,6 @@ export class Address extends Uint8Array {
226
226
  * Convert the address to a string
227
227
  */
228
228
  public toString(): string {
229
- if (this.#p2tr) {
230
- return this.#p2tr;
231
- }
232
-
233
229
  return this.toHex();
234
230
  }
235
231
 
@@ -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
  /**