remove unused code from core trades service
This commit is contained in:
parent
9a5d2d5862
commit
71b23e0ed9
1 changed files with 1 additions and 38 deletions
|
@ -54,9 +54,6 @@ import haveno.core.trade.protocol.BuyerProtocol;
|
||||||
import haveno.core.trade.protocol.SellerProtocol;
|
import haveno.core.trade.protocol.SellerProtocol;
|
||||||
import haveno.core.user.User;
|
import haveno.core.user.User;
|
||||||
import haveno.core.util.coin.CoinUtil;
|
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 haveno.core.xmr.wallet.BtcWalletService;
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
@ -67,7 +64,6 @@ import java.util.function.Consumer;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.bitcoinj.core.Coin;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -83,7 +79,6 @@ class CoreTradesService {
|
||||||
private final TakeOfferModel takeOfferModel;
|
private final TakeOfferModel takeOfferModel;
|
||||||
private final TradeManager tradeManager;
|
private final TradeManager tradeManager;
|
||||||
private final TraderChatManager traderChatManager;
|
private final TraderChatManager traderChatManager;
|
||||||
private final TradeUtil tradeUtil;
|
|
||||||
private final OfferUtil offerUtil;
|
private final OfferUtil offerUtil;
|
||||||
private final User user;
|
private final User user;
|
||||||
|
|
||||||
|
@ -105,7 +100,6 @@ class CoreTradesService {
|
||||||
this.takeOfferModel = takeOfferModel;
|
this.takeOfferModel = takeOfferModel;
|
||||||
this.tradeManager = tradeManager;
|
this.tradeManager = tradeManager;
|
||||||
this.traderChatManager = traderChatManager;
|
this.traderChatManager = traderChatManager;
|
||||||
this.tradeUtil = tradeUtil;
|
|
||||||
this.offerUtil = offerUtil;
|
this.offerUtil = offerUtil;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +199,7 @@ class CoreTradesService {
|
||||||
String getTradeRole(String tradeId) {
|
String getTradeRole(String tradeId) {
|
||||||
coreWalletsService.verifyWalletsAreAvailable();
|
coreWalletsService.verifyWalletsAreAvailable();
|
||||||
coreWalletsService.verifyEncryptedWalletIsUnlocked();
|
coreWalletsService.verifyEncryptedWalletIsUnlocked();
|
||||||
return tradeUtil.getRole(getTrade(tradeId));
|
return TradeUtil.getRole(getTrade(tradeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
Trade getTrade(String tradeId) {
|
Trade getTrade(String tradeId) {
|
||||||
|
@ -265,40 +259,9 @@ class CoreTradesService {
|
||||||
return tradeManager.getTradeProtocol(trade) instanceof BuyerProtocol;
|
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.
|
// Throws a RuntimeException trade is already closed.
|
||||||
private void verifyTradeIsNotClosed(String tradeId) {
|
private void verifyTradeIsNotClosed(String tradeId) {
|
||||||
if (getClosedTrade(tradeId).isPresent())
|
if (getClosedTrade(tradeId).isPresent())
|
||||||
throw new IllegalArgumentException(format("trade '%s' is already closed", tradeId));
|
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…
Reference in a new issue