diff --git a/core/src/main/java/haveno/core/api/CoreApi.java b/core/src/main/java/haveno/core/api/CoreApi.java index 99515019ca..5b20042950 100644 --- a/core/src/main/java/haveno/core/api/CoreApi.java +++ b/core/src/main/java/haveno/core/api/CoreApi.java @@ -405,7 +405,7 @@ public class CoreApi { long minAmountAsLong, double buyerSecurityDeposit, String triggerPriceAsString, - boolean splitOutput, + boolean reserveExactAmount, String paymentAccountId, Consumer resultHandler, ErrorMessageHandler errorMessageHandler) { @@ -418,7 +418,7 @@ public class CoreApi { minAmountAsLong, buyerSecurityDeposit, triggerPriceAsString, - splitOutput, + reserveExactAmount, paymentAccountId, resultHandler, errorMessageHandler); diff --git a/core/src/main/java/haveno/core/api/CoreOffersService.java b/core/src/main/java/haveno/core/api/CoreOffersService.java index 553dc091bd..e6e5aaf054 100644 --- a/core/src/main/java/haveno/core/api/CoreOffersService.java +++ b/core/src/main/java/haveno/core/api/CoreOffersService.java @@ -165,7 +165,7 @@ public class CoreOffersService { long minAmountAsLong, double buyerSecurityDeposit, String triggerPriceAsString, - boolean splitOutput, + boolean reserveExactAmount, String paymentAccountId, Consumer resultHandler, ErrorMessageHandler errorMessageHandler) { @@ -201,7 +201,7 @@ public class CoreOffersService { placeOffer(offer, triggerPriceAsString, useSavingsWallet, - splitOutput, + reserveExactAmount, transaction -> resultHandler.accept(offer), errorMessageHandler); } @@ -272,14 +272,14 @@ public class CoreOffersService { private void placeOffer(Offer offer, String triggerPriceAsString, boolean useSavingsWallet, - boolean splitOutput, + boolean reserveExactAmount, Consumer resultHandler, ErrorMessageHandler errorMessageHandler) { long triggerPriceAsLong = PriceUtil.getMarketPriceAsLong(triggerPriceAsString, offer.getCurrencyCode()); openOfferManager.placeOffer(offer, useSavingsWallet, triggerPriceAsLong, - splitOutput, + reserveExactAmount, resultHandler::accept, errorMessageHandler); } diff --git a/core/src/main/java/haveno/core/offer/OpenOffer.java b/core/src/main/java/haveno/core/offer/OpenOffer.java index 5688365686..b7e9efa510 100644 --- a/core/src/main/java/haveno/core/offer/OpenOffer.java +++ b/core/src/main/java/haveno/core/offer/OpenOffer.java @@ -56,7 +56,7 @@ public final class OpenOffer implements Tradable { private State state; @Setter @Getter - private boolean splitOutput; + private boolean reserveExactAmount; @Setter @Getter @Nullable @@ -96,10 +96,10 @@ public final class OpenOffer implements Tradable { this(offer, triggerPrice, false); } - public OpenOffer(Offer offer, long triggerPrice, boolean splitOutput) { + public OpenOffer(Offer offer, long triggerPrice, boolean reserveExactAmount) { this.offer = offer; this.triggerPrice = triggerPrice; - this.splitOutput = splitOutput; + this.reserveExactAmount = reserveExactAmount; state = State.SCHEDULED; } @@ -110,7 +110,7 @@ public final class OpenOffer implements Tradable { private OpenOffer(Offer offer, State state, long triggerPrice, - boolean splitOutput, + boolean reserveExactAmount, @Nullable String scheduledAmount, @Nullable List scheduledTxHashes, String splitOutputTxHash, @@ -120,7 +120,7 @@ public final class OpenOffer implements Tradable { this.offer = offer; this.state = state; this.triggerPrice = triggerPrice; - this.splitOutput = splitOutput; + this.reserveExactAmount = reserveExactAmount; this.scheduledTxHashes = scheduledTxHashes; this.splitOutputTxHash = splitOutputTxHash; this.reserveTxHash = reserveTxHash; @@ -137,7 +137,7 @@ public final class OpenOffer implements Tradable { .setOffer(offer.toProtoMessage()) .setTriggerPrice(triggerPrice) .setState(protobuf.OpenOffer.State.valueOf(state.name())) - .setSplitOutput(splitOutput); + .setReserveExactAmount(reserveExactAmount); Optional.ofNullable(scheduledAmount).ifPresent(e -> builder.setScheduledAmount(scheduledAmount)); Optional.ofNullable(scheduledTxHashes).ifPresent(e -> builder.addAllScheduledTxHashes(scheduledTxHashes)); @@ -153,7 +153,7 @@ public final class OpenOffer implements Tradable { OpenOffer openOffer = new OpenOffer(Offer.fromProto(proto.getOffer()), ProtoUtil.enumFromProto(OpenOffer.State.class, proto.getState().name()), proto.getTriggerPrice(), - proto.getSplitOutput(), + proto.getReserveExactAmount(), proto.getScheduledAmount(), proto.getScheduledTxHashesList(), ProtoUtil.stringOrNullFromProto(proto.getSplitOutputTxHash()), diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index a144c00ede..93a490b9af 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -490,13 +490,13 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe public void placeOffer(Offer offer, boolean useSavingsWallet, long triggerPrice, - boolean splitOutput, + boolean reserveExactAmount, TransactionResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { checkNotNull(offer.getMakerFee(), "makerFee must not be null"); // create open offer - OpenOffer openOffer = new OpenOffer(offer, triggerPrice, splitOutput); + OpenOffer openOffer = new OpenOffer(offer, triggerPrice, reserveExactAmount); // process open offer to schedule or post processUnpostedOffer(getOpenOffers(), openOffer, (transaction) -> { @@ -807,7 +807,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe BigInteger offerReserveAmount = openOffer.getOffer().getReserveAmount(); // handle split output offer - if (openOffer.isSplitOutput()) { + if (openOffer.isReserveExactAmount()) { // find tx with exact input amount MoneroTxWallet splitOutputTx = findSplitOutputFundingTx(openOffers, openOffer); diff --git a/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java b/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java index b6825679a6..d0a992f25b 100644 --- a/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java +++ b/core/src/main/java/haveno/core/offer/placeoffer/tasks/MakerReserveOfferFunds.java @@ -56,7 +56,7 @@ public class MakerReserveOfferFunds extends Task { String returnAddress = model.getXmrWalletService().getOrCreateAddressEntry(offer.getId(), XmrAddressEntry.Context.TRADE_PAYOUT).getAddressString(); XmrAddressEntry fundingEntry = model.getXmrWalletService().getAddressEntry(offer.getId(), XmrAddressEntry.Context.OFFER_FUNDING).orElse(null); Integer preferredSubaddressIndex = fundingEntry == null ? null : fundingEntry.getSubaddressIndex(); - MoneroTxWallet reserveTx = model.getXmrWalletService().createReserveTx(makerFee, sendAmount, securityDeposit, returnAddress, model.getOpenOffer().isSplitOutput(), preferredSubaddressIndex); + MoneroTxWallet reserveTx = model.getXmrWalletService().createReserveTx(makerFee, sendAmount, securityDeposit, returnAddress, model.getOpenOffer().isReserveExactAmount(), preferredSubaddressIndex); // check for error in case creating reserve tx exceeded timeout // TODO: better way? diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/MaybeSendSignContractRequest.java b/core/src/main/java/haveno/core/trade/protocol/tasks/MaybeSendSignContractRequest.java index 23c66a1587..5ce230e2e6 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/MaybeSendSignContractRequest.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/MaybeSendSignContractRequest.java @@ -76,12 +76,12 @@ public class MaybeSendSignContractRequest extends TradeTask { // create deposit tx and freeze inputs Integer subaddressIndex = null; - boolean isSplitOutputOffer = false; + boolean reserveExactAmount = false; if (trade instanceof MakerTrade) { - isSplitOutputOffer = processModel.getOpenOfferManager().getOpenOfferById(trade.getId()).get().isSplitOutput(); - if (isSplitOutputOffer) subaddressIndex = model.getXmrWalletService().getAddressEntry(trade.getId(), XmrAddressEntry.Context.OFFER_FUNDING).get().getSubaddressIndex(); + reserveExactAmount = processModel.getOpenOfferManager().getOpenOfferById(trade.getId()).get().isReserveExactAmount(); + if (reserveExactAmount) subaddressIndex = model.getXmrWalletService().getAddressEntry(trade.getId(), XmrAddressEntry.Context.OFFER_FUNDING).get().getSubaddressIndex(); } - MoneroTxWallet depositTx = trade.getXmrWalletService().createDepositTx(trade, isSplitOutputOffer, subaddressIndex); + MoneroTxWallet depositTx = trade.getXmrWalletService().createDepositTx(trade, reserveExactAmount, subaddressIndex); // collect reserved key images List reservedKeyImages = new ArrayList(); diff --git a/daemon/src/main/java/haveno/daemon/grpc/GrpcOffersService.java b/daemon/src/main/java/haveno/daemon/grpc/GrpcOffersService.java index 61e2905872..1b11d73ffe 100644 --- a/daemon/src/main/java/haveno/daemon/grpc/GrpcOffersService.java +++ b/daemon/src/main/java/haveno/daemon/grpc/GrpcOffersService.java @@ -158,7 +158,7 @@ class GrpcOffersService extends OffersImplBase { req.getMinAmount(), req.getBuyerSecurityDepositPct(), req.getTriggerPrice(), - req.getSplitOutput(), + req.getReserveExactAmount(), req.getPaymentAccountId(), offer -> { // This result handling consumer's accept operation will return 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 bc758b6e01..6ac76fc25f 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferDataModel.java @@ -129,7 +129,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel { @Getter protected long triggerPrice; @Getter - protected boolean splitOutput; + protected boolean reserveExactAmount; /////////////////////////////////////////////////////////////////////////////////////////// @@ -167,7 +167,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel { shortOfferId = Utilities.getShortId(offerId); addressEntry = xmrWalletService.getOrCreateAddressEntry(offerId, XmrAddressEntry.Context.OFFER_FUNDING); - splitOutput = preferences.getSplitOfferOutput(); + reserveExactAmount = preferences.getSplitOfferOutput(); useMarketBasedPrice.set(preferences.isUsePercentageBasedPrice()); buyerSecurityDepositPct.set(Restrictions.getMinBuyerSecurityDepositAsPercent()); @@ -299,7 +299,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel { openOfferManager.placeOffer(offer, useSavingsWallet, triggerPrice, - splitOutput, + reserveExactAmount, resultHandler, errorMessageHandler); } @@ -682,8 +682,8 @@ public abstract class MutableOfferDataModel extends OfferDataModel { this.triggerPrice = triggerPrice; } - public void setSplitOutput(boolean splitOutput) { - this.splitOutput = splitOutput; + public void setReserveExactAmount(boolean reserveExactAmount) { + this.reserveExactAmount = reserveExactAmount; } public boolean isUsingRoundedAtmCashAccount() { 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 22b3084529..342819bae5 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 TextField currencyTextField; private AddressTextField addressTextField; private BalanceTextField balanceTextField; - private CheckBox splitOutputCheckbox; + private CheckBox reserveExactAmountCheckbox; private FundsTextField totalToPayTextField; private Label amountDescriptionLabel, priceCurrencyLabel, priceDescriptionLabel, volumeDescriptionLabel, waitingForFundsLabel, marketBasedPriceLabel, percentagePriceDescriptionLabel, tradeFeeDescriptionLabel, @@ -421,7 +421,7 @@ public abstract class MutableOfferView> exten qrCodeImageView.setVisible(true); balanceTextField.setVisible(true); cancelButton2.setVisible(true); - splitOutputCheckbox.setVisible(true); + reserveExactAmountCheckbox.setVisible(true); } private void updateOfferElementsStyle() { @@ -1093,18 +1093,18 @@ public abstract class MutableOfferView> exten Res.get("shared.tradeWalletBalance")); balanceTextField.setVisible(false); - splitOutputCheckbox = FormBuilder.addLabelCheckBox(gridPane, ++gridRow, + reserveExactAmountCheckbox = FormBuilder.addLabelCheckBox(gridPane, ++gridRow, Res.get("shared.reserveExactAmount")); - GridPane.setHalignment(splitOutputCheckbox, HPos.LEFT); + GridPane.setHalignment(reserveExactAmountCheckbox, HPos.LEFT); - splitOutputCheckbox.setVisible(false); - splitOutputCheckbox.setSelected(preferences.getSplitOfferOutput()); - splitOutputCheckbox.setOnAction(event -> { - boolean selected = splitOutputCheckbox.isSelected(); + reserveExactAmountCheckbox.setVisible(false); + reserveExactAmountCheckbox.setSelected(preferences.getSplitOfferOutput()); + reserveExactAmountCheckbox.setOnAction(event -> { + boolean selected = reserveExactAmountCheckbox.isSelected(); if (selected != preferences.getSplitOfferOutput()) { preferences.setSplitOfferOutput(selected); - model.dataModel.setSplitOutput(selected); + model.dataModel.setReserveExactAmount(selected); } }); 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 8a0b01e1b9..6f05f65862 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java @@ -115,7 +115,7 @@ public abstract class MutableOfferViewModel ext // If we would change the price representation in the domain we would not be backward compatible public final StringProperty price = new SimpleStringProperty(); public final StringProperty triggerPrice = new SimpleStringProperty(""); - public final BooleanProperty splitOutput = new SimpleBooleanProperty(true); + public final BooleanProperty reserveExactAmount = new SimpleBooleanProperty(true); final StringProperty tradeFee = new SimpleStringProperty(); final StringProperty tradeFeeInXmrWithFiat = new SimpleStringProperty(); final StringProperty tradeFeeCurrencyCode = new SimpleStringProperty(); @@ -779,8 +779,8 @@ public abstract class MutableOfferViewModel ext } } - public void onSplitOutputCheckboxChanged() { - dataModel.setSplitOutput(splitOutput.get()); + public void onReserveExactAmountCheckboxChanged() { + dataModel.setReserveExactAmount(reserveExactAmount.get()); } void onFixPriceToggleChange(boolean fixedPriceSelected) { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferViewModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferViewModel.java index e8450aded5..e300bfbbb7 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/editoffer/EditOfferViewModel.java @@ -82,7 +82,7 @@ class EditOfferViewModel extends MutableOfferViewModel { triggerPrice.set(""); } onTriggerPriceTextFieldChanged(); - onSplitOutputCheckboxChanged(); + onReserveExactAmountCheckboxChanged(); } public void applyOpenOffer(OpenOffer openOffer) { diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index ed074f113f..dd308db6e2 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -498,7 +498,7 @@ message PostOfferRequest { uint64 min_amount = 7 [jstype = JS_STRING]; double buyer_security_deposit_pct = 8; string trigger_price = 9; - bool split_output = 10; + bool reserve_exact_amount = 10; string payment_account_id = 11; } diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index c566e98c8e..dea63c2b91 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -1377,7 +1377,7 @@ message OpenOffer { Offer offer = 1; State state = 2; int64 trigger_price = 3; - bool split_output = 4; + bool reserve_exact_amount = 4; repeated string scheduled_tx_hashes = 5; string scheduled_amount = 6; // BigInteger string split_output_tx_hash = 7;