diff --git a/BTCPayServer/Controllers/UIStoresController.Onchain.cs b/BTCPayServer/Controllers/UIStoresController.Onchain.cs index 0accff977..fa257cfad 100644 --- a/BTCPayServer/Controllers/UIStoresController.Onchain.cs +++ b/BTCPayServer/Controllers/UIStoresController.Onchain.cs @@ -119,17 +119,16 @@ namespace BTCPayServer.Controllers accountSettings.AccountKeyPath = vm.KeyPath == null ? null : KeyPath.Parse(vm.KeyPath); accountSettings.RootFingerprint = string.IsNullOrEmpty(vm.RootFingerprint) - ? (HDFingerprint?)null - : new HDFingerprint( - NBitcoin.DataEncoders.Encoders.Hex.DecodeData(vm.RootFingerprint)); + ? null + : new HDFingerprint(Encoders.Hex.DecodeData(vm.RootFingerprint)); } } vm.DerivationScheme = strategy.AccountDerivation.ToString(); ModelState.Remove(nameof(vm.DerivationScheme)); } - catch + catch (Exception ex) { - ModelState.AddModelError(nameof(vm.DerivationScheme), "Invalid wallet format"); + ModelState.AddModelError(nameof(vm.DerivationScheme), $"Invalid wallet format: {ex.Message}"); return View(vm.ViewName, vm); } } diff --git a/BTCPayServer/Controllers/UIStoresController.cs b/BTCPayServer/Controllers/UIStoresController.cs index 09c32160d..e49e303e0 100644 --- a/BTCPayServer/Controllers/UIStoresController.cs +++ b/BTCPayServer/Controllers/UIStoresController.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BTCPayServer.Abstractions.Constants; @@ -672,10 +673,10 @@ namespace BTCPayServer.Controllers private DerivationSchemeSettings ParseDerivationStrategy(string derivationScheme, BTCPayNetwork network) { var parser = new DerivationSchemeParser(network); - try + var isOD = Regex.Match(derivationScheme, @"\(.*?\)"); + if (isOD.Success) { - var derivationSchemeSettings = new DerivationSchemeSettings(); - derivationSchemeSettings.Network = network; + var derivationSchemeSettings = new DerivationSchemeSettings { Network = network }; var result = parser.ParseOutputDescriptor(derivationScheme); derivationSchemeSettings.AccountOriginal = derivationScheme.Trim(); derivationSchemeSettings.AccountDerivation = result.Item1; @@ -687,12 +688,9 @@ namespace BTCPayServer.Controllers }).ToArray() ?? new AccountKeySettings[result.Item1.GetExtPubKeys().Count()]; return derivationSchemeSettings; } - catch (Exception) - { - // ignored - } - - return new DerivationSchemeSettings(parser.Parse(derivationScheme), network); + + var strategy = parser.Parse(derivationScheme); + return new DerivationSchemeSettings(strategy, network); } [HttpGet]