mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 07:15:54 -04:00
remove unused code from core trades service
This commit is contained in:
parent
513be9f298
commit
145c642305
@ -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()));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user