@btc-vision/transaction 1.8.0-beta.0 → 1.8.0-beta.3

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.8.0-beta.0",
4
+ "version": "1.8.0-beta.3",
5
5
  "author": "BlobMaster41",
6
6
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
7
7
  "engines": {
@@ -156,15 +156,15 @@
156
156
  "@babel/preset-react": "^7.28.5",
157
157
  "@babel/preset-typescript": "^7.28.5",
158
158
  "@rollup/plugin-typescript": "^12.3.0",
159
- "@types/node": "^25.0.9",
159
+ "@types/node": "^25.0.10",
160
160
  "@types/sha.js": "^2.4.4",
161
161
  "@vitejs/plugin-legacy": "^7.2.1",
162
- "@vitest/ui": "^4.0.17",
162
+ "@vitest/ui": "^4.0.18",
163
163
  "eslint": "^9.39.2",
164
164
  "https-browserify": "^1.0.0",
165
165
  "madge": "^8.0.0",
166
166
  "os-browserify": "^0.3.0",
167
- "prettier": "^3.8.0",
167
+ "prettier": "^3.8.1",
168
168
  "stream-browserify": "^3.0.0",
169
169
  "stream-http": "^3.2.0",
170
170
  "tslib": "^2.8.1",
@@ -173,18 +173,18 @@
173
173
  "vite": "^7.3.1",
174
174
  "vite-plugin-dts": "^4.5.4",
175
175
  "vite-plugin-node-polyfills": "^0.25.0",
176
- "vitest": "^4.0.17"
176
+ "vitest": "^4.0.18"
177
177
  },
178
178
  "dependencies": {
179
179
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
180
180
  "@bitcoinerlab/secp256k1": "^1.2.0",
181
- "@btc-vision/bip32": "^6.0.3",
182
- "@btc-vision/bitcoin": "^6.5.5",
181
+ "@btc-vision/bip32": "^6.1.0",
182
+ "@btc-vision/bitcoin": "^6.5.6",
183
183
  "@btc-vision/bitcoin-rpc": "^1.0.6",
184
184
  "@btc-vision/logger": "^1.0.8",
185
185
  "@btc-vision/post-quantum": "^0.5.3",
186
186
  "@eslint/js": "^9.39.2",
187
- "@noble/curves": "^1.9.7",
187
+ "@noble/curves": "^2.0.1",
188
188
  "@noble/secp256k1": "^3.0.0",
189
189
  "assert": "^2.1.0",
190
190
  "babel-loader": "^10.0.0",
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.8.0-beta.0';
1
+ export const version = '1.8.0-beta.1';
@@ -1,8 +1,7 @@
1
1
  /* Browser Crypto Shims */
2
- import { hmac } from '@noble/hashes/hmac';
3
- import { pbkdf2 } from '@noble/hashes/pbkdf2';
4
- import { sha256 } from '@noble/hashes/sha256';
5
- import { sha512 } from '@noble/hashes/sha512';
2
+ import { hmac } from '@noble/hashes/hmac.js';
3
+ import { pbkdf2 } from '@noble/hashes/pbkdf2.js';
4
+ import { sha256, sha512 } from '@noble/hashes/sha2.js';
6
5
 
7
6
  function assertArgument(check, message, name, value) {
8
7
  if (!check) {
@@ -8,7 +8,7 @@ import { BitcoinUtils } from '../utils/BitcoinUtils.js';
8
8
  import { TimeLockGenerator } from '../transaction/mineable/TimelockGenerator.js';
9
9
  import { IP2WSHAddress } from '../transaction/mineable/IP2WSHAddress.js';
10
10
  import { P2WDADetector } from '../p2wda/P2WDADetector.js';
11
- import { sha256 } from '@noble/hashes/sha2';
11
+ import { sha256 } from '@noble/hashes/sha2.js';
12
12
  import { MLDSASecurityLevel } from '@btc-vision/bip32';
13
13
 
14
14
  /**
@@ -21,10 +21,11 @@ import bitcoin, {
21
21
  } from '@btc-vision/bitcoin';
22
22
  import { ECPairAPI, ECPairFactory, ECPairInterface } from 'ecpair';
23
23
  import { IWallet } from './interfaces/IWallet.js';
24
- import { secp256k1 } from '@noble/curves/secp256k1';
25
- import { mod } from '@noble/curves/abstract/modular';
26
- import { sha256 } from '@noble/hashes/sha2';
27
- import { bytesToNumberBE, concatBytes, randomBytes, utf8ToBytes } from '@noble/curves/utils.js';
24
+ import { secp256k1 } from '@noble/curves/secp256k1.js';
25
+ import { mod } from '@noble/curves/abstract/modular.js';
26
+ import { sha256 } from '@noble/hashes/sha2.js';
27
+ import { bytesToNumberBE, concatBytes, randomBytes } from '@noble/curves/utils.js';
28
+ import { Buffer } from 'buffer';
28
29
 
29
30
  initEccLib(ecc);
30
31
 
@@ -36,7 +37,7 @@ if (!BIP32factory) {
36
37
  const Point = secp256k1.Point;
37
38
  const CURVE_N = Point.Fn.ORDER;
38
39
 
39
- const TAP_TAG = utf8ToBytes('TapTweak');
40
+ const TAP_TAG = Buffer.from('TapTweak', 'utf-8');
40
41
  const TAP_TAG_HASH = sha256(TAP_TAG);
41
42
 
42
43
  function tapTweakHash(x: Uint8Array): Uint8Array {
@@ -281,7 +282,7 @@ export class EcKeyPair {
281
282
  public static tweakPublicKey(pub: Uint8Array | Buffer | string): Buffer {
282
283
  if (typeof pub === 'string' && pub.startsWith('0x')) pub = pub.slice(2);
283
284
 
284
- const P = Point.fromHex(pub);
285
+ const P = Point.fromHex(Buffer.from(pub).toString('hex'));
285
286
  const Peven = (P.y & 1n) === 0n ? P : P.negate();
286
287
 
287
288
  const xBytes = Buffer.from(Peven.toBytes(true).subarray(1));
@@ -305,7 +306,7 @@ export class EcKeyPair {
305
306
  const T = Point.BASE.multiply(tweakScalar);
306
307
 
307
308
  return pubkeys.map((bytes) => {
308
- const P = Point.fromHex(bytes);
309
+ const P = Point.fromHex(Buffer.from(bytes).toString('hex'));
309
310
  const P_even = P.y % 2n === 0n ? P : P.negate();
310
311
  const Q = P_even.add(T);
311
312
  return Q.toBytes(true);
@@ -323,9 +324,14 @@ export class EcKeyPair {
323
324
  network: Network = networks.bitcoin,
324
325
  securityLevel: MLDSASecurityLevel = MLDSASecurityLevel.LEVEL2,
325
326
  ): IWallet {
326
- // Generate classical keypair
327
+ // Generate classical keypair with custom rng to ensure Buffer compatibility
328
+ // This fixes "Expected Buffer, got Uint8Array" error in browser environments
327
329
  const keyPair = this.ECPair.makeRandom({
328
330
  network: network,
331
+ rng: (size: number): Buffer => {
332
+ const bytes = randomBytes(size);
333
+ return Buffer.from(bytes);
334
+ },
329
335
  });
330
336
 
331
337
  const wallet = this.getP2WPKHAddress(keyPair, network);
@@ -475,8 +481,13 @@ export class EcKeyPair {
475
481
  * @returns {ECPairInterface} - The generated keypair
476
482
  */
477
483
  public static generateRandomKeyPair(network: Network = networks.bitcoin): ECPairInterface {
484
+ // Use custom rng to ensure Buffer compatibility in browser environments
478
485
  return this.ECPair.makeRandom({
479
486
  network: network,
487
+ rng: (size: number): Buffer => {
488
+ const bytes = randomBytes(size);
489
+ return Buffer.from(bytes);
490
+ },
480
491
  });
481
492
  }
482
493