From d372cbad74adc7d677c16b7fb6dd1e14d08cdd3d Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Sun, 6 Mar 2022 20:56:37 -0800 Subject: [PATCH] Fix null reference error when "destinations" field is not specified or empty when creating a new wallet transaction fix #3537 --- .../GreenfieldStoreOnChainWalletsController.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs index d023a4a86..18f7dc9b2 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldStoreOnChainWalletsController.cs @@ -282,6 +282,16 @@ namespace BTCPayServer.Controllers.Greenfield return this.CreateAPIError(503, "not-available", $"You need to allow non-admins to use hotwallets for their stores (in /server/policies)"); } + if (request.Destinations == null || !request.Destinations.Any()) + { + ModelState.AddModelError( + nameof(request.Destinations), + "At least one destination must be specified" + ); + + return this.CreateValidationError(ModelState); + } + var explorerClient = _explorerClientProvider.GetExplorerClient(cryptoCode); var wallet = _btcPayWalletProvider.GetWallet(network);