btcpayserver/BTCPayServer/Models/WalletViewModels/SignWithSeedViewModel.cs
d11n d5d0be5824
Code formatting updates (#4502)
* Editorconfig: Add space_before_self_closing setting

This was a difference between the way dotnet-format and Rider format code. See https://www.jetbrains.com/help/rider/EditorConfig_Index.html

* Editorconfig: Keep 4 spaces indentation for Swagger JSON files

They are all formatted that way, let's keep it like that.

* Apply dotnet-format, mostly white-space related changes
2023-01-06 22:18:07 +09:00

46 lines
1.2 KiB
C#

using System;
using System.ComponentModel.DataAnnotations;
using NBitcoin;
namespace BTCPayServer.Models.WalletViewModels
{
public class SignWithSeedViewModel
{
public SigningContextModel SigningContext { get; set; } = new SigningContextModel();
[Required]
[Display(Name = "BIP39 Seed (12/24 word mnemonic phrase) or HD private key (xprv...)")]
public string SeedOrKey { get; set; }
[Display(Name = "Optional seed passphrase")]
public string Passphrase { get; set; }
public string BackUrl { get; set; }
public string ReturnUrl { get; set; }
public ExtKey GetExtKey(Network network)
{
ExtKey extKey = null;
try
{
var mnemonic = new Mnemonic(SeedOrKey);
extKey = mnemonic.DeriveExtKey(Passphrase);
}
catch (Exception)
{
}
if (extKey == null)
{
try
{
extKey = ExtKey.Parse(SeedOrKey, network);
}
catch (Exception)
{
}
}
return extKey;
}
}
}