From a9f7a06e1f3b25241931a9aa71f00cdbdae4bcfa Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 10 May 2024 10:04:50 -0400 Subject: [PATCH] make configurable if arbitrator assigns trade fee address --- .../main/java/haveno/core/trade/HavenoUtils.java | 14 ++++++++++++-- .../ArbitratorSendInitTradeOrMultisigRequests.java | 3 ++- .../protocol/tasks/ProcessInitMultisigRequest.java | 11 ++++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/HavenoUtils.java b/core/src/main/java/haveno/core/trade/HavenoUtils.java index 634d97a9..22e29d8a 100644 --- a/core/src/main/java/haveno/core/trade/HavenoUtils.java +++ b/core/src/main/java/haveno/core/trade/HavenoUtils.java @@ -72,6 +72,7 @@ public class HavenoUtils { public static final int ARBITRATOR_ACK_TIMEOUT_SECONDS = 30; // configure fees + public static final boolean ARBITRATOR_ASSIGNS_TRADE_FEE_ADDRESS = true; public static final double MAKER_FEE_PCT = 0.0015; // 0.15% public static final double TAKER_FEE_PCT = 0.0075; // 0.75% public static final double PENALTY_FEE_PCT = 0.02; // 2% @@ -432,8 +433,17 @@ public class HavenoUtils { // ----------------------------- OTHER UTILS ------------------------------ - public static String getTradeFeeAddress() { - return xmrWalletService.getBaseAddressEntry().getAddressString(); + public static String getGlobalTradeFeeAddress() { + switch (Config.baseCurrencyNetwork()) { + case XMR_LOCAL: + return "Bd37nTGHjL3RvPxc9dypzpWiXQrPzxxG4RsWAasD9CV2iZ1xfFZ7mzTKNDxWBfsqQSUimctAsGtTZ8c8bZJy35BYL9jYj88"; + case XMR_STAGENET: + return "5B11hTJdG2XDNwjdKGLRxwSLwDhkbGg7C7UEAZBxjE6FbCeRMjudrpNACmDNtWPiSnNfjDQf39QRjdtdgoL69txv81qc2Mc"; + case XMR_MAINNET: + throw new RuntimeException("Mainnet fee address not implemented"); + default: + throw new RuntimeException("Unhandled base currency network: " + Config.baseCurrencyNetwork()); + } } public static String getBurnAddress() { diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/ArbitratorSendInitTradeOrMultisigRequests.java b/core/src/main/java/haveno/core/trade/protocol/tasks/ArbitratorSendInitTradeOrMultisigRequests.java index d6d0685f..53b331ae 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/ArbitratorSendInitTradeOrMultisigRequests.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/ArbitratorSendInitTradeOrMultisigRequests.java @@ -126,8 +126,9 @@ public class ArbitratorSendInitTradeOrMultisigRequests extends TradeTask { trade.getSelf().setPreparedMultisigHex(preparedHex); // set trade fee address + String address = HavenoUtils.ARBITRATOR_ASSIGNS_TRADE_FEE_ADDRESS ? trade.getXmrWalletService().getBaseAddressEntry().getAddressString() : HavenoUtils.getGlobalTradeFeeAddress(); if (trade.getProcessModel().getTradeFeeAddress() == null) { - trade.getProcessModel().setTradeFeeAddress(HavenoUtils.getTradeFeeAddress()); + trade.getProcessModel().setTradeFeeAddress(address); } // create message to initialize multisig diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitMultisigRequest.java b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitMultisigRequest.java index 18761926..78fafed6 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitMultisigRequest.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitMultisigRequest.java @@ -21,6 +21,7 @@ import haveno.common.app.Version; import haveno.common.crypto.PubKeyRing; import haveno.common.taskrunner.TaskRunner; import haveno.core.trade.ArbitratorTrade; +import haveno.core.trade.HavenoUtils; import haveno.core.trade.MakerTrade; import haveno.core.trade.TakerTrade; import haveno.core.trade.Trade; @@ -65,9 +66,13 @@ public class ProcessInitMultisigRequest extends TradeTask { // get sender TradePeer sender = trade.getTradePeer(processModel.getTempTradePeerNodeAddress()); - // set trade fee address from arbitrator - if (request.getTradeFeeAddress() != null && sender == trade.getArbitrator()) { - trade.getProcessModel().setTradeFeeAddress(request.getTradeFeeAddress()); + // set trade fee address + if (HavenoUtils.ARBITRATOR_ASSIGNS_TRADE_FEE_ADDRESS) { + if (request.getTradeFeeAddress() != null && sender == trade.getArbitrator()) { + trade.getProcessModel().setTradeFeeAddress(request.getTradeFeeAddress()); + } + } else { + trade.getProcessModel().setTradeFeeAddress(HavenoUtils.getGlobalTradeFeeAddress()); } // reconcile peer's established multisig hex with message