Draft Inverse Bloom Filter
This commit is contained in:
@@ -21,6 +21,25 @@ import type {
|
||||
|
||||
/**
|
||||
* Hierarchically Deterministic Private Node Entity.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Import our primitives.
|
||||
* import { Mnemonic, HDPrivateNode } from '@xocash/primitives';
|
||||
*
|
||||
* // Generate a mnemonic.
|
||||
* const mnemonic = Mnemonic.generateRandom();
|
||||
*
|
||||
* // Initialize a HD Private Node from Mnemonic.
|
||||
* const hdPrivateNode = HDPrivateNode.fromMnemonic(mnemonic);
|
||||
*
|
||||
* // Derive the first Private Key.
|
||||
* const privateKey = hdPrivateNode.derivePath("m/44'/145'/0'/0/0").toPrivateKey();
|
||||
*
|
||||
* // Output the BCH Address.
|
||||
* console.log(privateKey.derivePublicKey().deriveAddress().toCashAddr());
|
||||
* ```
|
||||
*/
|
||||
export class HDPrivateNode {
|
||||
// The HD Private Node.
|
||||
@@ -72,18 +91,15 @@ export class HDPrivateNode {
|
||||
/**
|
||||
* Creates a HD Private Node from the given mnemonic.
|
||||
*
|
||||
* @param phrase The mnemonic phrase as a string or array of words.
|
||||
* @param mnemonic The mnemonic to use.
|
||||
*
|
||||
* @throws {Error} If HD Private Node cannot be created.
|
||||
*
|
||||
* @returns The created HD Private Node.
|
||||
*/
|
||||
public static fromMnemonic(phrase: string | Array<string>): HDPrivateNode {
|
||||
// Derive the seed from the mnemonic.
|
||||
const seed = Mnemonic.from(phrase).toSeed();
|
||||
|
||||
public static fromMnemonic(mnemonic: Mnemonic): HDPrivateNode {
|
||||
// Return a new HDPrivateNode from the given seed.
|
||||
return this.fromSeed(seed);
|
||||
return this.fromSeed(mnemonic.toSeed());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user