From b9cea968e5e6f57271d1fc0141abab1cd57c9cc0 Mon Sep 17 00:00:00 2001 From: Henry Hollingworth Date: Fri, 12 Apr 2024 13:51:56 +0800 Subject: [PATCH] (bug) handle null XMR settings (#5909) Co-authored-by: Henry Hollingworth --- .../Monero/UI/MoneroLikeStoreController.cs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs index 00f31b0dd..bfac948ab 100644 --- a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs +++ b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs @@ -109,14 +109,19 @@ namespace BTCPayServer.Services.Altcoins.Monero.UI new SelectListItem( $"{account.AccountIndex} - {(string.IsNullOrEmpty(account.Label) ? "No label" : account.Label)}", account.AccountIndex.ToString(CultureInfo.InvariantCulture))); - var settlementThresholdChoice = settings.InvoiceSettledConfirmationThreshold switch + + var settlementThresholdChoice = MoneroLikeSettlementThresholdChoice.StoreSpeedPolicy; + if (settings != null && settings.InvoiceSettledConfirmationThreshold is { } confirmations) { - null => MoneroLikeSettlementThresholdChoice.StoreSpeedPolicy, - 0 => MoneroLikeSettlementThresholdChoice.ZeroConfirmation, - 1 => MoneroLikeSettlementThresholdChoice.AtLeastOne, - 10 => MoneroLikeSettlementThresholdChoice.AtLeastTen, - _ => MoneroLikeSettlementThresholdChoice.Custom - }; + settlementThresholdChoice = confirmations switch + { + 0 => MoneroLikeSettlementThresholdChoice.ZeroConfirmation, + 1 => MoneroLikeSettlementThresholdChoice.AtLeastOne, + 10 => MoneroLikeSettlementThresholdChoice.AtLeastTen, + _ => MoneroLikeSettlementThresholdChoice.Custom + }; + } + return new MoneroLikePaymentMethodViewModel() { WalletFileFound = System.IO.File.Exists(fileAddress), @@ -129,9 +134,11 @@ namespace BTCPayServer.Services.Altcoins.Monero.UI Accounts = accounts == null ? null : new SelectList(accounts, nameof(SelectListItem.Value), nameof(SelectListItem.Text)), SettlementConfirmationThresholdChoice = settlementThresholdChoice, - CustomSettlementConfirmationThreshold = settlementThresholdChoice is MoneroLikeSettlementThresholdChoice.Custom - ? settings.InvoiceSettledConfirmationThreshold - : null + CustomSettlementConfirmationThreshold = + settings != null && + settlementThresholdChoice is MoneroLikeSettlementThresholdChoice.Custom + ? settings.InvoiceSettledConfirmationThreshold + : null }; }