@btc-vision/transaction 1.8.0-alpha.2 → 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.
- package/browser/_version.d.ts +1 -1
- package/browser/btc-vision-bitcoin.js +423 -422
- package/browser/index.js +941 -933
- package/browser/keypair/EcKeyPair.d.ts +1 -0
- package/browser/noble-hashes.js +2 -2
- package/browser/vendors.js +3 -3
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/keypair/EcKeyPair.d.ts +1 -0
- package/build/keypair/EcKeyPair.js +9 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/_version.ts +1 -1
- package/src/keypair/EcKeyPair.ts +12 -1
package/src/keypair/EcKeyPair.ts
CHANGED
|
@@ -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
|
|