mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Refactoring: Move isActivated method to BurningManService
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
dff6d48333
commit
0e79582819
@ -35,6 +35,9 @@ import bisq.core.dao.state.model.governance.IssuanceType;
|
||||
|
||||
import bisq.network.p2p.storage.P2PDataStorage;
|
||||
|
||||
import bisq.common.app.DevEnv;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@ -43,6 +46,8 @@ import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -61,6 +66,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
@Singleton
|
||||
public class BurningManService {
|
||||
private static final Date ACTIVATION_DATE = Utilities.getUTCDate(2023, GregorianCalendar.JANUARY, 1);
|
||||
|
||||
public static boolean isActivated() {
|
||||
return DevEnv.isDevTesting() || new Date().after(ACTIVATION_DATE);
|
||||
}
|
||||
|
||||
// Parameters
|
||||
// Cannot be changed after release as it would break trade protocol verification of DPT receivers.
|
||||
|
||||
@ -68,6 +79,7 @@ public class BurningManService {
|
||||
// Used as pre-image for burning.
|
||||
public static final String GENESIS_OUTPUT_PREFIX = "Bisq co-founder ";
|
||||
|
||||
|
||||
// Factor for weighting the genesis output amounts.
|
||||
private static final double GENESIS_OUTPUT_AMOUNT_FACTOR = 0.05;
|
||||
|
||||
|
@ -23,9 +23,7 @@ import bisq.core.dao.state.DaoStateListener;
|
||||
import bisq.core.dao.state.DaoStateService;
|
||||
import bisq.core.dao.state.model.blockchain.Block;
|
||||
|
||||
import bisq.common.app.DevEnv;
|
||||
import bisq.common.util.Tuple2;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -34,8 +32,6 @@ 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;
|
||||
|
||||
@ -50,8 +46,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
@Singleton
|
||||
public class DelayedPayoutTxReceiverService implements DaoStateListener {
|
||||
private static final Date ACTIVATION_DATE = Utilities.getUTCDate(2023, GregorianCalendar.JANUARY, 1);
|
||||
|
||||
// One part of the limit for the min. amount to be included in the DPT outputs.
|
||||
// The miner fee rate multiplied by 2 times the output size is the other factor.
|
||||
// The higher one of both is used. 1000 sat is about 2 USD @ 20k price.
|
||||
@ -69,10 +63,6 @@ public class DelayedPayoutTxReceiverService implements DaoStateListener {
|
||||
// spike when opening arbitration.
|
||||
private static final long DPT_MIN_TX_FEE_RATE = 10;
|
||||
|
||||
public static boolean isActivated() {
|
||||
return DevEnv.isDevTesting() || new Date().after(ACTIVATION_DATE);
|
||||
}
|
||||
|
||||
|
||||
private final DaoStateService daoStateService;
|
||||
private final BurningManService burningManService;
|
||||
|
@ -23,6 +23,7 @@ import bisq.core.btc.wallet.BtcWalletService;
|
||||
import bisq.core.btc.wallet.TradeWalletService;
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.burningman.BtcFeeReceiverService;
|
||||
import bisq.core.dao.burningman.BurningManService;
|
||||
import bisq.core.dao.burningman.DelayedPayoutTxReceiverService;
|
||||
import bisq.core.exceptions.TradePriceOutOfToleranceException;
|
||||
import bisq.core.filter.FilterManager;
|
||||
@ -672,7 +673,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
||||
return;
|
||||
}
|
||||
|
||||
if (DelayedPayoutTxReceiverService.isActivated()) {
|
||||
if (BurningManService.isActivated()) {
|
||||
try {
|
||||
int takersBurningManSelectionHeight = request.getBurningManSelectionHeight();
|
||||
checkArgument(takersBurningManSelectionHeight > 0, "takersBurningManSelectionHeight must not be 0");
|
||||
|
@ -18,7 +18,7 @@
|
||||
package bisq.core.trade.protocol.bisq_v1.tasks.buyer;
|
||||
|
||||
import bisq.core.btc.wallet.BtcWalletService;
|
||||
import bisq.core.dao.burningman.DelayedPayoutTxReceiverService;
|
||||
import bisq.core.dao.burningman.BurningManService;
|
||||
import bisq.core.trade.bisq_v1.TradeDataValidation;
|
||||
import bisq.core.trade.model.bisq_v1.Trade;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.TradeTask;
|
||||
@ -60,7 +60,7 @@ public class BuyerVerifiesFinalDelayedPayoutTx extends TradeTask {
|
||||
// Now as we know the deposit tx we can also verify the input
|
||||
TradeDataValidation.validatePayoutTxInput(depositTx, finalDelayedPayoutTx);
|
||||
|
||||
if (DelayedPayoutTxReceiverService.isActivated()) {
|
||||
if (BurningManService.isActivated()) {
|
||||
long inputAmount = depositTx.getOutput(0).getValue().value;
|
||||
long tradeTxFeeAsLong = trade.getTradeTxFeeAsLong();
|
||||
int selectionHeight = processModel.getBurningManSelectionHeight();
|
||||
|
@ -18,7 +18,7 @@
|
||||
package bisq.core.trade.protocol.bisq_v1.tasks.buyer;
|
||||
|
||||
import bisq.core.btc.wallet.BtcWalletService;
|
||||
import bisq.core.dao.burningman.DelayedPayoutTxReceiverService;
|
||||
import bisq.core.dao.burningman.BurningManService;
|
||||
import bisq.core.trade.bisq_v1.TradeDataValidation;
|
||||
import bisq.core.trade.model.bisq_v1.Trade;
|
||||
import bisq.core.trade.protocol.bisq_v1.tasks.TradeTask;
|
||||
@ -53,7 +53,7 @@ public class BuyerVerifiesPreparedDelayedPayoutTx extends TradeTask {
|
||||
btcWalletService);
|
||||
|
||||
Transaction preparedDepositTx = btcWalletService.getTxFromSerializedTx(processModel.getPreparedDepositTx());
|
||||
if (DelayedPayoutTxReceiverService.isActivated()) {
|
||||
if (BurningManService.isActivated()) {
|
||||
long inputAmount = preparedDepositTx.getOutput(0).getValue().value;
|
||||
long tradeTxFeeAsLong = trade.getTradeTxFeeAsLong();
|
||||
List<Tuple2<Long, String>> delayedPayoutTxReceivers = processModel.getDelayedPayoutTxReceiverService().getReceivers(
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package bisq.core.trade.protocol.bisq_v1.tasks.maker;
|
||||
|
||||
import bisq.core.dao.burningman.DelayedPayoutTxReceiverService;
|
||||
import bisq.core.dao.burningman.BurningManService;
|
||||
import bisq.core.exceptions.TradePriceOutOfToleranceException;
|
||||
import bisq.core.offer.Offer;
|
||||
import bisq.core.support.dispute.mediation.mediator.Mediator;
|
||||
@ -80,7 +80,7 @@ public class MakerProcessesInputsForDepositTxRequest extends TradeTask {
|
||||
|
||||
tradingPeer.setAccountId(nonEmptyStringOf(request.getTakerAccountId()));
|
||||
|
||||
if (DelayedPayoutTxReceiverService.isActivated()) {
|
||||
if (BurningManService.isActivated()) {
|
||||
int takersBurningManSelectionHeight = request.getBurningManSelectionHeight();
|
||||
checkArgument(takersBurningManSelectionHeight > 0, "takersBurningManSelectionHeight must not be 0");
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
package bisq.core.trade.protocol.bisq_v1.tasks.seller;
|
||||
|
||||
import bisq.core.btc.wallet.TradeWalletService;
|
||||
import bisq.core.dao.burningman.DelayedPayoutTxReceiverService;
|
||||
import bisq.core.dao.burningman.BurningManService;
|
||||
import bisq.core.dao.governance.param.Param;
|
||||
import bisq.core.trade.bisq_v1.TradeDataValidation;
|
||||
import bisq.core.trade.model.bisq_v1.Trade;
|
||||
@ -51,7 +51,7 @@ public class SellerCreatesDelayedPayoutTx extends TradeTask {
|
||||
TradeWalletService tradeWalletService = processModel.getTradeWalletService();
|
||||
Transaction depositTx = checkNotNull(processModel.getDepositTx());
|
||||
Transaction preparedDelayedPayoutTx;
|
||||
if (DelayedPayoutTxReceiverService.isActivated()) {
|
||||
if (BurningManService.isActivated()) {
|
||||
long inputAmount = depositTx.getOutput(0).getValue().value;
|
||||
long tradeTxFeeAsLong = trade.getTradeTxFeeAsLong();
|
||||
int selectionHeight = processModel.getBurningManSelectionHeight();
|
||||
|
Loading…
Reference in New Issue
Block a user