@btc-vision/transaction 1.8.0-beta.0 → 1.8.0-beta.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.
@@ -25,6 +25,7 @@ import { secp256k1 } from '@noble/curves/secp256k1';
25
25
  import { mod } from '@noble/curves/abstract/modular';
26
26
  import { sha256 } from '@noble/hashes/sha2';
27
27
  import { bytesToNumberBE, concatBytes, randomBytes, utf8ToBytes } from '@noble/curves/utils.js';
28
+ import { Buffer } from 'buffer';
28
29
 
29
30
  initEccLib(ecc);
30
31
 
@@ -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