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 4d2df54ad69..71576ad567e 100644 --- a/core/src/main/java/bisq/core/dao/burningman/DelayedPayoutTxReceiverService.java +++ b/core/src/main/java/bisq/core/dao/burningman/DelayedPayoutTxReceiverService.java @@ -52,7 +52,7 @@ @Slf4j @Singleton public class DelayedPayoutTxReceiverService implements DaoStateListener { - private static final Date HOTFIX_ACTIVATION_DATE = Utilities.getUTCDate(2023, GregorianCalendar.JANUARY, 10); + public static final Date HOTFIX_ACTIVATION_DATE = Utilities.getUTCDate(2023, GregorianCalendar.JANUARY, 10); public static boolean isHotfixActivated() { return new Date().after(HOTFIX_ACTIVATION_DATE); @@ -121,8 +121,15 @@ public int getBurningManSelectionHeight() { public List> getReceivers(int burningManSelectionHeight, long inputAmount, long tradeTxFee) { + return getReceivers(burningManSelectionHeight, inputAmount, tradeTxFee, isHotfixActivated()); + } + + public List> getReceivers(int burningManSelectionHeight, + long inputAmount, + long tradeTxFee, + boolean isHotfixActivated) { checkArgument(burningManSelectionHeight >= MIN_SNAPSHOT_HEIGHT, "Selection height must be >= " + MIN_SNAPSHOT_HEIGHT); - Collection burningManCandidates = isHotfixActivated() ? + Collection burningManCandidates = isHotfixActivated ? burningManService.getActiveBurningManCandidates(burningManSelectionHeight) : burningManService.getBurningManCandidatesByName(burningManSelectionHeight).values(); @@ -151,7 +158,9 @@ public List> getReceivers(int burningManSelectionHeight, // If we remove outputs it will be spent as miner fee. 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)); + long maxOutputAmount = isHotfixActivated ? + Math.round(spendableAmount * (BurningManService.MAX_BURN_SHARE * 1.2)) : + Math.round(inputAmount * (BurningManService.MAX_BURN_SHARE * 1.2)); // We accumulate small amounts which gets filtered out and subtract it from 1 to get an adjustment factor // used later to be applied to the remaining burningmen share. double adjustment = 1 - burningManCandidates.stream() @@ -180,7 +189,8 @@ public List> getReceivers(int burningManSelectionHeight, long available = spendableAmount - totalOutputValue; // If the available is larger than DPT_MIN_REMAINDER_TO_LEGACY_BM we send it to legacy BM // Otherwise we use it as miner fee - if (available > DPT_MIN_REMAINDER_TO_LEGACY_BM) { + long dptMinRemainderToLegacyBm = isHotfixActivated ? DPT_MIN_REMAINDER_TO_LEGACY_BM : 50000; + if (available > dptMinRemainderToLegacyBm) { receivers.add(new Tuple2<>(available, burningManService.getLegacyBurningManAddress(burningManSelectionHeight))); } } @@ -190,8 +200,8 @@ public List> getReceivers(int burningManSelectionHeight, private static long getSpendableAmount(int numOutputs, long inputAmount, long txFeePerVbyte) { // Output size: 32 bytes // Tx size without outputs: 51 bytes - int txSize = 51 + numOutputs * 32; // min value: txSize=83 - long minerFee = txFeePerVbyte * txSize; // min value: minerFee=830 + int txSize = 51 + numOutputs * 32; // Min value: txSize=83 + long minerFee = txFeePerVbyte * txSize; // Min value: minerFee=830 // We need to make sure we have at least 1000 sat as defined in TradeWalletService minerFee = Math.max(TradeWalletService.MIN_DELAYED_PAYOUT_TX_FEE.value, minerFee); return inputAmount - minerFee; diff --git a/core/src/main/java/bisq/core/support/dispute/refund/RefundManager.java b/core/src/main/java/bisq/core/support/dispute/refund/RefundManager.java index 06fdc0bdfb5..0ec75e3277c 100644 --- a/core/src/main/java/bisq/core/support/dispute/refund/RefundManager.java +++ b/core/src/main/java/bisq/core/support/dispute/refund/RefundManager.java @@ -320,10 +320,13 @@ public void verifyDelayedPayoutTxReceivers(Transaction delayedPayoutTx, Dispute Transaction depositTx = dispute.findDepositTx(btcWalletService).orElseThrow(); long inputAmount = depositTx.getOutput(0).getValue().value; int selectionHeight = dispute.getBurningManSelectionHeight(); + + boolean wasHotfixActivatedAtTradeDate = dispute.getTradeDate().after(DelayedPayoutTxReceiverService.HOTFIX_ACTIVATION_DATE); List> delayedPayoutTxReceivers = delayedPayoutTxReceiverService.getReceivers( selectionHeight, inputAmount, - dispute.getTradeTxFee()); + dispute.getTradeTxFee(), + wasHotfixActivatedAtTradeDate); 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");