mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-28 16:58:00 +01:00
* Use Mempoolspace fees Since bitcoind's fee estiomates are horrible, I would use an altenrative, but that adds a third party to the mix. We can either: * Accept the risk (it is only for fee estimation anyway) * Offer a toggle in the server settings * Move this code to a plugin * refactor * Refactor --------- Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
28 lines
774 B
C#
28 lines
774 B
C#
#nullable enable
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using NBitcoin;
|
|
|
|
namespace BTCPayServer.Services.Fees
|
|
{
|
|
public class FallbackFeeProvider(IFeeProvider[] Providers) : IFeeProvider
|
|
{
|
|
public async Task<FeeRate> GetFeeRateAsync(int blockTarget = 20)
|
|
{
|
|
for (int i = 0; i < Providers.Length; i++)
|
|
{
|
|
try
|
|
{
|
|
return await Providers[i].GetFeeRateAsync(blockTarget);
|
|
}
|
|
catch when (i < Providers.Length - 1)
|
|
{
|
|
}
|
|
}
|
|
throw new NotSupportedException("No provider available");
|
|
}
|
|
}
|
|
}
|