diff --git a/cli/src/main/java/haveno/cli/table/builder/AbstractTradeListBuilder.java b/cli/src/main/java/haveno/cli/table/builder/AbstractTradeListBuilder.java index 6226860878..a8c7d246ee 100644 --- a/cli/src/main/java/haveno/cli/table/builder/AbstractTradeListBuilder.java +++ b/cli/src/main/java/haveno/cli/table/builder/AbstractTradeListBuilder.java @@ -161,7 +161,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder { protected final Function toTradeVolumeAsString = (t) -> isFiatTrade.test(t) ? t.getTradeVolume() - : formatSatoshis(t.getAmountAsLong()); + : formatSatoshis(t.getAmount()); protected final Function toTradeVolumeAsLong = (t) -> isFiatTrade.test(t) @@ -170,7 +170,7 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder { protected final Function toTradeAmount = (t) -> isFiatTrade.test(t) - ? t.getAmountAsLong() + ? t.getAmount() : toTradeVolumeAsLong.apply(t); protected final Function toMarket = (t) -> @@ -192,13 +192,13 @@ abstract class AbstractTradeListBuilder extends AbstractTableBuilder { if (isMyOffer) { return t.getOffer().getMakerFee(); } else { - return t.getTakerFeeAsLong(); + return t.getTakerFee(); } }; protected final Function toMyMakerOrTakerFee = (t) -> { return isTaker.test(t) - ? t.getTakerFeeAsLong() + ? t.getTakerFee() : t.getOffer().getMakerFee(); }; diff --git a/cli/src/main/java/haveno/cli/table/builder/ClosedTradeTableBuilder.java b/cli/src/main/java/haveno/cli/table/builder/ClosedTradeTableBuilder.java index 2a26461ca4..2ac75b2f63 100644 --- a/cli/src/main/java/haveno/cli/table/builder/ClosedTradeTableBuilder.java +++ b/cli/src/main/java/haveno/cli/table/builder/ClosedTradeTableBuilder.java @@ -54,7 +54,7 @@ class ClosedTradeTableBuilder extends AbstractTradeListBuilder { colMarket.addRow(toMarket.apply(t)); colPrice.addRow(t.getPrice()); colPriceDeviation.addRow(toPriceDeviation.apply(t)); - colAmount.addRow(t.getAmountAsLong()); + colAmount.addRow(t.getAmount()); colMixedAmount.addRow(t.getTradeVolume()); colCurrency.addRow(toPaymentCurrencyCode.apply(t)); diff --git a/cli/src/main/java/haveno/cli/table/builder/FailedTradeTableBuilder.java b/cli/src/main/java/haveno/cli/table/builder/FailedTradeTableBuilder.java index f9ee47b194..82deb21618 100644 --- a/cli/src/main/java/haveno/cli/table/builder/FailedTradeTableBuilder.java +++ b/cli/src/main/java/haveno/cli/table/builder/FailedTradeTableBuilder.java @@ -52,7 +52,7 @@ class FailedTradeTableBuilder extends AbstractTradeListBuilder { colCreateDate.addRow(t.getDate()); colMarket.addRow(toMarket.apply(t)); colPrice.addRow(t.getPrice()); - colAmount.addRow(t.getAmountAsLong()); + colAmount.addRow(t.getAmount()); colMixedAmount.addRow(t.getTradeVolume()); colCurrency.addRow(toPaymentCurrencyCode.apply(t)); colOfferType.addRow(toOfferType.apply(t)); diff --git a/cli/src/main/java/haveno/cli/table/builder/OpenTradeTableBuilder.java b/cli/src/main/java/haveno/cli/table/builder/OpenTradeTableBuilder.java index a6d8475d7d..fd52ae05b3 100644 --- a/cli/src/main/java/haveno/cli/table/builder/OpenTradeTableBuilder.java +++ b/cli/src/main/java/haveno/cli/table/builder/OpenTradeTableBuilder.java @@ -51,7 +51,7 @@ class OpenTradeTableBuilder extends AbstractTradeListBuilder { colCreateDate.addRow(t.getDate()); colMarket.addRow(toMarket.apply(t)); colPrice.addRow(t.getPrice()); - colAmount.addRow(t.getAmountAsLong()); + colAmount.addRow(t.getAmount()); colMixedAmount.addRow(t.getTradeVolume()); colCurrency.addRow(toPaymentCurrencyCode.apply(t)); colPaymentMethod.addRow(t.getOffer().getPaymentMethodShortName()); diff --git a/core/src/main/java/haveno/core/api/CoreDisputesService.java b/core/src/main/java/haveno/core/api/CoreDisputesService.java index 44a658fc0e..d027d3696a 100644 --- a/core/src/main/java/haveno/core/api/CoreDisputesService.java +++ b/core/src/main/java/haveno/core/api/CoreDisputesService.java @@ -251,7 +251,7 @@ public class CoreDisputesService { String agentNodeAddress = checkNotNull(disputeManager.getAgentNodeAddress(dispute)).getFullAddress(); Contract contract = dispute.getContract(); String currencyCode = contract.getOfferPayload().getCurrencyCode(); - String amount = HavenoUtils.formatToXmrWithCode(contract.getTradeAmount()); + String amount = HavenoUtils.formatXmr(contract.getTradeAmount(), true); String textToSign = Res.get("disputeSummaryWindow.close.msg", FormattingUtils.formatDateTime(disputeResult.getCloseDate(), true), @@ -261,8 +261,8 @@ public class CoreDisputesService { currencyCode, Res.get("disputeSummaryWindow.reason." + reason.name()), amount, - HavenoUtils.formatToXmrWithCode(disputeResult.getBuyerPayoutAmount()), - HavenoUtils.formatToXmrWithCode(disputeResult.getSellerPayoutAmount()), + HavenoUtils.formatXmr(disputeResult.getBuyerPayoutAmount(), true), + HavenoUtils.formatXmr(disputeResult.getSellerPayoutAmount(), true), disputeResult.summaryNotesProperty().get() ); diff --git a/core/src/main/java/haveno/core/api/CoreOffersService.java b/core/src/main/java/haveno/core/api/CoreOffersService.java index d5b28ba3cb..216705a83b 100644 --- a/core/src/main/java/haveno/core/api/CoreOffersService.java +++ b/core/src/main/java/haveno/core/api/CoreOffersService.java @@ -33,7 +33,6 @@ import haveno.core.offer.OfferFilterService.Result; import haveno.core.payment.PaymentAccount; import haveno.core.user.User; import haveno.core.util.PriceUtil; -import org.bitcoinj.core.Coin; import org.bitcoinj.core.Transaction; import org.bitcoinj.utils.Fiat; @@ -184,14 +183,12 @@ public class CoreOffersService { Price price = priceAsString.isEmpty() ? null : Price.valueOf(upperCaseCurrencyCode, priceStringToLong(priceAsString, upperCaseCurrencyCode)); BigInteger amount = BigInteger.valueOf(amountAsLong); BigInteger minAmount = BigInteger.valueOf(minAmountAsLong); - Coin useDefaultTxFee = Coin.ZERO; Offer offer = createOfferService.createAndGetOffer(offerId, direction, upperCaseCurrencyCode, amount, minAmount, price, - useDefaultTxFee, useMarketBasedPrice, exactMultiply(marketPriceMargin, 0.01), buyerSecurityDeposit, @@ -219,14 +216,12 @@ public class CoreOffersService { BigInteger minAmount, double buyerSecurityDeposit, PaymentAccount paymentAccount) { - Coin useDefaultTxFee = Coin.ZERO; return createOfferService.createAndGetOffer(offerId, direction, currencyCode.toUpperCase(), amount, minAmount, price, - useDefaultTxFee, useMarketBasedPrice, exactMultiply(marketPriceMargin, 0.01), buyerSecurityDeposit, diff --git a/core/src/main/java/haveno/core/api/model/OfferInfo.java b/core/src/main/java/haveno/core/api/model/OfferInfo.java index 7d0b305bf4..6a4ef94dba 100644 --- a/core/src/main/java/haveno/core/api/model/OfferInfo.java +++ b/core/src/main/java/haveno/core/api/model/OfferInfo.java @@ -52,7 +52,6 @@ public class OfferInfo implements Payload { private final long minAmount; private final String volume; private final String minVolume; - private final long txFee; private final long makerFee; @Nullable private final String offerFeePaymentTxId; @@ -87,7 +86,6 @@ public class OfferInfo implements Payload { this.minAmount = builder.getMinAmount(); this.volume = builder.getVolume(); this.minVolume = builder.getMinVolume(); - this.txFee = builder.getTxFee(); this.makerFee = builder.getMakerFee(); this.offerFeePaymentTxId = builder.getOfferFeePaymentTxId(); this.buyerSecurityDeposit = builder.getBuyerSecurityDeposit(); @@ -189,7 +187,6 @@ public class OfferInfo implements Payload { .setVolume(volume) .setMinVolume(minVolume) .setMakerFee(makerFee) - .setTxFee(txFee) .setBuyerSecurityDeposit(buyerSecurityDeposit) .setSellerSecurityDeposit(sellerSecurityDeposit) .setTriggerPrice(triggerPrice == null ? "0" : triggerPrice) @@ -224,7 +221,6 @@ public class OfferInfo implements Payload { .withVolume(proto.getVolume()) .withMinVolume(proto.getMinVolume()) .withMakerFee(proto.getMakerFee()) - .withTxFee(proto.getTxFee()) .withOfferFeePaymentTxId(ProtoUtil.stringOrNullFromProto(proto.getOfferFeePaymentTxId())) .withBuyerSecurityDeposit(proto.getBuyerSecurityDeposit()) .withSellerSecurityDeposit(proto.getSellerSecurityDeposit()) diff --git a/core/src/main/java/haveno/core/api/model/TradeInfo.java b/core/src/main/java/haveno/core/api/model/TradeInfo.java index 0315906078..0916ca80e9 100644 --- a/core/src/main/java/haveno/core/api/model/TradeInfo.java +++ b/core/src/main/java/haveno/core/api/model/TradeInfo.java @@ -63,11 +63,11 @@ public class TradeInfo implements Payload { private final String shortId; private final long date; private final String role; - private final long takerFeeAsLong; + private final long takerFee; private final String makerDepositTxId; private final String takerDepositTxId; private final String payoutTxId; - private final long amountAsLong; + private final long amount; private final long buyerSecurityDeposit; private final long sellerSecurityDeposit; private final String price; @@ -97,11 +97,11 @@ public class TradeInfo implements Payload { this.shortId = builder.getShortId(); this.date = builder.getDate(); this.role = builder.getRole(); - this.takerFeeAsLong = builder.getTakerFeeAsLong(); + this.takerFee = builder.getTakerFee(); this.makerDepositTxId = builder.getMakerDepositTxId(); this.takerDepositTxId = builder.getTakerDepositTxId(); this.payoutTxId = builder.getPayoutTxId(); - this.amountAsLong = builder.getAmountAsLong(); + this.amount = builder.getAmount(); this.buyerSecurityDeposit = builder.getBuyerSecurityDeposit(); this.sellerSecurityDeposit = builder.getSellerSecurityDeposit(); this.price = builder.getPrice(); @@ -154,11 +154,11 @@ public class TradeInfo implements Payload { .withShortId(trade.getShortId()) .withDate(trade.getDate().getTime()) .withRole(role == null ? "" : role) - .withTakerFeeAsLong(trade.getTakerFeeAsLong()) + .withTakerFee(trade.getTakerFee().longValueExact()) .withMakerDepositTxId(trade.getMaker().getDepositTxHash()) .withTakerDepositTxId(trade.getTaker().getDepositTxHash()) .withPayoutTxId(trade.getPayoutTxId()) - .withAmountAsLong(trade.getAmountAsLong()) + .withAmount(trade.getAmount().longValueExact()) .withBuyerSecurityDeposit(trade.getBuyerSecurityDeposit() == null ? -1 : trade.getBuyerSecurityDeposit().longValueExact()) .withSellerSecurityDeposit(trade.getSellerSecurityDeposit() == null ? -1 : trade.getSellerSecurityDeposit().longValueExact()) .withPrice(toPreciseTradePrice.apply(trade)) @@ -197,11 +197,11 @@ public class TradeInfo implements Payload { .setShortId(shortId) .setDate(date) .setRole(role) - .setTakerFeeAsLong(takerFeeAsLong) + .setTakerFee(takerFee) .setMakerDepositTxId(makerDepositTxId == null ? "" : makerDepositTxId) .setTakerDepositTxId(takerDepositTxId == null ? "" : takerDepositTxId) .setPayoutTxId(payoutTxId == null ? "" : payoutTxId) - .setAmountAsLong(amountAsLong) + .setAmount(amount) .setBuyerSecurityDeposit(buyerSecurityDeposit) .setSellerSecurityDeposit(sellerSecurityDeposit) .setPrice(price) @@ -234,11 +234,11 @@ public class TradeInfo implements Payload { .withShortId(proto.getShortId()) .withDate(proto.getDate()) .withRole(proto.getRole()) - .withTakerFeeAsLong(proto.getTakerFeeAsLong()) + .withTakerFee(proto.getTakerFee()) .withMakerDepositTxId(proto.getMakerDepositTxId()) .withTakerDepositTxId(proto.getTakerDepositTxId()) .withPayoutTxId(proto.getPayoutTxId()) - .withAmountAsLong(proto.getAmountAsLong()) + .withAmount(proto.getAmount()) .withBuyerSecurityDeposit(proto.getBuyerSecurityDeposit()) .withSellerSecurityDeposit(proto.getSellerSecurityDeposit()) .withPrice(proto.getPrice()) @@ -271,11 +271,11 @@ public class TradeInfo implements Payload { ", shortId='" + shortId + '\'' + "\n" + ", date='" + date + '\'' + "\n" + ", role='" + role + '\'' + "\n" + - ", takerFeeAsLong='" + takerFeeAsLong + '\'' + "\n" + + ", takerFee='" + takerFee + '\'' + "\n" + ", makerDepositTxId='" + makerDepositTxId + '\'' + "\n" + ", takerDepositTxId='" + takerDepositTxId + '\'' + "\n" + ", payoutTxId='" + payoutTxId + '\'' + "\n" + - ", amountAsLong='" + amountAsLong + '\'' + "\n" + + ", amount='" + amount + '\'' + "\n" + ", buyerSecurityDeposit='" + buyerSecurityDeposit + '\'' + "\n" + ", sellerSecurityDeposit='" + sellerSecurityDeposit + '\'' + "\n" + ", price='" + price + '\'' + "\n" + diff --git a/core/src/main/java/haveno/core/api/model/builder/OfferInfoBuilder.java b/core/src/main/java/haveno/core/api/model/builder/OfferInfoBuilder.java index edeef7059b..c726551a3d 100644 --- a/core/src/main/java/haveno/core/api/model/builder/OfferInfoBuilder.java +++ b/core/src/main/java/haveno/core/api/model/builder/OfferInfoBuilder.java @@ -38,7 +38,6 @@ public final class OfferInfoBuilder { private long minAmount; private String volume; private String minVolume; - private long txFee; private long makerFee; private String offerFeePaymentTxId; private long buyerSecurityDeposit; @@ -107,11 +106,6 @@ public final class OfferInfoBuilder { return this; } - public OfferInfoBuilder withTxFee(long txFee) { - this.txFee = txFee; - return this; - } - public OfferInfoBuilder withMakerFee(long makerFee) { this.makerFee = makerFee; return this; diff --git a/core/src/main/java/haveno/core/api/model/builder/TradeInfoV1Builder.java b/core/src/main/java/haveno/core/api/model/builder/TradeInfoV1Builder.java index 3f8d6dab93..7987061806 100644 --- a/core/src/main/java/haveno/core/api/model/builder/TradeInfoV1Builder.java +++ b/core/src/main/java/haveno/core/api/model/builder/TradeInfoV1Builder.java @@ -37,14 +37,14 @@ public final class TradeInfoV1Builder { private long date; private String role; private boolean isCurrencyForTakerFeeBtc; - private long txFeeAsLong; - private long takerFeeAsLong; + private long totalTxFee; + private long takerFee; private long buyerSecurityDeposit; private long sellerSecurityDeposit; private String makerDepositTxId; private String takerDepositTxId; private String payoutTxId; - private long amountAsLong; + private long amount; private String price; private String volume; private String arbitratorNodeAddress; @@ -97,13 +97,13 @@ public final class TradeInfoV1Builder { return this; } - public TradeInfoV1Builder withTxFeeAsLong(long txFeeAsLong) { - this.txFeeAsLong = txFeeAsLong; + public TradeInfoV1Builder withTotalTxFee(long totalTxFee) { + this.totalTxFee = totalTxFee; return this; } - public TradeInfoV1Builder withTakerFeeAsLong(long takerFeeAsLong) { - this.takerFeeAsLong = takerFeeAsLong; + public TradeInfoV1Builder withTakerFee(long takerFee) { + this.takerFee = takerFee; return this; } @@ -132,8 +132,8 @@ public final class TradeInfoV1Builder { return this; } - public TradeInfoV1Builder withAmountAsLong(long amountAsLong) { - this.amountAsLong = amountAsLong; + public TradeInfoV1Builder withAmount(long amount) { + this.amount = amount; return this; } diff --git a/core/src/main/java/haveno/core/app/CoreModule.java b/core/src/main/java/haveno/core/app/CoreModule.java index d4f71d7267..e323b36a2e 100644 --- a/core/src/main/java/haveno/core/app/CoreModule.java +++ b/core/src/main/java/haveno/core/app/CoreModule.java @@ -23,7 +23,7 @@ import haveno.common.config.Config; import haveno.common.proto.network.NetworkProtoResolver; import haveno.common.proto.persistable.PersistenceProtoResolver; import haveno.core.alert.AlertModule; -import haveno.core.btc.BitcoinModule; +import haveno.core.btc.MoneroModule; import haveno.core.filter.FilterModule; import haveno.core.network.CoreNetworkFilter; import haveno.core.network.p2p.seed.DefaultSeedNodeRepository; @@ -82,7 +82,7 @@ public class CoreModule extends AppModule { install(new EncryptionServiceModule(config)); install(new OfferModule(config)); install(new P2PModule(config)); - install(new BitcoinModule(config)); + install(new MoneroModule(config)); install(new AlertModule(config)); install(new FilterModule(config)); install(new CorePresentationModule(config)); diff --git a/core/src/main/java/haveno/core/app/misc/ModuleForAppWithP2p.java b/core/src/main/java/haveno/core/app/misc/ModuleForAppWithP2p.java index e7d4c963d4..88c898ee34 100644 --- a/core/src/main/java/haveno/core/app/misc/ModuleForAppWithP2p.java +++ b/core/src/main/java/haveno/core/app/misc/ModuleForAppWithP2p.java @@ -27,7 +27,7 @@ import haveno.common.proto.network.NetworkProtoResolver; import haveno.common.proto.persistable.PersistenceProtoResolver; import haveno.core.alert.AlertModule; import haveno.core.app.TorSetup; -import haveno.core.btc.BitcoinModule; +import haveno.core.btc.MoneroModule; import haveno.core.filter.FilterModule; import haveno.core.network.CoreNetworkFilter; import haveno.core.network.p2p.seed.DefaultSeedNodeRepository; @@ -85,7 +85,7 @@ public class ModuleForAppWithP2p extends AppModule { install(new EncryptionServiceModule(config)); install(new OfferModule(config)); install(new P2PModule(config)); - install(new BitcoinModule(config)); + install(new MoneroModule(config)); install(new AlertModule(config)); install(new FilterModule(config)); install(new MoneroConnectionModule(config)); diff --git a/core/src/main/java/haveno/core/btc/BitcoinModule.java b/core/src/main/java/haveno/core/btc/MoneroModule.java similarity index 98% rename from core/src/main/java/haveno/core/btc/BitcoinModule.java rename to core/src/main/java/haveno/core/btc/MoneroModule.java index a1e2b3d993..3adf96512e 100644 --- a/core/src/main/java/haveno/core/btc/BitcoinModule.java +++ b/core/src/main/java/haveno/core/btc/MoneroModule.java @@ -44,9 +44,9 @@ import static haveno.common.config.Config.PROVIDERS; import static haveno.common.config.Config.WALLET_DIR; import static haveno.common.config.Config.WALLET_RPC_BIND_PORT; -public class BitcoinModule extends AppModule { +public class MoneroModule extends AppModule { - public BitcoinModule(Config config) { + public MoneroModule(Config config) { super(config); } diff --git a/core/src/main/java/haveno/core/offer/CreateOfferService.java b/core/src/main/java/haveno/core/offer/CreateOfferService.java index 15b715110b..35047ce625 100644 --- a/core/src/main/java/haveno/core/offer/CreateOfferService.java +++ b/core/src/main/java/haveno/core/offer/CreateOfferService.java @@ -39,7 +39,6 @@ import haveno.core.user.User; import haveno.core.util.coin.CoinUtil; import haveno.network.p2p.NodeAddress; import haveno.network.p2p.P2PService; -import org.bitcoinj.core.Coin; import javax.inject.Inject; import javax.inject.Singleton; @@ -105,7 +104,6 @@ public class CreateOfferService { BigInteger amount, BigInteger minAmount, Price price, - Coin txFee, boolean useMarketBasedPrice, double marketPriceMargin, double buyerSecurityDepositAsDouble, diff --git a/core/src/main/java/haveno/core/offer/OfferForJson.java b/core/src/main/java/haveno/core/offer/OfferForJson.java index 978aebac2e..a94e3be28c 100644 --- a/core/src/main/java/haveno/core/offer/OfferForJson.java +++ b/core/src/main/java/haveno/core/offer/OfferForJson.java @@ -112,8 +112,8 @@ public class OfferForJson { priceDisplayString = altcoinFormat.noCode().format(price.getMonetary()).toString(); primaryMarketMinAmountDisplayString = altcoinFormat.noCode().format(getMinVolume().getMonetary()).toString(); primaryMarketAmountDisplayString = altcoinFormat.noCode().format(getVolume().getMonetary()).toString(); - primaryMarketMinVolumeDisplayString = HavenoUtils.formatToXmr(getMinAmount()).toString(); - primaryMarketVolumeDisplayString = HavenoUtils.formatToXmr(getAmount()).toString(); + primaryMarketMinVolumeDisplayString = HavenoUtils.formatXmr(getMinAmount()).toString(); + primaryMarketVolumeDisplayString = HavenoUtils.formatXmr(getAmount()).toString(); primaryMarketPrice = price.getValue(); primaryMarketMinAmount = getMinVolume().getValue(); @@ -125,8 +125,8 @@ public class OfferForJson { currencyPair = Res.getBaseCurrencyCode() + "/" + currencyCode; priceDisplayString = fiatFormat.noCode().format(price.getMonetary()).toString(); - primaryMarketMinAmountDisplayString = HavenoUtils.formatToXmr(getMinAmount()).toString(); - primaryMarketAmountDisplayString = HavenoUtils.formatToXmr(getAmount()).toString(); + primaryMarketMinAmountDisplayString = HavenoUtils.formatXmr(getMinAmount()).toString(); + primaryMarketAmountDisplayString = HavenoUtils.formatXmr(getAmount()).toString(); primaryMarketMinVolumeDisplayString = fiatFormat.noCode().format(getMinVolume().getMonetary()).toString(); primaryMarketVolumeDisplayString = fiatFormat.noCode().format(getVolume().getMonetary()).toString(); diff --git a/core/src/main/java/haveno/core/payment/validation/XmrValidator.java b/core/src/main/java/haveno/core/payment/validation/XmrValidator.java index d47a3d4046..a7ba37d4c4 100644 --- a/core/src/main/java/haveno/core/payment/validation/XmrValidator.java +++ b/core/src/main/java/haveno/core/payment/validation/XmrValidator.java @@ -74,7 +74,7 @@ public class XmrValidator extends NumberValidator { BigDecimal bd = new BigDecimal(input); final BigDecimal atomicUnits = bd.movePointRight(HavenoUtils.XMR_SMALLEST_UNIT_EXPONENT); if (atomicUnits.scale() > 0) - return new ValidationResult(false, Res.get("validation.btc.fraction")); + return new ValidationResult(false, Res.get("validation.xmr.fraction")); else return new ValidationResult(true); } catch (Throwable t) { @@ -86,7 +86,7 @@ public class XmrValidator extends NumberValidator { try { final BigInteger amount = HavenoUtils.parseXmr(input); if (maxValue != null && amount.compareTo(maxValue) > 0) - return new ValidationResult(false, Res.get("validation.btc.toLarge", HavenoUtils.formatToXmrWithCode(maxValue))); + return new ValidationResult(false, Res.get("validation.xmr.tooLarge", HavenoUtils.formatXmr(maxValue, true))); else return new ValidationResult(true); } catch (Throwable t) { @@ -98,7 +98,7 @@ public class XmrValidator extends NumberValidator { try { final BigInteger amount = HavenoUtils.parseXmr(input); if (maxTradeLimit != null && amount.compareTo(maxTradeLimit) > 0) - return new ValidationResult(false, Res.get("validation.btc.exceedsMaxTradeLimit", HavenoUtils.formatToXmrWithCode(maxTradeLimit))); + return new ValidationResult(false, Res.get("validation.btc.exceedsMaxTradeLimit", HavenoUtils.formatXmr(maxTradeLimit, true))); else return new ValidationResult(true); } catch (Throwable t) { @@ -110,7 +110,7 @@ public class XmrValidator extends NumberValidator { try { final BigInteger amount = HavenoUtils.parseXmr(input); if (minValue != null && amount.compareTo(minValue) < 0) - return new ValidationResult(false, Res.get("validation.btc.toSmall", HavenoUtils.formatToXmr(minValue))); + return new ValidationResult(false, Res.get("validation.xmr.tooSmall", HavenoUtils.formatXmr(minValue))); else return new ValidationResult(true); } catch (Throwable t) { diff --git a/core/src/main/java/haveno/core/presentation/BalancePresentation.java b/core/src/main/java/haveno/core/presentation/BalancePresentation.java index 5a363d14e7..749cbcf1f2 100644 --- a/core/src/main/java/haveno/core/presentation/BalancePresentation.java +++ b/core/src/main/java/haveno/core/presentation/BalancePresentation.java @@ -42,13 +42,13 @@ public class BalancePresentation { @Inject public BalancePresentation(Balances balances) { balances.getAvailableBalance().addListener((observable, oldValue, newValue) -> { - UserThread.execute(() -> availableBalance.set(HavenoUtils.formatToXmrWithCode(newValue))); + UserThread.execute(() -> availableBalance.set(HavenoUtils.formatXmr(newValue, true))); }); balances.getPendingBalance().addListener((observable, oldValue, newValue) -> { - UserThread.execute(() -> pendingBalance.set(HavenoUtils.formatToXmrWithCode(newValue))); + UserThread.execute(() -> pendingBalance.set(HavenoUtils.formatXmr(newValue, true))); }); balances.getReservedBalance().addListener((observable, oldValue, newValue) -> { - UserThread.execute(() -> reservedBalance.set(HavenoUtils.formatToXmrWithCode(newValue))); + UserThread.execute(() -> reservedBalance.set(HavenoUtils.formatXmr(newValue, true))); }); } } diff --git a/core/src/main/java/haveno/core/proto/CoreProtoResolver.java b/core/src/main/java/haveno/core/proto/CoreProtoResolver.java index d4d34356ac..b582745702 100644 --- a/core/src/main/java/haveno/core/proto/CoreProtoResolver.java +++ b/core/src/main/java/haveno/core/proto/CoreProtoResolver.java @@ -79,7 +79,6 @@ import haveno.core.payment.payload.VenmoAccountPayload; import haveno.core.payment.payload.VerseAccountPayload; import haveno.core.payment.payload.WeChatPayAccountPayload; import haveno.core.payment.payload.WesternUnionAccountPayload; -import haveno.core.trade.statistics.TradeStatistics2; import haveno.core.trade.statistics.TradeStatistics3; import java.time.Clock; @@ -250,8 +249,6 @@ public class CoreProtoResolver implements ProtoResolver { switch (proto.getMessageCase()) { case ACCOUNT_AGE_WITNESS: return AccountAgeWitness.fromProto(proto.getAccountAgeWitness()); - case TRADE_STATISTICS2: - return TradeStatistics2.fromProto(proto.getTradeStatistics2()); case SIGNED_WITNESS: return SignedWitness.fromProto(proto.getSignedWitness()); case TRADE_STATISTICS3: diff --git a/core/src/main/java/haveno/core/proto/network/CoreNetworkProtoResolver.java b/core/src/main/java/haveno/core/proto/network/CoreNetworkProtoResolver.java index 183ec53873..c2c38c8805 100644 --- a/core/src/main/java/haveno/core/proto/network/CoreNetworkProtoResolver.java +++ b/core/src/main/java/haveno/core/proto/network/CoreNetworkProtoResolver.java @@ -48,7 +48,6 @@ import haveno.core.trade.messages.MediatedPayoutTxPublishedMessage; import haveno.core.trade.messages.MediatedPayoutTxSignatureMessage; import haveno.core.trade.messages.PaymentReceivedMessage; import haveno.core.trade.messages.PaymentSentMessage; -import haveno.core.trade.messages.RefreshTradeStateRequest; import haveno.core.trade.messages.SignContractRequest; import haveno.core.trade.messages.SignContractResponse; import haveno.network.p2p.AckMessage; @@ -131,9 +130,6 @@ public class CoreNetworkProtoResolver extends CoreProtoResolver implements Netwo case PREFIXED_SEALED_AND_SIGNED_MESSAGE: return PrefixedSealedAndSignedMessage.fromProto(proto.getPrefixedSealedAndSignedMessage(), messageVersion); - // trade protocol messages - case REFRESH_TRADE_STATE_REQUEST: - return RefreshTradeStateRequest.fromProto(proto.getRefreshTradeStateRequest(), messageVersion); case INIT_TRADE_REQUEST: return InitTradeRequest.fromProto(proto.getInitTradeRequest(), this, messageVersion); case INIT_MULTISIG_REQUEST: diff --git a/core/src/main/java/haveno/core/proto/persistable/CorePersistenceProtoResolver.java b/core/src/main/java/haveno/core/proto/persistable/CorePersistenceProtoResolver.java index e83acbb414..6084c16ab1 100644 --- a/core/src/main/java/haveno/core/proto/persistable/CorePersistenceProtoResolver.java +++ b/core/src/main/java/haveno/core/proto/persistable/CorePersistenceProtoResolver.java @@ -37,7 +37,6 @@ import haveno.core.support.dispute.arbitration.ArbitrationDisputeList; import haveno.core.support.dispute.mediation.MediationDisputeList; import haveno.core.support.dispute.refund.RefundDisputeList; import haveno.core.trade.TradableList; -import haveno.core.trade.statistics.TradeStatistics2Store; import haveno.core.trade.statistics.TradeStatistics3Store; import haveno.core.user.PreferencesPayload; import haveno.core.user.UserPayload; @@ -102,8 +101,6 @@ public class CorePersistenceProtoResolver extends CoreProtoResolver implements P return PaymentAccountList.fromProto(proto.getPaymentAccountList(), this); case ACCOUNT_AGE_WITNESS_STORE: return AccountAgeWitnessStore.fromProto(proto.getAccountAgeWitnessStore()); - case TRADE_STATISTICS2_STORE: - return TradeStatistics2Store.fromProto(proto.getTradeStatistics2Store()); case SIGNED_WITNESS_STORE: return SignedWitnessStore.fromProto(proto.getSignedWitnessStore()); case TRADE_STATISTICS3_STORE: diff --git a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java index cad6ae50dd..07f627eeb8 100644 --- a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java +++ b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java @@ -1049,14 +1049,14 @@ public abstract class DisputeManager> extends Sup String headline; if (potentialGain.compareTo(BigInteger.valueOf(0)) > 0) { headline = "This might be a potential option trade!"; - optionTradeDetails = "\nBTC amount calculated with price at dispute opening: " + HavenoUtils.formatToXmrWithCode(potentialAmountAtDisputeOpening) + - "\nMax loss of security deposit is: " + HavenoUtils.formatToXmrWithCode(maxLossSecDeposit) + - "\nPossible gain from an option trade is: " + HavenoUtils.formatToXmrWithCode(potentialGain); + optionTradeDetails = "\nBTC amount calculated with price at dispute opening: " + HavenoUtils.formatXmr(potentialAmountAtDisputeOpening, true) + + "\nMax loss of security deposit is: " + HavenoUtils.formatXmr(maxLossSecDeposit, true) + + "\nPossible gain from an option trade is: " + HavenoUtils.formatXmr(potentialGain, true); } else { headline = "It does not appear to be an option trade."; - optionTradeDetails = "\nBTC amount calculated with price at dispute opening: " + HavenoUtils.formatToXmrWithCode(potentialAmountAtDisputeOpening) + - "\nMax loss of security deposit is: " + HavenoUtils.formatToXmrWithCode(maxLossSecDeposit) + - "\nPossible loss from an option trade is: " + HavenoUtils.formatToXmrWithCode(potentialGain.multiply(BigInteger.valueOf(-1))); + optionTradeDetails = "\nBTC amount calculated with price at dispute opening: " + HavenoUtils.formatXmr(potentialAmountAtDisputeOpening, true) + + "\nMax loss of security deposit is: " + HavenoUtils.formatXmr(maxLossSecDeposit, true) + + "\nPossible loss from an option trade is: " + HavenoUtils.formatXmr(potentialGain.multiply(BigInteger.valueOf(-1)), true); } String percentagePriceDetails = offerPayload.isUseMarketBasedPrice() ? @@ -1065,7 +1065,7 @@ public abstract class DisputeManager> extends Sup String priceInfoText = "System message: " + headline + "\n\nTrade price: " + contract.getPrice().toFriendlyString() + percentagePriceDetails + - "\nTrade amount: " + HavenoUtils.formatToXmrWithCode(tradeAmount) + + "\nTrade amount: " + HavenoUtils.formatXmr(tradeAmount, true) + "\nPrice at dispute opening: " + priceAtDisputeOpening.toFriendlyString() + optionTradeDetails; diff --git a/core/src/main/java/haveno/core/trade/ArbitratorTrade.java b/core/src/main/java/haveno/core/trade/ArbitratorTrade.java index 0edcc1b79b..68407040c0 100644 --- a/core/src/main/java/haveno/core/trade/ArbitratorTrade.java +++ b/core/src/main/java/haveno/core/trade/ArbitratorTrade.java @@ -58,8 +58,8 @@ public class ArbitratorTrade extends Trade { } return fromProto(new ArbitratorTrade( Offer.fromProto(proto.getOffer()), - BigInteger.valueOf(proto.getAmountAsLong()), - BigInteger.valueOf(proto.getTakerFeeAsLong()), + BigInteger.valueOf(proto.getAmount()), + BigInteger.valueOf(proto.getTakerFee()), proto.getPrice(), xmrWalletService, processModel, diff --git a/core/src/main/java/haveno/core/trade/BuyerAsMakerTrade.java b/core/src/main/java/haveno/core/trade/BuyerAsMakerTrade.java index fd9b077bce..24fa0519b7 100644 --- a/core/src/main/java/haveno/core/trade/BuyerAsMakerTrade.java +++ b/core/src/main/java/haveno/core/trade/BuyerAsMakerTrade.java @@ -80,8 +80,8 @@ public final class BuyerAsMakerTrade extends BuyerTrade implements MakerTrade { } BuyerAsMakerTrade trade = new BuyerAsMakerTrade( Offer.fromProto(proto.getOffer()), - BigInteger.valueOf(proto.getAmountAsLong()), - BigInteger.valueOf(proto.getTakerFeeAsLong()), + BigInteger.valueOf(proto.getAmount()), + BigInteger.valueOf(proto.getTakerFee()), proto.getPrice(), xmrWalletService, processModel, @@ -90,7 +90,6 @@ public final class BuyerAsMakerTrade extends BuyerTrade implements MakerTrade { proto.getProcessModel().getTaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getTaker().getNodeAddress()) : null, proto.getProcessModel().getArbitrator().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getArbitrator().getNodeAddress()) : null); - trade.setAmountAsLong(proto.getAmountAsLong()); trade.setPrice(proto.getPrice()); return fromProto(trade, diff --git a/core/src/main/java/haveno/core/trade/BuyerAsTakerTrade.java b/core/src/main/java/haveno/core/trade/BuyerAsTakerTrade.java index 0b8d14d67e..747a74a8c6 100644 --- a/core/src/main/java/haveno/core/trade/BuyerAsTakerTrade.java +++ b/core/src/main/java/haveno/core/trade/BuyerAsTakerTrade.java @@ -83,8 +83,8 @@ public final class BuyerAsTakerTrade extends BuyerTrade implements TakerTrade { } return fromProto(new BuyerAsTakerTrade( Offer.fromProto(proto.getOffer()), - BigInteger.valueOf(proto.getAmountAsLong()), - BigInteger.valueOf(proto.getTakerFeeAsLong()), + BigInteger.valueOf(proto.getAmount()), + BigInteger.valueOf(proto.getTakerFee()), proto.getPrice(), xmrWalletService, processModel, diff --git a/core/src/main/java/haveno/core/trade/ClosedTradableFormatter.java b/core/src/main/java/haveno/core/trade/ClosedTradableFormatter.java index 80a63774f5..64112ab910 100644 --- a/core/src/main/java/haveno/core/trade/ClosedTradableFormatter.java +++ b/core/src/main/java/haveno/core/trade/ClosedTradableFormatter.java @@ -17,19 +17,16 @@ package haveno.core.trade; -import org.bitcoinj.core.Coin; import org.bitcoinj.core.Monetary; import org.bitcoinj.utils.Fiat; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; import static haveno.core.trade.ClosedTradableUtil.*; import static haveno.core.trade.Trade.DisputeState.DISPUTE_CLOSED; import static haveno.core.trade.Trade.DisputeState.MEDIATION_CLOSED; import static haveno.core.trade.Trade.DisputeState.REFUND_REQUEST_CLOSED; -import static haveno.core.util.FormattingUtils.BTC_FORMATTER_KEY; import static haveno.core.util.FormattingUtils.formatPercentagePrice; import static haveno.core.util.FormattingUtils.formatToPercentWithSymbol; import static haveno.core.util.VolumeUtil.formatVolume; @@ -41,7 +38,9 @@ import haveno.core.monetary.Altcoin; import haveno.core.monetary.Volume; import haveno.core.offer.OpenOffer; import haveno.core.util.FormattingUtils; -import haveno.core.util.coin.CoinFormatter; + +import java.math.BigDecimal; +import java.math.BigInteger; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -55,56 +54,53 @@ public class ClosedTradableFormatter { // having "generic-enough" property values to be referenced in the core layer. private static final String I18N_KEY_TOTAL_AMOUNT = "closedTradesSummaryWindow.totalAmount.value"; private static final String I18N_KEY_TOTAL_TX_FEE = "closedTradesSummaryWindow.totalMinerFee.value"; - private static final String I18N_KEY_TOTAL_TRADE_FEE_BTC = "closedTradesSummaryWindow.totalTradeFeeInBtc.value"; + private static final String I18N_KEY_TOTAL_TRADE_FEE_BTC = "closedTradesSummaryWindow.totalTradeFeeInXmr.value"; - private final CoinFormatter btcFormatter; private final ClosedTradableManager closedTradableManager; @Inject - public ClosedTradableFormatter(ClosedTradableManager closedTradableManager, - @Named(BTC_FORMATTER_KEY) CoinFormatter btcFormatter) { + public ClosedTradableFormatter(ClosedTradableManager closedTradableManager) { this.closedTradableManager = closedTradableManager; - this.btcFormatter = btcFormatter; } public String getAmountAsString(Tradable tradable) { - return tradable.getOptionalAmount().map(HavenoUtils::formatToXmr).orElse(""); + return tradable.getOptionalAmount().map(HavenoUtils::formatXmr).orElse(""); } - public String getTotalAmountWithVolumeAsString(Coin totalTradeAmount, Volume volume) { + public String getTotalAmountWithVolumeAsString(BigInteger totalTradeAmount, Volume volume) { return Res.get(I18N_KEY_TOTAL_AMOUNT, - btcFormatter.formatCoin(totalTradeAmount, true), + HavenoUtils.formatXmr(totalTradeAmount, true), formatVolumeWithCode(volume)); } - public String getTxFeeAsString(Tradable tradable) { - return btcFormatter.formatCoin(getTxFee(tradable)); + public String getTotalTxFeeAsString(Tradable tradable) { + return HavenoUtils.formatXmr(getTotalTxFee(tradable)); } - public String getTotalTxFeeAsString(Coin totalTradeAmount, Coin totalTxFee) { - double percentage = ((double) totalTxFee.value) / totalTradeAmount.value; + public String getTotalTxFeeAsString(BigInteger totalTradeAmount, BigInteger totalTxFee) { + double percentage = new BigDecimal(totalTxFee).divide(new BigDecimal(totalTradeAmount)).doubleValue(); return Res.get(I18N_KEY_TOTAL_TX_FEE, - btcFormatter.formatCoin(totalTxFee, true), + HavenoUtils.formatXmr(totalTxFee, true), formatToPercentWithSymbol(percentage)); } public String getBuyerSecurityDepositAsString(Tradable tradable) { - return HavenoUtils.formatToXmr(tradable.getOffer().getBuyerSecurityDeposit()); + return HavenoUtils.formatXmr(tradable.getOffer().getBuyerSecurityDeposit()); } public String getSellerSecurityDepositAsString(Tradable tradable) { - return HavenoUtils.formatToXmr(tradable.getOffer().getSellerSecurityDeposit()); + return HavenoUtils.formatXmr(tradable.getOffer().getSellerSecurityDeposit()); } public String getTradeFeeAsString(Tradable tradable, boolean appendCode) { - closedTradableManager.getBtcTradeFee(tradable); - return btcFormatter.formatCoin(Coin.valueOf(closedTradableManager.getBtcTradeFee(tradable)), appendCode); + BigInteger tradeFee = closedTradableManager.getXmrTradeFee(tradable); + return HavenoUtils.formatXmr(tradeFee, appendCode); } - public String getTotalTradeFeeInBtcAsString(Coin totalTradeAmount, Coin totalTradeFee) { - double percentage = ((double) totalTradeFee.value) / totalTradeAmount.value; + public String getTotalTradeFeeAsString(BigInteger totalTradeAmount, BigInteger totalTradeFee) { + double percentage = new BigDecimal(totalTradeFee).divide(new BigDecimal(totalTradeAmount)).doubleValue(); return Res.get(I18N_KEY_TOTAL_TRADE_FEE_BTC, - btcFormatter.formatCoin(totalTradeFee, true), + HavenoUtils.formatXmr(totalTradeFee, true), formatToPercentWithSymbol(percentage)); } diff --git a/core/src/main/java/haveno/core/trade/ClosedTradableManager.java b/core/src/main/java/haveno/core/trade/ClosedTradableManager.java index 1e9ceb98a2..9af8b6abf9 100644 --- a/core/src/main/java/haveno/core/trade/ClosedTradableManager.java +++ b/core/src/main/java/haveno/core/trade/ClosedTradableManager.java @@ -214,20 +214,20 @@ public class ClosedTradableManager implements PersistedDataHost { .count(); } - public Coin getTotalTradeFee(List tradableList) { - return Coin.valueOf(tradableList.stream() - .mapToLong(tradable -> getTradeFee(tradable)) + public BigInteger getTotalTradeFee(List tradableList) { + return BigInteger.valueOf(tradableList.stream() + .mapToLong(tradable -> getTradeFee(tradable).longValueExact()) .sum()); } - private long getTradeFee(Tradable tradable) { - return getBtcTradeFee(tradable); + private BigInteger getTradeFee(Tradable tradable) { + return getXmrTradeFee(tradable); } - public long getBtcTradeFee(Tradable tradable) { + public BigInteger getXmrTradeFee(Tradable tradable) { return isMaker(tradable) ? - tradable.getOptionalMakerFee().orElse(BigInteger.valueOf(0)).longValueExact() : - tradable.getOptionalTakerFee().orElse(BigInteger.valueOf(0)).longValueExact(); + tradable.getOptionalMakerFee().orElse(BigInteger.valueOf(0)) : + tradable.getOptionalTakerFee().orElse(BigInteger.valueOf(0)); } public boolean isMaker(Tradable tradable) { diff --git a/core/src/main/java/haveno/core/trade/ClosedTradableUtil.java b/core/src/main/java/haveno/core/trade/ClosedTradableUtil.java index acb4eaffcd..8a093d8031 100644 --- a/core/src/main/java/haveno/core/trade/ClosedTradableUtil.java +++ b/core/src/main/java/haveno/core/trade/ClosedTradableUtil.java @@ -17,25 +17,24 @@ package haveno.core.trade; -import org.bitcoinj.core.Coin; import haveno.core.offer.OpenOffer; -import haveno.core.trade.Tradable; -import haveno.core.trade.Trade; + +import java.math.BigInteger; import java.util.HashMap; import java.util.List; import java.util.Map; public class ClosedTradableUtil { - public static Coin getTotalAmount(List tradableList) { - return Coin.valueOf(tradableList.stream() - .flatMap(tradable -> tradable.getOptionalAmountAsLong().stream()) - .mapToLong(value -> value) + public static BigInteger getTotalAmount(List tradableList) { + return BigInteger.valueOf(tradableList.stream() + .flatMap(tradable -> tradable.getOptionalAmount().stream()) + .mapToLong(value -> value.longValueExact()) .sum()); } - public static Coin getTotalTxFee(List tradableList) { - return Coin.valueOf(tradableList.stream() - .mapToLong(tradable -> getTxFee(tradable).getValue()) + public static BigInteger getTotalTxFee(List tradableList) { + return BigInteger.valueOf(tradableList.stream() + .mapToLong(tradable -> getTotalTxFee(tradable).longValueExact()) .sum()); } @@ -51,8 +50,8 @@ public class ClosedTradableUtil { return map; } - public static Coin getTxFee(Tradable tradable) { - return tradable.getOptionalTxFee().orElse(Coin.ZERO); + public static BigInteger getTotalTxFee(Tradable tradable) { + return tradable.getTotalTxFee(); } public static boolean isOpenOffer(Tradable tradable) { diff --git a/core/src/main/java/haveno/core/trade/HavenoUtils.java b/core/src/main/java/haveno/core/trade/HavenoUtils.java index b8e746ceb9..3aeca238e5 100644 --- a/core/src/main/java/haveno/core/trade/HavenoUtils.java +++ b/core/src/main/java/haveno/core/trade/HavenoUtils.java @@ -132,16 +132,32 @@ public class HavenoUtils { // ------------------------- FORMAT UTILS --------------------------------- - public static String formatToXmr(BigInteger atomicUnits) { + public static String formatXmr(BigInteger atomicUnits) { + return formatXmr(atomicUnits, false); + } + + public static String formatXmr(BigInteger atomicUnits, int decimalPlaces) { + return formatXmr(atomicUnits, false, decimalPlaces); + } + + public static String formatXmr(BigInteger atomicUnits, boolean appendCode) { + return formatXmr(atomicUnits, appendCode, 0); + } + + public static String formatXmr(BigInteger atomicUnits, boolean appendCode, int decimalPlaces) { if (atomicUnits == null) return ""; - return formatToXmr(atomicUnits.longValueExact()); + return formatXmr(atomicUnits.longValueExact(), appendCode, decimalPlaces); } - public static String formatToXmr(BigInteger atomicUnits, int decimalPlaces) { - return applyDecimals(formatToXmr(atomicUnits), decimalPlaces); + public static String formatXmr(long atomicUnits) { + return formatXmr(atomicUnits, false, 0); } - public static String formatToXmr(long atomicUnits) { + public static String formatXmr(long atomicUnits, boolean appendCode) { + return formatXmr(atomicUnits, appendCode, 0); + } + + public static String formatXmr(long atomicUnits, boolean appendCode, int decimalPlaces) { String formatted = XMR_FORMATTER.format(atomicUnitsToXmr(atomicUnits)); // strip trailing 0s @@ -150,7 +166,7 @@ public class HavenoUtils { formatted = formatted.substring(0, formatted.length() - 1); } } - return applyDecimals(formatted, 2); + return applyDecimals(formatted, Math.max(2, decimalPlaces)) + (appendCode ? " XMR" : ""); } private static String applyDecimals(String decimalStr, int decimalPlaces) { @@ -164,15 +180,6 @@ public class HavenoUtils { return zeros; } - public static String formatToXmrWithCode(BigInteger atomicUnits) { - if (atomicUnits == null) return ""; - return formatToXmrWithCode(atomicUnits.longValueExact()); - } - - public static String formatToXmrWithCode(long atomicUnits) { - return formatToXmr(atomicUnits).concat(" XMR"); - } - public static BigInteger parseXmr(String input) { if (input == null || input.length() == 0) return BigInteger.valueOf(0); try { diff --git a/core/src/main/java/haveno/core/trade/SellerAsMakerTrade.java b/core/src/main/java/haveno/core/trade/SellerAsMakerTrade.java index 4ea22574df..a2e9b42ff3 100644 --- a/core/src/main/java/haveno/core/trade/SellerAsMakerTrade.java +++ b/core/src/main/java/haveno/core/trade/SellerAsMakerTrade.java @@ -83,8 +83,8 @@ public final class SellerAsMakerTrade extends SellerTrade implements MakerTrade } SellerAsMakerTrade trade = new SellerAsMakerTrade( Offer.fromProto(proto.getOffer()), - BigInteger.valueOf(proto.getAmountAsLong()), - BigInteger.valueOf(proto.getTakerFeeAsLong()), + BigInteger.valueOf(proto.getAmount()), + BigInteger.valueOf(proto.getTakerFee()), proto.getPrice(), xmrWalletService, processModel, @@ -93,7 +93,6 @@ public final class SellerAsMakerTrade extends SellerTrade implements MakerTrade proto.getProcessModel().getTaker().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getTaker().getNodeAddress()) : null, proto.getProcessModel().getArbitrator().hasNodeAddress() ? NodeAddress.fromProto(proto.getProcessModel().getArbitrator().getNodeAddress()) : null); - trade.setAmountAsLong(proto.getAmountAsLong()); trade.setPrice(proto.getPrice()); return fromProto(trade, diff --git a/core/src/main/java/haveno/core/trade/SellerAsTakerTrade.java b/core/src/main/java/haveno/core/trade/SellerAsTakerTrade.java index ef3de2c9b6..3d9b7d604e 100644 --- a/core/src/main/java/haveno/core/trade/SellerAsTakerTrade.java +++ b/core/src/main/java/haveno/core/trade/SellerAsTakerTrade.java @@ -83,8 +83,8 @@ public final class SellerAsTakerTrade extends SellerTrade implements TakerTrade } return fromProto(new SellerAsTakerTrade( Offer.fromProto(proto.getOffer()), - BigInteger.valueOf(proto.getAmountAsLong()), - BigInteger.valueOf(proto.getTakerFeeAsLong()), + BigInteger.valueOf(proto.getAmount()), + BigInteger.valueOf(proto.getTakerFee()), proto.getPrice(), xmrWalletService, processModel, diff --git a/core/src/main/java/haveno/core/trade/Tradable.java b/core/src/main/java/haveno/core/trade/Tradable.java index 0b16df4d1c..596f4c6c93 100644 --- a/core/src/main/java/haveno/core/trade/Tradable.java +++ b/core/src/main/java/haveno/core/trade/Tradable.java @@ -22,7 +22,6 @@ import haveno.core.monetary.Price; import haveno.core.monetary.Volume; import haveno.core.offer.Offer; import haveno.network.p2p.NodeAddress; -import org.bitcoinj.core.Coin; import java.math.BigInteger; import java.util.Date; @@ -57,12 +56,8 @@ public interface Tradable extends PersistablePayload { return asTradeModel().map(Trade::getAmount); } - default Optional getOptionalAmountAsLong() { - return asTradeModel().map(Trade::getAmountAsLong); - } - - default Optional getOptionalTxFee() { - return asTradeModel().map(Trade::getTxFee); + default BigInteger getTotalTxFee() { + return asTradeModel().map(Trade::getTotalTxFee).get(); } default Optional getOptionalTakerFee() { diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index 785e64c9c2..20a865be52 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -324,8 +324,7 @@ public abstract class Trade implements Tradable, Model { private final ProcessModel processModel; @Getter private final Offer offer; - @Getter - private final long takerFeeAsLong; + private final long takerFee; // Added in 1.5.1 @Getter @@ -335,9 +334,7 @@ public abstract class Trade implements Tradable, Model { private long takeOfferDate; // Mutable - @Getter - @Setter - private long amountAsLong; + private long amount; @Setter private long price; @Nullable @@ -373,9 +370,7 @@ public abstract class Trade implements Tradable, Model { // Transient // Immutable @Getter - transient final private Coin txFee; - @Getter - transient final private BigInteger takerFee; + transient final private BigInteger totalTxFee; @Getter transient final private XmrWalletService xmrWalletService; @@ -401,9 +396,6 @@ public abstract class Trade implements Tradable, Model { transient private boolean isShutDown; // Added in v1.2.0 - @Nullable - transient private BigInteger tradeAmount; - transient private ObjectProperty tradeAmountProperty; transient private ObjectProperty tradeVolumeProperty; @@ -479,15 +471,13 @@ public abstract class Trade implements Tradable, Model { @Nullable NodeAddress takerNodeAddress, @Nullable NodeAddress arbitratorNodeAddress) { this.offer = offer; - this.tradeAmount = tradeAmount; - this.txFee = Coin.valueOf(0); // TODO (woodser): remove this field - this.takerFee = takerFee; + this.amount = tradeAmount.longValueExact(); + this.takerFee = takerFee.longValueExact(); + this.totalTxFee = BigInteger.valueOf(0); // TODO: sum tx fees this.price = tradePrice; this.xmrWalletService = xmrWalletService; this.processModel = processModel; this.uid = uid; - - this.takerFeeAsLong = takerFee.longValueExact(); this.takeOfferDate = new Date().getTime(); this.tradeListeners = new ArrayList(); @@ -1262,9 +1252,8 @@ public abstract class Trade implements Tradable, Model { } public void setAmount(BigInteger tradeAmount) { - this.tradeAmount = tradeAmount; - amountAsLong = tradeAmount.longValueExact(); - getAmountProperty().set(tradeAmount); + this.amount = tradeAmount.longValueExact(); + getAmountProperty().set(getAmount()); getVolumeProperty().set(getVolume()); } @@ -1566,15 +1555,17 @@ public abstract class Trade implements Tradable, Model { @Nullable public BigInteger getAmount() { - if (tradeAmount == null) - tradeAmount = BigInteger.valueOf(amountAsLong); - return tradeAmount; + return BigInteger.valueOf(amount); } public BigInteger getMakerFee() { return offer.getMakerFee(); } + public BigInteger getTakerFee() { + return BigInteger.valueOf(takerFee); + } + public BigInteger getBuyerSecurityDeposit() { if (getBuyer().getDepositTxHash() == null) return null; return BigInteger.valueOf(getBuyer().getSecurityDeposit()); @@ -1858,10 +1849,10 @@ public abstract class Trade implements Tradable, Model { public Message toProtoMessage() { protobuf.Trade.Builder builder = protobuf.Trade.newBuilder() .setOffer(offer.toProtoMessage()) - .setTakerFeeAsLong(takerFeeAsLong) + .setTakerFee(takerFee) .setTakeOfferDate(takeOfferDate) .setProcessModel(processModel.toProtoMessage()) - .setAmountAsLong(amountAsLong) + .setAmount(amount) .setPrice(price) .setState(Trade.State.toProtoMessage(state)) .setPayoutState(Trade.PayoutState.toProtoMessage(payoutState)) @@ -1927,11 +1918,11 @@ public abstract class Trade implements Tradable, Model { public String toString() { return "Trade{" + "\n offer=" + offer + - ",\n takerFeeAsLong=" + takerFeeAsLong + + ",\n takerFee=" + takerFee + ",\n takeOfferDate=" + takeOfferDate + ",\n processModel=" + processModel + ",\n payoutTxId='" + payoutTxId + '\'' + - ",\n tradeAmountAsLong=" + amountAsLong + + ",\n amount=" + amount + ",\n tradePrice=" + price + ",\n state=" + state + ",\n payoutState=" + payoutState + @@ -1945,7 +1936,7 @@ public abstract class Trade implements Tradable, Model { ",\n counterCurrencyExtraData='" + counterCurrencyExtraData + '\'' + ",\n assetTxProofResult='" + assetTxProofResult + '\'' + ",\n chatMessages=" + chatMessages + - ",\n txFee=" + txFee + + ",\n totalTxFee=" + totalTxFee + ",\n takerFee=" + takerFee + ",\n xmrWalletService=" + xmrWalletService + ",\n stateProperty=" + stateProperty + @@ -1954,7 +1945,7 @@ public abstract class Trade implements Tradable, Model { ",\n tradePeriodStateProperty=" + tradePeriodStateProperty + ",\n errorMessageProperty=" + errorMessageProperty + ",\n payoutTx=" + payoutTx + - ",\n tradeAmount=" + tradeAmount + + ",\n amount=" + amount + ",\n tradeAmountProperty=" + tradeAmountProperty + ",\n tradeVolumeProperty=" + tradeVolumeProperty + ",\n mediationResultState=" + mediationResultState + diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index 75ca375c5e..ba106add8e 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -787,7 +787,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi trade.getProcessModel().setTradeMessage(model.getTradeRequest()); trade.getProcessModel().setMakerSignature(model.getMakerSignature()); trade.getProcessModel().setUseSavingsWallet(useSavingsWallet); - trade.getProcessModel().setFundsNeededForTradeAsLong(fundsNeededForTrade.longValueExact()); + trade.getProcessModel().setFundsNeededForTrade(fundsNeededForTrade.longValueExact()); trade.getMaker().setPubKeyRing(trade.getOffer().getPubKeyRing()); trade.getSelf().setPubKeyRing(model.getPubKeyRing()); trade.getSelf().setPaymentAccountId(paymentAccountId); diff --git a/core/src/main/java/haveno/core/trade/messages/RefreshTradeStateRequest.java b/core/src/main/java/haveno/core/trade/messages/RefreshTradeStateRequest.java deleted file mode 100644 index 3a529f82c6..0000000000 --- a/core/src/main/java/haveno/core/trade/messages/RefreshTradeStateRequest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package haveno.core.trade.messages; - -import haveno.network.p2p.NodeAddress; -import lombok.EqualsAndHashCode; -import lombok.Value; - -/** - * Not used anymore since v1.4.0 - * We do the re-sending of the payment sent message via the BuyerSendPaymentSentMessage task on the - * buyer side, so seller do not need to do anything interactively. - */ -@Deprecated -@SuppressWarnings("ALL") -@EqualsAndHashCode(callSuper = true) -@Value -public class RefreshTradeStateRequest extends TradeMailboxMessage { - private final NodeAddress senderNodeAddress; - - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - private RefreshTradeStateRequest(String messageVersion, - String uid, - String tradeId, - NodeAddress senderNodeAddress) { - super(messageVersion, tradeId, uid); - this.senderNodeAddress = senderNodeAddress; - } - - @Override - public protobuf.NetworkEnvelope toProtoNetworkEnvelope() { - final protobuf.RefreshTradeStateRequest.Builder builder = protobuf.RefreshTradeStateRequest.newBuilder(); - builder.setUid(uid) - .setTradeId(tradeId) - .setSenderNodeAddress(senderNodeAddress.toProtoMessage()); - return getNetworkEnvelopeBuilder().setRefreshTradeStateRequest(builder).build(); - } - - public static RefreshTradeStateRequest fromProto(protobuf.RefreshTradeStateRequest proto, String messageVersion) { - return new RefreshTradeStateRequest(messageVersion, - proto.getUid(), - proto.getTradeId(), - NodeAddress.fromProto(proto.getSenderNodeAddress())); - } -} diff --git a/core/src/main/java/haveno/core/trade/protocol/ProcessModel.java b/core/src/main/java/haveno/core/trade/protocol/ProcessModel.java index 2239f0ea16..e4ecdab61a 100644 --- a/core/src/main/java/haveno/core/trade/protocol/ProcessModel.java +++ b/core/src/main/java/haveno/core/trade/protocol/ProcessModel.java @@ -25,7 +25,6 @@ import haveno.common.proto.ProtoUtil; import haveno.common.proto.persistable.PersistablePayload; import haveno.common.taskrunner.Model; import haveno.core.account.witness.AccountAgeWitnessService; -import haveno.core.btc.model.RawTransactionInput; import haveno.core.btc.wallet.BtcWalletService; import haveno.core.btc.wallet.TradeWalletService; import haveno.core.btc.wallet.XmrWalletService; @@ -56,9 +55,7 @@ import org.bitcoinj.core.Transaction; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; -import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import lombok.Getter; import lombok.Setter; @@ -86,14 +83,6 @@ public class ProcessModel implements Model, PersistablePayload { transient private TradeManager tradeManager; transient private Offer offer; - // Added in v1.2.0 - @Setter - @Nullable - transient private byte[] delayedPayoutTxSignature; - @Setter - @Nullable - transient private Transaction preparedDelayedPayoutTx; - // Added in v1.4.0 // MessageState of the last message sent from the seller to the buyer in the take offer process. // It is used only in a task which would not be executed after restart, so no need to persist it. @@ -121,21 +110,11 @@ public class ProcessModel implements Model, PersistablePayload { @Nullable @Setter private byte[] preparedDepositTx; - @Nullable - @Setter - private List rawTransactionInputs; - @Setter - private long changeOutputValue; - @Nullable - @Setter - private String changeOutputAddress; @Setter private boolean useSavingsWallet; @Setter - private long fundsNeededForTradeAsLong; - @Nullable - @Setter - private byte[] myMultiSigPubKey; + private long fundsNeededForTrade; + // that is used to store temp. the peers address when we get an incoming message before the message is verified. // After successful verified we copy that over to the trade.tradePeerAddress @Nullable @@ -229,9 +208,8 @@ public class ProcessModel implements Model, PersistablePayload { .setOfferId(offerId) .setAccountId(accountId) .setPubKeyRing(pubKeyRing.toProtoMessage()) - .setChangeOutputValue(changeOutputValue) .setUseSavingsWallet(useSavingsWallet) - .setFundsNeededForTradeAsLong(fundsNeededForTradeAsLong) + .setFundsNeededForTrade(fundsNeededForTrade) .setPaymentSentMessageState(paymentSentMessageStateProperty.get().name()) .setBuyerPayoutAmountFromMediation(buyerPayoutAmountFromMediation) .setSellerPayoutAmountFromMediation(sellerPayoutAmountFromMediation) @@ -241,9 +219,6 @@ public class ProcessModel implements Model, PersistablePayload { Optional.ofNullable(arbitrator).ifPresent(e -> builder.setArbitrator((protobuf.TradePeer) arbitrator.toProtoMessage())); Optional.ofNullable(takeOfferFeeTxId).ifPresent(builder::setTakeOfferFeeTxId); Optional.ofNullable(payoutTxSignature).ifPresent(e -> builder.setPayoutTxSignature(ByteString.copyFrom(payoutTxSignature))); - Optional.ofNullable(rawTransactionInputs).ifPresent(e -> builder.addAllRawTransactionInputs(ProtoUtil.collectionToProto(rawTransactionInputs, protobuf.RawTransactionInput.class))); - Optional.ofNullable(changeOutputAddress).ifPresent(builder::setChangeOutputAddress); - Optional.ofNullable(myMultiSigPubKey).ifPresent(e -> builder.setMyMultiSigPubKey(ByteString.copyFrom(myMultiSigPubKey))); Optional.ofNullable(tempTradePeerNodeAddress).ifPresent(e -> builder.setTempTradePeerNodeAddress(tempTradePeerNodeAddress.toProtoMessage())); Optional.ofNullable(makerSignature).ifPresent(e -> builder.setMakerSignature(makerSignature)); Optional.ofNullable(multisigAddress).ifPresent(e -> builder.setMultisigAddress(multisigAddress)); @@ -259,9 +234,8 @@ public class ProcessModel implements Model, PersistablePayload { TradePeer taker = TradePeer.fromProto(proto.getTaker(), coreProtoResolver); PubKeyRing pubKeyRing = PubKeyRing.fromProto(proto.getPubKeyRing()); ProcessModel processModel = new ProcessModel(proto.getOfferId(), proto.getAccountId(), pubKeyRing, arbitrator, maker, taker); - processModel.setChangeOutputValue(proto.getChangeOutputValue()); processModel.setUseSavingsWallet(proto.getUseSavingsWallet()); - processModel.setFundsNeededForTradeAsLong(proto.getFundsNeededForTradeAsLong()); + processModel.setFundsNeededForTrade(proto.getFundsNeededForTrade()); processModel.setBuyerPayoutAmountFromMediation(proto.getBuyerPayoutAmountFromMediation()); processModel.setSellerPayoutAmountFromMediation(proto.getSellerPayoutAmountFromMediation()); processModel.setDepositsConfirmedMessagesDelivered(proto.getDepositsConfirmedMessagesDelivered()); @@ -269,12 +243,6 @@ public class ProcessModel implements Model, PersistablePayload { // nullable processModel.setTakeOfferFeeTxId(ProtoUtil.stringOrNullFromProto(proto.getTakeOfferFeeTxId())); processModel.setPayoutTxSignature(ProtoUtil.byteArrayOrNullFromProto(proto.getPayoutTxSignature())); - List rawTransactionInputs = proto.getRawTransactionInputsList().isEmpty() ? - null : proto.getRawTransactionInputsList().stream() - .map(RawTransactionInput::fromProto).collect(Collectors.toList()); - processModel.setRawTransactionInputs(rawTransactionInputs); - processModel.setChangeOutputAddress(ProtoUtil.stringOrNullFromProto(proto.getChangeOutputAddress())); - processModel.setMyMultiSigPubKey(ProtoUtil.byteArrayOrNullFromProto(proto.getMyMultiSigPubKey())); processModel.setTempTradePeerNodeAddress(proto.hasTempTradePeerNodeAddress() ? NodeAddress.fromProto(proto.getTempTradePeerNodeAddress()) : null); processModel.setMediatedPayoutTxSignature(ProtoUtil.byteArrayOrNullFromProto(proto.getMediatedPayoutTxSignature())); processModel.setMakerSignature(proto.getMakerSignature()); @@ -311,7 +279,7 @@ public class ProcessModel implements Model, PersistablePayload { } public Coin getFundsNeededForTrade() { - return Coin.valueOf(fundsNeededForTradeAsLong); + return Coin.valueOf(fundsNeededForTrade); } public MoneroTxWallet resolveTakeOfferFeeTx(Trade trade) { diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitTradeRequest.java b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitTradeRequest.java index 70c9afb5d3..ffdc79ccf5 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitTradeRequest.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/ProcessInitTradeRequest.java @@ -131,7 +131,7 @@ public class ProcessInitTradeRequest extends TradeTask { // check trade amount checkArgument(request.getTradeAmount() > 0); - trade.setAmount(BigInteger.valueOf(request.getTradeAmount())); + checkArgument(request.getTradeAmount() == trade.getAmount().longValueExact(), "Trade amount does not match request's trade amount"); // persist trade processModel.getTradeManager().requestPersistence(); diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/PublishTradeStatistics.java b/core/src/main/java/haveno/core/trade/protocol/tasks/PublishTradeStatistics.java deleted file mode 100644 index a7731404f9..0000000000 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/PublishTradeStatistics.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package haveno.core.trade.protocol.tasks; - -import haveno.common.taskrunner.TaskRunner; -import haveno.core.offer.Offer; -import haveno.core.offer.OfferPayload; -import haveno.core.trade.Trade; -import haveno.core.trade.statistics.TradeStatistics2; -import haveno.network.p2p.NodeAddress; -import haveno.network.p2p.network.NetworkNode; -import haveno.network.p2p.network.TorNetworkNode; -import java.util.HashMap; -import java.util.Map; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkNotNull; - -@Slf4j -public class PublishTradeStatistics extends TradeTask { - public PublishTradeStatistics(TaskRunner taskHandler, Trade trade) { - super(taskHandler, trade); - } - - @Override - protected void run() { - try { - runInterceptHook(); - - checkNotNull(trade.getMakerDepositTx()); - checkNotNull(trade.getTakerDepositTx()); - - Map extraDataMap = new HashMap<>(); - if (processModel.getReferralIdService().getOptionalReferralId().isPresent()) { - extraDataMap.put(OfferPayload.REFERRAL_ID, processModel.getReferralIdService().getOptionalReferralId().get()); - } - - NodeAddress mediatorNodeAddress = checkNotNull(trade.getArbitrator().getNodeAddress()); - // The first 4 chars are sufficient to identify a mediator. - // For testing with regtest/localhost we use the full address as its localhost and would result in - // same values for multiple mediators. - NetworkNode networkNode = model.getProcessModel().getP2PService().getNetworkNode(); - String address = networkNode instanceof TorNetworkNode ? - mediatorNodeAddress.getFullAddress().substring(0, 4) : - mediatorNodeAddress.getFullAddress(); - extraDataMap.put(TradeStatistics2.ARBITRATOR_ADDRESS, address); - - Offer offer = checkNotNull(trade.getOffer()); - TradeStatistics2 tradeStatistics = new TradeStatistics2(offer.getOfferPayload(), - trade.getPrice(), - trade.getAmount(), - trade.getDate(), - trade.getMaker().getDepositTxHash(), - trade.getTaker().getDepositTxHash(), - extraDataMap); - processModel.getP2PService().addPersistableNetworkPayload(tradeStatistics, true); - - complete(); - } catch (Throwable t) { - failed(t); - } - } -} diff --git a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics2.java b/core/src/main/java/haveno/core/trade/statistics/TradeStatistics2.java deleted file mode 100644 index 92d99851c3..0000000000 --- a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics2.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package haveno.core.trade.statistics; - -import com.google.protobuf.ByteString; -import haveno.common.app.Capabilities; -import haveno.common.app.Capability; -import haveno.common.crypto.Hash; -import haveno.common.proto.ProtoUtil; -import haveno.common.util.CollectionUtils; -import haveno.common.util.ExtraDataMapValidator; -import haveno.common.util.JsonExclude; -import haveno.common.util.Utilities; -import haveno.core.monetary.Altcoin; -import haveno.core.monetary.AltcoinExchangeRate; -import haveno.core.monetary.Price; -import haveno.core.monetary.Volume; -import haveno.core.offer.Offer; -import haveno.core.offer.OfferDirection; -import haveno.core.offer.OfferPayload; -import haveno.core.trade.HavenoUtils; -import haveno.core.trade.Trade; -import haveno.core.util.JsonUtil; -import haveno.core.util.VolumeUtil; -import haveno.network.p2p.NodeAddress; -import haveno.network.p2p.storage.payload.CapabilityRequiringPayload; -import haveno.network.p2p.storage.payload.PersistableNetworkPayload; -import haveno.network.p2p.storage.payload.ProcessOncePersistableNetworkPayload; -import org.bitcoinj.utils.ExchangeRate; -import org.bitcoinj.utils.Fiat; - -import com.google.common.base.Charsets; - -import java.math.BigInteger; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -import lombok.Value; -import lombok.extern.slf4j.Slf4j; - -import org.jetbrains.annotations.NotNull; - -import javax.annotation.Nullable; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Serialized size is about 180-210 byte. Nov 2017 we have 5500 objects - */ -@Deprecated -@Slf4j -@Value -public final class TradeStatistics2 implements ProcessOncePersistableNetworkPayload, PersistableNetworkPayload, - CapabilityRequiringPayload, Comparable { - - public static TradeStatistics2 from(Trade trade, - @Nullable String referralId, - boolean isTorNetworkNode) { - Map extraDataMap = new HashMap<>(); - if (referralId != null) { - extraDataMap.put(OfferPayload.REFERRAL_ID, referralId); - } - - NodeAddress arbitratorNodeAddress = trade.getArbitratorNodeAddress(); - if (arbitratorNodeAddress != null) { - // The first 4 chars are sufficient to identify a arbitrator. - // For testing with regtest/localhost we use the full address as its localhost and would result in - // same values for multiple arbitrators. - String address = isTorNetworkNode ? - arbitratorNodeAddress.getFullAddress().substring(0, 4) : - arbitratorNodeAddress.getFullAddress(); - extraDataMap.put(TradeStatistics2.ARBITRATOR_ADDRESS, address); - } - - Offer offer = trade.getOffer(); - checkNotNull(offer, "offer must not ne null"); - checkNotNull(trade.getAmount(), "trade.getTradeAmount() must not ne null"); - return new TradeStatistics2(offer.getOfferPayload(), - trade.getPrice(), - trade.getAmount(), - trade.getDate(), - trade.getMaker().getDepositTxHash(), - trade.getTaker().getDepositTxHash(), - extraDataMap); - } - - @SuppressWarnings("SpellCheckingInspection") - public static final String ARBITRATOR_ADDRESS = "arbAddr"; - @SuppressWarnings("SpellCheckingInspection") - public static final String REFUND_AGENT_ADDRESS = "refAddr"; - - private final OfferDirection direction; - private final String baseCurrency; - private final String counterCurrency; - private final String offerPaymentMethod; - private final long offerDate; - private final boolean offerUseMarketBasedPrice; - private final double offerMarketPriceMargin; - private final long offerAmount; - private final long offerMinAmount; - private final String offerId; - private final long tradePrice; - private final long tradeAmount; - // tradeDate is different for both peers so we ignore it for hash - @JsonExclude - private final long tradeDate; - @JsonExclude - @Nullable - private final String makerDepositTxId; - @Nullable - private final String takerDepositTxId; - - // Hash get set in constructor from json of all the other data fields (with hash = null). - @JsonExclude - private final byte[] hash; - // PB field signature_pub_key_bytes not used anymore from v0.6 on - - // Should be only used in emergency case if we need to add data but do not want to break backward compatibility - // at the P2P network storage checks. The hash of the object will be used to verify if the data is valid. Any new - // field in a class would break that hash and therefore break the storage mechanism. - @Nullable - @JsonExclude - private Map extraDataMap; - - public TradeStatistics2(OfferPayload offerPayload, - Price tradePrice, - BigInteger tradeAmount, - Date tradeDate, - String makerDepositTxId, - String takerDepositTxId, - Map extraDataMap) { - this(offerPayload.getDirection(), - offerPayload.getBaseCurrencyCode(), - offerPayload.getCounterCurrencyCode(), - offerPayload.getPaymentMethodId(), - offerPayload.getDate(), - offerPayload.isUseMarketBasedPrice(), - offerPayload.getMarketPriceMarginPct(), - offerPayload.getAmount(), - offerPayload.getMinAmount(), - offerPayload.getId(), - tradePrice.getValue(), - tradeAmount.longValueExact(), - tradeDate.getTime(), - makerDepositTxId, - takerDepositTxId, - null, - extraDataMap); - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - public TradeStatistics2(OfferDirection direction, - String baseCurrency, - String counterCurrency, - String offerPaymentMethod, - long offerDate, - boolean offerUseMarketBasedPrice, - double offerMarketPriceMargin, - long offerAmount, - long offerMinAmount, - String offerId, - long tradePrice, - long tradeAmount, - long tradeDate, - @Nullable String makerDepositTxId, - @Nullable String takerDepositTxId, - @Nullable byte[] hash, - @Nullable Map extraDataMap) { - this.direction = direction; - this.baseCurrency = baseCurrency; - this.counterCurrency = counterCurrency; - this.offerPaymentMethod = offerPaymentMethod; - this.offerDate = offerDate; - this.offerUseMarketBasedPrice = offerUseMarketBasedPrice; - this.offerMarketPriceMargin = offerMarketPriceMargin; - this.offerAmount = offerAmount; - this.offerMinAmount = offerMinAmount; - this.offerId = offerId; - this.tradePrice = tradePrice; - this.tradeAmount = tradeAmount; - this.tradeDate = tradeDate; - this.makerDepositTxId = makerDepositTxId; - this.takerDepositTxId = takerDepositTxId; - this.extraDataMap = ExtraDataMapValidator.getValidatedExtraDataMap(extraDataMap); - - this.hash = hash == null ? createHash() : hash; - } - - public byte[] createHash() { - // We create hash from all fields excluding hash itself. We use json as simple data serialisation. - // TradeDate is different for both peers so we ignore it for hash. ExtraDataMap is ignored as well as at - // software updates we might have different entries which would cause a different hash. - return Hash.getSha256Ripemd160hash(JsonUtil.objectToJson(this).getBytes(Charsets.UTF_8)); - } - - private protobuf.TradeStatistics2.Builder getBuilder() { - final protobuf.TradeStatistics2.Builder builder = protobuf.TradeStatistics2.newBuilder() - .setDirection(OfferDirection.toProtoMessage(direction)) - .setBaseCurrency(baseCurrency) - .setCounterCurrency(counterCurrency) - .setPaymentMethodId(offerPaymentMethod) - .setOfferDate(offerDate) - .setOfferUseMarketBasedPrice(offerUseMarketBasedPrice) - .setOfferMarketPriceMargin(offerMarketPriceMargin) - .setOfferAmount(offerAmount) - .setOfferMinAmount(offerMinAmount) - .setOfferId(offerId) - .setTradePrice(tradePrice) - .setTradeAmount(tradeAmount) - .setTradeDate(tradeDate) - .setHash(ByteString.copyFrom(hash)); - Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData); - Optional.ofNullable(makerDepositTxId).ifPresent(builder::setMakerDepositTxId); - Optional.ofNullable(takerDepositTxId).ifPresent(builder::setTakerDepositTxId); - return builder; - } - - public protobuf.TradeStatistics2 toProtoTradeStatistics2() { - return getBuilder().build(); - } - - @Override - public protobuf.PersistableNetworkPayload toProtoMessage() { - return protobuf.PersistableNetworkPayload.newBuilder().setTradeStatistics2(getBuilder()).build(); - } - - public static TradeStatistics2 fromProto(protobuf.TradeStatistics2 proto) { - return new TradeStatistics2( - OfferDirection.fromProto(proto.getDirection()), - proto.getBaseCurrency(), - proto.getCounterCurrency(), - proto.getPaymentMethodId(), - proto.getOfferDate(), - proto.getOfferUseMarketBasedPrice(), - proto.getOfferMarketPriceMargin(), - proto.getOfferAmount(), - proto.getOfferMinAmount(), - proto.getOfferId(), - proto.getTradePrice(), - proto.getTradeAmount(), - proto.getTradeDate(), - ProtoUtil.stringOrNullFromProto(proto.getMakerDepositTxId()), - ProtoUtil.stringOrNullFromProto(proto.getTakerDepositTxId()), - null, // We want to clean up the hashes with the changed hash method in v.1.2.0 so we don't use the value from the proto - CollectionUtils.isEmpty(proto.getExtraDataMap()) ? null : proto.getExtraDataMap()); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // API - /////////////////////////////////////////////////////////////////////////////////////////// - - @Override - public byte[] getHash() { - return hash; - } - - @Override - public boolean verifyHashSize() { - checkNotNull(hash, "hash must not be null"); - return hash.length == 20; - } - - // With v1.2.0 we changed the way how the hash is created. To not create too heavy load for seed nodes from - // requests from old nodes we use the TRADE_STATISTICS_HASH_UPDATE capability to send trade statistics only to new - // nodes. As trade statistics are only used for informational purpose it will not have any critical issue for the - // old nodes beside that they don't see the latest trades. We added TRADE_STATISTICS_HASH_UPDATE in v1.2.2 to fix a - // problem of not handling the hashes correctly. - @Override - public Capabilities getRequiredCapabilities() { - return new Capabilities(Capability.TRADE_STATISTICS_HASH_UPDATE); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Getters - /////////////////////////////////////////////////////////////////////////////////////////// - - - public Date getTradeDate() { - return new Date(tradeDate); - } - - public Price getPrice() { - return Price.valueOf(getCurrencyCode(), tradePrice); - } - - public String getCurrencyCode() { - return baseCurrency.equals("XMR") ? counterCurrency : baseCurrency; - } - - public BigInteger getTradeAmount() { - return BigInteger.valueOf(tradeAmount); - } - - public Volume getTradeVolume() { - if (getPrice().getMonetary() instanceof Altcoin) { - return new Volume(new AltcoinExchangeRate((Altcoin) getPrice().getMonetary()).coinToAltcoin(HavenoUtils.atomicUnitsToCoin(getTradeAmount()))); - } else { - Volume volume = new Volume(new ExchangeRate((Fiat) getPrice().getMonetary()).coinToFiat(HavenoUtils.atomicUnitsToCoin(getTradeAmount()))); - return VolumeUtil.getRoundedFiatVolume(volume); - } - } - - public boolean isValid() { - // Exclude a disputed BSQ trade where the price was off by a factor 10 due to a mistake by the maker. - // Since the trade wasn't executed it's better to filter it out to avoid it having an undue influence on the - // BSQ trade stats. - boolean excludedFailedTrade = offerId.equals("6E5KOI6O-3a06a037-6f03-4bfa-98c2-59f49f73466a-112"); - boolean makerDepositTxIdValid = makerDepositTxId == null || !makerDepositTxId.isEmpty(); - boolean takerDepositTxIdValid = takerDepositTxId == null || !takerDepositTxId.isEmpty(); - return tradeAmount > 0 && tradePrice > 0 && !excludedFailedTrade && makerDepositTxIdValid && takerDepositTxIdValid; - } - - // TODO: Can be removed as soon as everyone uses v1.2.6+ - @Override - public int compareTo(@NotNull TradeStatistics2 o) { - if (direction.equals(o.direction) && - baseCurrency.equals(o.baseCurrency) && - counterCurrency.equals(o.counterCurrency) && - offerPaymentMethod.equals(o.offerPaymentMethod) && - offerDate == o.offerDate && - offerUseMarketBasedPrice == o.offerUseMarketBasedPrice && - offerAmount == o.offerAmount && - offerMinAmount == o.offerMinAmount && - offerId.equals(o.offerId) && - tradePrice == o.tradePrice && - tradeAmount == o.tradeAmount) { - return 0; - } - - return -1; - } - - @Override - public String toString() { - return "TradeStatistics2{" + - "\n direction=" + direction + - ",\n baseCurrency='" + baseCurrency + '\'' + - ",\n counterCurrency='" + counterCurrency + '\'' + - ",\n offerPaymentMethod='" + offerPaymentMethod + '\'' + - ",\n offerDate=" + offerDate + - ",\n offerUseMarketBasedPrice=" + offerUseMarketBasedPrice + - ",\n offerMarketPriceMargin=" + offerMarketPriceMargin + - ",\n offerAmount=" + offerAmount + - ",\n offerMinAmount=" + offerMinAmount + - ",\n offerId='" + offerId + '\'' + - ",\n tradePrice=" + tradePrice + - ",\n tradeAmount=" + tradeAmount + - ",\n tradeDate=" + tradeDate + - ",\n makerDepositTxId='" + makerDepositTxId + '\'' + - ",\n takerDepositTxId='" + takerDepositTxId + '\'' + - ",\n hash=" + Utilities.bytesAsHexString(hash) + - ",\n extraDataMap=" + extraDataMap + - "\n}"; - } -} diff --git a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics2StorageService.java b/core/src/main/java/haveno/core/trade/statistics/TradeStatistics2StorageService.java deleted file mode 100644 index b7162b3b58..0000000000 --- a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics2StorageService.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package haveno.core.trade.statistics; - -import haveno.common.config.Config; -import haveno.common.persistence.PersistenceManager; -import haveno.network.p2p.storage.P2PDataStorage; -import haveno.network.p2p.storage.payload.PersistableNetworkPayload; -import haveno.network.p2p.storage.persistence.MapStoreService; -import javax.inject.Inject; -import javax.inject.Named; - -import java.io.File; - -import java.util.HashMap; -import java.util.Map; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class TradeStatistics2StorageService extends MapStoreService { - private static final String FILE_NAME = "TradeStatistics2Store"; - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Constructor - /////////////////////////////////////////////////////////////////////////////////////////// - - @Inject - public TradeStatistics2StorageService(@Named(Config.STORAGE_DIR) File storageDir, - PersistenceManager persistenceManager) { - super(storageDir, persistenceManager); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // API - /////////////////////////////////////////////////////////////////////////////////////////// - - @Override - protected void initializePersistenceManager() { - persistenceManager.initialize(store, PersistenceManager.Source.NETWORK); - } - - @Override - public String getFileName() { - return FILE_NAME; - } - - @Override - public Map getMap() { - // As it is used for data request and response and we do not want to send any old trade stat data anymore. - return new HashMap<>(); - } - - // We overwrite that method to receive old trade stats from the network. As we deactivated getMap to not deliver - // hashes we needed to use the getMapOfAllData method to actually store the data. - // That's a bit of a hack but it's just for transition and can be removed after a few months anyway. - // Alternatively we could create a new interface to handle it differently on the other client classes but that - // seems to be not justified as it is needed only temporarily. - @Override - protected PersistableNetworkPayload putIfAbsent(P2PDataStorage.ByteArray hash, PersistableNetworkPayload payload) { - return getMapOfAllData().putIfAbsent(hash, payload); - } - - @Override - protected void readFromResources(String postFix, Runnable completeHandler) { - // We do not attempt to read from resources as that file is not provided anymore - readStore(persisted -> completeHandler.run()); - } - - public Map getMapOfAllData() { - return store.getMap(); - } - - @Override - public boolean canHandle(PersistableNetworkPayload payload) { - return payload instanceof TradeStatistics2; - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Protected - /////////////////////////////////////////////////////////////////////////////////////////// - - @Override - protected TradeStatistics2Store createStore() { - return new TradeStatistics2Store(); - } -} diff --git a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics2Store.java b/core/src/main/java/haveno/core/trade/statistics/TradeStatistics2Store.java deleted file mode 100644 index ed71d3b7db..0000000000 --- a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics2Store.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package haveno.core.trade.statistics; - -import com.google.protobuf.Message; -import haveno.network.p2p.storage.persistence.PersistableNetworkPayloadStore; -import java.util.List; -import java.util.stream.Collectors; - -import lombok.extern.slf4j.Slf4j; - -/** - * We store only the payload in the PB file to save disc space. The hash of the payload can be created anyway and - * is only used as key in the map. So we have a hybrid data structure which is represented as list in the protobuffer - * definition and provide a hashMap for the domain access. - */ -@Slf4j -public class TradeStatistics2Store extends PersistableNetworkPayloadStore { - - TradeStatistics2Store() { - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - private TradeStatistics2Store(List list) { - super(list); - } - - public Message toProtoMessage() { - return protobuf.PersistableEnvelope.newBuilder() - .setTradeStatistics2Store(getBuilder()) - .build(); - } - - private protobuf.TradeStatistics2Store.Builder getBuilder() { - final List protoList = map.values().stream() - .map(payload -> (TradeStatistics2) payload) - .map(TradeStatistics2::toProtoTradeStatistics2) - .collect(Collectors.toList()); - return protobuf.TradeStatistics2Store.newBuilder().addAllItems(protoList); - } - - public static TradeStatistics2Store fromProto(protobuf.TradeStatistics2Store proto) { - List list = proto.getItemsList().stream() - .map(TradeStatistics2::fromProto).collect(Collectors.toList()); - return new TradeStatistics2Store(list); - } -} diff --git a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics3.java b/core/src/main/java/haveno/core/trade/statistics/TradeStatistics3.java index a34ab68a95..43cc459428 100644 --- a/core/src/main/java/haveno/core/trade/statistics/TradeStatistics3.java +++ b/core/src/main/java/haveno/core/trade/statistics/TradeStatistics3.java @@ -94,7 +94,7 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl Offer offer = checkNotNull(trade.getOffer()); return new TradeStatistics3(offer.getCurrencyCode(), trade.getPrice().getValue(), - trade.getAmountAsLong(), + trade.getAmount().longValueExact(), offer.getPaymentMethod().getId(), trade.getTakeOfferDate().getTime(), truncatedArbitratorNodeAddress, diff --git a/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsConverter.java b/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsConverter.java deleted file mode 100644 index 254bded1b0..0000000000 --- a/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsConverter.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package haveno.core.trade.statistics; - -import com.google.inject.Inject; -import haveno.common.UserThread; -import haveno.common.config.Config; -import haveno.common.file.FileUtil; -import haveno.common.util.Utilities; -import haveno.core.offer.availability.DisputeAgentSelection; -import haveno.network.p2p.BootstrapListener; -import haveno.network.p2p.P2PService; -import haveno.network.p2p.storage.P2PDataStorage; -import haveno.network.p2p.storage.payload.PersistableNetworkPayload; -import haveno.network.p2p.storage.persistence.AppendOnlyDataStoreService; -import javax.inject.Named; -import javax.inject.Singleton; - -import java.io.File; -import java.io.IOException; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutorService; - -import lombok.extern.slf4j.Slf4j; - -@Singleton -@Slf4j -public class TradeStatisticsConverter { - - private ExecutorService executor; - - @Inject - public TradeStatisticsConverter(P2PService p2PService, - P2PDataStorage p2PDataStorage, - TradeStatistics2StorageService tradeStatistics2StorageService, - TradeStatistics3StorageService tradeStatistics3StorageService, - AppendOnlyDataStoreService appendOnlyDataStoreService, - @Named(Config.STORAGE_DIR) File storageDir) { - File tradeStatistics2Store = new File(storageDir, "TradeStatistics2Store"); - appendOnlyDataStoreService.addService(tradeStatistics2StorageService); - - p2PService.addP2PServiceListener(new BootstrapListener() { - - @Override - public void onTorNodeReady() { - if (!tradeStatistics2Store.exists()) { - return; - } - executor = Utilities.getSingleThreadExecutor("TradeStatisticsConverter"); - executor.submit(() -> { - // We convert early once tor is initialized but still not ready to receive data - Map tempMap = new HashMap<>(); - convertToTradeStatistics3(tradeStatistics2StorageService.getMapOfAllData().values()) - .forEach(e -> tempMap.put(new P2PDataStorage.ByteArray(e.getHash()), e)); - - // We map to user thread to avoid potential threading issues - UserThread.execute(() -> { - tradeStatistics3StorageService.getMapOfLiveData().putAll(tempMap); - tradeStatistics3StorageService.persistNow(); - }); - - try { - log.info("We delete now the old trade statistics file as it was converted to the new format."); - FileUtil.deleteFileIfExists(tradeStatistics2Store); - } catch (IOException e) { - e.printStackTrace(); - log.error(e.toString()); - } - }); - } - - @Override - public void onUpdatedDataReceived() { - } - }); - - // We listen to old TradeStatistics2 objects, convert and store them and rebroadcast. - p2PDataStorage.addAppendOnlyDataStoreListener(payload -> { - if (payload instanceof TradeStatistics2) { - TradeStatistics3 tradeStatistics3 = convertToTradeStatistics3((TradeStatistics2) payload); - // We add it to the p2PDataStorage, which handles to get the data stored in the maps and maybe - // re-broadcast as tradeStatistics3 object if not already received. - p2PDataStorage.addPersistableNetworkPayload(tradeStatistics3, null, true); - } - }); - } - - public void shutDown() { - if (executor != null) - executor.shutdown(); - } - - private static List convertToTradeStatistics3(Collection persistableNetworkPayloads) { - List list = new ArrayList<>(); - long ts = System.currentTimeMillis(); - - // We might have duplicate entries from both traders as the trade date was different from old clients. - // This should not be the case with converting old persisted data as we did filter those out but it is the case - // when we receive old trade stat objects from the network of 2 not updated traders. - // The hash was ignoring the trade date so we use that to get a unique list - Map mapWithoutDuplicates = new HashMap<>(); - persistableNetworkPayloads.stream() - .filter(e -> e instanceof TradeStatistics2) - .map(e -> (TradeStatistics2) e) - .filter(TradeStatistics2::isValid) - .forEach(e -> mapWithoutDuplicates.putIfAbsent(new P2PDataStorage.ByteArray(e.getHash()), e)); - - log.info("We convert the existing {} trade statistics objects to the new format.", mapWithoutDuplicates.size()); - - mapWithoutDuplicates.values().stream() - .map(TradeStatisticsConverter::convertToTradeStatistics3) - .filter(TradeStatistics3::isValid) - .forEach(list::add); - - int size = list.size(); - log.info("Conversion to {} new trade statistic objects has been completed after {} ms", - size, System.currentTimeMillis() - ts); - - // We prune mediator and refundAgent data from all objects but the last 100 as we only use the - // last 100 entries (DisputeAgentSelection.LOOK_BACK_RANGE). - list.sort(Comparator.comparing(TradeStatistics3::getDateAsLong)); - if (size > DisputeAgentSelection.LOOK_BACK_RANGE) { - int start = size - DisputeAgentSelection.LOOK_BACK_RANGE; - for (int i = start; i < size; i++) { - TradeStatistics3 tradeStatistics3 = list.get(i); - tradeStatistics3.pruneOptionalData(); - } - } - return list; - } - - private static TradeStatistics3 convertToTradeStatistics3(TradeStatistics2 tradeStatistics2) { - Map extraDataMap = tradeStatistics2.getExtraDataMap(); - String mediator = extraDataMap != null ? extraDataMap.get(TradeStatistics2.ARBITRATOR_ADDRESS) : null; // TODO (woodser): using mediator as arbitrator - long time = tradeStatistics2.getTradeDate().getTime(); - // We need to avoid that we duplicate tradeStatistics2 objects in case both traders have not updated yet. - // Before v1.4.0 both traders published the trade statistics. If one trader has updated he will check - // the capabilities of the peer and if the peer has not updated he will leave publishing to the peer, so we - // do not have the problem of duplicated objects. - // Also at conversion of locally stored old trade statistics we need to avoid duplicated entries. - // To ensure we add only one object we will use the hash of the tradeStatistics2 object which is the same - // for both traders as it excluded the trade date which is different for both. - byte[] hash = tradeStatistics2.getHash(); - return new TradeStatistics3(tradeStatistics2.getCurrencyCode(), - tradeStatistics2.getPrice().getValue(), - tradeStatistics2.getTradeAmount().longValueExact(), - tradeStatistics2.getOfferPaymentMethod(), - time, - mediator, - hash); - } -} diff --git a/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java b/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java index 43e0efc784..0e07b93c4c 100644 --- a/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java +++ b/core/src/main/java/haveno/core/trade/statistics/TradeStatisticsManager.java @@ -20,7 +20,6 @@ package haveno.core.trade.statistics; import com.google.inject.Inject; import haveno.common.config.Config; import haveno.common.file.JsonFileManager; -import haveno.common.util.Utilities; import haveno.core.locale.CurrencyTuple; import haveno.core.locale.CurrencyUtil; import haveno.core.locale.Res; @@ -57,7 +56,6 @@ public class TradeStatisticsManager { private final P2PService p2PService; private final PriceFeedService priceFeedService; private final TradeStatistics3StorageService tradeStatistics3StorageService; - private final TradeStatisticsConverter tradeStatisticsConverter; private final File storageDir; private final boolean dumpStatistics; private final ObservableSet observableTradeStatisticsSet = FXCollections.observableSet(); @@ -68,13 +66,11 @@ public class TradeStatisticsManager { PriceFeedService priceFeedService, TradeStatistics3StorageService tradeStatistics3StorageService, AppendOnlyDataStoreService appendOnlyDataStoreService, - TradeStatisticsConverter tradeStatisticsConverter, @Named(Config.STORAGE_DIR) File storageDir, @Named(Config.DUMP_STATISTICS) boolean dumpStatistics) { this.p2PService = p2PService; this.priceFeedService = priceFeedService; this.tradeStatistics3StorageService = tradeStatistics3StorageService; - this.tradeStatisticsConverter = tradeStatisticsConverter; this.storageDir = storageDir; this.dumpStatistics = dumpStatistics; @@ -83,7 +79,6 @@ public class TradeStatisticsManager { } public void shutDown() { - tradeStatisticsConverter.shutDown(); if (jsonFileManager != null) { jsonFileManager.shutDown(); } @@ -184,17 +179,6 @@ public class TradeStatisticsManager { return; } - // If we did not find a TradeStatistics3 we look up if we find a TradeStatistics3 converted from - // TradeStatistics2 where we used the original hash, which is not the native hash of the - // TradeStatistics3 but of TradeStatistics2. - TradeStatistics2 tradeStatistics2 = TradeStatistics2.from(trade, referralId, isTorNetworkNode); - boolean hasTradeStatistics2 = hashes.contains(new P2PDataStorage.ByteArray(tradeStatistics2.getHash())); - if (hasTradeStatistics2) { - log.debug("Trade: {}. We have already a tradeStatistics matching the hash of tradeStatistics2. ", - trade.getShortId()); - return; - } - if (!tradeStatistics3.isValid()) { log.warn("Trade: {}. Trade statistics is invalid. We do not publish it.", tradeStatistics3); return; diff --git a/core/src/main/java/haveno/core/trade/txproof/xmr/XmrTxProofRequestsPerTrade.java b/core/src/main/java/haveno/core/trade/txproof/xmr/XmrTxProofRequestsPerTrade.java index e7ec9fe23c..bfead26b72 100644 --- a/core/src/main/java/haveno/core/trade/txproof/xmr/XmrTxProofRequestsPerTrade.java +++ b/core/src/main/java/haveno/core/trade/txproof/xmr/XmrTxProofRequestsPerTrade.java @@ -328,7 +328,7 @@ class XmrTxProofRequestsPerTrade implements AssetTxProofRequestsPerTrade { BigInteger tradeLimit = BigInteger.valueOf(autoConfirmSettings.getTradeLimit()); if (tradeAmount != null && tradeAmount.compareTo(tradeLimit) > 0) { log.warn("Trade amount {} is higher than limit from auto-conf setting {}.", - HavenoUtils.formatToXmrWithCode(tradeAmount), HavenoUtils.formatToXmrWithCode(tradeLimit)); + HavenoUtils.formatXmr(tradeAmount, true), HavenoUtils.formatXmr(tradeLimit, true)); return true; } return false; diff --git a/core/src/main/java/haveno/core/user/Preferences.java b/core/src/main/java/haveno/core/user/Preferences.java index b09224f724..e928d62452 100644 --- a/core/src/main/java/haveno/core/user/Preferences.java +++ b/core/src/main/java/haveno/core/user/Preferences.java @@ -912,7 +912,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid void setSelectedPaymentAccountForCreateOffer(@Nullable PaymentAccount paymentAccount); - void setPayFeeInBtc(boolean payFeeInBtc); + void setPayFeeInXmr(boolean payFeeInXmr); void setFiatCurrencies(List currencies); diff --git a/core/src/main/java/haveno/core/user/PreferencesPayload.java b/core/src/main/java/haveno/core/user/PreferencesPayload.java index 5350a0bcf9..4d44537d1a 100644 --- a/core/src/main/java/haveno/core/user/PreferencesPayload.java +++ b/core/src/main/java/haveno/core/user/PreferencesPayload.java @@ -89,9 +89,6 @@ public final class PreferencesPayload implements PersistableEnvelope { private List ignoreTradersList = new ArrayList<>(); private String directoryChooserPath; - @Deprecated // Superseded by buyerSecurityDepositAsPercent - private long buyerSecurityDepositAsLong; - private boolean useAnimations; private int cssTheme; @Nullable @@ -178,7 +175,6 @@ public final class PreferencesPayload implements PersistableEnvelope { .setBitcoinNodes(bitcoinNodes) .addAllIgnoreTradersList(ignoreTradersList) .setDirectoryChooserPath(directoryChooserPath) - .setBuyerSecurityDepositAsLong(buyerSecurityDepositAsLong) .setUseAnimations(useAnimations) .setCssTheme(cssTheme) .setBridgeOptionOrdinal(bridgeOptionOrdinal) @@ -268,7 +264,6 @@ public final class PreferencesPayload implements PersistableEnvelope { proto.getBitcoinNodes(), proto.getIgnoreTradersListList(), proto.getDirectoryChooserPath(), - proto.getBuyerSecurityDepositAsLong(), proto.getUseAnimations(), proto.getCssTheme(), paymentAccount, diff --git a/core/src/main/java/haveno/core/util/VolumeUtil.java b/core/src/main/java/haveno/core/util/VolumeUtil.java index a6e45f8069..5d7e4774ba 100644 --- a/core/src/main/java/haveno/core/util/VolumeUtil.java +++ b/core/src/main/java/haveno/core/util/VolumeUtil.java @@ -28,6 +28,9 @@ import haveno.core.monetary.AltcoinExchangeRate; import haveno.core.monetary.Price; import haveno.core.monetary.Volume; import haveno.core.offer.Offer; +import haveno.core.trade.HavenoUtils; + +import java.math.BigInteger; import java.text.DecimalFormat; import java.text.NumberFormat; @@ -64,11 +67,12 @@ public class VolumeUtil { return Volume.parse(String.valueOf(roundedVolume), volumeByAmount.getCurrencyCode()); } - public static Volume getVolume(Coin amount, Price price) { + public static Volume getVolume(BigInteger amount, Price price) { + // TODO: conversion to Coin loses precision if (price.getMonetary() instanceof Altcoin) { - return new Volume(new AltcoinExchangeRate((Altcoin) price.getMonetary()).coinToAltcoin(amount)); + return new Volume(new AltcoinExchangeRate((Altcoin) price.getMonetary()).coinToAltcoin(HavenoUtils.atomicUnitsToCoin(amount))); } else { - return new Volume(new ExchangeRate((Fiat) price.getMonetary()).coinToFiat(amount)); + return new Volume(new ExchangeRate((Fiat) price.getMonetary()).coinToFiat(HavenoUtils.atomicUnitsToCoin(amount))); } } diff --git a/core/src/main/java/haveno/core/util/validation/IntegerValidator.java b/core/src/main/java/haveno/core/util/validation/IntegerValidator.java index aa015256de..a1843bd115 100644 --- a/core/src/main/java/haveno/core/util/validation/IntegerValidator.java +++ b/core/src/main/java/haveno/core/util/validation/IntegerValidator.java @@ -45,10 +45,10 @@ public class IntegerValidator extends InputValidator { return new ValidationResult(false, Res.get("validation.notAnInteger")); if (isBelowMinValue(intValue)) - return new ValidationResult(false, Res.get("validation.btc.toSmall", minValue)); + return new ValidationResult(false, Res.get("validation.xmr.tooSmall", minValue)); if (isAboveMaxValue(intValue)) - return new ValidationResult(false, Res.get("validation.btc.toLarge", maxValue)); + return new ValidationResult(false, Res.get("validation.xmr.tooLarge", maxValue)); return validationResult; } diff --git a/core/src/main/java/haveno/core/util/validation/MonetaryValidator.java b/core/src/main/java/haveno/core/util/validation/MonetaryValidator.java index 30dcc82e44..803f659bc9 100644 --- a/core/src/main/java/haveno/core/util/validation/MonetaryValidator.java +++ b/core/src/main/java/haveno/core/util/validation/MonetaryValidator.java @@ -53,7 +53,7 @@ public abstract class MonetaryValidator extends NumberValidator { protected ValidationResult validateIfNotExceedsMinValue(String input) { double d = Double.parseDouble(input); if (d < getMinValue()) - return new ValidationResult(false, Res.get("validation.fiat.toSmall")); + return new ValidationResult(false, Res.get("validation.fiat.tooSmall")); else return new ValidationResult(true); } @@ -61,7 +61,7 @@ public abstract class MonetaryValidator extends NumberValidator { protected ValidationResult validateIfNotExceedsMaxValue(String input) { double d = Double.parseDouble(input); if (d > getMaxValue()) - return new ValidationResult(false, Res.get("validation.fiat.toLarge")); + return new ValidationResult(false, Res.get("validation.fiat.tooLarge")); else return new ValidationResult(true); } diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index e1c4d2b644..fe42c7d70b 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2009,8 +2009,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in XMR +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=Enter password to unlock torNetworkSettingWindow.header=Tor networks settings @@ -3230,11 +3230,11 @@ validation.NaN=Input is not a valid number. validation.notAnInteger=Input is not an integer value. validation.zero=Input of 0 is not allowed. validation.negative=A negative value is not allowed. -validation.fiat.toSmall=Input smaller than minimum possible amount is not allowed. -validation.fiat.toLarge=Input larger than maximum possible amount is not allowed. -validation.btc.fraction=Input will result in a bitcoin value of less than 1 satoshi -validation.btc.toLarge=Input larger than {0} is not allowed. -validation.btc.toSmall=Input smaller than {0} is not allowed. +validation.fiat.tooSmall=Input smaller than minimum possible amount is not allowed. +validation.fiat.tooLarge=Input larger than maximum possible amount is not allowed. +validation.xmr.fraction=Input will result in a bitcoin value of less than 1 satoshi +validation.xmr.tooLarge=Input larger than {0} is not allowed. +validation.xmr.tooSmall=Input smaller than {0} is not allowed. validation.passwordTooShort=The password you entered is too short. It needs to have a min. of 8 characters. validation.passwordTooLong=The password you entered is too long. It cannot be longer than 50 characters. validation.sortCodeNumber={0} must consist of {1} numbers. diff --git a/core/src/main/resources/i18n/displayStrings_cs.properties b/core/src/main/resources/i18n/displayStrings_cs.properties index 4e0d03ccd0..55dc556c10 100644 --- a/core/src/main/resources/i18n/displayStrings_cs.properties +++ b/core/src/main/resources/i18n/displayStrings_cs.properties @@ -1511,8 +1511,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} podle aktuální tržní ce closedTradesSummaryWindow.totalVolume.title=Celkový objem obchodovaný v {0} closedTradesSummaryWindow.totalMinerFee.title=Suma poplatků za těžbu closedTradesSummaryWindow.totalMinerFee.value={0} ({1} z celkového objemu obchodů) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Suma obchodních poplatků v BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} z celkového objemu obchodů) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Suma obchodních poplatků v BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} z celkového objemu obchodů) walletPasswordWindow.headline=Pro odemknutí zadejte heslo torNetworkSettingWindow.header=Nastavení sítě Tor @@ -2152,11 +2152,11 @@ validation.NaN=Vstup není platné číslo. validation.notAnInteger=Vstup není celočíselná hodnota. validation.zero=Vstup 0 není povolen. validation.negative=Záporná hodnota není povolena. -validation.fiat.toSmall=Vstup menší než minimální možné množství není povolen. -validation.fiat.toLarge=Vstup větší než maximální možné množství není povolen. -validation.btc.fraction=Zadání povede k hodnotě bitcoinu menší než 1 satoshi -validation.btc.toLarge=Vstup větší než {0} není povolen. -validation.btc.toSmall=Vstup menší než {0} není povolen. +validation.fiat.tooSmall=Vstup menší než minimální možné množství není povolen. +validation.fiat.tooLarge=Vstup větší než maximální možné množství není povolen. +validation.xmr.fraction=Zadání povede k hodnotě bitcoinu menší než 1 satoshi +validation.xmr.tooLarge=Vstup větší než {0} není povolen. +validation.xmr.tooSmall=Vstup menší než {0} není povolen. validation.passwordTooShort=Zadané heslo je příliš krátké. Musí mít min. 8 znaků. validation.passwordTooLong=Zadané heslo je příliš dlouhé. Nemůže být delší než 50 znaků. validation.sortCodeNumber={0} se musí skládat z {1} čísel. diff --git a/core/src/main/resources/i18n/displayStrings_de.properties b/core/src/main/resources/i18n/displayStrings_de.properties index 322f34ffcf..aa34eab01f 100644 --- a/core/src/main/resources/i18n/displayStrings_de.properties +++ b/core/src/main/resources/i18n/displayStrings_de.properties @@ -1511,8 +1511,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=Passwort zum Entsperren eingeben torNetworkSettingWindow.header=Tor-Netzwerkeinstellungen @@ -2152,11 +2152,11 @@ validation.NaN=Die Eingabe ist keine gültige Zahl. validation.notAnInteger=Eingabe ist keine ganze Zahl. validation.zero=Die Eingabe von 0 ist nicht erlaubt. validation.negative=Ein negativer Wert ist nicht erlaubt. -validation.fiat.toSmall=Eingaben kleiner als der minimal mögliche Betrag sind nicht erlaubt. -validation.fiat.toLarge=Eingaben größer als der maximal mögliche Betrag sind nicht erlaubt. -validation.btc.fraction=Input wird einem Bitcoin Wert von weniger als 1 satoshi entsprechen -validation.btc.toLarge=Eingaben größer als {0} sind nicht erlaubt. -validation.btc.toSmall=Eingabe kleiner als {0} ist nicht erlaubt. +validation.fiat.tooSmall=Eingaben kleiner als der minimal mögliche Betrag sind nicht erlaubt. +validation.fiat.tooLarge=Eingaben größer als der maximal mögliche Betrag sind nicht erlaubt. +validation.xmr.fraction=Input wird einem Bitcoin Wert von weniger als 1 satoshi entsprechen +validation.xmr.tooLarge=Eingaben größer als {0} sind nicht erlaubt. +validation.xmr.tooSmall=Eingabe kleiner als {0} ist nicht erlaubt. validation.passwordTooShort=Das Passwort das Sie eingegeben haben ist zu kurz. Es muss mindestens 8 Zeichen enthalten. validation.passwordTooLong=Das eingegebene Passwort ist zu lang. Es darf nicht aus mehr als 50 Zeichen bestehen. validation.sortCodeNumber={0} muss aus {1} Zahlen bestehen. diff --git a/core/src/main/resources/i18n/displayStrings_es.properties b/core/src/main/resources/i18n/displayStrings_es.properties index ec11588488..1ee6d9e026 100644 --- a/core/src/main/resources/i18n/displayStrings_es.properties +++ b/core/src/main/resources/i18n/displayStrings_es.properties @@ -1511,8 +1511,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} con el precio de mercado ac closedTradesSummaryWindow.totalVolume.title=Cantidad total intercambiada en {0} closedTradesSummaryWindow.totalMinerFee.title=Suma de todas las trasas de minado closedTradesSummaryWindow.totalMinerFee.value={0} ({1} de la cantidad total intercambiada) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Suma de todas las tasas de intercambio pagadas en BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} de la cantidad total intercambiada) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Suma de todas las tasas de intercambio pagadas en BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} de la cantidad total intercambiada) walletPasswordWindow.headline=Introducir contraseña para desbloquear torNetworkSettingWindow.header=Confirmación de red Tor @@ -2152,11 +2152,11 @@ validation.NaN=El valor introducido no es válido validation.notAnInteger=El valor introducido no es entero validation.zero=El 0 no es un valor permitido. validation.negative=No se permiten entradas negativas. -validation.fiat.toSmall=No se permite introducir un valor menor que el mínimo posible -validation.fiat.toLarge=No se permiten entradas más grandes que la mayor posible. -validation.btc.fraction=El valor introducido resulta en un valor de bitcoin menor a 1 satoshi -validation.btc.toLarge=No se permiten valores mayores que {0}. -validation.btc.toSmall=Valores menores que {0} no se permiten. +validation.fiat.tooSmall=No se permite introducir un valor menor que el mínimo posible +validation.fiat.tooLarge=No se permiten entradas más grandes que la mayor posible. +validation.xmr.fraction=El valor introducido resulta en un valor de bitcoin menor a 1 satoshi +validation.xmr.tooLarge=No se permiten valores mayores que {0}. +validation.xmr.tooSmall=Valores menores que {0} no se permiten. validation.passwordTooShort=El password introducido es muy corto. Necesita tener al menos 8 caracteres. validation.passwordTooLong=La clave introducida es demasiado larga. Máximo 50 caracteres. validation.sortCodeNumber={0} debe consistir en {1} números. diff --git a/core/src/main/resources/i18n/displayStrings_fa.properties b/core/src/main/resources/i18n/displayStrings_fa.properties index 099ddaee50..e88cc5e2d1 100644 --- a/core/src/main/resources/i18n/displayStrings_fa.properties +++ b/core/src/main/resources/i18n/displayStrings_fa.properties @@ -1511,8 +1511,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=وارد کردن رمز عبور به منظور باز کردن torNetworkSettingWindow.header=تنظیمات شبکه Tor  @@ -2152,11 +2152,11 @@ validation.NaN=ورودی، یک عدد معتبر نیست. validation.notAnInteger=ورودی یک مقدار صحیح نیست. validation.zero=ورودی 0 مجاز نیست. validation.negative=یک مقدار منفی مجاز نیست. -validation.fiat.toSmall=ورودی کوچکتر از حداقل مقدار ممکن مجاز نیست. -validation.fiat.toLarge=ورودی بزرگتر از حداکثر مقدار ممکن مجاز نیست. -validation.btc.fraction=Input will result in a bitcoin value of less than 1 satoshi -validation.btc.toLarge=ورودی بزرگتر از {0} مجاز نیست. -validation.btc.toSmall=ورودی کوچکتر از {0} مجاز نیست. +validation.fiat.tooSmall=ورودی کوچکتر از حداقل مقدار ممکن مجاز نیست. +validation.fiat.tooLarge=ورودی بزرگتر از حداکثر مقدار ممکن مجاز نیست. +validation.xmr.fraction=Input will result in a bitcoin value of less than 1 satoshi +validation.xmr.tooLarge=ورودی بزرگتر از {0} مجاز نیست. +validation.xmr.tooSmall=ورودی کوچکتر از {0} مجاز نیست. validation.passwordTooShort=The password you entered is too short. It needs to have a min. of 8 characters. validation.passwordTooLong=رمز عبور که شما وارد کرده اید خیلی طولانی است.رمز عبور بیش از 50 کاراکتر نمی تواند باشد. validation.sortCodeNumber={0} باید شامل {1} عدد باشد. diff --git a/core/src/main/resources/i18n/displayStrings_fr.properties b/core/src/main/resources/i18n/displayStrings_fr.properties index 53121eb274..2b0b8f4363 100644 --- a/core/src/main/resources/i18n/displayStrings_fr.properties +++ b/core/src/main/resources/i18n/displayStrings_fr.properties @@ -1512,8 +1512,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} avec le prix courant du mar closedTradesSummaryWindow.totalVolume.title=Montant total échangé en {0} closedTradesSummaryWindow.totalMinerFee.title=Somme de tous les frais de mineur closedTradesSummaryWindow.totalMinerFee.value={0} ({1} du montant total du trade) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Somme de tous les frais de trade payés en BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} du montant total du trade) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Somme de tous les frais de trade payés en BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} du montant total du trade) walletPasswordWindow.headline=Entrer le mot de passe pour déverouiller torNetworkSettingWindow.header=Paramètres du réseau Tor @@ -2153,11 +2153,11 @@ validation.NaN=La valeur saisie n'est pas un nombre valide. validation.notAnInteger=Input is not an integer value. validation.zero=La saisie d'une valeur égale à 0 n'est pas autorisé. validation.negative=Une valeur négative n'est pas autorisée. -validation.fiat.toSmall=La saisie d'une valeur plus petite que le montant minimal possible n'est pas autorisée. -validation.fiat.toLarge=La saisie d'une valeur supérieure au montant maximal possible n'est pas autorisée. -validation.btc.fraction=L'entrée résultera dans une valeur bitcoin plus petite qu'1 satoshi -validation.btc.toLarge=La saisie d''une valeur supérieure à {0} n''est pas autorisée. -validation.btc.toSmall=La saisie d''une valeur inférieure à {0} n''est pas autorisée. +validation.fiat.tooSmall=La saisie d'une valeur plus petite que le montant minimal possible n'est pas autorisée. +validation.fiat.tooLarge=La saisie d'une valeur supérieure au montant maximal possible n'est pas autorisée. +validation.xmr.fraction=L'entrée résultera dans une valeur bitcoin plus petite qu'1 satoshi +validation.xmr.tooLarge=La saisie d''une valeur supérieure à {0} n''est pas autorisée. +validation.xmr.tooSmall=La saisie d''une valeur inférieure à {0} n''est pas autorisée. validation.passwordTooShort=Le mot de passe que vous avez saisi est trop court. Il doit comporter un minimum de 8 caractères. validation.passwordTooLong=Le mot de passe que vous avez saisi est trop long. Il ne doit pas contenir plus de 50 caractères. validation.sortCodeNumber={0} doit être composer de {1} chiffres. diff --git a/core/src/main/resources/i18n/displayStrings_it.properties b/core/src/main/resources/i18n/displayStrings_it.properties index 2bfd568be6..22efcfe7e9 100644 --- a/core/src/main/resources/i18n/displayStrings_it.properties +++ b/core/src/main/resources/i18n/displayStrings_it.properties @@ -1511,8 +1511,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=Inserisci la password per sbloccare torNetworkSettingWindow.header=Impostazioni rete Tor @@ -2152,11 +2152,11 @@ validation.NaN=L'input non è un numero valido. validation.notAnInteger=L'input non è un valore intero. validation.zero=Un input di 0 non è consentito. validation.negative=Un valore negativo non è consentito. -validation.fiat.toSmall=Non è consentito un input inferiore al minimo possibile. -validation.fiat.toLarge=Non è consentito un input maggiore del massimo possibile. -validation.btc.fraction=Input will result in a bitcoin value of less than 1 satoshi -validation.btc.toLarge=L'immissione maggiore di {0} non è consentita. -validation.btc.toSmall=L'immissione inferiore a {0} non è consentita. +validation.fiat.tooSmall=Non è consentito un input inferiore al minimo possibile. +validation.fiat.tooLarge=Non è consentito un input maggiore del massimo possibile. +validation.xmr.fraction=Input will result in a bitcoin value of less than 1 satoshi +validation.xmr.tooLarge=L'immissione maggiore di {0} non è consentita. +validation.xmr.tooSmall=L'immissione inferiore a {0} non è consentita. validation.passwordTooShort=The password you entered is too short. It needs to have a min. of 8 characters. validation.passwordTooLong=La password inserita è troppo lunga. Non può contenere più di 50 caratteri. validation.sortCodeNumber={0} deve essere composto da {1} numeri. diff --git a/core/src/main/resources/i18n/displayStrings_ja.properties b/core/src/main/resources/i18n/displayStrings_ja.properties index 4052bc01b0..f76c3d6e54 100644 --- a/core/src/main/resources/i18n/displayStrings_ja.properties +++ b/core/src/main/resources/i18n/displayStrings_ja.properties @@ -1511,8 +1511,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=アンロックするためにパスワードを入力してください torNetworkSettingWindow.header=Torネットワークの設定 @@ -2152,11 +2152,11 @@ validation.NaN=入力が不正な数です。 validation.notAnInteger=入力が整数値ではありません。 validation.zero=0の入力は許可されていません。 validation.negative=負の値は許可されていません。 -validation.fiat.toSmall=可能な最小量より小さい入力は許可されていません。 -validation.fiat.toLarge=可能な最大量より大きい入力は許可されていません。 -validation.btc.fraction=この入力では1サトシ以下のビットコイン値が生成されます。 -validation.btc.toLarge={0}より大きい入力は許可されていません。 -validation.btc.toSmall={0}より小さい入力は許可されていません。 +validation.fiat.tooSmall=可能な最小量より小さい入力は許可されていません。 +validation.fiat.tooLarge=可能な最大量より大きい入力は許可されていません。 +validation.xmr.fraction=この入力では1サトシ以下のビットコイン値が生成されます。 +validation.xmr.tooLarge={0}より大きい入力は許可されていません。 +validation.xmr.tooSmall={0}より小さい入力は許可されていません。 validation.passwordTooShort=入力したパスワードが短すぎます。最低8文字が必要です。 validation.passwordTooLong=入力したパスワードが長すぎます。 50文字を超えることはできません。 validation.sortCodeNumber={0}は{1}個の数字で構成されている必要があります。 diff --git a/core/src/main/resources/i18n/displayStrings_pt-br.properties b/core/src/main/resources/i18n/displayStrings_pt-br.properties index 3ef4d5adbc..108a240a81 100644 --- a/core/src/main/resources/i18n/displayStrings_pt-br.properties +++ b/core/src/main/resources/i18n/displayStrings_pt-br.properties @@ -1516,8 +1516,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=Digite senha para abrir: @@ -2160,11 +2160,11 @@ validation.NaN=Número inválido validation.notAnInteger=A quantia não é um valor inteiro. validation.zero=Número 0 não é permitido validation.negative=Valores negativos não são permitidos. -validation.fiat.toSmall=Quantia menor do que a mínima permitida. -validation.fiat.toLarge=Quantia maior do que a máxima permitida. -validation.btc.fraction=Input will result in a bitcoin value of less than 1 satoshi -validation.btc.toLarge=Quantia máx. permitida: {0} -validation.btc.toSmall=Quantia mín. permitida: {0} +validation.fiat.tooSmall=Quantia menor do que a mínima permitida. +validation.fiat.tooLarge=Quantia maior do que a máxima permitida. +validation.xmr.fraction=Input will result in a bitcoin value of less than 1 satoshi +validation.xmr.tooLarge=Quantia máx. permitida: {0} +validation.xmr.tooSmall=Quantia mín. permitida: {0} validation.passwordTooShort=The password you entered is too short. It needs to have a min. of 8 characters. validation.passwordTooLong=A senha inserida é muito longa. Não pode ser maior do que 50 caracteres validation.sortCodeNumber={0} deve consistir de {1} números. diff --git a/core/src/main/resources/i18n/displayStrings_pt.properties b/core/src/main/resources/i18n/displayStrings_pt.properties index 2ea2ea9a63..57b37a19d2 100644 --- a/core/src/main/resources/i18n/displayStrings_pt.properties +++ b/core/src/main/resources/i18n/displayStrings_pt.properties @@ -1509,8 +1509,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=Digite senha para abrir: torNetworkSettingWindow.header=Definições de redes Tor @@ -2150,11 +2150,11 @@ validation.NaN=Número inválido validation.notAnInteger=O input não é um número inteiro. validation.zero=Número 0 não é permitido validation.negative=Valores negativos não são permitidos. -validation.fiat.toSmall=Input menor do que a quantia mínima permitida. -validation.fiat.toLarge=Input maior do que a quantia máxima permitida. -validation.btc.fraction=Input will result in a bitcoin value of less than 1 satoshi -validation.btc.toLarge=O input maior que {0} não é permitido. -validation.btc.toSmall=Input menor que {0} não é permitido. +validation.fiat.tooSmall=Input menor do que a quantia mínima permitida. +validation.fiat.tooLarge=Input maior do que a quantia máxima permitida. +validation.xmr.fraction=Input will result in a bitcoin value of less than 1 satoshi +validation.xmr.tooLarge=O input maior que {0} não é permitido. +validation.xmr.tooSmall=Input menor que {0} não é permitido. validation.passwordTooShort=The password you entered is too short. It needs to have a min. of 8 characters. validation.passwordTooLong=A senha inserida é muito longa. Não pode ser maior do que 50 caracteres. validation.sortCodeNumber={0} deve consistir de {1} números. diff --git a/core/src/main/resources/i18n/displayStrings_ru.properties b/core/src/main/resources/i18n/displayStrings_ru.properties index 82fd9ce5b7..3aaeb1b47a 100644 --- a/core/src/main/resources/i18n/displayStrings_ru.properties +++ b/core/src/main/resources/i18n/displayStrings_ru.properties @@ -1511,8 +1511,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=Введите пароль для разблокировки torNetworkSettingWindow.header=Настройки сети Тоr @@ -2152,11 +2152,11 @@ validation.NaN=Введённое число недопустимо. validation.notAnInteger=Введённое число не является целым. validation.zero=Введённое значение не может быть равно 0. validation.negative=Отрицательное значение недопустимо. -validation.fiat.toSmall=Ввод значения меньше минимально возможного не допускается. -validation.fiat.toLarge=Ввод значения больше максимально возможного не допускается. -validation.btc.fraction=Input will result in a bitcoin value of less than 1 satoshi -validation.btc.toLarge=Значение не может превышать {0}. -validation.btc.toSmall=Значение не может быть меньше {0}. +validation.fiat.tooSmall=Ввод значения меньше минимально возможного не допускается. +validation.fiat.tooLarge=Ввод значения больше максимально возможного не допускается. +validation.xmr.fraction=Input will result in a bitcoin value of less than 1 satoshi +validation.xmr.tooLarge=Значение не может превышать {0}. +validation.xmr.tooSmall=Значение не может быть меньше {0}. validation.passwordTooShort=The password you entered is too short. It needs to have a min. of 8 characters. validation.passwordTooLong=Введенный пароль слишком длинный. Его длина не должна превышать 50 символов. validation.sortCodeNumber={0} должен состоять из {1} цифр. diff --git a/core/src/main/resources/i18n/displayStrings_th.properties b/core/src/main/resources/i18n/displayStrings_th.properties index 396f6cf55d..3cd46771b8 100644 --- a/core/src/main/resources/i18n/displayStrings_th.properties +++ b/core/src/main/resources/i18n/displayStrings_th.properties @@ -1511,8 +1511,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=ป้อนรหัสผ่านเพื่อปลดล็อก torNetworkSettingWindow.header=ตั้งค่าเครือข่าย Tor @@ -2152,11 +2152,11 @@ validation.NaN=การป้อนข้อมูลไม่ใช่ตั validation.notAnInteger=ค่าที่ป้อนไม่ใช่ค่าจำนวนเต็ม validation.zero=ไม่อนุญาตให้ป้อนข้อมูลเป็น 0 validation.negative=ไม่อนุญาตให้ใช้ค่าลบ -validation.fiat.toSmall=ไม่อนุญาตให้ป้อนข้อมูลที่มีขนาดเล็กกว่าจำนวนเป็นไปได้ต่ำสุด -validation.fiat.toLarge=ไม่อนุญาตให้ป้อนข้อมูลที่มีขนาดใหญ่กว่าจำนวนสูงสุดที่เป็นไปได้ -validation.btc.fraction=Input will result in a bitcoin value of less than 1 satoshi -validation.btc.toLarge=ไม่อนุญาตให้ป้อนข้อมูลขนาดใหญ่กว่า {0} -validation.btc.toSmall=ไม่อนุญาตให้ป้อนข้อมูลที่มีขนาดเล็กกว่า {0} +validation.fiat.tooSmall=ไม่อนุญาตให้ป้อนข้อมูลที่มีขนาดเล็กกว่าจำนวนเป็นไปได้ต่ำสุด +validation.fiat.tooLarge=ไม่อนุญาตให้ป้อนข้อมูลที่มีขนาดใหญ่กว่าจำนวนสูงสุดที่เป็นไปได้ +validation.xmr.fraction=Input will result in a bitcoin value of less than 1 satoshi +validation.xmr.tooLarge=ไม่อนุญาตให้ป้อนข้อมูลขนาดใหญ่กว่า {0} +validation.xmr.tooSmall=ไม่อนุญาตให้ป้อนข้อมูลที่มีขนาดเล็กกว่า {0} validation.passwordTooShort=The password you entered is too short. It needs to have a min. of 8 characters. validation.passwordTooLong=รหัสผ่านที่คุณป้อนยาวเกินไป ต้องมีความยาวไม่เกิน 50 ตัว validation.sortCodeNumber={0} ต้องประกอบด้วย {1} ตัวเลข diff --git a/core/src/main/resources/i18n/displayStrings_vi.properties b/core/src/main/resources/i18n/displayStrings_vi.properties index 898a95036a..c46596b034 100644 --- a/core/src/main/resources/i18n/displayStrings_vi.properties +++ b/core/src/main/resources/i18n/displayStrings_vi.properties @@ -1513,8 +1513,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=Nhập mật khẩu để mở khóa torNetworkSettingWindow.header=Cài đặt mạng Tor @@ -2154,11 +2154,11 @@ validation.NaN=Giá trị nhập là số không có hiệu lực. validation.notAnInteger=Giá trị nhập không phải là một số nguyên. validation.zero=Không cho phép nhập giá trị 0. validation.negative=Không cho phép nhập giá trị âm. -validation.fiat.toSmall=Không cho phép giá trị nhập nhỏ hơn giá trị có thể nhỏ nhất. -validation.fiat.toLarge=Không cho phép giá trị nhập lớn hơn giá trị có thể lớn nhất. -validation.btc.fraction=Input will result in a bitcoin value of less than 1 satoshi -validation.btc.toLarge=Không cho phép giá trị nhập lớn hơn {0}. -validation.btc.toSmall=Không cho phép giá trị nhập nhỏ hơn {0}. +validation.fiat.tooSmall=Không cho phép giá trị nhập nhỏ hơn giá trị có thể nhỏ nhất. +validation.fiat.tooLarge=Không cho phép giá trị nhập lớn hơn giá trị có thể lớn nhất. +validation.xmr.fraction=Input will result in a bitcoin value of less than 1 satoshi +validation.xmr.tooLarge=Không cho phép giá trị nhập lớn hơn {0}. +validation.xmr.tooSmall=Không cho phép giá trị nhập nhỏ hơn {0}. validation.passwordTooShort=The password you entered is too short. It needs to have a min. of 8 characters. validation.passwordTooLong=Mật khẩu bạn vừa nhập quá dài. Không được quá 50 ký tự. validation.sortCodeNumber={0} phải có {1} số. diff --git a/core/src/main/resources/i18n/displayStrings_zh-hans.properties b/core/src/main/resources/i18n/displayStrings_zh-hans.properties index 61dfdd0a44..d3f372ccf7 100644 --- a/core/src/main/resources/i18n/displayStrings_zh-hans.properties +++ b/core/src/main/resources/i18n/displayStrings_zh-hans.properties @@ -1512,8 +1512,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=输入密码解锁 @@ -2156,11 +2156,11 @@ validation.NaN=输入的不是有效数字。 validation.notAnInteger=输入的不是整数。 validation.zero=不允许输入0。 validation.negative=不允许输入负值。 -validation.fiat.toSmall=不允许输入比最小可能值还小的数值。 -validation.fiat.toLarge=不允许输入比最大可能值还大的数值。 -validation.btc.fraction=此充值将会产生小于 1 聪的比特币数量。 -validation.btc.toLarge=不允许充值大于{0} -validation.btc.toSmall=不允许充值小于{0} +validation.fiat.tooSmall=不允许输入比最小可能值还小的数值。 +validation.fiat.tooLarge=不允许输入比最大可能值还大的数值。 +validation.xmr.fraction=此充值将会产生小于 1 聪的比特币数量。 +validation.xmr.tooLarge=不允许充值大于{0} +validation.xmr.tooSmall=不允许充值小于{0} validation.passwordTooShort=你输入的密码太短。最少 8 个字符。 validation.passwordTooLong=你输入的密码太长。最长不要超过50个字符。 validation.sortCodeNumber={0} 必须由 {1} 个数字构成。 diff --git a/core/src/main/resources/i18n/displayStrings_zh-hant.properties b/core/src/main/resources/i18n/displayStrings_zh-hant.properties index 62ff133864..22682014a6 100644 --- a/core/src/main/resources/i18n/displayStrings_zh-hant.properties +++ b/core/src/main/resources/i18n/displayStrings_zh-hant.properties @@ -1512,8 +1512,8 @@ closedTradesSummaryWindow.totalAmount.value={0} ({1} with current market price) closedTradesSummaryWindow.totalVolume.title=Total amount traded in {0} closedTradesSummaryWindow.totalMinerFee.title=Sum of all miner fees closedTradesSummaryWindow.totalMinerFee.value={0} ({1} of total trade amount) -closedTradesSummaryWindow.totalTradeFeeInBtc.title=Sum of all trade fees paid in BTC -closedTradesSummaryWindow.totalTradeFeeInBtc.value={0} ({1} of total trade amount) +closedTradesSummaryWindow.totalTradeFeeInXmr.title=Sum of all trade fees paid in BTC +closedTradesSummaryWindow.totalTradeFeeInXmr.value={0} ({1} of total trade amount) walletPasswordWindow.headline=輸入密碼解鎖 torNetworkSettingWindow.header=Tor 網絡設置 @@ -2152,11 +2152,11 @@ validation.NaN=輸入的不是有效數字。 validation.notAnInteger=輸入的不是整數。 validation.zero=不允許輸入0。 validation.negative=不允許輸入負值。 -validation.fiat.toSmall=不允許輸入比最小可能值還小的數值。 -validation.fiat.toLarge=不允許輸入比最大可能值還大的數值。 -validation.btc.fraction=此充值將會產生小於 1 聰的比特幣數量。 -validation.btc.toLarge=不允許充值大於{0} -validation.btc.toSmall=不允許充值小於{0} +validation.fiat.tooSmall=不允許輸入比最小可能值還小的數值。 +validation.fiat.tooLarge=不允許輸入比最大可能值還大的數值。 +validation.xmr.fraction=此充值將會產生小於 1 聰的比特幣數量。 +validation.xmr.tooLarge=不允許充值大於{0} +validation.xmr.tooSmall=不允許充值小於{0} validation.passwordTooShort=你輸入的密碼太短。最少 8 個字符。 validation.passwordTooLong=你輸入的密碼太長。最長不要超過50個字符。 validation.sortCodeNumber={0} 必須由 {1} 個數字構成。 diff --git a/core/src/test/java/haveno/core/util/coin/CoinUtilTest.java b/core/src/test/java/haveno/core/util/coin/CoinUtilTest.java index a507a5b329..8d6e11f0e8 100644 --- a/core/src/test/java/haveno/core/util/coin/CoinUtilTest.java +++ b/core/src/test/java/haveno/core/util/coin/CoinUtilTest.java @@ -67,8 +67,8 @@ public class CoinUtilTest { 1); assertEquals( "Minimum trade amount allowed should be adjusted to the smallest trade allowed.", - HavenoUtils.formatToXmrWithCode(Restrictions.MIN_TRADE_AMOUNT), - HavenoUtils.formatToXmrWithCode(result) + HavenoUtils.formatXmr(Restrictions.MIN_TRADE_AMOUNT, true), + HavenoUtils.formatXmr(result, true) ); try { @@ -94,7 +94,7 @@ public class CoinUtilTest { assertEquals( "Minimum allowed trade amount should not be adjusted.", "0.10 XMR", - HavenoUtils.formatToXmrWithCode(result) + HavenoUtils.formatXmr(result, true) ); result = CoinUtil.getAdjustedAmount( @@ -105,7 +105,7 @@ public class CoinUtilTest { assertEquals( "Minimum trade amount allowed should respect maxTradeLimit and factor, if possible.", "0.10 XMR", - HavenoUtils.formatToXmrWithCode(result) + HavenoUtils.formatXmr(result, true) ); // TODO(chirhonul): The following seems like it should raise an exception or otherwise fail. @@ -121,7 +121,7 @@ public class CoinUtilTest { assertEquals( "Minimum trade amount allowed with low maxTradeLimit should still respect that limit, even if result does not respect the factor specified.", "0.00005 XMR", - HavenoUtils.formatToXmrWithCode(result) + HavenoUtils.formatXmr(result, true) ); } } diff --git a/desktop/src/main/java/haveno/desktop/components/AccountStatusTooltipLabel.java b/desktop/src/main/java/haveno/desktop/components/AccountStatusTooltipLabel.java index bc91b570aa..bf7ad0a976 100644 --- a/desktop/src/main/java/haveno/desktop/components/AccountStatusTooltipLabel.java +++ b/desktop/src/main/java/haveno/desktop/components/AccountStatusTooltipLabel.java @@ -56,7 +56,7 @@ public class AccountStatusTooltipLabel extends AutoTooltipLabel { this.textIcon = FormBuilder.getIcon(witnessAgeData.getIcon()); this.popupTitle = witnessAgeData.isLimitLifted() ? Res.get("offerbook.timeSinceSigning.tooltip.accountLimitLifted") - : Res.get("offerbook.timeSinceSigning.tooltip.accountLimit", HavenoUtils.formatToXmrWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT)); + : Res.get("offerbook.timeSinceSigning.tooltip.accountLimit", HavenoUtils.formatXmr(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT, true)); positionAndActivateIcon(); } diff --git a/desktop/src/main/java/haveno/desktop/components/BalanceTextField.java b/desktop/src/main/java/haveno/desktop/components/BalanceTextField.java index db29498da5..9ec2e5164d 100644 --- a/desktop/src/main/java/haveno/desktop/components/BalanceTextField.java +++ b/desktop/src/main/java/haveno/desktop/components/BalanceTextField.java @@ -82,7 +82,7 @@ public class BalanceTextField extends AnchorPane { private void updateBalance(BigInteger balance) { if (formatter != null) - textField.setText(HavenoUtils.formatToXmrWithCode(balance)); + textField.setText(HavenoUtils.formatXmr(balance, true)); //TODO: replace with new validation logic // if (targetAmount != null) { diff --git a/desktop/src/main/java/haveno/desktop/main/account/content/fiataccounts/FiatAccountsView.java b/desktop/src/main/java/haveno/desktop/main/account/content/fiataccounts/FiatAccountsView.java index 6f09f76d89..60423a57f2 100644 --- a/desktop/src/main/java/haveno/desktop/main/account/content/fiataccounts/FiatAccountsView.java +++ b/desktop/src/main/java/haveno/desktop/main/account/content/fiataccounts/FiatAccountsView.java @@ -285,17 +285,17 @@ public class FiatAccountsView extends PaymentAccountsView { amountFocusListener = (observable, oldValue, newValue) -> { if (oldValue && !newValue) { if (amount.compareTo(BigInteger.valueOf(0)) > 0) - amountTextField.setText(HavenoUtils.formatToXmr(amount)); + amountTextField.setText(HavenoUtils.formatXmr(amount)); else amountTextField.setText(""); } @@ -186,10 +186,10 @@ public class WithdrawalView extends ActivatableView { BigInteger sendersAmount = receiverAmount; BigInteger fee = tx.getFee(); String messageText = Res.get("shared.sendFundsDetailsWithFee", - HavenoUtils.formatToXmrWithCode(sendersAmount), + HavenoUtils.formatXmr(sendersAmount, true), withdrawToAddress, - HavenoUtils.formatToXmrWithCode(fee), - HavenoUtils.formatToXmrWithCode(receiverAmount)); + HavenoUtils.formatXmr(fee, true), + HavenoUtils.formatXmr(receiverAmount, true)); // popup confirmation message new Popup().headLine(Res.get("funds.withdrawal.confirmWithdrawalRequest")) @@ -203,7 +203,7 @@ public class WithdrawalView extends ActivatableView { xmrWalletService.getWallet().setTxNote(tx.getHash(), withdrawMemoTextField.getText()); // TODO (monero-java): tx note does not persist when tx created then relayed String key = "showTransactionSent"; if (DontShowAgainLookup.showAgain(key)) { - new TxDetails(tx.getHash(), withdrawToAddress, HavenoUtils.formatToXmrWithCode(sendersAmount), HavenoUtils.formatToXmrWithCode(fee), xmrWalletService.getWallet().getTxNote(tx.getHash())) + new TxDetails(tx.getHash(), withdrawToAddress, HavenoUtils.formatXmr(sendersAmount, true), HavenoUtils.formatXmr(fee, true), xmrWalletService.getWallet().getTxNote(tx.getHash())) .dontShowAgainId(key) .show(); } diff --git a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadView.java b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadView.java index 3df8e883d0..4121b36ba7 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadView.java +++ b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadView.java @@ -129,7 +129,7 @@ public class SpreadView extends ActivatableViewAndModel { numberOfOffersColumn.setGraphic(new AutoTooltipLabel(Res.get("market.spread.numberOfOffersColumn", numberOfOffers))); diff --git a/desktop/src/main/java/haveno/desktop/main/market/trades/charts/volume/VolumeBar.java b/desktop/src/main/java/haveno/desktop/main/market/trades/charts/volume/VolumeBar.java index 5a3a3d1617..061cb262b4 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/trades/charts/volume/VolumeBar.java +++ b/desktop/src/main/java/haveno/desktop/main/market/trades/charts/volume/VolumeBar.java @@ -54,9 +54,9 @@ public class VolumeBar extends Group { public void update(double height, double candleWidth, CandleData candleData) { bar.resizeRelocate(-candleWidth / 2, 0, candleWidth, height); - String volumeInBtc = volumeStringConverter.toString(candleData.accumulatedAmount); + String volumeInXmr = volumeStringConverter.toString(candleData.accumulatedAmount); String volumeInUsd = VolumeUtil.formatLargeFiat(candleData.volumeInUsd, "USD"); - tooltip.setText(Res.get("market.trades.tooltip.volumeBar", volumeInBtc, volumeInUsd, candleData.numTrades, candleData.date)); + tooltip.setText(Res.get("market.trades.tooltip.volumeBar", volumeInXmr, volumeInUsd, candleData.numTrades, candleData.date)); } private void updateStyleClasses() { diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java index c91606839a..229e4a060b 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java @@ -17,7 +17,6 @@ package haveno.desktop.main.offer; -import org.bitcoinj.core.Coin; import org.jetbrains.annotations.NotNull; import com.google.inject.Inject; import haveno.common.handlers.ErrorMessageHandler; @@ -290,7 +289,6 @@ public abstract class MutableOfferDataModel extends OfferDataModel { amount.get(), minAmount.get(), useMarketBasedPrice.get() ? null : price.get(), - Coin.ZERO, useMarketBasedPrice.get(), marketPriceMargin, buyerSecurityDepositPct.get(), diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java index 435173b304..0fa96690fe 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java @@ -136,7 +136,7 @@ public abstract class MutableOfferView> exten private FundsTextField totalToPayTextField; private Label amountDescriptionLabel, priceCurrencyLabel, priceDescriptionLabel, volumeDescriptionLabel, waitingForFundsLabel, marketBasedPriceLabel, percentagePriceDescriptionLabel, tradeFeeDescriptionLabel, - resultLabel, tradeFeeInBtcLabel, xLabel, fakeXLabel, buyerSecurityDepositLabel, + resultLabel, tradeFeeInXmrLabel, xLabel, fakeXLabel, buyerSecurityDepositLabel, buyerSecurityDepositPercentageLabel, triggerPriceCurrencyLabel, triggerPriceDescriptionLabel; protected Label amountBtcLabel, volumeCurrencyLabel, minAmountBtcLabel; private ComboBox paymentAccountsComboBox; @@ -548,7 +548,7 @@ public abstract class MutableOfferView> exten addressTextField.amountAsProperty().bind(model.getDataModel().getMissingCoin()); buyerSecurityDepositInputTextField.textProperty().bindBidirectional(model.buyerSecurityDeposit); buyerSecurityDepositLabel.textProperty().bind(model.buyerSecurityDepositLabel); - tradeFeeInBtcLabel.textProperty().bind(model.tradeFeeInBtcWithFiat); + tradeFeeInXmrLabel.textProperty().bind(model.tradeFeeInXmrWithFiat); tradeFeeDescriptionLabel.textProperty().bind(model.tradeFeeDescription); // Validation @@ -596,9 +596,9 @@ public abstract class MutableOfferView> exten addressTextField.amountAsProperty().unbind(); buyerSecurityDepositInputTextField.textProperty().unbindBidirectional(model.buyerSecurityDeposit); buyerSecurityDepositLabel.textProperty().unbind(); - tradeFeeInBtcLabel.textProperty().unbind(); + tradeFeeInXmrLabel.textProperty().unbind(); tradeFeeDescriptionLabel.textProperty().unbind(); - tradeFeeInBtcLabel.visibleProperty().unbind(); + tradeFeeInXmrLabel.visibleProperty().unbind(); tradeFeeDescriptionLabel.visibleProperty().unbind(); // Validation @@ -731,7 +731,7 @@ public abstract class MutableOfferView> exten if (newValue) { Notification walletFundedNotification = new Notification() .headLine(Res.get("notification.walletUpdate.headline")) - .notification(Res.get("notification.walletUpdate.msg", HavenoUtils.formatToXmrWithCode(model.getDataModel().getTotalToPay().get()))) + .notification(Res.get("notification.walletUpdate.msg", HavenoUtils.formatXmr(model.getDataModel().getTotalToPay().get(), true))) .autoClose(); walletFundedNotification.show(); @@ -1347,14 +1347,14 @@ public abstract class MutableOfferView> exten } private VBox getTradeFeeFieldsBox() { - tradeFeeInBtcLabel = new Label(); - tradeFeeInBtcLabel.setMouseTransparent(true); - tradeFeeInBtcLabel.setId("trade-fee-textfield"); + tradeFeeInXmrLabel = new Label(); + tradeFeeInXmrLabel.setMouseTransparent(true); + tradeFeeInXmrLabel.setId("trade-fee-textfield"); VBox vBox = new VBox(); vBox.setSpacing(6); vBox.setMaxWidth(300); vBox.setAlignment(Pos.CENTER_LEFT); - vBox.getChildren().addAll(tradeFeeInBtcLabel); + vBox.getChildren().addAll(tradeFeeInXmrLabel); HBox hBox = new HBox(); hBox.getChildren().addAll(vBox); diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java index ae869a34c4..025806f00c 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java @@ -121,7 +121,7 @@ public abstract class MutableOfferViewModel ext public final StringProperty price = new SimpleStringProperty(); public final StringProperty triggerPrice = new SimpleStringProperty(""); final StringProperty tradeFee = new SimpleStringProperty(); - final StringProperty tradeFeeInBtcWithFiat = new SimpleStringProperty(); + final StringProperty tradeFeeInXmrWithFiat = new SimpleStringProperty(); final StringProperty tradeFeeCurrencyCode = new SimpleStringProperty(); final StringProperty tradeFeeDescription = new SimpleStringProperty(); final BooleanProperty isTradeFeeVisible = new SimpleBooleanProperty(false); @@ -271,10 +271,10 @@ public abstract class MutableOfferViewModel ext () -> Res.get("createOffer.volume.prompt", dataModel.getTradeCurrencyCode().get()), dataModel.getTradeCurrencyCode())); - totalToPay.bind(createStringBinding(() -> HavenoUtils.formatToXmrWithCode(dataModel.totalToPayAsProperty().get()), + totalToPay.bind(createStringBinding(() -> HavenoUtils.formatXmr(dataModel.totalToPayAsProperty().get(), true), dataModel.totalToPayAsProperty())); - tradeAmount.bind(createStringBinding(() -> HavenoUtils.formatToXmrWithCode(dataModel.getAmount().get()), + tradeAmount.bind(createStringBinding(() -> HavenoUtils.formatXmr(dataModel.getAmount().get(), true), dataModel.getAmount())); tradeCurrencyCode.bind(dataModel.getTradeCurrencyCode()); @@ -433,8 +433,8 @@ public abstract class MutableOfferViewModel ext amountListener = (ov, oldValue, newValue) -> { if (newValue != null) { - amount.set(HavenoUtils.formatToXmr(newValue)); - buyerSecurityDepositInBTC.set(HavenoUtils.formatToXmrWithCode(dataModel.getBuyerSecurityDeposit())); + amount.set(HavenoUtils.formatXmr(newValue)); + buyerSecurityDepositInBTC.set(HavenoUtils.formatXmr(dataModel.getBuyerSecurityDeposit(), true)); } else { amount.set(""); buyerSecurityDepositInBTC.set(""); @@ -444,7 +444,7 @@ public abstract class MutableOfferViewModel ext }; minAmountListener = (ov, oldValue, newValue) -> { if (newValue != null) - minAmount.set(HavenoUtils.formatToXmr(newValue)); + minAmount.set(HavenoUtils.formatXmr(newValue)); else minAmount.set(""); }; @@ -473,7 +473,7 @@ public abstract class MutableOfferViewModel ext if (newValue != null) { buyerSecurityDeposit.set(FormattingUtils.formatToPercent((double) newValue)); if (dataModel.getAmount().get() != null) { - buyerSecurityDepositInBTC.set(HavenoUtils.formatToXmrWithCode(dataModel.getBuyerSecurityDeposit())); + buyerSecurityDepositInBTC.set(HavenoUtils.formatXmr(dataModel.getBuyerSecurityDeposit(), true)); } updateBuyerSecurityDeposit(); } else { @@ -504,8 +504,8 @@ public abstract class MutableOfferViewModel ext } isTradeFeeVisible.setValue(true); - tradeFee.set(HavenoUtils.formatToXmr(makerFee)); - tradeFeeInBtcWithFiat.set(OfferViewModelUtil.getTradeFeeWithFiatEquivalent(offerUtil, + tradeFee.set(HavenoUtils.formatXmr(makerFee)); + tradeFeeInXmrWithFiat.set(OfferViewModelUtil.getTradeFeeWithFiatEquivalent(offerUtil, dataModel.getMakerFee(), btcFormatter)); } @@ -659,8 +659,8 @@ public abstract class MutableOfferViewModel ext updateButtonDisableState(); } else { new Popup().warning(Res.get("shared.notEnoughFunds", - HavenoUtils.formatToXmrWithCode(dataModel.totalToPayAsProperty().get()), - HavenoUtils.formatToXmrWithCode(dataModel.getTotalBalance()))) + HavenoUtils.formatXmr(dataModel.totalToPayAsProperty().get(), true), + HavenoUtils.formatXmr(dataModel.getTotalBalance(), true))) .actionButtonTextWithGoTo("navigation.funds.depositFunds") .onAction(() -> navigation.navigateTo(MainView.class, FundsView.class, DepositView.class)) .show(); @@ -680,7 +680,7 @@ public abstract class MutableOfferViewModel ext if (result.isValid) { setAmountToModel(); ignoreAmountStringListener = true; - amount.set(HavenoUtils.formatToXmr(dataModel.getAmount().get())); + amount.set(HavenoUtils.formatXmr(dataModel.getAmount().get())); ignoreAmountStringListener = false; dataModel.calculateVolume(); @@ -692,10 +692,10 @@ public abstract class MutableOfferViewModel ext if (minAmount.get() != null) minAmountValidationResult.set(isXmrInputValid(minAmount.get())); } else if (amount.get() != null && xmrValidator.getMaxTradeLimit() != null && xmrValidator.getMaxTradeLimit().longValueExact() == OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT.longValueExact()) { - amount.set(HavenoUtils.formatToXmr(xmrValidator.getMaxTradeLimit())); + amount.set(HavenoUtils.formatXmr(xmrValidator.getMaxTradeLimit())); boolean isBuy = dataModel.getDirection() == OfferDirection.BUY; new Popup().information(Res.get(isBuy ? "popup.warning.tradeLimitDueAccountAgeRestriction.buyer" : "popup.warning.tradeLimitDueAccountAgeRestriction.seller", - HavenoUtils.formatToXmrWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT), + HavenoUtils.formatXmr(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT, true), Res.get("offerbook.warning.newVersionAnnouncement"))) .width(900) .show(); @@ -732,7 +732,7 @@ public abstract class MutableOfferViewModel ext updateButtonDisableState(); } - this.minAmount.set(HavenoUtils.formatToXmr(minAmount)); + this.minAmount.set(HavenoUtils.formatXmr(minAmount)); if (!dataModel.isMinAmountLessOrEqualAmount()) { this.amount.set(this.minAmount.get()); @@ -990,7 +990,7 @@ public abstract class MutableOfferViewModel ext } public String getSecurityDepositWithCode() { - return HavenoUtils.formatToXmrWithCode(dataModel.getSecurityDeposit()); + return HavenoUtils.formatXmr(dataModel.getSecurityDeposit(), true); } @@ -1219,7 +1219,7 @@ public abstract class MutableOfferViewModel ext if (dataModel.isMinBuyerSecurityDeposit()) { buyerSecurityDepositLabel.set(Res.get("createOffer.minSecurityDepositUsed")); - buyerSecurityDeposit.set(HavenoUtils.formatToXmr(Restrictions.getMinBuyerSecurityDeposit())); + buyerSecurityDeposit.set(HavenoUtils.formatXmr(Restrictions.getMinBuyerSecurityDeposit())); } else { buyerSecurityDepositLabel.set(getSecurityDepositLabel()); buyerSecurityDeposit.set(FormattingUtils.formatToPercent(dataModel.getBuyerSecurityDepositPct().get())); diff --git a/desktop/src/main/java/haveno/desktop/main/offer/OfferViewModelUtil.java b/desktop/src/main/java/haveno/desktop/main/offer/OfferViewModelUtil.java index 5f46caf266..36d71f310a 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/OfferViewModelUtil.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/OfferViewModelUtil.java @@ -45,7 +45,7 @@ public class OfferViewModelUtil { BigInteger tradeAmount, CoinFormatter formatter, BigInteger minTradeFee) { - String feeAsBtc = HavenoUtils.formatToXmrWithCode(tradeFee); + String feeAsBtc = HavenoUtils.formatXmr(tradeFee, true); String percentage; if (tradeFee.compareTo(minTradeFee) <= 0) { percentage = Res.get("guiUtil.requiredMinimum") diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookView.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookView.java index 33ab469952..134edc0025 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookView.java @@ -1185,7 +1185,7 @@ abstract public class OfferBookView CurrencyUtil.getCounterCurrency(model.dataModel.getCurrencyCode()))); priceAsPercentageLabel.prefWidthProperty().bind(priceCurrencyLabel.widthProperty()); nextButton.disableProperty().bind(model.isNextButtonDisabled); - tradeFeeInBtcLabel.textProperty().bind(model.tradeFeeInXmrWithFiat); + tradeFeeInXmrLabel.textProperty().bind(model.tradeFeeInXmrWithFiat); tradeFeeDescriptionLabel.textProperty().bind(model.tradeFeeDescription); - tradeFeeInBtcLabel.visibleProperty().bind(model.isTradeFeeVisible); + tradeFeeInXmrLabel.visibleProperty().bind(model.isTradeFeeVisible); tradeFeeDescriptionLabel.visibleProperty().bind(model.isTradeFeeVisible); tradeFeeDescriptionLabel.managedProperty().bind(tradeFeeDescriptionLabel.visibleProperty()); @@ -567,9 +567,9 @@ public class TakeOfferView extends ActivatableViewAndModel im volumeDescriptionLabel.set(Res.get(sellVolumeDescriptionKey, dataModel.getCurrencyCode())); } - amount.set(HavenoUtils.formatToXmr(dataModel.getAmount().get())); + amount.set(HavenoUtils.formatXmr(dataModel.getAmount().get())); showTransactionPublishedScreen.set(false); // when getting back to an open screen we want to re-check again @@ -207,7 +207,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel im ? Res.get(buyAmountDescriptionKey) : Res.get(sellAmountDescriptionKey); - amountRange = HavenoUtils.formatToXmr(offer.getMinAmount()) + " - " + HavenoUtils.formatToXmr(offer.getAmount()); + amountRange = HavenoUtils.formatXmr(offer.getMinAmount()) + " - " + HavenoUtils.formatXmr(offer.getAmount()); price = FormattingUtils.formatPrice(dataModel.tradePrice); marketPriceMargin = FormattingUtils.formatToPercent(offer.getMarketPriceMarginPct()); paymentLabel = Res.get("takeOffer.fundsBox.paymentLabel", offer.getShortId()); @@ -263,8 +263,8 @@ class TakeOfferViewModel extends ActivatableWithDataModel im return true; } else { new Popup().warning(Res.get("shared.notEnoughFunds", - HavenoUtils.formatToXmrWithCode(dataModel.getTotalToPay().get()), - HavenoUtils.formatToXmrWithCode(dataModel.getTotalAvailableBalance()))) + HavenoUtils.formatXmr(dataModel.getTotalToPay().get(), true), + HavenoUtils.formatXmr(dataModel.getTotalAvailableBalance(), true))) .actionButtonTextWithGoTo("navigation.funds.depositFunds") .onAction(() -> navigation.navigateTo(MainView.class, FundsView.class, DepositView.class)) .show(); @@ -280,7 +280,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel im } isTradeFeeVisible.setValue(true); - tradeFee.set(HavenoUtils.formatToXmr(takerFee)); + tradeFee.set(HavenoUtils.formatXmr(takerFee)); tradeFeeInXmrWithFiat.set(OfferViewModelUtil.getTradeFeeWithFiatEquivalent(offerUtil, dataModel.getTakerFee(), xmrFormatter)); @@ -301,7 +301,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel im // only allow max 4 decimal places for btc values setAmountToModel(); // reformat input - amount.set(HavenoUtils.formatToXmr(dataModel.getAmount().get())); + amount.set(HavenoUtils.formatXmr(dataModel.getAmount().get())); calculateVolume(); @@ -312,7 +312,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel im tradePrice, maxTradeLimit); dataModel.applyAmount(adjustedAmountForHalCash); - amount.set(HavenoUtils.formatToXmr(dataModel.getAmount().get())); + amount.set(HavenoUtils.formatXmr(dataModel.getAmount().get())); } else if (dataModel.getOffer().isFiatOffer()) { if (!isAmountEqualMinAmount(dataModel.getAmount().get()) && (!isAmountEqualMaxAmount(dataModel.getAmount().get()))) { // We only apply the rounding if the amount is variable (minAmount is lower as amount). @@ -321,7 +321,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel im maxTradeLimit); dataModel.applyAmount(roundedAmount); } - amount.set(HavenoUtils.formatToXmr(dataModel.getAmount().get())); + amount.set(HavenoUtils.formatXmr(dataModel.getAmount().get())); } if (!dataModel.isMinAmountLessOrEqualAmount()) @@ -338,13 +338,13 @@ class TakeOfferViewModel extends ActivatableWithDataModel im } else if (btcValidator.getMaxTradeLimit() != null && btcValidator.getMaxTradeLimit().equals(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT)) { if (dataModel.getDirection() == OfferDirection.BUY) { new Popup().information(Res.get("popup.warning.tradeLimitDueAccountAgeRestriction.seller", - HavenoUtils.formatToXmrWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT), + HavenoUtils.formatXmr(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT, true), Res.get("offerbook.warning.newVersionAnnouncement"))) .width(900) .show(); } else { new Popup().information(Res.get("popup.warning.tradeLimitDueAccountAgeRestriction.buyer", - HavenoUtils.formatToXmrWithCode(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT), + HavenoUtils.formatXmr(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT, true), Res.get("offerbook.warning.newVersionAnnouncement"))) .width(900) .show(); @@ -466,7 +466,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel im private void addBindings() { volume.bind(createStringBinding(() -> VolumeUtil.formatVolume(dataModel.volume.get()), dataModel.volume)); - totalToPay.bind(createStringBinding(() -> HavenoUtils.formatToXmrWithCode(dataModel.getTotalToPay().get()), dataModel.getTotalToPay())); + totalToPay.bind(createStringBinding(() -> HavenoUtils.formatXmr(dataModel.getTotalToPay().get(), true), dataModel.getTotalToPay())); } @@ -487,7 +487,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel im updateButtonDisableState(); }; amountListener = (ov, oldValue, newValue) -> { - amount.set(HavenoUtils.formatToXmr(newValue)); + amount.set(HavenoUtils.formatXmr(newValue)); applyTakerFee(); }; isWalletFundedListener = (ov, oldValue, newValue) -> updateButtonDisableState(); @@ -682,7 +682,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel im } public String getSecurityDepositWithCode() { - return HavenoUtils.formatToXmrWithCode(dataModel.getSecurityDeposit()); + return HavenoUtils.formatXmr(dataModel.getSecurityDeposit(), true); } public String getTradeFee() { diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/ClosedTradesSummaryWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/ClosedTradesSummaryWindow.java index 6deaaf1126..a21213b619 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/ClosedTradesSummaryWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/ClosedTradesSummaryWindow.java @@ -24,12 +24,12 @@ import haveno.core.locale.Res; import haveno.desktop.main.overlays.Overlay; import haveno.desktop.main.portfolio.closedtrades.ClosedTradesViewModel; import haveno.desktop.util.Layout; -import org.bitcoinj.core.Coin; import javax.inject.Inject; import javafx.geometry.Insets; +import java.math.BigInteger; import java.util.Map; public class ClosedTradesSummaryWindow extends Overlay { @@ -66,7 +66,7 @@ public class ClosedTradesSummaryWindow extends Overlay totalVolumeByCurrency = model.getTotalVolumeByCurrency(); int rowSpan = totalVolumeByCurrency.size() + 4; addTitledGroupBg(gridPane, rowIndex, rowSpan, Res.get("closedTradesSummaryWindow.headline")); - Coin totalTradeAmount = model.getTotalTradeAmount(); + BigInteger totalTradeAmount = model.getTotalTradeAmount(); addConfirmationLabelLabel(gridPane, rowIndex, Res.get("closedTradesSummaryWindow.totalAmount.title"), model.getTotalAmountWithVolume(totalTradeAmount), Layout.TWICE_FIRST_ROW_DISTANCE); @@ -78,7 +78,7 @@ public class ClosedTradesSummaryWindow extends Overlay { addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradePrice"), FormattingUtils.formatPrice(contract.getPrice())); addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.tradeAmount"), - HavenoUtils.formatToXmrWithCode(contract.getTradeAmount())); + HavenoUtils.formatXmr(contract.getTradeAmount(), true)); addConfirmationLabelTextField(gridPane, ++rowIndex, VolumeUtil.formatVolumeLabel(currencyCode, ":"), VolumeUtil.formatVolumeWithCode(contract.getTradeVolume())); String securityDeposit = Res.getWithColAndCap("shared.buyer") + " " + - HavenoUtils.formatToXmrWithCode(offer.getBuyerSecurityDeposit()) + + HavenoUtils.formatXmr(offer.getBuyerSecurityDeposit(), true) + " / " + Res.getWithColAndCap("shared.seller") + " " + - HavenoUtils.formatToXmrWithCode(offer.getSellerSecurityDeposit()); + HavenoUtils.formatXmr(offer.getSellerSecurityDeposit(), true); addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit); addConfirmationLabelTextField(gridPane, ++rowIndex, diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/DisputeSummaryWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/DisputeSummaryWindow.java index e941e9b20e..493284737e 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/DisputeSummaryWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/DisputeSummaryWindow.java @@ -273,26 +273,26 @@ public class DisputeSummaryWindow extends Overlay { } addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.role"), role); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeAmount"), - HavenoUtils.formatToXmrWithCode(contract.getTradeAmount())); + HavenoUtils.formatXmr(contract.getTradeAmount(), true)); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"), FormattingUtils.formatPrice(contract.getPrice())); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeVolume"), VolumeUtil.formatVolumeWithCode(contract.getTradeVolume())); String tradeFee = Res.getWithColAndCap("shared.buyer") + " " + - HavenoUtils.formatToXmrWithCode(trade.getBuyer() == trade.getMaker() ? trade.getMakerFee() : trade.getTakerFee()) + + HavenoUtils.formatXmr(trade.getBuyer() == trade.getMaker() ? trade.getMakerFee() : trade.getTakerFee(), true) + " / " + Res.getWithColAndCap("shared.seller") + " " + - HavenoUtils.formatToXmrWithCode(trade.getSeller() == trade.getMaker() ? trade.getMakerFee() : trade.getTakerFee()); + HavenoUtils.formatXmr(trade.getSeller() == trade.getMaker() ? trade.getMakerFee() : trade.getTakerFee(), true); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeFee"), tradeFee); String securityDeposit = Res.getWithColAndCap("shared.buyer") + " " + - HavenoUtils.formatToXmrWithCode(trade.getBuyerSecurityDeposit()) + + HavenoUtils.formatXmr(trade.getBuyerSecurityDeposit(), true) + " / " + Res.getWithColAndCap("shared.seller") + " " + - HavenoUtils.formatToXmrWithCode(trade.getSellerSecurityDeposit()); + HavenoUtils.formatXmr(trade.getSellerSecurityDeposit(), true); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit); } @@ -388,10 +388,10 @@ public class DisputeSummaryWindow extends Overlay { if (enteredAmount.compareTo(available) > 0) { enteredAmount = available; BigInteger finalEnteredAmount = enteredAmount; - inputTextField.setText(HavenoUtils.formatToXmr(finalEnteredAmount)); + inputTextField.setText(HavenoUtils.formatXmr(finalEnteredAmount)); } BigInteger counterPart = available.subtract(enteredAmount); - String formattedCounterPartAmount = HavenoUtils.formatToXmr(counterPart); + String formattedCounterPartAmount = HavenoUtils.formatXmr(counterPart); BigInteger buyerAmount; BigInteger sellerAmount; if (inputTextField == buyerPayoutAmountInputTextField) { @@ -622,20 +622,20 @@ public class DisputeSummaryWindow extends Overlay { String buyerDetails = ""; if (buyerPayoutAmount.compareTo(BigInteger.valueOf(0)) > 0) { buyerDetails = Res.get("disputeSummaryWindow.close.txDetails.buyer", - HavenoUtils.formatToXmrWithCode(buyerPayoutAmount), + HavenoUtils.formatXmr(buyerPayoutAmount, true), buyerPayoutAddressString); } String sellerDetails = ""; if (sellerPayoutAmount.compareTo(BigInteger.valueOf(0)) > 0) { sellerDetails = Res.get("disputeSummaryWindow.close.txDetails.seller", - HavenoUtils.formatToXmrWithCode(sellerPayoutAmount), + HavenoUtils.formatXmr(sellerPayoutAmount, true), sellerPayoutAddressString); } if (outputAmount.compareTo(BigInteger.valueOf(0)) > 0) { new Popup().width(900) .headLine(Res.get("disputeSummaryWindow.close.txDetails.headline")) .confirmation(Res.get("disputeSummaryWindow.close.txDetails", - HavenoUtils.formatToXmrWithCode(outputAmount), + HavenoUtils.formatXmr(outputAmount, true), buyerDetails, sellerDetails, formatter.formatCoinWithCode(HavenoUtils.atomicUnitsToCoin(payoutTx.getFee())))) @@ -711,8 +711,8 @@ public class DisputeSummaryWindow extends Overlay { throw new IllegalStateException("Unknown radio button"); } disputesService.applyPayoutAmountsToDisputeResult(payout, dispute, disputeResult, -1); - buyerPayoutAmountInputTextField.setText(HavenoUtils.formatToXmr(disputeResult.getBuyerPayoutAmount())); - sellerPayoutAmountInputTextField.setText(HavenoUtils.formatToXmr(disputeResult.getSellerPayoutAmount())); + buyerPayoutAmountInputTextField.setText(HavenoUtils.formatXmr(disputeResult.getBuyerPayoutAmount())); + sellerPayoutAmountInputTextField.setText(HavenoUtils.formatXmr(disputeResult.getSellerPayoutAmount())); } private void applyTradeAmountRadioButtonStates() { @@ -724,8 +724,8 @@ public class DisputeSummaryWindow extends Overlay { BigInteger buyerPayoutAmount = disputeResult.getBuyerPayoutAmount(); BigInteger sellerPayoutAmount = disputeResult.getSellerPayoutAmount(); - buyerPayoutAmountInputTextField.setText(HavenoUtils.formatToXmr(buyerPayoutAmount)); - sellerPayoutAmountInputTextField.setText(HavenoUtils.formatToXmr(sellerPayoutAmount)); + buyerPayoutAmountInputTextField.setText(HavenoUtils.formatXmr(buyerPayoutAmount)); + sellerPayoutAmountInputTextField.setText(HavenoUtils.formatXmr(sellerPayoutAmount)); if (buyerPayoutAmount.equals(tradeAmount.add(buyerSecurityDeposit)) && sellerPayoutAmount.equals(sellerSecurityDeposit)) { diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java index 3d67980e86..d16bd68919 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/OfferDetailsWindow.java @@ -206,14 +206,14 @@ public class OfferDetailsWindow extends Overlay { String btcAmount = Res.get("shared.btcAmount"); if (takeOfferHandlerOptional.isPresent()) { addConfirmationLabelLabel(gridPane, ++rowIndex, btcAmount + btcDirectionInfo, - HavenoUtils.formatToXmrWithCode(tradeAmount)); + HavenoUtils.formatXmr(tradeAmount, true)); addConfirmationLabelLabel(gridPane, ++rowIndex, VolumeUtil.formatVolumeLabel(currencyCode) + fiatDirectionInfo, VolumeUtil.formatVolumeWithCode(offer.getVolumeByAmount(tradeAmount))); } else { addConfirmationLabelLabel(gridPane, ++rowIndex, btcAmount + btcDirectionInfo, - HavenoUtils.formatToXmrWithCode(offer.getAmount())); + HavenoUtils.formatXmr(offer.getAmount(), true)); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("offerDetailsWindow.minBtcAmount"), - HavenoUtils.formatToXmrWithCode(offer.getMinAmount())); + HavenoUtils.formatXmr(offer.getMinAmount(), true)); String volume = VolumeUtil.formatVolumeWithCode(offer.getVolume()); String minVolume = ""; if (offer.getVolume() != null && offer.getMinVolume() != null && @@ -322,11 +322,11 @@ public class OfferDetailsWindow extends Overlay { DisplayUtils.formatDateTime(offer.getDate())); String value = Res.getWithColAndCap("shared.buyer") + " " + - HavenoUtils.formatToXmrWithCode(offer.getBuyerSecurityDeposit()) + + HavenoUtils.formatXmr(offer.getBuyerSecurityDeposit(), true) + " / " + Res.getWithColAndCap("shared.seller") + " " + - HavenoUtils.formatToXmrWithCode(offer.getSellerSecurityDeposit()); + HavenoUtils.formatXmr(offer.getSellerSecurityDeposit(), true); addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), value); if (countryCode != null && !isF2F) diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java index 3cf194db9e..9df3dd114e 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/TradeDetailsWindow.java @@ -159,7 +159,7 @@ public class TradeDetailsWindow extends Overlay { } addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.btcAmount") + btcDirectionInfo, - HavenoUtils.formatToXmrWithCode(trade.getAmount())); + HavenoUtils.formatXmr(trade.getAmount(), true)); addConfirmationLabelTextField(gridPane, ++rowIndex, VolumeUtil.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo, VolumeUtil.formatVolumeWithCode(trade.getVolume())); @@ -212,11 +212,11 @@ public class TradeDetailsWindow extends Overlay { DisplayUtils.formatDateTime(trade.getDate())); String securityDeposit = Res.getWithColAndCap("shared.buyer") + " " + - HavenoUtils.formatToXmrWithCode(offer.getBuyerSecurityDeposit()) + + HavenoUtils.formatXmr(offer.getBuyerSecurityDeposit(), true) + " / " + Res.getWithColAndCap("shared.seller") + " " + - HavenoUtils.formatToXmrWithCode(offer.getSellerSecurityDeposit()); + HavenoUtils.formatXmr(offer.getSellerSecurityDeposit(), true); addConfirmationLabelTextField(gridPane, ++rowIndex, Res.get("shared.securityDeposit"), securityDeposit); NodeAddress arbitratorNodeAddress = trade.getArbitratorNodeAddress(); diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesDataModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesDataModel.java index 70a5cf69e6..98b8f479d0 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesDataModel.java @@ -17,8 +17,6 @@ package haveno.desktop.main.portfolio.closedtrades; -import org.bitcoinj.core.Coin; - import com.google.inject.Inject; import haveno.core.account.witness.AccountAgeWitnessService; import haveno.core.monetary.Price; @@ -37,6 +35,7 @@ import javafx.collections.FXCollections; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; +import java.math.BigInteger; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -85,15 +84,15 @@ class ClosedTradesDataModel extends ActivatableDataModel { return list.stream().map(ClosedTradesListItem::getTradable).collect(Collectors.toList()); } - Coin getTotalAmount() { + BigInteger getTotalAmount() { return ClosedTradableUtil.getTotalAmount(getListAsTradables()); } - Optional getVolumeInUserFiatCurrency(Coin amount) { + Optional getVolumeInUserFiatCurrency(BigInteger amount) { return getVolume(amount, preferences.getPreferredTradeCurrency().getCode()); } - Optional getVolume(Coin amount, String currencyCode) { + Optional getVolume(BigInteger amount, String currencyCode) { MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode); if (marketPrice == null) { return Optional.empty(); @@ -103,15 +102,11 @@ class ClosedTradesDataModel extends ActivatableDataModel { return Optional.of(VolumeUtil.getVolume(amount, price)); } - Volume getBsqVolumeInUsdWithAveragePrice(Coin amount) { - return closedTradableManager.getBsqVolumeInUsdWithAveragePrice(amount); - } - - Coin getTotalTxFee() { + BigInteger getTotalTxFee() { return ClosedTradableUtil.getTotalTxFee(getListAsTradables()); } - Coin getTotalTradeFee() { + BigInteger getTotalTradeFee() { return closedTradableManager.getTotalTradeFee(getListAsTradables()); } diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesListItem.java b/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesListItem.java index 9c7be1de61..4c4e691a6d 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesListItem.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesListItem.java @@ -84,7 +84,7 @@ public class ClosedTradesListItem implements FilterableListItem { } public String getTxFeeAsString() { - return closedTradableFormatter.getTxFeeAsString(tradable); + return closedTradableFormatter.getTotalTxFeeAsString(tradable); } public String getTradeFeeAsString(boolean appendCode) { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesViewModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesViewModel.java index 23179246de..d522ca9b98 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/closedtrades/ClosedTradesViewModel.java @@ -17,12 +17,12 @@ package haveno.desktop.main.portfolio.closedtrades; -import org.bitcoinj.core.Coin; - import com.google.inject.Inject; import haveno.core.trade.ClosedTradableFormatter; import haveno.desktop.common.model.ActivatableWithDataModel; import haveno.desktop.common.model.ViewModel; + +import java.math.BigInteger; import java.util.Map; public class ClosedTradesViewModel extends ActivatableWithDataModel implements ViewModel { @@ -39,11 +39,11 @@ public class ClosedTradesViewModel extends ActivatableWithDataModel closedTradableFormatter.getTotalAmountWithVolumeAsString(totalTradeAmount, volume)) .orElse(""); @@ -53,13 +53,13 @@ public class ClosedTradesViewModel extends ActivatableWithDataModel public String getMakerFeeAsString(OpenOffer openOffer) { Offer offer = openOffer.getOffer(); - return HavenoUtils.formatToXmrWithCode(offer.getMakerFee()); + return HavenoUtils.formatXmr(offer.getMakerFee(), true); } String getTriggerPrice(OpenOfferListItem item) { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java index 5b7732ea6b..b7c2fe7cce 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesDataModel.java @@ -272,7 +272,7 @@ public class PendingTradesDataModel extends ActivatableDataModel { return isMaker; } - BigInteger getTradeFeeInBTC() { + BigInteger getTradeFee() { Trade trade = getTrade(); if (trade != null) { Offer offer = trade.getOffer(); diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesListItem.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesListItem.java index 0c6b897545..6869877272 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesListItem.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesListItem.java @@ -56,7 +56,7 @@ public class PendingTradesListItem implements FilterableListItem { } public String getAmountAsString() { - return HavenoUtils.formatToXmr(trade.getAmount()); + return HavenoUtils.formatXmr(trade.getAmount()); } public String getPaymentMethod() { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesView.java index 25cf252ec4..6076a47d9d 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesView.java @@ -695,7 +695,7 @@ public class PendingTradesView extends ActivatableViewAndModel { DisputeResult disputeResult = firstDispute.getDisputeResultProperty().get(); String winner = disputeResult != null && disputeResult.getWinner() == DisputeResult.Winner.BUYER ? "Buyer" : "Seller"; - String buyerPayoutAmount = disputeResult != null ? HavenoUtils.formatToXmrWithCode(disputeResult.getBuyerPayoutAmount()) : ""; - String sellerPayoutAmount = disputeResult != null ? HavenoUtils.formatToXmrWithCode(disputeResult.getSellerPayoutAmount()) : ""; + String buyerPayoutAmount = disputeResult != null ? HavenoUtils.formatXmr(disputeResult.getBuyerPayoutAmount(), true) : ""; + String sellerPayoutAmount = disputeResult != null ? HavenoUtils.formatXmr(disputeResult.getSellerPayoutAmount(), true) : ""; int index = disputeIndex.incrementAndGet(); String tradeDateString = dateFormatter.format(firstDispute.getTradeDate()); @@ -703,7 +703,7 @@ public abstract class DisputeView extends ActivatableView { String paymentMethod = Res.get(contract.getPaymentMethodId()); String currency = CurrencyUtil.getNameAndCode(contract.getOfferPayload().getCurrencyCode()); - String tradeAmount = HavenoUtils.formatToXmrWithCode(contract.getTradeAmount()); + String tradeAmount = HavenoUtils.formatXmr(contract.getTradeAmount(), true); String buyerDeposit = Coin.valueOf(contract.getOfferPayload().getBuyerSecurityDeposit()).toFriendlyString(); String sellerDeposit = Coin.valueOf(contract.getOfferPayload().getSellerSecurityDeposit()).toFriendlyString(); stringBuilder.append("Payment method: ") diff --git a/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/SignedOfferView.java b/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/SignedOfferView.java index b3cc29dad3..bdb3b2be3b 100644 --- a/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/SignedOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/support/dispute/agent/SignedOfferView.java @@ -163,8 +163,8 @@ public class SignedOfferView extends ActivatableView { if(selectedSignedOffer != null) { new Popup().warning(Res.get("support.prompt.signedOffer.penalty.msg", selectedSignedOffer.getOfferId(), - HavenoUtils.formatToXmrWithCode(selectedSignedOffer.getMakerTradeFee()), - HavenoUtils.formatToXmrWithCode(selectedSignedOffer.getReserveTxMinerFee()), + HavenoUtils.formatXmr(selectedSignedOffer.getMakerTradeFee(), true), + HavenoUtils.formatXmr(selectedSignedOffer.getReserveTxMinerFee(), true), selectedSignedOffer.getReserveTxHash(), selectedSignedOffer.getReserveTxKeyImages()) ).onAction(() -> OfferViewUtil.submitTransactionHex(xmrWalletService, tableView, @@ -405,7 +405,7 @@ public class SignedOfferView extends ActivatableView { public void updateItem(final SignedOffer item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) - setText(HavenoUtils.formatToXmrWithCode(item.getMakerTradeFee())); + setText(HavenoUtils.formatXmr(item.getMakerTradeFee(), true)); else setText(""); } @@ -431,7 +431,7 @@ public class SignedOfferView extends ActivatableView { public void updateItem(final SignedOffer item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) - setText(HavenoUtils.formatToXmrWithCode(item.getReserveTxMinerFee())); + setText(HavenoUtils.formatXmr(item.getReserveTxMinerFee(), true)); else setText(""); } diff --git a/desktop/src/main/java/haveno/desktop/util/DisplayUtils.java b/desktop/src/main/java/haveno/desktop/util/DisplayUtils.java index 3e48bc659d..64c1f59531 100644 --- a/desktop/src/main/java/haveno/desktop/util/DisplayUtils.java +++ b/desktop/src/main/java/haveno/desktop/util/DisplayUtils.java @@ -193,8 +193,8 @@ public class DisplayUtils { public static String formatAmount(Offer offer, CoinFormatter coinFormatter) { return offer.isRange() - ? HavenoUtils.formatToXmr(offer.getMinAmount()) + FormattingUtils.RANGE_SEPARATOR + HavenoUtils.formatToXmr(offer.getAmount()) - : HavenoUtils.formatToXmr(offer.getAmount()); + ? HavenoUtils.formatXmr(offer.getMinAmount()) + FormattingUtils.RANGE_SEPARATOR + HavenoUtils.formatXmr(offer.getAmount()) + : HavenoUtils.formatXmr(offer.getAmount()); } public static String formatAmount(Offer offer, @@ -203,8 +203,8 @@ public class DisplayUtils { int maxPlaces, CoinFormatter coinFormatter) { String formattedAmount = offer.isRange() - ? HavenoUtils.formatToXmr(offer.getMinAmount(), decimalPlaces) + FormattingUtils.RANGE_SEPARATOR + HavenoUtils.formatToXmr(offer.getAmount(), decimalPlaces) - : HavenoUtils.formatToXmr(offer.getAmount(), decimalPlaces); + ? HavenoUtils.formatXmr(offer.getMinAmount(), decimalPlaces) + FormattingUtils.RANGE_SEPARATOR + HavenoUtils.formatXmr(offer.getAmount(), decimalPlaces) + : HavenoUtils.formatXmr(offer.getAmount(), decimalPlaces); if (decimalAligned) { formattedAmount = FormattingUtils.fillUpPlacesWithEmptyStrings(formattedAmount, maxPlaces); @@ -228,7 +228,7 @@ public class DisplayUtils { public static String getFeeWithFiatAmount(BigInteger makerFee, Optional optionalFeeInFiat, CoinFormatter formatter) { - String feeInXmr = makerFee != null ? HavenoUtils.formatToXmrWithCode(makerFee) : Res.get("shared.na"); + String feeInXmr = makerFee != null ? HavenoUtils.formatXmr(makerFee, true) : Res.get("shared.na"); if (optionalFeeInFiat != null && optionalFeeInFiat.isPresent()) { String feeInFiat = VolumeUtil.formatAverageVolumeWithCode(optionalFeeInFiat.get()); return Res.get("feeOptionWindow.fee", feeInXmr, feeInFiat); diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index 94a9a3d3b0..bd3fb195e0 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -533,7 +533,6 @@ message OfferInfo { string state = 18; uint64 seller_security_deposit = 19 [jstype = JS_STRING]; string offer_fee_payment_tx_id = 20; - uint64 tx_fee = 21 [jstype = JS_STRING]; uint64 maker_fee = 22 [jstype = JS_STRING]; bool is_activated = 23; bool is_my_offer = 24; @@ -828,10 +827,10 @@ message TradeInfo { string short_id = 3; uint64 date = 4; string role = 5; - uint64 taker_fee_as_long = 6 [jstype = JS_STRING]; + uint64 taker_fee = 6 [jstype = JS_STRING]; string taker_fee_tx_id = 7; string payout_tx_id = 8; - uint64 amount_as_long = 9 [jstype = JS_STRING]; + uint64 amount = 9 [jstype = JS_STRING]; uint64 buyer_security_deposit = 10 [jstype = JS_STRING]; uint64 seller_security_deposit = 11 [jstype = JS_STRING]; string price = 12; diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index 19712a8cab..b2e8629d22 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -36,44 +36,34 @@ message NetworkEnvelope { CloseConnectionMessage close_connection_message = 15; PrefixedSealedAndSignedMessage prefixed_sealed_and_signed_message = 16; - InputsForDepositTxRequest inputs_for_deposit_tx_request = 17; - InputsForDepositTxResponse inputs_for_deposit_tx_response = 18; - DepositTxMessage deposit_tx_message = 19; + PrivateNotificationMessage private_notification_message = 17; - DisputeOpenedMessage dispute_opened_message = 20; - DisputeClosedMessage dispute_closed_message = 21; - ChatMessage chat_message = 22; + AddPersistableNetworkPayloadMessage add_persistable_network_payload_message = 18; + AckMessage ack_message = 19; - PrivateNotificationMessage private_notification_message = 23; + BundleOfEnvelopes bundle_of_envelopes = 20; - AddPersistableNetworkPayloadMessage add_persistable_network_payload_message = 24; - AckMessage ack_message = 25; + GetInventoryRequest get_inventory_request = 21; + GetInventoryResponse get_inventory_response = 22; - BundleOfEnvelopes bundle_of_envelopes = 26; - MediatedPayoutTxSignatureMessage mediated_payout_tx_signature_message = 27; - MediatedPayoutTxPublishedMessage mediated_payout_tx_published_message = 28; + SignOfferRequest sign_offer_request = 23; + SignOfferResponse sign_offer_response = 24; + InitTradeRequest init_trade_request = 25; + InitMultisigRequest init_multisig_request = 26; + SignContractRequest sign_contract_request = 27; + SignContractResponse sign_contract_response = 28; + DepositRequest deposit_request = 29; + DepositResponse deposit_response = 30; + DepositsConfirmedMessage deposits_confirmed_message = 31; + PaymentSentMessage payment_sent_message = 32; + PaymentReceivedMessage payment_received_message = 33; - DelayedPayoutTxSignatureRequest delayed_payout_tx_signature_request = 29; - DelayedPayoutTxSignatureResponse delayed_payout_tx_signature_response = 30; - DepositTxAndDelayedPayoutTxMessage deposit_tx_and_delayed_payout_tx_message = 31; - PeerPublishedDelayedPayoutTxMessage peer_published_delayed_payout_tx_message = 32; + DisputeOpenedMessage dispute_opened_message = 34; + DisputeClosedMessage dispute_closed_message = 35; + ChatMessage chat_message = 36; - RefreshTradeStateRequest refresh_trade_state_request = 33 [deprecated = true]; - - GetInventoryRequest get_inventory_request = 35; - GetInventoryResponse get_inventory_response = 36; - - SignOfferRequest sign_offer_request = 1001; - SignOfferResponse sign_offer_response = 1002; - InitTradeRequest init_trade_request = 1003; - InitMultisigRequest init_multisig_request = 1004; - SignContractRequest sign_contract_request = 1005; - SignContractResponse sign_contract_response = 1006; - DepositRequest deposit_request = 1007; - DepositResponse deposit_response = 1008; - DepositsConfirmedMessage deposits_confirmed_message = 1009; - PaymentSentMessage payment_sent_message = 1010; - PaymentReceivedMessage payment_received_message = 1011; + MediatedPayoutTxSignatureMessage mediated_payout_tx_signature_message = 37; + MediatedPayoutTxPublishedMessage mediated_payout_tx_published_message = 38; } } @@ -223,50 +213,6 @@ message PrefixedSealedAndSignedMessage { string uid = 4; } -message InputsForDepositTxRequest { - string trade_id = 1; - NodeAddress sender_node_address = 2; - int64 trade_amount = 3; - int64 trade_price = 4; - int64 tx_fee = 5; - int64 taker_fee = 6; - repeated RawTransactionInput raw_transaction_inputs = 7; - int64 change_output_value = 8; - string change_output_address = 9; - bytes taker_multi_sig_pub_key = 10; - string taker_payout_address_string = 11; - PubKeyRing taker_pub_key_ring = 12; - PaymentAccountPayload taker_payment_account_payload = 13; - string taker_account_id = 14; - string taker_fee_tx_id = 15; - repeated NodeAddress accepted_arbitrator_node_addresses = 16; - repeated NodeAddress accepted_mediator_node_addresses = 17; - NodeAddress arbitrator_node_address = 18; - NodeAddress mediator_node_address = 29; - string uid = 20; - bytes account_age_witness_signature_of_offer_id = 21; - int64 current_date = 22; - repeated NodeAddress accepted_refund_agent_node_addresses = 23; - NodeAddress refund_agent_node_address = 24; -} - -message InputsForDepositTxResponse { - string trade_id = 1; - PaymentAccountPayload maker_payment_account_payload = 2; - string maker_account_id = 3; - string maker_contract_as_json = 4; - string maker_contract_signature = 5; - string maker_payout_address_string = 6; - bytes prepared_deposit_tx = 7; - repeated RawTransactionInput maker_inputs = 8; - bytes maker_multi_sig_pub_key = 9; - NodeAddress sender_node_address = 10; - string uid = 11; - bytes account_age_witness_signature_of_prepared_deposit_tx = 12; - int64 current_date = 13; - int64 lock_time = 14; -} - message InitTradeRequest { string trade_id = 1; NodeAddress sender_node_address = 2; @@ -345,47 +291,6 @@ message DepositsConfirmedMessage { string updated_multisig_hex = 6; } -message DelayedPayoutTxSignatureRequest { - string uid = 1; - string trade_id = 2; - NodeAddress sender_node_address = 3; - bytes delayed_payout_tx = 4; - bytes delayed_payout_tx_seller_signature = 5; -} - -message DelayedPayoutTxSignatureResponse { - string uid = 1; - string trade_id = 2; - NodeAddress sender_node_address = 3; - bytes delayed_payout_tx_buyer_signature = 4; - bytes deposit_tx = 5; -} - -message DepositTxAndDelayedPayoutTxMessage { - string uid = 1; - string trade_id = 2; - NodeAddress sender_node_address = 3; - bytes deposit_tx = 4; - bytes delayed_payout_tx = 5; -} - -message DepositTxMessage { - string uid = 1; - string trade_id = 2; - NodeAddress sender_node_address = 3; - bytes deposit_tx_without_witnesses = 4; - PubKeyRing pub_key_ring = 100; - reserved 5; // WAS: bytes deposit_tx = 101; - string trade_fee_tx_id = 102; - string deposit_tx_id = 103; -} - -message PeerPublishedDelayedPayoutTxMessage { - string uid = 1; - string trade_id = 2; - NodeAddress sender_node_address = 3; -} - message PaymentSentMessage { string trade_id = 1; NodeAddress sender_node_address = 2; @@ -427,13 +332,6 @@ message MediatedPayoutTxSignatureMessage { NodeAddress sender_node_address = 4; } -// Deprecated since 1.4.0 -message RefreshTradeStateRequest { - string uid = 1 [deprecated = true]; - string trade_id = 2 [deprecated = true]; - NodeAddress sender_node_address = 3 [deprecated = true]; -} - message ChatMessage { int64 date = 1; string trade_id = 2; @@ -507,7 +405,6 @@ message Peer { message PubKeyRing { bytes signature_pub_key_bytes = 1; bytes encryption_pub_key_bytes = 2; - reserved 3; // WAS: string pgp_pub_key_as_pem = 3; } message SealedAndSigned { @@ -525,21 +422,17 @@ message StoragePayload { Arbitrator arbitrator = 2; Mediator mediator = 3; Filter filter = 4; - - // TradeStatistics trade_statistics = 5 [deprecated = true]; Removed in v.1.4.0 - - MailboxStoragePayload mailbox_storage_payload = 6; - OfferPayload offer_payload = 7; - RefundAgent refund_agent = 8; + MailboxStoragePayload mailbox_storage_payload = 5; + OfferPayload offer_payload = 6; + RefundAgent refund_agent = 7; } } message PersistableNetworkPayload { oneof message { AccountAgeWitness account_age_witness = 1; - TradeStatistics2 trade_statistics2 = 2 [deprecated = true]; - SignedWitness signed_witness = 3; - TradeStatistics3 trade_statistics3 = 4; + SignedWitness signed_witness = 2; + TradeStatistics3 trade_statistics3 = 3; } } @@ -686,42 +579,17 @@ message Filter { bool disable_mempool_validation = 26; } -// Deprecated -message TradeStatistics2 { - string base_currency = 1 [deprecated = true]; - string counter_currency = 2 [deprecated = true]; - OfferDirection direction = 3 [deprecated = true]; - int64 trade_price = 4 [deprecated = true]; - int64 trade_amount = 5 [deprecated = true]; - int64 trade_date = 6 [deprecated = true]; - string payment_method_id = 7 [deprecated = true]; - int64 offer_date = 8 [deprecated = true]; - bool offer_use_market_based_price = 9 [deprecated = true]; - double offer_market_price_margin = 10 [deprecated = true]; - int64 offer_amount = 11 [deprecated = true]; - int64 offer_min_amount = 12 [deprecated = true]; - string offer_id = 13 [deprecated = true]; - string deposit_tx_id = 14 [deprecated = true]; - bytes hash = 15 [deprecated = true]; - map extra_data = 16 [deprecated = true]; - string maker_deposit_tx_id = 100; - string taker_deposit_tx_id = 101; -} - message TradeStatistics3 { string currency = 1; int64 price = 2; int64 amount = 3; string payment_method = 4; int64 date = 5; - reserved 6; // was string mediator = 6; - reserved 7; // was string refund_agent = 7; - bytes hash = 8; - map extra_data = 9; - - string arbitrator = 100; - string maker_deposit_tx_id = 101; - string taker_deposit_tx_id = 102; + string arbitrator = 6; + bytes hash = 7; + string maker_deposit_tx_id = 8; + string taker_deposit_tx_id = 9; + map extra_data = 10; } message MailboxStoragePayload { @@ -900,25 +768,23 @@ message Contract { OfferPayload offer_payload = 1; int64 trade_amount = 2; int64 trade_price = 3; - reserved 4; // WAS: taker_fee_tx_id - reserved 5; // WAS: arbitrator_node_address - bool is_buyer_maker_and_seller_taker = 6; - string maker_account_id = 7; - string taker_account_id = 8; - string maker_payment_method_id = 9; - string taker_payment_method_id = 10; - bytes maker_payment_account_payload_hash = 11; - bytes taker_payment_account_payload_hash = 12; - PubKeyRing maker_pub_key_ring = 13; - PubKeyRing taker_pub_key_ring = 14; - NodeAddress buyer_node_address = 15; - NodeAddress seller_node_address = 16; - string maker_payout_address_string = 17; - string taker_payout_address_string = 18; - NodeAddress arbitrator_node_address = 19; + NodeAddress arbitrator_node_address = 4; + bool is_buyer_maker_and_seller_taker = 5; + string maker_account_id = 6; + string taker_account_id = 7; + string maker_payment_method_id = 8; + string taker_payment_method_id = 9; + bytes maker_payment_account_payload_hash = 10; + bytes taker_payment_account_payload_hash = 11; + PubKeyRing maker_pub_key_ring = 12; + PubKeyRing taker_pub_key_ring = 13; + NodeAddress buyer_node_address = 14; + NodeAddress seller_node_address = 15; + string maker_payout_address_string = 16; + string taker_payout_address_string = 17; + string maker_deposit_tx_hash = 18; + string taker_deposit_tx_hash = 19; int64 lock_time = 20; - string maker_deposit_tx_hash = 21; - string taker_deposit_tx_hash = 22; } message RawTransactionInput { @@ -953,19 +819,20 @@ enum AvailabilityResult { message PaymentAccountPayload { string id = 1; string payment_method_id = 2; - int64 max_trade_period = 3 [deprecated = true]; // not used anymore but we need to keep it in PB for backward compatibility + int64 max_trade_period = 3; // not used + map exclude_from_json_data = 4; oneof message { - AliPayAccountPayload ali_pay_account_payload = 4; - ChaseQuickPayAccountPayload chase_quick_pay_account_payload = 5; - ClearXchangeAccountPayload clear_xchange_account_payload = 6; - CountryBasedPaymentAccountPayload country_based_payment_account_payload = 7; - CryptoCurrencyAccountPayload crypto_currency_account_payload = 8; - FasterPaymentsAccountPayload faster_payments_account_payload = 9; - InteracETransferAccountPayload interac_e_transfer_account_payload = 10; - OKPayAccountPayload o_k_pay_account_payload = 11 [deprecated = true]; - PerfectMoneyAccountPayload perfect_money_account_payload = 12; - SwishAccountPayload swish_account_payload = 13; - USPostalMoneyOrderAccountPayload u_s_postal_money_order_account_payload = 14; + AliPayAccountPayload ali_pay_account_payload = 5; + ChaseQuickPayAccountPayload chase_quick_pay_account_payload = 6; + ClearXchangeAccountPayload clear_xchange_account_payload = 7; + CountryBasedPaymentAccountPayload country_based_payment_account_payload = 8; + CryptoCurrencyAccountPayload crypto_currency_account_payload = 9; + FasterPaymentsAccountPayload faster_payments_account_payload = 10; + InteracETransferAccountPayload interac_e_transfer_account_payload = 11; + OKPayAccountPayload o_k_pay_account_payload = 12 [deprecated = true]; + PerfectMoneyAccountPayload perfect_money_account_payload = 13; + SwishAccountPayload swish_account_payload = 14; + USPostalMoneyOrderAccountPayload u_s_postal_money_order_account_payload = 15; UpholdAccountPayload uphold_account_payload = 16; CashAppAccountPayload cash_app_account_payload = 17 [deprecated = true]; MoneyBeamAccountPayload money_beam_account_payload = 18; @@ -991,7 +858,6 @@ message PaymentAccountPayload { MoneseAccountPayload monese_account_payload = 38; VerseAccountPayload verse_account_payload = 39; } - map exclude_from_json_data = 15; } message AliPayAccountPayload { @@ -1339,33 +1205,27 @@ message SwiftAccountPayload { message PersistableEnvelope { oneof message { SequenceNumberMap sequence_number_map = 1; - PersistedEntryMap persisted_entry_map = 2 [deprecated = true]; - PeerList peer_list = 3; - AddressEntryList address_entry_list = 4; - NavigationPath navigation_path = 5; + PeerList peer_list = 2; + AddressEntryList address_entry_list = 3; + NavigationPath navigation_path = 4; - TradableList tradable_list = 6; + TradableList tradable_list = 5; - // TradeStatisticsList trade_statistics_list = 7; Deprecated, Was used in pre v0.6.0 version. Not used anymore. + ArbitrationDisputeList arbitration_dispute_list = 6; - ArbitrationDisputeList arbitration_dispute_list = 8; + PreferencesPayload preferences_payload = 7; + UserPayload user_payload = 8; + PaymentAccountList payment_account_list = 9; - PreferencesPayload preferences_payload = 9; - UserPayload user_payload = 10; - PaymentAccountList payment_account_list = 11; + AccountAgeWitnessStore account_age_witness_store = 10; - AccountAgeWitnessStore account_age_witness_store = 12; - TradeStatistics2Store trade_statistics2_store = 13 [deprecated = true]; - - // PersistableNetworkPayloadList persistable_network_payload_list = 14; // long deprecated & migration away from it is already done - - SignedWitnessStore signed_witness_store = 15; - MediationDisputeList mediation_dispute_list = 16; - RefundDisputeList refund_dispute_list = 17; - TradeStatistics3Store trade_statistics3_store = 18; - MailboxMessageList mailbox_message_list = 19; - IgnoredMailboxMap ignored_mailbox_map = 20; - RemovedPayloadsMap removed_payloads_map = 21; + SignedWitnessStore signed_witness_store = 11; + MediationDisputeList mediation_dispute_list = 12; + RefundDisputeList refund_dispute_list = 13; + TradeStatistics3Store trade_statistics3_store = 14; + MailboxMessageList mailbox_message_list = 15; + IgnoredMailboxMap ignored_mailbox_map = 16; + RemovedPayloadsMap removed_payloads_map = 17; XmrAddressEntryList xmr_address_entry_list = 1001; SignedOfferList signed_offer_list = 1002; @@ -1391,11 +1251,6 @@ message MapValue { int64 time_stamp = 2; } -// deprecated. Not used anymore. -message PersistedEntryMap { - map persisted_entry_map = 1; -} - // We use a list not a hash map to save disc space. The hash can be calculated from the payload anyway message AccountAgeWitnessStore { repeated AccountAgeWitness items = 1; @@ -1405,12 +1260,6 @@ message SignedWitnessStore { repeated SignedWitness items = 1; } -// We use a list not a hash map to save disc space. The hash can be calculated from the payload anyway -// Deprecated -message TradeStatistics2Store { - repeated TradeStatistics2 items = 1 [deprecated = true]; -} - message TradeStatistics3Store { repeated TradeStatistics3 items = 1; } @@ -1626,8 +1475,8 @@ message Trade { string payout_tx_id = 3; string payout_tx_hex = 4; string payout_tx_key = 5; - int64 amount_as_long = 6; - int64 taker_fee_as_long = 8; + int64 amount = 6; + int64 taker_fee = 8; int64 take_offer_date = 9; int64 price = 10; State state = 11; @@ -1673,38 +1522,27 @@ message ArbitratorTrade { } message ProcessModel { - reserved 1; // Not used anymore - string offer_id = 2; - string account_id = 3; - PubKeyRing pub_key_ring = 4; - string take_offer_fee_tx_id = 5; - bytes payout_tx_signature = 6; - reserved 7; // Not used anymore - reserved 8; // Not used anymore - reserved 9; // Not used anymore - repeated RawTransactionInput raw_transaction_inputs = 10; - int64 change_output_value = 11; - string change_output_address = 12; - bool use_savings_wallet = 13; - int64 funds_needed_for_trade_as_long = 14; - bytes my_multi_sig_pub_key = 15; - reserved 16; // Not used anymore - string payment_sent_message_state = 17; - bytes mediated_payout_tx_signature = 18; - int64 buyer_payout_amount_from_mediation = 19; - int64 seller_payout_amount_from_mediation = 20; - bool deposits_confirmed_messages_delivered = 21; - - string maker_signature = 1001; - TradePeer maker = 1002; - TradePeer taker = 1003; - TradePeer arbitrator = 1004; - NodeAddress temp_trade_peer_node_address = 1005; - string multisig_address = 1006; - - PaymentSentMessage payment_sent_message = 1012; - PaymentReceivedMessage payment_received_message = 1013; - DisputeClosedMessage dispute_closed_message = 1014; + string offer_id = 1; + string account_id = 2; + PubKeyRing pub_key_ring = 3; + string take_offer_fee_tx_id = 4; + bytes payout_tx_signature = 5; + bool use_savings_wallet = 6; + int64 funds_needed_for_trade = 7; + string payment_sent_message_state = 8; + bool deposits_confirmed_messages_delivered = 9; + string maker_signature = 10; + TradePeer maker = 11; + TradePeer taker = 12; + TradePeer arbitrator = 13; + NodeAddress temp_trade_peer_node_address = 14; + string multisig_address = 15; + PaymentSentMessage payment_sent_message = 16; + PaymentReceivedMessage payment_received_message = 17; + DisputeClosedMessage dispute_closed_message = 18; + bytes mediated_payout_tx_signature = 19; // placeholder if mediation used in future + int64 buyer_payout_amount_from_mediation = 20; + int64 seller_payout_amount_from_mediation = 21; } message TradePeer { @@ -1839,40 +1677,39 @@ message PreferencesPayload { string bitcoin_nodes = 26; repeated string ignore_traders_list = 27; string directory_chooser_path = 28; - int64 buyer_security_deposit_as_long = 29 [deprecated = true]; // Superseded by buyerSecurityDepositAsPercent - bool use_animations = 30; - PaymentAccount selectedPayment_account_for_createOffer = 31; - repeated string bridge_addresses = 32; - int32 bridge_option_ordinal = 33; - int32 tor_transport_ordinal = 34; - string custom_bridges = 35; - int32 bitcoin_nodes_option_ordinal = 36; - string referral_id = 37; - string phone_key_and_token = 38; - bool use_sound_for_mobile_notifications = 39; - bool use_trade_notifications = 40; - bool use_market_notifications = 41; - bool use_price_notifications = 42; - bool use_standby_mode = 43; - string rpc_user = 44; - string rpc_pw = 45; - string take_offer_selected_payment_account_id = 46; - double buyer_security_deposit_as_percent = 47; - int32 ignore_dust_threshold = 48; - double buyer_security_deposit_as_percent_for_crypto = 49; - int32 block_notify_port = 50; - int32 css_theme = 51; - bool tac_accepted_v120 = 52; - repeated AutoConfirmSettings auto_confirm_settings = 53; - double bsq_average_trim_threshold = 54; - bool hide_non_account_payment_methods = 55; - bool show_offers_matching_my_accounts = 56; - bool deny_api_taker = 57; - bool notify_on_pre_release = 58; - MoneroNodeSettings monero_node_settings = 59; - int32 clear_data_after_days = 60; - string buy_screen_crypto_currency_code = 61; - string sell_screen_crypto_currency_code = 62; + bool use_animations = 29; + PaymentAccount selectedPayment_account_for_createOffer = 30; + repeated string bridge_addresses = 31; + int32 bridge_option_ordinal = 32; + int32 tor_transport_ordinal = 33; + string custom_bridges = 34; + int32 bitcoin_nodes_option_ordinal = 35; + string referral_id = 36; + string phone_key_and_token = 37; + bool use_sound_for_mobile_notifications = 38; + bool use_trade_notifications = 39; + bool use_market_notifications = 40; + bool use_price_notifications = 41; + bool use_standby_mode = 42; + string rpc_user = 43; + string rpc_pw = 44; + string take_offer_selected_payment_account_id = 45; + double buyer_security_deposit_as_percent = 46; + int32 ignore_dust_threshold = 47; + double buyer_security_deposit_as_percent_for_crypto = 48; + int32 block_notify_port = 49; + int32 css_theme = 50; + bool tac_accepted_v120 = 51; + repeated AutoConfirmSettings auto_confirm_settings = 52; + double bsq_average_trim_threshold = 53; + bool hide_non_account_payment_methods = 54; + bool show_offers_matching_my_accounts = 55; + bool deny_api_taker = 56; + bool notify_on_pre_release = 57; + MoneroNodeSettings monero_node_settings = 58; + int32 clear_data_after_days = 59; + string buy_screen_crypto_currency_code = 60; + string sell_screen_crypto_currency_code = 61; } message AutoConfirmSettings {