mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 10:40:29 +01:00
44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using NBitcoin;
|
|
|
|
namespace BTCPayServer.Models.WalletViewModels
|
|
{
|
|
public class SignWithSeedViewModel
|
|
{
|
|
[Required]
|
|
public string PSBT { get; set; }
|
|
[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;
|
|
}
|
|
}
|
|
}
|