diff --git a/BTCPayServer/Payments/Bitcoin/BitcoinLikeOnChainPaymentMethod.cs b/BTCPayServer/Payments/Bitcoin/BitcoinLikeOnChainPaymentMethod.cs index ee10290ce..cbd7cab9c 100644 --- a/BTCPayServer/Payments/Bitcoin/BitcoinLikeOnChainPaymentMethod.cs +++ b/BTCPayServer/Payments/Bitcoin/BitcoinLikeOnChainPaymentMethod.cs @@ -17,7 +17,8 @@ namespace BTCPayServer.Payments.Bitcoin public decimal GetNextNetworkFee() { - return NextNetworkFee.ToDecimal(MoneyUnit.BTC); + // NextNetworkFee is sometimes not initialized properly, so we return 0 in that case + return NextNetworkFee?.ToDecimal(MoneyUnit.BTC) ?? 0; } public decimal GetFeeRate() diff --git a/BTCPayServer/Payments/Bitcoin/BitcoinLikePaymentHandler.cs b/BTCPayServer/Payments/Bitcoin/BitcoinLikePaymentHandler.cs index 30ccc8374..88b001ff6 100644 --- a/BTCPayServer/Payments/Bitcoin/BitcoinLikePaymentHandler.cs +++ b/BTCPayServer/Payments/Bitcoin/BitcoinLikePaymentHandler.cs @@ -143,9 +143,11 @@ namespace BTCPayServer.Payments.Bitcoin if (!_ExplorerProvider.IsAvailable(network)) throw new PaymentMethodUnavailableException($"Full node not available"); var prepare = (Prepare)preparePaymentObject; - Payments.Bitcoin.BitcoinLikeOnChainPaymentMethod onchainMethod = - new Payments.Bitcoin.BitcoinLikeOnChainPaymentMethod(); + var onchainMethod = new BitcoinLikeOnChainPaymentMethod(); var blob = store.GetStoreBlob(); + + // TODO: this needs to be refactored to move this logic into BitcoinLikeOnChainPaymentMethod + // This is likely a constructor code onchainMethod.NetworkFeeMode = blob.NetworkFeeMode; onchainMethod.FeeRate = await prepare.GetFeeRate; switch (onchainMethod.NetworkFeeMode)