コード例 #1
0
        /// <summary>
        ///     Creates a mnemonic, a seed, encrypts it and stores in the specified path.
        /// </summary>
        /// <param name="mnemonic">empty string</param>
        /// <param name="password"></param>
        /// <param name="walletFilePath"></param>
        /// <param name="network"></param>
        /// <returns>KeyRing</returns>
        public static KeyRing Create(out string mnemonic, string password, string walletFilePath, Network network)
        {
            var wallet = new KeyRing(walletFilePath, network);

            mnemonic = wallet.SetSeed(password).ToString();
            wallet.Save(password);
            return(wallet);
        }
コード例 #2
0
        public static KeyRing Load(string password, string walletFilePath)
        {
            var walletFileRawContent = KeyRingStore.Read(walletFilePath);

            var encryptedBitcoinPrivateKeyString = walletFileRawContent.EncryptedSeed;
            var chainCodeString = walletFileRawContent.ChainCode;
            var network         = walletFileRawContent.Network;
            var chainCode       = Convert.FromBase64String(chainCodeString);

            var wallet = new KeyRing(walletFilePath, network);

            var privateKey = Key.Parse(encryptedBitcoinPrivateKeyString, password, wallet._network);
            var seedExtKey = new ExtKey(privateKey, chainCode);

            wallet.SetSeed(seedExtKey);
            return(wallet);
        }