Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var _newTarget = this.constructor;
logger.checkNew(_newTarget, HDNode);
if (constructorGuard !== _constructorGuard) {
throw new Error("HDNode constructor cannot be called directly");
}
if (privateKey) {
var signingKey = new signing_key_1.SigningKey(privateKey);
properties_1.defineReadOnly(this, "privateKey", signingKey.privateKey);
properties_1.defineReadOnly(this, "publicKey", signingKey.compressedPublicKey);
}
else {
properties_1.defineReadOnly(this, "privateKey", null);
properties_1.defineReadOnly(this, "publicKey", bytes_1.hexlify(publicKey));
}
properties_1.defineReadOnly(this, "parentFingerprint", parentFingerprint);
properties_1.defineReadOnly(this, "fingerprint", bytes_1.hexDataSlice(sha2_1.ripemd160(sha2_1.sha256(this.publicKey)), 0, 4));
properties_1.defineReadOnly(this, "address", transactions_1.computeAddress(this.publicKey));
properties_1.defineReadOnly(this, "chainCode", chainCode);
properties_1.defineReadOnly(this, "index", index);
properties_1.defineReadOnly(this, "depth", depth);
properties_1.defineReadOnly(this, "mnemonic", mnemonic);
properties_1.defineReadOnly(this, "path", path);
}
Object.defineProperty(HDNode.prototype, "extendedKey", {
constructor(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) {
logger.checkNew(new.target, HDNode);
if (constructorGuard !== _constructorGuard) {
throw new Error("HDNode constructor cannot be called directly");
}
if (privateKey) {
const signingKey = new SigningKey(privateKey);
defineReadOnly(this, "privateKey", signingKey.privateKey);
defineReadOnly(this, "publicKey", signingKey.compressedPublicKey);
}
else {
defineReadOnly(this, "privateKey", null);
defineReadOnly(this, "publicKey", hexlify(publicKey));
}
defineReadOnly(this, "parentFingerprint", parentFingerprint);
defineReadOnly(this, "fingerprint", hexDataSlice(ripemd160(sha256(this.publicKey)), 0, 4));
defineReadOnly(this, "address", computeAddress(this.publicKey));
defineReadOnly(this, "chainCode", chainCode);
defineReadOnly(this, "index", index);
defineReadOnly(this, "depth", depth);
defineReadOnly(this, "mnemonic", mnemonic);
defineReadOnly(this, "path", path);
}
get extendedKey() {
if (constructorGuard !== _constructorGuard) {
throw new Error("HDNode constructor cannot be called directly");
}
if (privateKey) {
const signingKey = new SigningKey(privateKey);
defineReadOnly(this, "privateKey", signingKey.privateKey);
defineReadOnly(this, "publicKey", signingKey.compressedPublicKey);
} else {
defineReadOnly(this, "privateKey", null);
defineReadOnly(this, "publicKey", hexlify(publicKey));
}
defineReadOnly(this, "parentFingerprint", parentFingerprint);
defineReadOnly(this, "fingerprint", hexDataSlice(ripemd160(sha256(this.publicKey)), 0, 4));
defineReadOnly(this, "address", computeAddress(this.publicKey));
defineReadOnly(this, "chainCode", chainCode);
defineReadOnly(this, "index", index);
defineReadOnly(this, "depth", depth);
defineReadOnly(this, "mnemonic", mnemonic);
defineReadOnly(this, "path", path);
}