diff --git a/BTCPayServer/Controllers/WalletsController.cs b/BTCPayServer/Controllers/WalletsController.cs index e33a69bc5..20e2d394e 100644 --- a/BTCPayServer/Controllers/WalletsController.cs +++ b/BTCPayServer/Controllers/WalletsController.cs @@ -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 diff --git a/BTCPayServer/DerivationSchemeSettings.cs b/BTCPayServer/DerivationSchemeSettings.cs index 3ddcac379..c5e6edef3 100644 --- a/BTCPayServer/DerivationSchemeSettings.cs +++ b/BTCPayServer/DerivationSchemeSettings.cs @@ -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 GetPSBTRebaseKeyRules() { - foreach(var accountKey in AccountKeySettings) + foreach (var accountKey in AccountKeySettings) { if (accountKey.AccountKeyPath != null && accountKey.RootFingerprint is HDFingerprint fp) { diff --git a/BTCPayServer/Models/WalletViewModels/WalletSettingsViewModel.cs b/BTCPayServer/Models/WalletViewModels/WalletSettingsViewModel.cs index d7119c34b..40d93844b 100644 --- a/BTCPayServer/Models/WalletViewModels/WalletSettingsViewModel.cs +++ b/BTCPayServer/Models/WalletViewModels/WalletSettingsViewModel.cs @@ -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 AccountKeys { get; set; } = new List(); } diff --git a/BTCPayServer/Views/Wallets/WalletSettings.cshtml b/BTCPayServer/Views/Wallets/WalletSettings.cshtml index 9247a276a..f286fdcf7 100644 --- a/BTCPayServer/Views/Wallets/WalletSettings.cshtml +++ b/BTCPayServer/Views/Wallets/WalletSettings.cshtml @@ -60,6 +60,13 @@ + @if (Model.IsMultiSig) + { +
+ + +
+ } }