From 54700979812b4dc02d6ac918a628faa142a731fe Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Tue, 3 Jan 2023 11:31:41 -0500 Subject: [PATCH] Fix but with calculating the miner fee for the DPT. Add activation date for hotfix. We used all potential BM instead only the ones who have a positive cappedBurnAmountShare. --- .../core/dao/burningman/BurningManService.java | 8 ++++++++ .../DelayedPayoutTxReceiverService.java | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/bisq/core/dao/burningman/BurningManService.java b/core/src/main/java/bisq/core/dao/burningman/BurningManService.java index 8fc2a9bc58..c85f8aff18 100644 --- a/core/src/main/java/bisq/core/dao/burningman/BurningManService.java +++ b/core/src/main/java/bisq/core/dao/burningman/BurningManService.java @@ -53,6 +53,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; @@ -207,6 +208,13 @@ public class BurningManService { return daoStateService.getParamValue(Param.RECIPIENT_BTC_ADDRESS, chainHeight); } + Set getActiveBurningManCandidates(int chainHeight) { + return getBurningManCandidatesByName(chainHeight).values().stream() + .filter(burningManCandidate -> burningManCandidate.getCappedBurnAmountShare() > 0) + .filter(candidate -> candidate.getMostRecentAddress().isPresent()) + .collect(Collectors.toSet()); + } + /////////////////////////////////////////////////////////////////////////////////////////// // Private diff --git a/core/src/main/java/bisq/core/dao/burningman/DelayedPayoutTxReceiverService.java b/core/src/main/java/bisq/core/dao/burningman/DelayedPayoutTxReceiverService.java index 1f3056fec2..f1aba97d9c 100644 --- a/core/src/main/java/bisq/core/dao/burningman/DelayedPayoutTxReceiverService.java +++ b/core/src/main/java/bisq/core/dao/burningman/DelayedPayoutTxReceiverService.java @@ -25,6 +25,7 @@ import bisq.core.dao.state.model.blockchain.Block; import bisq.common.config.Config; import bisq.common.util.Tuple2; +import bisq.common.util.Utilities; import javax.inject.Inject; import javax.inject.Singleton; @@ -33,6 +34,8 @@ import com.google.common.annotations.VisibleForTesting; import java.util.Collection; import java.util.Comparator; +import java.util.Date; +import java.util.GregorianCalendar; import java.util.List; import java.util.stream.Collectors; @@ -49,6 +52,12 @@ import static com.google.common.base.Preconditions.checkArgument; @Slf4j @Singleton public class DelayedPayoutTxReceiverService implements DaoStateListener { + private static final Date HOTFIX_ACTIVATION_DATE = Utilities.getUTCDate(2023, GregorianCalendar.JANUARY, 10); + + public static boolean isHotfixActivated() { + return new Date().after(HOTFIX_ACTIVATION_DATE); + } + // We don't allow to get further back than 767950 (the block height from Dec. 18th 2022). static final int MIN_SNAPSHOT_HEIGHT = Config.baseCurrencyNetwork().isRegtest() ? 0 : 767950; @@ -113,9 +122,12 @@ public class DelayedPayoutTxReceiverService implements DaoStateListener { public List> getReceivers(int burningManSelectionHeight, long inputAmount, long tradeTxFee) { - checkArgument(burningManSelectionHeight >= MIN_SNAPSHOT_HEIGHT, "Selection height must be >= " + MIN_SNAPSHOT_HEIGHT); - Collection burningManCandidates = burningManService.getBurningManCandidatesByName(burningManSelectionHeight).values(); + Collection burningManCandidates = isHotfixActivated() ? + burningManService.getActiveBurningManCandidates(burningManSelectionHeight) : + burningManService.getBurningManCandidatesByName(burningManSelectionHeight).values(); + + if (burningManCandidates.isEmpty()) { // If there are no compensation requests (e.g. at dev testing) we fall back to the legacy BM return List.of(new Tuple2<>(inputAmount, burningManService.getLegacyBurningManAddress(burningManSelectionHeight)));