Adopt economyFee recommendation from mempool rate provider.

This commit is contained in:
jmacxx 2022-06-06 10:09:39 -05:00
parent a62655c15d
commit 08570c929d
No known key found for this signature in database
GPG Key ID: 155297BABFE94A1B
2 changed files with 5 additions and 6 deletions

View File

@ -26,7 +26,7 @@ import java.time.Duration;
*/
public abstract class FeeRateProvider extends PriceProvider<FeeRate> {
public static final long MIN_FEE_RATE_FOR_WITHDRAWAL = 2; // satoshi/vbyte
public static final long MIN_FEE_RATE_FOR_WITHDRAWAL = 1; // satoshi/vbyte
public static final long MIN_FEE_RATE_FOR_TRADING = 10; // satoshi/vbyte
public static final long MAX_FEE_RATE = 1000;

View File

@ -97,14 +97,13 @@ abstract class MempoolFeeRateProvider extends FeeRateProvider {
.map(r -> Math.max(r, MIN_FEE_RATE_FOR_TRADING))
.map(r -> Math.min(r, MAX_FEE_RATE))
.orElse(MIN_FEE_RATE_FOR_TRADING);
long minimumFee = feeRatePredictions.stream()
.filter(p -> p.getKey().equalsIgnoreCase("minimumFee"))
long economyFee = feeRatePredictions.stream()
.filter(p -> p.getKey().equalsIgnoreCase("economyFee"))
.map(Map.Entry::getValue)
.findFirst()
.map(r -> Math.multiplyExact(r, 2)) // multiply the minimumFee by 2 (per wiz)
.orElse(MIN_FEE_RATE_FOR_WITHDRAWAL);
log.info("Retrieved estimated mining fee of {} sat/vB and minimumFee of {} sat/vB from {}", estimatedFeeRate, minimumFee, getMempoolApiHostname());
return new FeeRate("BTC", estimatedFeeRate, minimumFee, Instant.now().getEpochSecond());
log.info("Retrieved estimated mining fee of {} sat/vB and economyFee of {} sat/vB from {}", estimatedFeeRate, economyFee, getMempoolApiHostname());
return new FeeRate("BTC", estimatedFeeRate, economyFee, Instant.now().getEpochSecond());
}
private Set<Map.Entry<String, Long>> getFeeRatePredictions() {