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
37 lines (36 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PhraseWallet = void 0;
const Phrase_1 = require("./Phrase");
const HDWallet_1 = require("../HDWallet");
/**
* HD wallet created from a mnemonic phrase.
*
* @example
* ```ts
* const wallet = new PhraseWallet(new Phrase('abandon abandon ... about'));
* const key = await wallet.derive("m/44'/60'/0'/0/0");
* ```
*/
class PhraseWallet extends HDWallet_1.HDWallet {
/** @param phrase - The mnemonic phrase. */
constructor(phrase, restoreData) {
super(phrase, restoreData);
this.walletType = 'phrase';
}
/** @internal */
getKeySource() {
return { seed: this.secret.getSeed().raw };
}
/** Returns the {@link Phrase}. Prompts for password if encrypted. */
async getPhrase() {
if (!this.secret.encrypted)
return this.secret;
return this.secret.withDecrypted(() => new Phrase_1.Phrase(this.secret.words.join(' ')));
}
/** @internal */
doSerialize() {
return { type: 'phrase', phrase: this.secret.words.join(' ') };
}
}
exports.PhraseWallet = PhraseWallet;