mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Displaying information from walletunlock.json if file is present
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user