Add bch-mnemonic protocol
This commit is contained in:
@@ -27,7 +27,11 @@ export type WalletHDGenesisData = {
|
||||
type: 'WalletHD';
|
||||
derivationPath: string;
|
||||
addressGap?: number;
|
||||
} & ({ seed: string } | { mnemonic: string } | { xpriv: string });
|
||||
} & (
|
||||
| { seed: string }
|
||||
| { mnemonic: string; passphrase?: string }
|
||||
| { xpriv: string }
|
||||
);
|
||||
|
||||
/**
|
||||
* A Hierarhical Determinstic (BIP44) Wallet.
|
||||
@@ -111,9 +115,16 @@ export class WalletHD extends BaseWallet {
|
||||
if ('seed' in genesisData) {
|
||||
this.hdPrivateNode = HDPrivateNode.fromSeed(genesisData.seed);
|
||||
} else if ('mnemonic' in genesisData) {
|
||||
this.hdPrivateNode = HDPrivateNode.fromMnemonic(
|
||||
Mnemonic.fromPhrase(genesisData.mnemonic),
|
||||
);
|
||||
// TODO: We really want to support multiple word-lists somehow.
|
||||
// But this is not trivial because other word-lists are technically not standard.
|
||||
// For now, we are allowing any phrase (BIP39 derives seed from literal phrase, not word indexes).
|
||||
const mnemonic = Mnemonic.fromRaw({
|
||||
words: genesisData.mnemonic.split(' '),
|
||||
passphrase: genesisData.passphrase,
|
||||
});
|
||||
|
||||
// Create the HD Node from our Mnemonic instance.
|
||||
this.hdPrivateNode = HDPrivateNode.fromMnemonic(mnemonic);
|
||||
} else {
|
||||
this.hdPrivateNode = HDPrivateNode.fromXPriv(genesisData.xpriv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user