Displaying information from walletunlock.json if file is present

This commit is contained in:
rockstardev
2019-11-05 13:40:06 -06:00
parent 2b1aac9aa9
commit 58b834fe9d
5 changed files with 78 additions and 13 deletions

View File

@@ -1,4 +1,8 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using Newtonsoft.Json;
namespace BTCPayServer.Models.ServerViewModels
{
@@ -8,6 +12,39 @@ namespace BTCPayServer.Models.ServerViewModels
public string WalletPassword { get; set; }
public string[] Seed { get; set; }
public List<string> Seed { get; set; }
public static LndSeedBackupViewModel Parse(string lndSeedFilePath)
{
try
{
if (!String.IsNullOrEmpty(lndSeedFilePath) && File.Exists(lndSeedFilePath))
{
var unlockFileContents = File.ReadAllText(lndSeedFilePath);
var unlockFile = JsonConvert.DeserializeObject<LndSeedFile>(unlockFileContents);
if (!String.IsNullOrEmpty(unlockFile.wallet_password))
{
return new LndSeedBackupViewModel
{
WalletPassword = unlockFile.wallet_password,
Seed = unlockFile.cipher_seed_mnemonic,
IsWalletUnlockPresent = true,
};
}
}
}
catch
{
}
return new LndSeedBackupViewModel();
}
private class LndSeedFile
{
public string wallet_password { get; set; }
public List<string> cipher_seed_mnemonic { get; set; }
}
}
}