Draft Inverse Bloom Filter
This commit is contained in:
@@ -2,7 +2,8 @@ import { Bytes } from './bytes.js';
|
||||
import { PublicKey } from './public-key.js';
|
||||
|
||||
import {
|
||||
binToHex,
|
||||
type RecoverableSignature,
|
||||
type WalletImportFormatType,
|
||||
decodePrivateKeyWif,
|
||||
encodePrivateKeyWif,
|
||||
generatePrivateKey,
|
||||
@@ -11,13 +12,24 @@ import {
|
||||
sha256,
|
||||
} from '@bitauth/libauth';
|
||||
|
||||
import type {
|
||||
RecoverableSignature,
|
||||
WalletImportFormatType,
|
||||
} from '@bitauth/libauth';
|
||||
|
||||
/**
|
||||
* Private Key entity.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Import our primitives
|
||||
* import { PrivateKey } from '@xocash/primitives';
|
||||
*
|
||||
* // Create a Private Key from a WIF.
|
||||
* const privateKey = PrivateKey.from('wif');
|
||||
*
|
||||
* // Derive the Public Key
|
||||
* const publicKey = PrivateKey.derivePublicKey();
|
||||
*
|
||||
* // Output the CashAddr.
|
||||
* console.log(publicKey.deriveAddress().toCashAddr());
|
||||
* ```
|
||||
*/
|
||||
export class PrivateKey {
|
||||
// The raw bytes representing the Private Key.
|
||||
@@ -101,7 +113,7 @@ export class PrivateKey {
|
||||
*/
|
||||
public static fromWIF(
|
||||
wif: string,
|
||||
removePrefixes = ['bitcoincash:', 'wif:'],
|
||||
removePrefixes = ['bitcoincash:', 'wif:', 'bch-wif:'],
|
||||
): PrivateKey {
|
||||
// Remove the prefixes from the WIF (if they exist).
|
||||
const wifWithoutPrefixes = removePrefixes.reduce((result, prefix) => {
|
||||
@@ -176,7 +188,7 @@ export class PrivateKey {
|
||||
*/
|
||||
public toHex(): string {
|
||||
// Return the hexadecimal encoded bytes of this Private Key.
|
||||
return binToHex(this.bytes);
|
||||
return Bytes.fromBytes(this.bytes).toHex();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user