chaingate
Version:
Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO
31 lines (30 loc) • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DerivedKey = void 0;
const PrivateKey_1 = require("./SigningWallet/PrivateKeyWallet/PrivateKey");
const DerivedPublicKey_1 = require("./DerivedPublicKey");
/**
* A full key pair (public + private) derived from an HD wallet.
* Returned by {@link HDWallet.derive}.
*/
class DerivedKey extends DerivedPublicKey_1.DerivedPublicKey {
/** @internal */
constructor(data) {
super({ publicKey: data.publicKey, xpub: data.xpub });
this._privateData = { privateKey: data.privateKey, xpriv: data.xpriv };
}
/** The derived private key as a {@link PrivateKey}. */
get privateKey() {
return (this._cachedPrivateKey ?? (this._cachedPrivateKey = new PrivateKey_1.PrivateKey(this._privateData.privateKey)));
}
/** The extended private key (xpriv). */
get xpriv() {
return this._privateData.xpriv;
}
/** Zeros out the private key in memory. */
zeroize() {
this._privateData.privateKey.fill(0);
this._cachedPrivateKey?.zeroize();
}
}
exports.DerivedKey = DerivedKey;