From 71b23e0ed9ba3776a8879aa4207747771895c8a4 Mon Sep 17 00:00:00 2001 From: woodser <13068859+woodser@users.noreply.github.com> Date: Sat, 12 Apr 2025 06:47:22 -0400 Subject: [PATCH] remove unused code from core trades service --- .../haveno/core/api/CoreTradesService.java | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/core/src/main/java/haveno/core/api/CoreTradesService.java b/core/src/main/java/haveno/core/api/CoreTradesService.java index 9854167c71..5e53ff64e4 100644 --- a/core/src/main/java/haveno/core/api/CoreTradesService.java +++ b/core/src/main/java/haveno/core/api/CoreTradesService.java @@ -54,9 +54,6 @@ import haveno.core.trade.protocol.BuyerProtocol; import haveno.core.trade.protocol.SellerProtocol; import haveno.core.user.User; import haveno.core.util.coin.CoinUtil; -import haveno.core.util.validation.BtcAddressValidator; -import haveno.core.xmr.model.AddressEntry; -import static haveno.core.xmr.model.AddressEntry.Context.TRADE_PAYOUT; import haveno.core.xmr.wallet.BtcWalletService; import static java.lang.String.format; import java.math.BigInteger; @@ -67,7 +64,6 @@ import java.util.function.Consumer; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.bitcoinj.core.Coin; @Singleton @Slf4j @@ -83,7 +79,6 @@ class CoreTradesService { private final TakeOfferModel takeOfferModel; private final TradeManager tradeManager; private final TraderChatManager traderChatManager; - private final TradeUtil tradeUtil; private final OfferUtil offerUtil; private final User user; @@ -105,7 +100,6 @@ class CoreTradesService { this.takeOfferModel = takeOfferModel; this.tradeManager = tradeManager; this.traderChatManager = traderChatManager; - this.tradeUtil = tradeUtil; this.offerUtil = offerUtil; this.user = user; } @@ -205,7 +199,7 @@ class CoreTradesService { String getTradeRole(String tradeId) { coreWalletsService.verifyWalletsAreAvailable(); coreWalletsService.verifyEncryptedWalletIsUnlocked(); - return tradeUtil.getRole(getTrade(tradeId)); + return TradeUtil.getRole(getTrade(tradeId)); } Trade getTrade(String tradeId) { @@ -265,40 +259,9 @@ class CoreTradesService { return tradeManager.getTradeProtocol(trade) instanceof BuyerProtocol; } - private Coin getEstimatedTxFee(String fromAddress, String toAddress, Coin amount) { - // TODO This and identical logic should be refactored into TradeUtil. - try { - return btcWalletService.getFeeEstimationTransaction(fromAddress, - toAddress, - amount, - TRADE_PAYOUT).getFee(); - } catch (Exception ex) { - log.error("", ex); - throw new IllegalStateException(format("could not estimate tx fee: %s", ex.getMessage())); - } - } - // Throws a RuntimeException trade is already closed. private void verifyTradeIsNotClosed(String tradeId) { if (getClosedTrade(tradeId).isPresent()) throw new IllegalArgumentException(format("trade '%s' is already closed", tradeId)); } - - // Throws a RuntimeException if address is not valid. - private void verifyIsValidBTCAddress(String address) { - try { - new BtcAddressValidator().validate(address); - } catch (Throwable t) { - log.error("", t); - throw new IllegalArgumentException(format("'%s' is not a valid btc address", address)); - } - } - - // Throws a RuntimeException if address has a zero balance. - private void verifyFundsNotWithdrawn(AddressEntry fromAddressEntry) { - Coin fromAddressBalance = btcWalletService.getBalanceForAddress(fromAddressEntry.getAddress()); - if (fromAddressBalance.isZero()) - throw new IllegalStateException(format("funds already withdrawn from address '%s'", - fromAddressEntry.getAddressString())); - } }