public IHDNode Derive(uint index) { switch (this.NodeType) { case HDNodeType.Mnemonic: { string derivePath = string.Format("{0}/{1}", this._wallet.Path, index.ToString()); return(new HDNode(new Wallet(Mnemonic.WordsJoin(this._wallet.Words), derivePath), this.NodeType)); } case HDNodeType.Seed: { string derivePath = string.Format("{0}/{1}", this._wallet.Path, index.ToString()); return(new HDNode(new Wallet(this._wallet.Seed.ToBytes(), derivePath), this.NodeType)); } case HDNodeType.PrivateKey: { ExtKey childKey = this._masterKey.Derive(index); return(new HDNode(childKey)); } default: { return(null); } } }
public static bool Validate(string[] words) { try { NBitcoin.Mnemonic mnemonic = new NBitcoin.Mnemonic(Mnemonic.WordsJoin(words)); return(true); } catch { return(false); } }
/// <summary> /// instantiation a HDNode with words /// </summary> /// <param name="words"></param> /// <param name="path"> vechain default path is m/44'/818'/0'/0/address_index</param> /// <returns></returns> public HDNode(string[] words, string path = VeChainConstant.VET_DERIVATION_PATH) : this(new Wallet(Mnemonic.WordsJoin(words), "", path), HDNodeType.Mnemonic) { }