Пример #1
0
        public static WalletSeed from_file(WalletConfig walletConfig)
        {
            // create directory if it doesn't exist
            Directory.CreateDirectory(walletConfig.DataFileDir);


            var seedFilePath = Path.Combine(walletConfig.DataFileDir, Types.SeedFile);

            Log.Debug("Using wallet seed at: {seed_file_path}", seedFilePath);

            if (File.Exists(seedFilePath))
            {
                using (var file = File.Open(seedFilePath, FileMode.Open, FileAccess.Read, FileShare.None))
                    using (var sr = new StreamReader(file))
                    {
                        var hex        = sr.ReadToEnd();
                        var walletSeed = from_hex(hex);
                        return(walletSeed);
                    }
            }

            return(init_file(walletConfig));

            //Log.Error("Run: \"grin wallet init\" to initialize a new wallet.");
            //throw new Exception("wallet seed file does not yet exist (grin wallet init)");
        }
Пример #2
0
        public static WalletSeed init_file(WalletConfig walletConfig)
        {
            // create directory if it doesn't exist
            Directory.CreateDirectory(walletConfig.DataFileDir);


            var seedFilePath = Path.Combine(walletConfig.DataFileDir, Types.SeedFile);


            Log.Debug("Generating wallet seed file at: {seed_file_path}", seedFilePath);


            if (File.Exists(seedFilePath))
            {
                throw new Exception("Wallet seed file already exists!");
            }

            var seed = init_new();

            using (var seedFile = File.CreateText(seedFilePath))
            {
                seedFile.Write(seed.to_hex());
            }


            return(seed);
        }