From dde841383a66435bf6083a425a5fd70bf3391c43 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 27 May 2019 21:50:08 +0900 Subject: [PATCH] Don't throw exception if derivation scheme is not found --- .../Controllers/WalletsController.PSBT.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/Controllers/WalletsController.PSBT.cs b/BTCPayServer/Controllers/WalletsController.PSBT.cs index 365304760..7933cbeca 100644 --- a/BTCPayServer/Controllers/WalletsController.PSBT.cs +++ b/BTCPayServer/Controllers/WalletsController.PSBT.cs @@ -114,11 +114,15 @@ namespace BTCPayServer.Controllers var vm = new WalletPSBTReadyViewModel() { PSBT = psbt }; vm.SigningKey = signingKey; vm.SigningKeyPath = signingKeyPath; - await FetchTransactionDetails(walletId, vm, network); + + var derivationSchemeSettings = await GetDerivationSchemeSettings(walletId); + if (derivationSchemeSettings == null) + return NotFound(); + await FetchTransactionDetails(derivationSchemeSettings, vm, network); return View(nameof(WalletPSBTReady), vm); } - private async Task FetchTransactionDetails(WalletId walletId, WalletPSBTReadyViewModel vm, BTCPayNetwork network) + private Task FetchTransactionDetails(DerivationSchemeSettings derivationSchemeSettings, WalletPSBTReadyViewModel vm, BTCPayNetwork network) { var psbtObject = PSBT.Parse(vm.PSBT, network.NBitcoinNetwork); IHDKey signingKey = null; @@ -141,7 +145,6 @@ namespace BTCPayServer.Controllers } catch { } - var derivationSchemeSettings = await GetDerivationSchemeSettings(walletId); if (signingKey == null || signingKeyPath == null) { var signingKeySettings = derivationSchemeSettings.GetSigningAccountKeySettings(); @@ -200,6 +203,7 @@ namespace BTCPayServer.Controllers { vm.SetErrors(errors); } + return Task.CompletedTask; } [HttpPost] @@ -213,7 +217,10 @@ namespace BTCPayServer.Controllers try { psbt = PSBT.Parse(vm.PSBT, network.NBitcoinNetwork); - await FetchTransactionDetails(walletId, vm, network); + var derivationSchemeSettings = await GetDerivationSchemeSettings(walletId); + if (derivationSchemeSettings == null) + return NotFound(); + await FetchTransactionDetails(derivationSchemeSettings, vm, network); } catch {