Removing LND seed information from walletunlock.json

This commit is contained in:
rockstardev
2019-11-07 17:06:16 -06:00
parent 58b834fe9d
commit 9c165d84ef
3 changed files with 66 additions and 2 deletions

View File

@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace BTCPayServer.Models.ServerViewModels
@@ -14,6 +16,29 @@ namespace BTCPayServer.Models.ServerViewModels
public List<string> Seed { get; set; }
public async Task<bool> RemoveSeedAndWrite(string lndSeedFilePath)
{
var removedDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ssZ", CultureInfo.InvariantCulture);
var seedFile = new LndSeedFile
{
wallet_password = WalletPassword,
cipher_seed_mnemonic = new List<string> { $"Seed removed on {removedDate}" }
};
var json = JsonConvert.SerializeObject(seedFile);
try
{
await File.WriteAllTextAsync(lndSeedFilePath, json);
return true;
}
catch
{
// file access exception and such
return false;
}
}
public static LndSeedBackupViewModel Parse(string lndSeedFilePath)
{
try