Merge pull request #2325 from btcpayserver/fix/nextnetworkfee-null

Returning 0 for NextNetworkFee if it's null
This commit is contained in:
Nicolas Dorier 2021-03-02 11:19:43 +09:00 committed by GitHub
commit 4f6ec3aa32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -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()

View file

@ -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)