mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Can select the signing key in WalletSettings
This commit is contained in:
@@ -453,8 +453,7 @@ namespace BTCPayServer.Controllers
|
||||
if (!_dashboard.IsFullySynched(network.CryptoCode, out var summary))
|
||||
throw new Exception($"{network.CryptoCode}: not started or fully synched");
|
||||
|
||||
var accountKey = derivationSettings.AccountKeySettings.Where(a => a.IsFullySetup()).FirstOrDefault();
|
||||
accountKey = accountKey ?? derivationSettings.AccountKeySettings.FirstOrDefault();
|
||||
var accountKey = derivationSettings.GetSigningAccountKeySettings();
|
||||
// Some deployment does not have the AccountKeyPath set, let's fix this...
|
||||
if (accountKey.AccountKeyPath == null)
|
||||
{
|
||||
@@ -540,12 +539,13 @@ namespace BTCPayServer.Controllers
|
||||
var derivationSchemeSettings = await GetDerivationSchemeSettings(walletId);
|
||||
if (derivationSchemeSettings == null)
|
||||
return NotFound();
|
||||
|
||||
var store = (await Repository.FindStore(walletId.StoreId, GetUserId()));
|
||||
var vm = new WalletSettingsViewModel()
|
||||
{
|
||||
Label = derivationSchemeSettings.Label,
|
||||
DerivationScheme = derivationSchemeSettings.AccountDerivation.ToString(),
|
||||
DerivationSchemeInput = derivationSchemeSettings.AccountOriginal
|
||||
DerivationSchemeInput = derivationSchemeSettings.AccountOriginal,
|
||||
SelectedSigningKey = derivationSchemeSettings.SigningKey.ToString()
|
||||
};
|
||||
vm.AccountKeys = derivationSchemeSettings.AccountKeySettings
|
||||
.Select(e => new WalletSettingsAccountKeyViewModel()
|
||||
@@ -569,6 +569,7 @@ namespace BTCPayServer.Controllers
|
||||
if (derivationScheme == null)
|
||||
return NotFound();
|
||||
derivationScheme.Label = vm.Label;
|
||||
derivationScheme.SigningKey = new BitcoinExtPubKey(vm.SelectedSigningKey, derivationScheme.Network.NBitcoinNetwork);
|
||||
for (int i = 0; i < derivationScheme.AccountKeySettings.Length; i++)
|
||||
{
|
||||
derivationScheme.AccountKeySettings[i].AccountKeyPath = string.IsNullOrWhiteSpace(vm.AccountKeys[i].AccountKeyPath) ? null
|
||||
|
||||
@@ -116,6 +116,7 @@ namespace BTCPayServer
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DerivationSchemeSettings(DerivationStrategyBase derivationStrategy, BTCPayNetwork network)
|
||||
{
|
||||
if (network == null)
|
||||
@@ -129,6 +130,21 @@ namespace BTCPayServer
|
||||
AccountKey = c.GetWif(network.NBitcoinNetwork)
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
|
||||
BitcoinExtPubKey _SigningKey;
|
||||
public BitcoinExtPubKey SigningKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SigningKey ?? AccountKeySettings?.Select(k => k.AccountKey).FirstOrDefault();
|
||||
}
|
||||
set
|
||||
{
|
||||
_SigningKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public BTCPayNetwork Network { get; set; }
|
||||
public string Source { get; set; }
|
||||
@@ -158,6 +174,11 @@ namespace BTCPayServer
|
||||
}
|
||||
}
|
||||
|
||||
public AccountKeySettings GetSigningAccountKeySettings()
|
||||
{
|
||||
return AccountKeySettings.Single(a => a.AccountKey == SigningKey);
|
||||
}
|
||||
|
||||
AccountKeySettings[] _AccountKeySettings;
|
||||
public AccountKeySettings[] AccountKeySettings
|
||||
{
|
||||
@@ -190,7 +211,7 @@ namespace BTCPayServer
|
||||
|
||||
public IEnumerable<NBXplorer.Models.PSBTRebaseKeyRules> GetPSBTRebaseKeyRules()
|
||||
{
|
||||
foreach(var accountKey in AccountKeySettings)
|
||||
foreach (var accountKey in AccountKeySettings)
|
||||
{
|
||||
if (accountKey.AccountKeyPath != null && accountKey.RootFingerprint is HDFingerprint fp)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -10,6 +11,9 @@ namespace BTCPayServer.Models.WalletViewModels
|
||||
public string Label { get; set; }
|
||||
public string DerivationScheme { get; set; }
|
||||
public string DerivationSchemeInput { get; set; }
|
||||
[Display(Name = "Is signing key")]
|
||||
public string SelectedSigningKey { get; set; }
|
||||
public bool IsMultiSig => AccountKeys.Count > 1;
|
||||
|
||||
public List<WalletSettingsAccountKeyViewModel> AccountKeys { get; set; } = new List<WalletSettingsAccountKeyViewModel>();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,13 @@
|
||||
<input asp-for="@Model.AccountKeys[i].AccountKeyPath" class="form-control" />
|
||||
<span asp-validation-for="@Model.AccountKeys[i].AccountKeyPath" class="text-danger"></span>
|
||||
</div>
|
||||
@if (Model.IsMultiSig)
|
||||
{
|
||||
<div class="form-group">
|
||||
<label asp-for="SelectedSigningKey"></label>
|
||||
<input asp-for="SelectedSigningKey" type="radio" value="@Model.AccountKeys[i].AccountKey" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user