mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-09 07:02:24 -04:00
remove btc fee service
This commit is contained in:
parent
3314eac881
commit
31dfdd7710
49 changed files with 66 additions and 1797 deletions
|
@ -59,7 +59,6 @@ import bisq.core.payment.RevolutAccount;
|
|||
import bisq.core.presentation.BalancePresentation;
|
||||
import bisq.core.presentation.SupportTicketsPresentation;
|
||||
import bisq.core.presentation.TradePresentation;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.trade.TradeManager;
|
||||
import bisq.core.user.DontShowAgainLookup;
|
||||
|
@ -173,7 +172,6 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
|
|||
WalletPasswordWindow walletPasswordWindow,
|
||||
NotificationCenter notificationCenter,
|
||||
TacWindow tacWindow,
|
||||
FeeService feeService,
|
||||
PriceFeedService priceFeedService,
|
||||
Config config,
|
||||
LocalBitcoinNode localBitcoinNode,
|
||||
|
@ -210,7 +208,6 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
|
|||
|
||||
TxIdTextField.setXmrWalletService(xmrWalletService);
|
||||
|
||||
GUIUtil.setFeeService(feeService);
|
||||
GUIUtil.setPreferences(preferences);
|
||||
|
||||
setupHandlers();
|
||||
|
|
|
@ -31,7 +31,6 @@ import bisq.core.btc.model.XmrAddressEntry;
|
|||
import bisq.core.btc.setup.WalletsSetup;
|
||||
import bisq.core.btc.wallet.XmrWalletService;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.trade.HavenoUtils;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.TradeManager;
|
||||
|
@ -97,8 +96,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
|||
WalletsSetup walletsSetup,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||
BtcAddressValidator btcAddressValidator,
|
||||
WalletPasswordWindow walletPasswordWindow,
|
||||
FeeService feeService) {
|
||||
WalletPasswordWindow walletPasswordWindow) {
|
||||
this.xmrWalletService = xmrWalletService;
|
||||
this.tradeManager = tradeManager;
|
||||
this.p2PService = p2PService;
|
||||
|
|
|
@ -22,7 +22,6 @@ import bisq.desktop.util.DisplayUtils;
|
|||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.btc.TxFeeEstimationService;
|
||||
import bisq.core.btc.listeners.XmrBalanceListener;
|
||||
import bisq.core.btc.model.XmrAddressEntry;
|
||||
import bisq.core.btc.wallet.Restrictions;
|
||||
|
@ -37,7 +36,6 @@ import bisq.core.offer.OfferDirection;
|
|||
import bisq.core.offer.OfferUtil;
|
||||
import bisq.core.offer.OpenOfferManager;
|
||||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.trade.handlers.TransactionResultHandler;
|
||||
import bisq.core.trade.statistics.TradeStatistics3;
|
||||
|
@ -104,7 +102,6 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
|||
protected final PriceFeedService priceFeedService;
|
||||
final String shortOfferId;
|
||||
private final AccountAgeWitnessService accountAgeWitnessService;
|
||||
private final FeeService feeService;
|
||||
private final CoinFormatter btcFormatter;
|
||||
private final Navigation navigation;
|
||||
private final String offerId;
|
||||
|
@ -132,7 +129,6 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
|||
private Coin txFeeFromFeeService = Coin.ZERO;
|
||||
@Getter
|
||||
private boolean marketPriceAvailable;
|
||||
private int feeTxVsize = TxFeeEstimationService.TYPICAL_TX_WITH_1_INPUT_VSIZE;
|
||||
protected boolean allowAmountUpdate = true;
|
||||
private final TradeStatisticsManager tradeStatisticsManager;
|
||||
|
||||
|
@ -157,7 +153,6 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
|||
P2PService p2PService,
|
||||
PriceFeedService priceFeedService,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
FeeService feeService,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
|
||||
TradeStatisticsManager tradeStatisticsManager,
|
||||
Navigation navigation) {
|
||||
|
@ -171,7 +166,6 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
|||
this.p2PService = p2PService;
|
||||
this.priceFeedService = priceFeedService;
|
||||
this.accountAgeWitnessService = accountAgeWitnessService;
|
||||
this.feeService = feeService;
|
||||
this.btcFormatter = btcFormatter;
|
||||
this.navigation = navigation;
|
||||
this.tradeStatisticsManager = tradeStatisticsManager;
|
||||
|
|
|
@ -44,9 +44,9 @@ import bisq.core.payment.payload.PaymentMethod;
|
|||
import bisq.core.payment.validation.BtcValidator;
|
||||
import bisq.core.payment.validation.FiatVolumeValidator;
|
||||
import bisq.core.payment.validation.SecurityDepositValidator;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.price.MarketPrice;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.trade.HavenoUtils;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.util.FormattingUtils;
|
||||
import bisq.core.util.ParsingUtils;
|
||||
|
@ -999,7 +999,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
dataModel.getMakerFeeInBtc(),
|
||||
dataModel.getAmount().get(),
|
||||
btcFormatter,
|
||||
FeeService.getMinMakerFee());
|
||||
HavenoUtils.getMinMakerFee());
|
||||
}
|
||||
|
||||
public String getMakerFeePercentage() {
|
||||
|
|
|
@ -25,7 +25,6 @@ import bisq.core.offer.CreateOfferService;
|
|||
import bisq.core.offer.OfferUtil;
|
||||
import bisq.core.offer.OpenOfferManager;
|
||||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.trade.statistics.TradeStatisticsManager;
|
||||
import bisq.core.user.Preferences;
|
||||
|
@ -58,7 +57,6 @@ class CreateOfferDataModel extends MutableOfferDataModel {
|
|||
P2PService p2PService,
|
||||
PriceFeedService priceFeedService,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
FeeService feeService,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
|
||||
TradeStatisticsManager tradeStatisticsManager,
|
||||
Navigation navigation) {
|
||||
|
@ -71,7 +69,6 @@ class CreateOfferDataModel extends MutableOfferDataModel {
|
|||
p2PService,
|
||||
priceFeedService,
|
||||
accountAgeWitnessService,
|
||||
feeService,
|
||||
btcFormatter,
|
||||
tradeStatisticsManager,
|
||||
navigation);
|
||||
|
|
|
@ -39,9 +39,9 @@ import bisq.core.offer.OfferUtil;
|
|||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.payment.PaymentAccountUtil;
|
||||
import bisq.core.payment.payload.PaymentMethod;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.mempool.MempoolService;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.trade.HavenoUtils;
|
||||
import bisq.core.trade.TradeManager;
|
||||
import bisq.core.trade.handlers.TradeResultHandler;
|
||||
import bisq.core.user.Preferences;
|
||||
|
@ -86,7 +86,6 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
private final TradeManager tradeManager;
|
||||
private final OfferBook offerBook;
|
||||
private final User user;
|
||||
private final FeeService feeService;
|
||||
private final MempoolService mempoolService;
|
||||
private final FilterManager filterManager;
|
||||
final Preferences preferences;
|
||||
|
@ -95,9 +94,7 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
private final Navigation navigation;
|
||||
private final P2PService p2PService;
|
||||
|
||||
private Coin txFeeFromFeeService;
|
||||
private Coin securityDeposit;
|
||||
// Coin feeFromFundingTx = Coin.NEGATIVE_SATOSHI;
|
||||
|
||||
private Offer offer;
|
||||
|
||||
|
@ -110,10 +107,6 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
private PaymentAccount paymentAccount;
|
||||
private boolean isTabSelected;
|
||||
Price tradePrice;
|
||||
// Use an average of a typical trade fee tx with 1 input, deposit tx and payout tx.
|
||||
private int feeTxVsize = 192; // (175+233+169)/3
|
||||
private boolean freezeFee;
|
||||
private Coin txFeePerVbyteFromFeeService;
|
||||
@Getter
|
||||
protected final IntegerProperty mempoolStatus = new SimpleIntegerProperty();
|
||||
@Getter
|
||||
|
@ -130,7 +123,7 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
OfferBook offerBook,
|
||||
OfferUtil offerUtil,
|
||||
XmrWalletService xmrWalletService,
|
||||
User user, FeeService feeService,
|
||||
User user,
|
||||
MempoolService mempoolService,
|
||||
FilterManager filterManager,
|
||||
Preferences preferences,
|
||||
|
@ -144,7 +137,6 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
this.tradeManager = tradeManager;
|
||||
this.offerBook = offerBook;
|
||||
this.user = user;
|
||||
this.feeService = feeService;
|
||||
this.mempoolService = mempoolService;
|
||||
this.filterManager = filterManager;
|
||||
this.preferences = preferences;
|
||||
|
@ -212,39 +204,6 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
getBuyerSecurityDeposit() :
|
||||
getSellerSecurityDeposit();
|
||||
|
||||
// Taker pays 3 times the tx fee (taker fee, deposit, payout) because the mining fee might be different when maker created the offer
|
||||
// and reserved his funds. Taker creates at least taker fee and deposit tx at nearly the same moment. Just the payout will
|
||||
// be later and still could lead to issues if the required fee changed a lot in the meantime. using RBF and/or
|
||||
// multiple batch-signed payout tx with different fees might be an option but RBF is not supported yet in BitcoinJ
|
||||
// and batched txs would add more complexity to the trade protocol.
|
||||
|
||||
// A typical trade fee tx has about 175 vbytes (if one input). The trade txs has about 169-263 vbytes.
|
||||
// We use 192 as average value.
|
||||
|
||||
// trade fee tx: 175 vbytes (1 input)
|
||||
// deposit tx: 233 vbytes (1 MS output+ OP_RETURN) - 263 vbytes (1 MS output + OP_RETURN + change in case of smaller trade amount)
|
||||
// payout tx: 169 vbytes
|
||||
// disputed payout tx: 139 vbytes
|
||||
|
||||
// Set the default values (in rare cases if the fee request was not done yet we get the hard coded default values)
|
||||
// But the "take offer" happens usually after that so we should have already the value from the estimation service.
|
||||
txFeePerVbyteFromFeeService = feeService.getTxFeePerVbyte();
|
||||
txFeeFromFeeService = getTxFeeByVsize(feeTxVsize);
|
||||
|
||||
// We request to get the actual estimated fee
|
||||
log.info("Start requestTxFee: txFeeFromFeeService={}", txFeeFromFeeService);
|
||||
feeService.requestFees(() -> {
|
||||
if (!freezeFee) {
|
||||
txFeePerVbyteFromFeeService = feeService.getTxFeePerVbyte();
|
||||
txFeeFromFeeService = getTxFeeByVsize(feeTxVsize);
|
||||
calculateTotalToPay();
|
||||
log.info("Completed requestTxFee: txFeeFromFeeService={}", txFeeFromFeeService);
|
||||
} else {
|
||||
log.debug("We received the tx fee response after we have shown the funding screen and ignore that " +
|
||||
"to avoid that the total funds to pay changes due changed tx fees.");
|
||||
}
|
||||
});
|
||||
|
||||
mempoolStatus.setValue(-1);
|
||||
mempoolService.validateOfferMakerTx(offer.getOfferPayload(), (txValidator -> {
|
||||
mempoolStatus.setValue(txValidator.isFail() ? 0 : 1);
|
||||
|
@ -271,7 +230,6 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
|
||||
// We don't want that the fee gets updated anymore after we show the funding screen.
|
||||
void onShowPayFundsScreen() {
|
||||
freezeFee = true;
|
||||
calculateTotalToPay();
|
||||
}
|
||||
|
||||
|
@ -303,7 +261,6 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
// errorMessageHandler is used only in the check availability phase. As soon we have a trade we write the error msg in the trade object as we want to
|
||||
// have it persisted as well.
|
||||
void onTakeOffer(TradeResultHandler tradeResultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
checkNotNull(txFeeFromFeeService, "txFeeFromFeeService must not be null");
|
||||
checkNotNull(getTakerFee(), "takerFee must not be null");
|
||||
|
||||
Coin fundsNeededForTrade = getFundsNeededForTrade();
|
||||
|
@ -324,7 +281,6 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
new Popup().warning(Res.get("offerbook.warning.offerWasAlreadyUsedInTrade")).show();
|
||||
} else {
|
||||
tradeManager.onTakeOffer(amount.get(),
|
||||
txFeeFromFeeService,
|
||||
getTakerFee(),
|
||||
fundsNeededForTrade,
|
||||
offer,
|
||||
|
@ -481,8 +437,8 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
Coin amount = this.amount.get();
|
||||
if (amount != null) {
|
||||
// TODO write unit test for that
|
||||
Coin feePerBtc = CoinUtil.getFeePerBtc(FeeService.getTakerFeePerBtc(), amount);
|
||||
return CoinUtil.maxCoin(feePerBtc, FeeService.getMinTakerFee());
|
||||
Coin feePerBtc = CoinUtil.getFeePerBtc(HavenoUtils.getTakerFeePerBtc(), amount);
|
||||
return CoinUtil.maxCoin(feePerBtc, HavenoUtils.getMinTakerFee());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -493,18 +449,6 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
xmrWalletService.resetAddressEntriesForOpenOffer(offer.getId());
|
||||
}
|
||||
|
||||
// We use the sum of the vsize of the trade fee and the deposit tx to get an average.
|
||||
// Miners will take the trade fee tx if the total fee of both dependent txs are good enough.
|
||||
// With that we avoid that we overpay in case that the trade fee has many inputs and we would apply that fee for the
|
||||
// other 2 txs as well. We still might overpay a bit for the payout tx.
|
||||
private int getAverageVsize(int txVsize) {
|
||||
return (txVsize + 233) / 2;
|
||||
}
|
||||
|
||||
private Coin getTxFeeByVsize(int vsizeInVbytes) {
|
||||
return txFeePerVbyteFromFeeService.multiply(getAverageVsize(vsizeInVbytes));
|
||||
}
|
||||
|
||||
/* private void setFeeFromFundingTx(Coin fee) {
|
||||
feeFromFundingTx = fee;
|
||||
isFeeFromFundingTxSufficient.set(feeFromFundingTx.compareTo(FeePolicy.getMinRequiredFeeForFundingTx()) >= 0);
|
||||
|
@ -557,23 +501,7 @@ class TakeOfferDataModel extends OfferDataModel {
|
|||
|
||||
@NotNull
|
||||
private Coin getFundsNeededForTrade() {
|
||||
return getSecurityDeposit().add(getTxFeeForDepositTx()).add(getTxFeeForPayoutTx());
|
||||
}
|
||||
|
||||
private Coin getTxFeeForDepositTx() {
|
||||
//TODO fix with new trade protocol!
|
||||
// Unfortunately we cannot change that to the correct fees as it would break backward compatibility
|
||||
// We still might find a way with offer version or app version checks so lets keep that commented out
|
||||
// code as that shows how it should be.
|
||||
return txFeeFromFeeService; //feeService.getTxFee(233);
|
||||
}
|
||||
|
||||
private Coin getTxFeeForPayoutTx() {
|
||||
//TODO fix with new trade protocol!
|
||||
// Unfortunately we cannot change that to the correct fees as it would break backward compatibility
|
||||
// We still might find a way with offer version or app version checks so lets keep that commented out
|
||||
// code as that shows how it should be.
|
||||
return txFeeFromFeeService; //feeService.getTxFee(169);
|
||||
return getSecurityDeposit();
|
||||
}
|
||||
|
||||
public XmrAddressEntry getAddressEntry() {
|
||||
|
|
|
@ -38,7 +38,7 @@ import bisq.core.offer.OfferUtil;
|
|||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.payment.payload.PaymentMethod;
|
||||
import bisq.core.payment.validation.BtcValidator;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.trade.HavenoUtils;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.util.FormattingUtils;
|
||||
import bisq.core.util.VolumeUtil;
|
||||
|
@ -692,7 +692,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
dataModel.getTakerFeeInBtc(),
|
||||
dataModel.getAmount().get(),
|
||||
btcFormatter,
|
||||
FeeService.getMinMakerFee());
|
||||
HavenoUtils.getMinMakerFee());
|
||||
}
|
||||
|
||||
public String getTakerFeePercentage() {
|
||||
|
|
|
@ -31,7 +31,6 @@ import bisq.core.offer.OfferUtil;
|
|||
import bisq.core.offer.OpenOfferManager;
|
||||
import bisq.core.offer.CreateOfferService;
|
||||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.trade.statistics.TradeStatisticsManager;
|
||||
import bisq.core.user.Preferences;
|
||||
|
@ -65,7 +64,6 @@ class DuplicateOfferDataModel extends MutableOfferDataModel {
|
|||
P2PService p2PService,
|
||||
PriceFeedService priceFeedService,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
FeeService feeService,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
|
||||
TradeStatisticsManager tradeStatisticsManager,
|
||||
Navigation navigation) {
|
||||
|
@ -79,7 +77,6 @@ class DuplicateOfferDataModel extends MutableOfferDataModel {
|
|||
p2PService,
|
||||
priceFeedService,
|
||||
accountAgeWitnessService,
|
||||
feeService,
|
||||
btcFormatter,
|
||||
tradeStatisticsManager,
|
||||
navigation);
|
||||
|
|
|
@ -35,7 +35,6 @@ import bisq.core.offer.OpenOffer;
|
|||
import bisq.core.offer.OpenOfferManager;
|
||||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.proto.persistable.CorePersistenceProtoResolver;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.trade.statistics.TradeStatisticsManager;
|
||||
import bisq.core.user.Preferences;
|
||||
|
@ -72,7 +71,6 @@ class EditOfferDataModel extends MutableOfferDataModel {
|
|||
P2PService p2PService,
|
||||
PriceFeedService priceFeedService,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
FeeService feeService,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
|
||||
CorePersistenceProtoResolver corePersistenceProtoResolver,
|
||||
TradeStatisticsManager tradeStatisticsManager,
|
||||
|
@ -87,7 +85,6 @@ class EditOfferDataModel extends MutableOfferDataModel {
|
|||
p2PService,
|
||||
priceFeedService,
|
||||
accountAgeWitnessService,
|
||||
feeService,
|
||||
btcFormatter,
|
||||
tradeStatisticsManager,
|
||||
navigation);
|
||||
|
|
|
@ -28,12 +28,12 @@ import bisq.core.btc.wallet.Restrictions;
|
|||
import bisq.core.network.MessageState;
|
||||
import bisq.core.offer.Offer;
|
||||
import bisq.core.offer.OfferUtil;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.mempool.MempoolService;
|
||||
import bisq.core.trade.ArbitratorTrade;
|
||||
import bisq.core.trade.BuyerTrade;
|
||||
import bisq.core.trade.ClosedTradableManager;
|
||||
import bisq.core.trade.Contract;
|
||||
import bisq.core.trade.HavenoUtils;
|
||||
import bisq.core.trade.SellerTrade;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.TradeUtil;
|
||||
|
@ -338,8 +338,8 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
Coin tradeFeeInBTC = dataModel.getTradeFeeInBTC();
|
||||
|
||||
Coin minTradeFee = dataModel.isMaker() ?
|
||||
FeeService.getMinMakerFee() :
|
||||
FeeService.getMinTakerFee();
|
||||
HavenoUtils.getMinMakerFee() :
|
||||
HavenoUtils.getMinTakerFee();
|
||||
|
||||
String percentage = GUIUtil.getPercentageOfTradeAmount(tradeFeeInBTC, trade.getAmount(),
|
||||
minTradeFee);
|
||||
|
|
|
@ -25,7 +25,6 @@ import bisq.core.btc.wallet.XmrWalletService;
|
|||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.locale.TradeCurrency;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.provider.price.MarketPrice;
|
||||
import bisq.core.provider.price.PriceFeedService;
|
||||
import bisq.core.user.Preferences;
|
||||
|
@ -88,17 +87,13 @@ public class MarketPricePresentation {
|
|||
@Inject
|
||||
public MarketPricePresentation(XmrWalletService xmrWalletService,
|
||||
PriceFeedService priceFeedService,
|
||||
Preferences preferences,
|
||||
FeeService feeService) {
|
||||
Preferences preferences) {
|
||||
this.priceFeedService = priceFeedService;
|
||||
this.preferences = preferences;
|
||||
|
||||
TxIdTextField.setPreferences(preferences);
|
||||
|
||||
// TODO
|
||||
TxIdTextField.setXmrWalletService(xmrWalletService);
|
||||
|
||||
GUIUtil.setFeeService(feeService);
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package bisq.desktop.main.settings.preferences;
|
||||
|
||||
import bisq.desktop.app.HavenoApp;
|
||||
import bisq.desktop.common.view.ActivatableViewAndModel;
|
||||
import bisq.desktop.common.view.FxmlView;
|
||||
import bisq.desktop.components.AutoTooltipButton;
|
||||
|
@ -44,7 +43,6 @@ import bisq.core.locale.TradeCurrency;
|
|||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.payment.payload.PaymentMethod;
|
||||
import bisq.core.payment.validation.BtcValidator;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.user.User;
|
||||
import bisq.core.util.FormattingUtils;
|
||||
|
@ -121,14 +119,13 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
notifyOnPreReleaseToggle;
|
||||
private int gridRow = 0;
|
||||
private int displayCurrenciesGridRowIndex = 0;
|
||||
private InputTextField transactionFeeInputTextField, ignoreTradersListInputTextField, ignoreDustThresholdInputTextField,
|
||||
private InputTextField ignoreTradersListInputTextField, ignoreDustThresholdInputTextField,
|
||||
autoConfRequiredConfirmationsTf, autoConfServiceAddressTf, autoConfTradeLimitTf, /*referralIdInputTextField,*/
|
||||
rpcUserTextField, blockNotifyPortTextField;
|
||||
private PasswordTextField rpcPwTextField;
|
||||
|
||||
private ChangeListener<Boolean> transactionFeeFocusedListener, autoConfServiceAddressFocusOutListener, autoConfRequiredConfirmationsFocusOutListener;
|
||||
private ChangeListener<Boolean> autoConfServiceAddressFocusOutListener, autoConfRequiredConfirmationsFocusOutListener;
|
||||
private final Preferences preferences;
|
||||
private final FeeService feeService;
|
||||
//private final ReferralIdService referralIdService;
|
||||
private final FilterManager filterManager;
|
||||
private final File storageDir;
|
||||
|
@ -150,8 +147,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
rpcUserListener, rpcPwListener, blockNotifyPortListener,
|
||||
autoConfTradeLimitListener, autoConfServiceAddressListener;
|
||||
private ChangeListener<Boolean> deviationFocusedListener;
|
||||
private ChangeListener<Boolean> useCustomFeeCheckboxListener;
|
||||
private ChangeListener<Number> transactionFeeChangeListener;
|
||||
private final boolean displayStandbyModeFeature;
|
||||
private ChangeListener<Filter> filterChangeListener;
|
||||
|
||||
|
@ -163,7 +158,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
@Inject
|
||||
public PreferencesView(PreferencesViewModel model,
|
||||
Preferences preferences,
|
||||
FeeService feeService,
|
||||
FilterManager filterManager,
|
||||
Config config,
|
||||
User user,
|
||||
|
@ -173,7 +167,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
this.user = user;
|
||||
this.formatter = formatter;
|
||||
this.preferences = preferences;
|
||||
this.feeService = feeService;
|
||||
this.filterManager = filterManager;
|
||||
this.storageDir = storageDir;
|
||||
this.displayStandbyModeFeature = Utilities.isLinux() || Utilities.isOSX() || Utilities.isWindows();
|
||||
|
@ -238,56 +231,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
btcExplorerTextField = btcExp.first;
|
||||
editCustomBtcExplorer = btcExp.second;
|
||||
|
||||
Tuple3<Label, InputTextField, ToggleButton> tuple = addTopLabelInputTextFieldSlideToggleButton(root, ++gridRow,
|
||||
Res.get("setting.preferences.txFee"), Res.get("setting.preferences.useCustomValue"));
|
||||
transactionFeeInputTextField = tuple.second;
|
||||
useCustomFee = tuple.third;
|
||||
|
||||
useCustomFeeCheckboxListener = (observable, oldValue, newValue) -> {
|
||||
preferences.setUseCustomWithdrawalTxFee(newValue);
|
||||
transactionFeeInputTextField.setEditable(newValue);
|
||||
if (!newValue) {
|
||||
transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerVbyte().value));
|
||||
try {
|
||||
preferences.setWithdrawalTxFeeInVbytes(feeService.getTxFeePerVbyte().value);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
preferences.setUseCustomWithdrawalTxFee(newValue);
|
||||
};
|
||||
|
||||
transactionFeeFocusedListener = (o, oldValue, newValue) -> {
|
||||
if (oldValue && !newValue) {
|
||||
String estimatedFee = String.valueOf(feeService.getTxFeePerVbyte().value);
|
||||
try {
|
||||
int withdrawalTxFeePerVbyte = Integer.parseInt(transactionFeeInputTextField.getText());
|
||||
final long minFeePerVbyte = feeService.getMinFeePerVByte();
|
||||
if (withdrawalTxFeePerVbyte < minFeePerVbyte) {
|
||||
new Popup().warning(Res.get("setting.preferences.txFeeMin", minFeePerVbyte)).show();
|
||||
transactionFeeInputTextField.setText(estimatedFee);
|
||||
} else if (withdrawalTxFeePerVbyte > 5000) {
|
||||
new Popup().warning(Res.get("setting.preferences.txFeeTooLarge")).show();
|
||||
transactionFeeInputTextField.setText(estimatedFee);
|
||||
} else {
|
||||
preferences.setWithdrawalTxFeeInVbytes(withdrawalTxFeePerVbyte);
|
||||
}
|
||||
} catch (NumberFormatException t) {
|
||||
log.error(t.toString());
|
||||
t.printStackTrace();
|
||||
new Popup().warning(Res.get("validation.integerOnly")).show();
|
||||
transactionFeeInputTextField.setText(estimatedFee);
|
||||
} catch (Throwable t) {
|
||||
log.error(t.toString());
|
||||
t.printStackTrace();
|
||||
new Popup().warning(Res.get("validation.inputError", t.getMessage())).show();
|
||||
transactionFeeInputTextField.setText(estimatedFee);
|
||||
}
|
||||
}
|
||||
};
|
||||
transactionFeeChangeListener = (observable, oldValue, newValue) -> transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerVbyte().value));
|
||||
|
||||
// deviation
|
||||
deviationInputTextField = addInputTextField(root, ++gridRow,
|
||||
Res.get("setting.preferences.deviation"));
|
||||
|
@ -693,15 +636,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void activateGeneralOptions() {
|
||||
boolean useCustomWithdrawalTxFee = preferences.isUseCustomWithdrawalTxFee();
|
||||
useCustomFee.setSelected(useCustomWithdrawalTxFee);
|
||||
|
||||
transactionFeeInputTextField.setEditable(useCustomWithdrawalTxFee);
|
||||
if (!useCustomWithdrawalTxFee) {
|
||||
transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerVbyte().value));
|
||||
feeService.feeUpdateCounterProperty().addListener(transactionFeeChangeListener);
|
||||
}
|
||||
transactionFeeInputTextField.setText(String.valueOf(getTxFeeForWithdrawalPerVbyte()));
|
||||
ignoreTradersListInputTextField.setText(String.join(", ", preferences.getIgnoreTradersList()));
|
||||
/* referralIdService.getOptionalReferralId().ifPresent(referralId -> referralIdInputTextField.setText(referralId));
|
||||
referralIdInputTextField.setPromptText(Res.get("setting.preferences.refererId.prompt"));*/
|
||||
|
@ -764,21 +698,11 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
deviationInputTextField.textProperty().addListener(deviationListener);
|
||||
deviationInputTextField.focusedProperty().addListener(deviationFocusedListener);
|
||||
|
||||
transactionFeeInputTextField.focusedProperty().addListener(transactionFeeFocusedListener);
|
||||
ignoreTradersListInputTextField.textProperty().addListener(ignoreTradersListListener);
|
||||
useCustomFee.selectedProperty().addListener(useCustomFeeCheckboxListener);
|
||||
//referralIdInputTextField.textProperty().addListener(referralIdListener);
|
||||
ignoreDustThresholdInputTextField.textProperty().addListener(ignoreDustThresholdListener);
|
||||
}
|
||||
|
||||
private Coin getTxFeeForWithdrawalPerVbyte() {
|
||||
Coin fee = (preferences.isUseCustomWithdrawalTxFee()) ?
|
||||
Coin.valueOf(preferences.getWithdrawalTxFeeInVbytes()) :
|
||||
feeService.getTxFeePerVbyte();
|
||||
log.info("tx fee = " + fee.toFriendlyString());
|
||||
return fee;
|
||||
}
|
||||
|
||||
private void activateDisplayCurrencies() {
|
||||
preferredTradeCurrencyComboBox.setItems(tradeCurrencies);
|
||||
preferredTradeCurrencyComboBox.getSelectionModel().select(preferences.getPreferredTradeCurrency());
|
||||
|
@ -897,11 +821,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
editCustomBtcExplorer.setOnAction(null);
|
||||
deviationInputTextField.textProperty().removeListener(deviationListener);
|
||||
deviationInputTextField.focusedProperty().removeListener(deviationFocusedListener);
|
||||
transactionFeeInputTextField.focusedProperty().removeListener(transactionFeeFocusedListener);
|
||||
if (transactionFeeChangeListener != null)
|
||||
feeService.feeUpdateCounterProperty().removeListener(transactionFeeChangeListener);
|
||||
ignoreTradersListInputTextField.textProperty().removeListener(ignoreTradersListListener);
|
||||
useCustomFee.selectedProperty().removeListener(useCustomFeeCheckboxListener);
|
||||
//referralIdInputTextField.textProperty().removeListener(referralIdListener);
|
||||
ignoreDustThresholdInputTextField.textProperty().removeListener(ignoreDustThresholdListener);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ import bisq.core.locale.TradeCurrency;
|
|||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.payment.PaymentAccountList;
|
||||
import bisq.core.payment.payload.PaymentMethod;
|
||||
import bisq.core.provider.fee.FeeService;
|
||||
import bisq.core.trade.HavenoUtils;
|
||||
import bisq.core.trade.txproof.AssetTxProofResult;
|
||||
import bisq.core.user.DontShowAgainLookup;
|
||||
|
@ -160,15 +159,10 @@ public class GUIUtil {
|
|||
public final static int AMOUNT_DECIMALS_WITH_ZEROS = 3;
|
||||
public final static int AMOUNT_DECIMALS = 4;
|
||||
|
||||
private static FeeService feeService;
|
||||
private static Preferences preferences;
|
||||
|
||||
public static TradeCurrency TOP_ALTCOIN = CurrencyUtil.getTradeCurrency("ETH").get();
|
||||
|
||||
public static void setFeeService(FeeService feeService) {
|
||||
GUIUtil.feeService = feeService;
|
||||
}
|
||||
|
||||
public static void setPreferences(Preferences preferences) {
|
||||
GUIUtil.preferences = preferences;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue