mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Remove date checks for Bugfix 6699 & Proposal 412 activation
These are both redundant now and will always return true. Also add a missing past check for Proposal 412 activation to 'RefundManager', instead of just defaulting to the current date, in case of any very old disputes involving DPTs created prior to the activation.
This commit is contained in:
parent
508ab1f8e2
commit
c52fe0e605
5 changed files with 18 additions and 24 deletions
|
@ -96,9 +96,7 @@ public class BtcFeeReceiverService implements DaoStateListener {
|
|||
// the burningManCandidates as we added for the legacy BM an entry at the end.
|
||||
return burningManService.getLegacyBurningManAddress(currentChainHeight);
|
||||
}
|
||||
// For the fee selection we do not need to wait for activation date of the bugfix for
|
||||
// the receiver address (https://github.com/bisq-network/bisq/issues/6699) as it has no impact on the trade protocol.
|
||||
return activeBurningManCandidates.get(winnerIndex).getReceiverAddress(true)
|
||||
return activeBurningManCandidates.get(winnerIndex).getReceiverAddress()
|
||||
.orElse(burningManService.getLegacyBurningManAddress(currentChainHeight));
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ public class BurningManService {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Map<String, BurningManCandidate> getBurningManCandidatesByName(int chainHeight) {
|
||||
return getBurningManCandidatesByName(chainHeight, !DelayedPayoutTxReceiverService.isProposal412Activated());
|
||||
return getBurningManCandidatesByName(chainHeight, false);
|
||||
}
|
||||
|
||||
Map<String, BurningManCandidate> getBurningManCandidatesByName(int chainHeight, boolean limitCappingRounds) {
|
||||
|
@ -210,7 +210,7 @@ public class BurningManService {
|
|||
}
|
||||
|
||||
List<BurningManCandidate> getActiveBurningManCandidates(int chainHeight) {
|
||||
return getActiveBurningManCandidates(chainHeight, !DelayedPayoutTxReceiverService.isProposal412Activated());
|
||||
return getActiveBurningManCandidates(chainHeight, false);
|
||||
}
|
||||
|
||||
List<BurningManCandidate> getActiveBurningManCandidates(int chainHeight, boolean limitCappingRounds) {
|
||||
|
|
|
@ -59,15 +59,6 @@ public class DelayedPayoutTxReceiverService implements DaoStateListener {
|
|||
// See: https://github.com/bisq-network/proposals/issues/412
|
||||
public static final Date PROPOSAL_412_ACTIVATION_DATE = Utilities.getUTCDate(2024, GregorianCalendar.MAY, 1);
|
||||
|
||||
public static boolean isBugfix6699Activated() {
|
||||
return new Date().after(BUGFIX_6699_ACTIVATION_DATE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public static boolean isProposal412Activated() {
|
||||
return new Date().after(PROPOSAL_412_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;
|
||||
|
||||
|
@ -131,15 +122,17 @@ public class DelayedPayoutTxReceiverService implements DaoStateListener {
|
|||
public List<Tuple2<Long, String>> getReceivers(int burningManSelectionHeight,
|
||||
long inputAmount,
|
||||
long tradeTxFee) {
|
||||
return getReceivers(burningManSelectionHeight, inputAmount, tradeTxFee, isBugfix6699Activated());
|
||||
return getReceivers(burningManSelectionHeight, inputAmount, tradeTxFee, true, true);
|
||||
}
|
||||
|
||||
public List<Tuple2<Long, String>> getReceivers(int burningManSelectionHeight,
|
||||
long inputAmount,
|
||||
long tradeTxFee,
|
||||
boolean isBugfix6699Activated) {
|
||||
boolean isBugfix6699Activated,
|
||||
boolean isProposal412Activated) {
|
||||
checkArgument(burningManSelectionHeight >= MIN_SNAPSHOT_HEIGHT, "Selection height must be >= " + MIN_SNAPSHOT_HEIGHT);
|
||||
Collection<BurningManCandidate> burningManCandidates = burningManService.getActiveBurningManCandidates(burningManSelectionHeight);
|
||||
Collection<BurningManCandidate> burningManCandidates = burningManService.getActiveBurningManCandidates(burningManSelectionHeight,
|
||||
!isProposal412Activated);
|
||||
|
||||
// We need to use the same txFeePerVbyte value for both traders.
|
||||
// We use the tradeTxFee value which is calculated from the average of taker fee tx size and deposit tx size.
|
||||
|
@ -162,8 +155,8 @@ public class DelayedPayoutTxReceiverService implements DaoStateListener {
|
|||
}
|
||||
|
||||
long spendableAmount = getSpendableAmount(burningManCandidates.size(), inputAmount, txFeePerVbyte);
|
||||
// We only use outputs > 1000 sat or at least 2 times the cost for the output (32 bytes).
|
||||
// If we remove outputs it will be spent as miner fee.
|
||||
// We only use outputs >= 1000 sat or at least 2 times the cost for the output (32 bytes).
|
||||
// If we remove outputs it will be distributed to the remaining receivers.
|
||||
long minOutputAmount = Math.max(DPT_MIN_OUTPUT_AMOUNT, txFeePerVbyte * 32 * 2);
|
||||
// Sanity check that max share of a non-legacy BM is 20% over MAX_BURN_SHARE (taking into account potential increase due adjustment)
|
||||
long maxOutputAmount = Math.round(spendableAmount * (BurningManService.MAX_BURN_SHARE * 1.2));
|
||||
|
@ -178,6 +171,9 @@ public class DelayedPayoutTxReceiverService implements DaoStateListener {
|
|||
})
|
||||
.sum();
|
||||
|
||||
// FIXME: The small outputs should be filtered out before adjustment, not afterwards. Otherwise, outputs of
|
||||
// amount just under 1000 sats or 64 * fee-rate could get erroneously included and lead to significant
|
||||
// underpaying of the DPT (by perhaps around 5-10% per erroneously included output).
|
||||
List<Tuple2<Long, String>> receivers = burningManCandidates.stream()
|
||||
.filter(candidate -> candidate.getReceiverAddress(isBugfix6699Activated).isPresent())
|
||||
.map(candidate -> {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package bisq.core.dao.burningman.model;
|
||||
|
||||
import bisq.core.dao.burningman.BurningManService;
|
||||
import bisq.core.dao.burningman.DelayedPayoutTxReceiverService;
|
||||
|
||||
import bisq.common.util.DateUtil;
|
||||
|
||||
|
@ -77,7 +76,7 @@ public class BurningManCandidate {
|
|||
}
|
||||
|
||||
public Optional<String> getReceiverAddress() {
|
||||
return getReceiverAddress(DelayedPayoutTxReceiverService.isBugfix6699Activated());
|
||||
return getReceiverAddress(true);
|
||||
}
|
||||
|
||||
public Optional<String> getReceiverAddress(boolean isBugfix6699Activated) {
|
||||
|
|
|
@ -56,7 +56,6 @@ import bisq.common.util.Tuple2;
|
|||
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
import org.bitcoinj.core.TransactionInput;
|
||||
import org.bitcoinj.core.TransactionOutPoint;
|
||||
import org.bitcoinj.core.TransactionOutput;
|
||||
|
@ -195,7 +194,7 @@ public final class RefundManager extends DisputeManager<RefundDisputeList> {
|
|||
checkNotNull(chatMessage, "chatMessage must not be null");
|
||||
Optional<Dispute> disputeOptional = findDispute(disputeResult);
|
||||
String uid = disputeResultMessage.getUid();
|
||||
if (!disputeOptional.isPresent()) {
|
||||
if (disputeOptional.isEmpty()) {
|
||||
log.warn("We got a dispute result msg but we don't have a matching dispute. " +
|
||||
"That might happen when we get the disputeResultMessage before the dispute was created. " +
|
||||
"We try again after 2 sec. to apply the disputeResultMessage. TradeId = " + tradeId);
|
||||
|
@ -333,11 +332,13 @@ public final class RefundManager extends DisputeManager<RefundDisputeList> {
|
|||
int selectionHeight = dispute.getBurningManSelectionHeight();
|
||||
|
||||
boolean wasBugfix6699ActivatedAtTradeDate = dispute.getTradeDate().after(DelayedPayoutTxReceiverService.BUGFIX_6699_ACTIVATION_DATE);
|
||||
boolean wasProposal412ActivatedAtTradeDate = dispute.getTradeDate().after(DelayedPayoutTxReceiverService.PROPOSAL_412_ACTIVATION_DATE);
|
||||
List<Tuple2<Long, String>> delayedPayoutTxReceivers = delayedPayoutTxReceiverService.getReceivers(
|
||||
selectionHeight,
|
||||
inputAmount,
|
||||
dispute.getTradeTxFee(),
|
||||
wasBugfix6699ActivatedAtTradeDate);
|
||||
wasBugfix6699ActivatedAtTradeDate,
|
||||
wasProposal412ActivatedAtTradeDate);
|
||||
log.info("Verify delayedPayoutTx using selectionHeight {} and receivers {}", selectionHeight, delayedPayoutTxReceivers);
|
||||
checkArgument(delayedPayoutTx.getOutputs().size() == delayedPayoutTxReceivers.size(),
|
||||
"Size of outputs and delayedPayoutTxReceivers must be the same");
|
||||
|
|
Loading…
Add table
Reference in a new issue