Resolve "WIP: UTXO Selection and Storage"
This commit is contained in:
@@ -50,20 +50,23 @@ export class HDPublicNode {
|
||||
return new HDPublicNode(decodeResult.node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XPub string for this node.
|
||||
*
|
||||
* @returns {string} The XPub string for this node.
|
||||
*/
|
||||
public toString(): string {
|
||||
// Return the Mainnet XPub.
|
||||
return this.toXPub();
|
||||
public static fromRaw(node: HdPublicNodeValid) {
|
||||
return new this(node);
|
||||
}
|
||||
|
||||
public static isXPub(xpub: string): boolean {
|
||||
try {
|
||||
this.fromXPub(xpub);
|
||||
return true;
|
||||
} catch (_error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Public Key Entity for this node.
|
||||
*
|
||||
* @returns {PublicKey} The Public Key Entity for this node.
|
||||
* @returns The Public Key Entity for this node.
|
||||
*/
|
||||
public publicKey(): PublicKey {
|
||||
// Return a Public Key Entity from the public key of our node.
|
||||
@@ -73,11 +76,11 @@ export class HDPublicNode {
|
||||
/**
|
||||
* Derives a HD Public Node from the given BIP32 path.
|
||||
*
|
||||
* @param path {string} The BIP32 Path (e.g. m/44'/145'/0'/0/1).
|
||||
* @param path The BIP32 Path (e.g. m/44'/145'/0'/0/1).
|
||||
*
|
||||
* @throws {Error} If HD Public Node cannot be derived.
|
||||
*
|
||||
* @returns {HDPrivateNode} The derived HD Public Node
|
||||
* @returns The derived HD Public Node
|
||||
*/
|
||||
public derivePath(path: string): HDPublicNode {
|
||||
// Attempt to derive the given path.
|
||||
@@ -95,9 +98,9 @@ export class HDPublicNode {
|
||||
/**
|
||||
* Converts this node to an XPub Key for export.
|
||||
*
|
||||
* @param network {HdKeyNetwork} The network to encode for.
|
||||
* @param network The network to encode for.
|
||||
*
|
||||
* @returns {string} The XPub Key.
|
||||
* @returns The XPub Key.
|
||||
*/
|
||||
public toXPub(network: HdKeyNetwork = 'mainnet'): string {
|
||||
// Create our node info structure.
|
||||
@@ -109,4 +112,18 @@ export class HDPublicNode {
|
||||
// Encode the XPub from our node info.
|
||||
return encodeHdPublicKey(nodeInfo).hdPublicKey;
|
||||
}
|
||||
|
||||
public toRaw(): HdPublicNodeValid {
|
||||
return this.node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XPub string for this node.
|
||||
*
|
||||
* @returns {string} The XPub string for this node.
|
||||
*/
|
||||
public toString(): string {
|
||||
// Return the Mainnet XPub.
|
||||
return this.toXPub();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user