private void Save(string password, string walletFilePath, Network network, DateTimeOffset creationTime) { if (File.Exists(walletFilePath)) { throw new NotSupportedException($"Wallet already exists at {walletFilePath}"); } var directoryPath = Path.GetDirectoryName(Path.GetFullPath(walletFilePath)); if (directoryPath != null) { Directory.CreateDirectory(directoryPath); } var privateKey = ExtKey.PrivateKey; var chainCode = ExtKey.ChainCode; var encryptedBitcoinPrivateKeyString = privateKey.GetEncryptedBitcoinSecret(password, Network).ToWif(); var chainCodeString = Convert.ToBase64String(chainCode); var networkString = network.ToString(); var creationTimeString = creationTime.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); WalletFileSerializer.Serialize( walletFilePath, encryptedBitcoinPrivateKeyString, chainCodeString, networkString, creationTimeString); }
private void Save(string password, string walletFilePath, Network network) { if (File.Exists(walletFilePath)) { throw new Exception("WalletFileAlreadyExists"); } var directoryPath = Path.GetDirectoryName(Path.GetFullPath(walletFilePath)); if (directoryPath != null) { Directory.CreateDirectory(directoryPath); } var privateKey = ExtKey.PrivateKey; var chainCode = ExtKey.ChainCode; var encryptedBitcoinPrivateKeyString = privateKey.GetEncryptedBitcoinSecret(password, Network).ToWif(); var chainCodeString = Convert.ToBase64String(chainCode); var networkString = network.ToString(); WalletFileSerializer.Serialize(walletFilePath, encryptedBitcoinPrivateKeyString, chainCodeString, networkString); }