mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
44 lines
1.1 KiB
C#
44 lines
1.1 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 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;
|
|
}
|
|
}
|
|
}
|