From 0896e10d9730700c8f970b68670db9317d8ca257 Mon Sep 17 00:00:00 2001
From: woodser <13068859+woodser@users.noreply.github.com>
Date: Tue, 18 Mar 2025 18:44:30 -0400
Subject: [PATCH] bump offer protocol version, do not verify miner fee for
 outdated trades

---
 .../main/java/haveno/common/app/Version.java  |  5 +++--
 .../main/java/haveno/core/trade/Trade.java    | 22 +++++++++++--------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/common/src/main/java/haveno/common/app/Version.java b/common/src/main/java/haveno/common/app/Version.java
index 1d7b99f747..3dc04889b8 100644
--- a/common/src/main/java/haveno/common/app/Version.java
+++ b/common/src/main/java/haveno/common/app/Version.java
@@ -110,8 +110,9 @@ public class Version {
     // For the switch to version 2, offers created with the old version will become invalid and have to be canceled.
     // For the switch to version 3, offers created with the old version can be migrated to version 3 just by opening
     // the Haveno app.
-    // VERSION = 0.0.1 -> TRADE_PROTOCOL_VERSION = 1
-    public static final int TRADE_PROTOCOL_VERSION = 1;
+    // Version = 0.0.1 -> TRADE_PROTOCOL_VERSION = 1
+    // Version = 1.0.19 -> TRADE_PROTOCOL_VERSION = 2
+    public static final int TRADE_PROTOCOL_VERSION = 2;
     private static String p2pMessageVersion;
 
     public static String getP2PMessageVersion() {
diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java
index 19cab12662..eaec78a6b0 100644
--- a/core/src/main/java/haveno/core/trade/Trade.java
+++ b/core/src/main/java/haveno/core/trade/Trade.java
@@ -1430,15 +1430,19 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
                 throw new IllegalStateException(e);
             }
 
-            // verify fee is within tolerance by recreating payout tx
-            // TODO (monero-project): creating tx will require exchanging updated multisig hex if message needs reprocessed. provide weight with describe_transfer so fee can be estimated?
-            log.info("Creating fee estimate tx for {} {}", getClass().getSimpleName(), getId());
-            saveWallet(); // save wallet before creating fee estimate tx
-            MoneroTxWallet feeEstimateTx = createPayoutTx();
-            BigInteger feeEstimate = feeEstimateTx.getFee();
-            double feeDiff = payoutTx.getFee().subtract(feeEstimate).abs().doubleValue() / feeEstimate.doubleValue(); // TODO: use BigDecimal?
-            if (feeDiff > XmrWalletService.MINER_FEE_TOLERANCE) throw new IllegalArgumentException("Miner fee is not within " + (XmrWalletService.MINER_FEE_TOLERANCE * 100) + "% of estimated fee, expected " + feeEstimate + " but was " + payoutTx.getFee());
-            log.info("Payout tx fee {} is within tolerance, diff %={}", payoutTx.getFee(), feeDiff);
+            // verify miner fee is within tolerance unless outdated offer version
+            if (getOffer().getOfferPayload().getProtocolVersion() >= 2) {
+
+                // verify fee is within tolerance by recreating payout tx
+                // TODO (monero-project): creating tx will require exchanging updated multisig hex if message needs reprocessed. provide weight with describe_transfer so fee can be estimated?
+                log.info("Creating fee estimate tx for {} {}", getClass().getSimpleName(), getId());
+                saveWallet(); // save wallet before creating fee estimate tx
+                MoneroTxWallet feeEstimateTx = createPayoutTx();
+                BigInteger feeEstimate = feeEstimateTx.getFee();
+                double feeDiff = payoutTx.getFee().subtract(feeEstimate).abs().doubleValue() / feeEstimate.doubleValue(); // TODO: use BigDecimal?
+                if (feeDiff > XmrWalletService.MINER_FEE_TOLERANCE) throw new IllegalArgumentException("Miner fee is not within " + (XmrWalletService.MINER_FEE_TOLERANCE * 100) + "% of estimated fee, expected " + feeEstimate + " but was " + payoutTx.getFee());
+                log.info("Payout tx fee {} is within tolerance, diff %={}", payoutTx.getFee(), feeDiff);
+            }
 
             // set signed payout tx hex
             setPayoutTxHex(signedPayoutTxHex);