mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +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))
|
if (!_dashboard.IsFullySynched(network.CryptoCode, out var summary))
|
||||||
throw new Exception($"{network.CryptoCode}: not started or fully synched");
|
throw new Exception($"{network.CryptoCode}: not started or fully synched");
|
||||||
|
|
||||||
var accountKey = derivationSettings.AccountKeySettings.Where(a => a.IsFullySetup()).FirstOrDefault();
|
var accountKey = derivationSettings.GetSigningAccountKeySettings();
|
||||||
accountKey = accountKey ?? derivationSettings.AccountKeySettings.FirstOrDefault();
|
|
||||||
// Some deployment does not have the AccountKeyPath set, let's fix this...
|
// Some deployment does not have the AccountKeyPath set, let's fix this...
|
||||||
if (accountKey.AccountKeyPath == null)
|
if (accountKey.AccountKeyPath == null)
|
||||||
{
|
{
|
||||||
@@ -540,12 +539,13 @@ namespace BTCPayServer.Controllers
|
|||||||
var derivationSchemeSettings = await GetDerivationSchemeSettings(walletId);
|
var derivationSchemeSettings = await GetDerivationSchemeSettings(walletId);
|
||||||
if (derivationSchemeSettings == null)
|
if (derivationSchemeSettings == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
var store = (await Repository.FindStore(walletId.StoreId, GetUserId()));
|
||||||
var vm = new WalletSettingsViewModel()
|
var vm = new WalletSettingsViewModel()
|
||||||
{
|
{
|
||||||
Label = derivationSchemeSettings.Label,
|
Label = derivationSchemeSettings.Label,
|
||||||
DerivationScheme = derivationSchemeSettings.AccountDerivation.ToString(),
|
DerivationScheme = derivationSchemeSettings.AccountDerivation.ToString(),
|
||||||
DerivationSchemeInput = derivationSchemeSettings.AccountOriginal
|
DerivationSchemeInput = derivationSchemeSettings.AccountOriginal,
|
||||||
|
SelectedSigningKey = derivationSchemeSettings.SigningKey.ToString()
|
||||||
};
|
};
|
||||||
vm.AccountKeys = derivationSchemeSettings.AccountKeySettings
|
vm.AccountKeys = derivationSchemeSettings.AccountKeySettings
|
||||||
.Select(e => new WalletSettingsAccountKeyViewModel()
|
.Select(e => new WalletSettingsAccountKeyViewModel()
|
||||||
@@ -569,6 +569,7 @@ namespace BTCPayServer.Controllers
|
|||||||
if (derivationScheme == null)
|
if (derivationScheme == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
derivationScheme.Label = vm.Label;
|
derivationScheme.Label = vm.Label;
|
||||||
|
derivationScheme.SigningKey = new BitcoinExtPubKey(vm.SelectedSigningKey, derivationScheme.Network.NBitcoinNetwork);
|
||||||
for (int i = 0; i < derivationScheme.AccountKeySettings.Length; i++)
|
for (int i = 0; i < derivationScheme.AccountKeySettings.Length; i++)
|
||||||
{
|
{
|
||||||
derivationScheme.AccountKeySettings[i].AccountKeyPath = string.IsNullOrWhiteSpace(vm.AccountKeys[i].AccountKeyPath) ? null
|
derivationScheme.AccountKeySettings[i].AccountKeyPath = string.IsNullOrWhiteSpace(vm.AccountKeys[i].AccountKeyPath) ? null
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ namespace BTCPayServer
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DerivationSchemeSettings(DerivationStrategyBase derivationStrategy, BTCPayNetwork network)
|
public DerivationSchemeSettings(DerivationStrategyBase derivationStrategy, BTCPayNetwork network)
|
||||||
{
|
{
|
||||||
if (network == null)
|
if (network == null)
|
||||||
@@ -129,6 +130,21 @@ namespace BTCPayServer
|
|||||||
AccountKey = c.GetWif(network.NBitcoinNetwork)
|
AccountKey = c.GetWif(network.NBitcoinNetwork)
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BitcoinExtPubKey _SigningKey;
|
||||||
|
public BitcoinExtPubKey SigningKey
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _SigningKey ?? AccountKeySettings?.Select(k => k.AccountKey).FirstOrDefault();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_SigningKey = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public BTCPayNetwork Network { get; set; }
|
public BTCPayNetwork Network { get; set; }
|
||||||
public string Source { 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;
|
AccountKeySettings[] _AccountKeySettings;
|
||||||
public AccountKeySettings[] AccountKeySettings
|
public AccountKeySettings[] AccountKeySettings
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@@ -10,6 +11,9 @@ namespace BTCPayServer.Models.WalletViewModels
|
|||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
public string DerivationScheme { get; set; }
|
public string DerivationScheme { get; set; }
|
||||||
public string DerivationSchemeInput { 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>();
|
public List<WalletSettingsAccountKeyViewModel> AccountKeys { get; set; } = new List<WalletSettingsAccountKeyViewModel>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,13 @@
|
|||||||
<input asp-for="@Model.AccountKeys[i].AccountKeyPath" class="form-control" />
|
<input asp-for="@Model.AccountKeys[i].AccountKeyPath" class="form-control" />
|
||||||
<span asp-validation-for="@Model.AccountKeys[i].AccountKeyPath" class="text-danger"></span>
|
<span asp-validation-for="@Model.AccountKeys[i].AccountKeyPath" class="text-danger"></span>
|
||||||
</div>
|
</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">
|
<div class="form-group">
|
||||||
|
|||||||
Reference in New Issue
Block a user