2019-05-15 15:00:09 +09:00
|
|
|
using System;
|
2019-05-14 16:03:48 +00:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
2019-05-15 15:00:09 +09:00
|
|
|
using NBitcoin;
|
2019-05-14 16:03:48 +00:00
|
|
|
|
|
|
|
namespace BTCPayServer.Models.WalletViewModels
|
|
|
|
{
|
|
|
|
public class SignWithSeedViewModel
|
|
|
|
{
|
2020-05-25 04:55:28 +09:00
|
|
|
public SigningContextModel SigningContext { get; set; } = new SigningContextModel();
|
2020-05-25 06:27:01 +09:00
|
|
|
|
2019-05-14 16:03:48 +00:00
|
|
|
[Required]
|
2020-05-25 06:27:01 +09:00
|
|
|
[Display(Name = "BIP39 Seed (12/24 word mnemonic phrase) or HD private key (xprv...)")]
|
2019-05-14 16:03:48 +00:00
|
|
|
public string SeedOrKey { get; set; }
|
|
|
|
|
|
|
|
[Display(Name = "Optional seed passphrase")]
|
|
|
|
public string Passphrase { get; set; }
|
2023-01-06 14:18:07 +01:00
|
|
|
|
2022-07-04 06:20:08 +02:00
|
|
|
public string BackUrl { get; set; }
|
|
|
|
public string ReturnUrl { get; set; }
|
2019-05-14 16:03:48 +00:00
|
|
|
|
2019-05-15 15:00:09 +09:00
|
|
|
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;
|
|
|
|
}
|
2019-05-14 16:03:48 +00:00
|
|
|
}
|
|
|
|
}
|