rename splitOutput to reserveExactAmount

This commit is contained in:
woodser 2023-07-23 11:05:16 -04:00
parent 242bc0e3bb
commit 426d25f78c
13 changed files with 42 additions and 42 deletions

View File

@ -405,7 +405,7 @@ public class CoreApi {
long minAmountAsLong, long minAmountAsLong,
double buyerSecurityDeposit, double buyerSecurityDeposit,
String triggerPriceAsString, String triggerPriceAsString,
boolean splitOutput, boolean reserveExactAmount,
String paymentAccountId, String paymentAccountId,
Consumer<Offer> resultHandler, Consumer<Offer> resultHandler,
ErrorMessageHandler errorMessageHandler) { ErrorMessageHandler errorMessageHandler) {
@ -418,7 +418,7 @@ public class CoreApi {
minAmountAsLong, minAmountAsLong,
buyerSecurityDeposit, buyerSecurityDeposit,
triggerPriceAsString, triggerPriceAsString,
splitOutput, reserveExactAmount,
paymentAccountId, paymentAccountId,
resultHandler, resultHandler,
errorMessageHandler); errorMessageHandler);

View File

@ -165,7 +165,7 @@ public class CoreOffersService {
long minAmountAsLong, long minAmountAsLong,
double buyerSecurityDeposit, double buyerSecurityDeposit,
String triggerPriceAsString, String triggerPriceAsString,
boolean splitOutput, boolean reserveExactAmount,
String paymentAccountId, String paymentAccountId,
Consumer<Offer> resultHandler, Consumer<Offer> resultHandler,
ErrorMessageHandler errorMessageHandler) { ErrorMessageHandler errorMessageHandler) {
@ -201,7 +201,7 @@ public class CoreOffersService {
placeOffer(offer, placeOffer(offer,
triggerPriceAsString, triggerPriceAsString,
useSavingsWallet, useSavingsWallet,
splitOutput, reserveExactAmount,
transaction -> resultHandler.accept(offer), transaction -> resultHandler.accept(offer),
errorMessageHandler); errorMessageHandler);
} }
@ -272,14 +272,14 @@ public class CoreOffersService {
private void placeOffer(Offer offer, private void placeOffer(Offer offer,
String triggerPriceAsString, String triggerPriceAsString,
boolean useSavingsWallet, boolean useSavingsWallet,
boolean splitOutput, boolean reserveExactAmount,
Consumer<Transaction> resultHandler, Consumer<Transaction> resultHandler,
ErrorMessageHandler errorMessageHandler) { ErrorMessageHandler errorMessageHandler) {
long triggerPriceAsLong = PriceUtil.getMarketPriceAsLong(triggerPriceAsString, offer.getCurrencyCode()); long triggerPriceAsLong = PriceUtil.getMarketPriceAsLong(triggerPriceAsString, offer.getCurrencyCode());
openOfferManager.placeOffer(offer, openOfferManager.placeOffer(offer,
useSavingsWallet, useSavingsWallet,
triggerPriceAsLong, triggerPriceAsLong,
splitOutput, reserveExactAmount,
resultHandler::accept, resultHandler::accept,
errorMessageHandler); errorMessageHandler);
} }

View File

@ -56,7 +56,7 @@ public final class OpenOffer implements Tradable {
private State state; private State state;
@Setter @Setter
@Getter @Getter
private boolean splitOutput; private boolean reserveExactAmount;
@Setter @Setter
@Getter @Getter
@Nullable @Nullable
@ -96,10 +96,10 @@ public final class OpenOffer implements Tradable {
this(offer, triggerPrice, false); this(offer, triggerPrice, false);
} }
public OpenOffer(Offer offer, long triggerPrice, boolean splitOutput) { public OpenOffer(Offer offer, long triggerPrice, boolean reserveExactAmount) {
this.offer = offer; this.offer = offer;
this.triggerPrice = triggerPrice; this.triggerPrice = triggerPrice;
this.splitOutput = splitOutput; this.reserveExactAmount = reserveExactAmount;
state = State.SCHEDULED; state = State.SCHEDULED;
} }
@ -110,7 +110,7 @@ public final class OpenOffer implements Tradable {
private OpenOffer(Offer offer, private OpenOffer(Offer offer,
State state, State state,
long triggerPrice, long triggerPrice,
boolean splitOutput, boolean reserveExactAmount,
@Nullable String scheduledAmount, @Nullable String scheduledAmount,
@Nullable List<String> scheduledTxHashes, @Nullable List<String> scheduledTxHashes,
String splitOutputTxHash, String splitOutputTxHash,
@ -120,7 +120,7 @@ public final class OpenOffer implements Tradable {
this.offer = offer; this.offer = offer;
this.state = state; this.state = state;
this.triggerPrice = triggerPrice; this.triggerPrice = triggerPrice;
this.splitOutput = splitOutput; this.reserveExactAmount = reserveExactAmount;
this.scheduledTxHashes = scheduledTxHashes; this.scheduledTxHashes = scheduledTxHashes;
this.splitOutputTxHash = splitOutputTxHash; this.splitOutputTxHash = splitOutputTxHash;
this.reserveTxHash = reserveTxHash; this.reserveTxHash = reserveTxHash;
@ -137,7 +137,7 @@ public final class OpenOffer implements Tradable {
.setOffer(offer.toProtoMessage()) .setOffer(offer.toProtoMessage())
.setTriggerPrice(triggerPrice) .setTriggerPrice(triggerPrice)
.setState(protobuf.OpenOffer.State.valueOf(state.name())) .setState(protobuf.OpenOffer.State.valueOf(state.name()))
.setSplitOutput(splitOutput); .setReserveExactAmount(reserveExactAmount);
Optional.ofNullable(scheduledAmount).ifPresent(e -> builder.setScheduledAmount(scheduledAmount)); Optional.ofNullable(scheduledAmount).ifPresent(e -> builder.setScheduledAmount(scheduledAmount));
Optional.ofNullable(scheduledTxHashes).ifPresent(e -> builder.addAllScheduledTxHashes(scheduledTxHashes)); 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()), OpenOffer openOffer = new OpenOffer(Offer.fromProto(proto.getOffer()),
ProtoUtil.enumFromProto(OpenOffer.State.class, proto.getState().name()), ProtoUtil.enumFromProto(OpenOffer.State.class, proto.getState().name()),
proto.getTriggerPrice(), proto.getTriggerPrice(),
proto.getSplitOutput(), proto.getReserveExactAmount(),
proto.getScheduledAmount(), proto.getScheduledAmount(),
proto.getScheduledTxHashesList(), proto.getScheduledTxHashesList(),
ProtoUtil.stringOrNullFromProto(proto.getSplitOutputTxHash()), ProtoUtil.stringOrNullFromProto(proto.getSplitOutputTxHash()),

View File

@ -490,13 +490,13 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
public void placeOffer(Offer offer, public void placeOffer(Offer offer,
boolean useSavingsWallet, boolean useSavingsWallet,
long triggerPrice, long triggerPrice,
boolean splitOutput, boolean reserveExactAmount,
TransactionResultHandler resultHandler, TransactionResultHandler resultHandler,
ErrorMessageHandler errorMessageHandler) { ErrorMessageHandler errorMessageHandler) {
checkNotNull(offer.getMakerFee(), "makerFee must not be null"); checkNotNull(offer.getMakerFee(), "makerFee must not be null");
// create open offer // create open offer
OpenOffer openOffer = new OpenOffer(offer, triggerPrice, splitOutput); OpenOffer openOffer = new OpenOffer(offer, triggerPrice, reserveExactAmount);
// process open offer to schedule or post // process open offer to schedule or post
processUnpostedOffer(getOpenOffers(), openOffer, (transaction) -> { processUnpostedOffer(getOpenOffers(), openOffer, (transaction) -> {
@ -807,7 +807,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
BigInteger offerReserveAmount = openOffer.getOffer().getReserveAmount(); BigInteger offerReserveAmount = openOffer.getOffer().getReserveAmount();
// handle split output offer // handle split output offer
if (openOffer.isSplitOutput()) { if (openOffer.isReserveExactAmount()) {
// find tx with exact input amount // find tx with exact input amount
MoneroTxWallet splitOutputTx = findSplitOutputFundingTx(openOffers, openOffer); MoneroTxWallet splitOutputTx = findSplitOutputFundingTx(openOffers, openOffer);

View File

@ -56,7 +56,7 @@ public class MakerReserveOfferFunds extends Task<PlaceOfferModel> {
String returnAddress = model.getXmrWalletService().getOrCreateAddressEntry(offer.getId(), XmrAddressEntry.Context.TRADE_PAYOUT).getAddressString(); 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); XmrAddressEntry fundingEntry = model.getXmrWalletService().getAddressEntry(offer.getId(), XmrAddressEntry.Context.OFFER_FUNDING).orElse(null);
Integer preferredSubaddressIndex = fundingEntry == null ? null : fundingEntry.getSubaddressIndex(); 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 // check for error in case creating reserve tx exceeded timeout
// TODO: better way? // TODO: better way?

View File

@ -76,12 +76,12 @@ public class MaybeSendSignContractRequest extends TradeTask {
// create deposit tx and freeze inputs // create deposit tx and freeze inputs
Integer subaddressIndex = null; Integer subaddressIndex = null;
boolean isSplitOutputOffer = false; boolean reserveExactAmount = false;
if (trade instanceof MakerTrade) { if (trade instanceof MakerTrade) {
isSplitOutputOffer = processModel.getOpenOfferManager().getOpenOfferById(trade.getId()).get().isSplitOutput(); reserveExactAmount = processModel.getOpenOfferManager().getOpenOfferById(trade.getId()).get().isReserveExactAmount();
if (isSplitOutputOffer) subaddressIndex = model.getXmrWalletService().getAddressEntry(trade.getId(), XmrAddressEntry.Context.OFFER_FUNDING).get().getSubaddressIndex(); 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 // collect reserved key images
List<String> reservedKeyImages = new ArrayList<String>(); List<String> reservedKeyImages = new ArrayList<String>();

View File

@ -158,7 +158,7 @@ class GrpcOffersService extends OffersImplBase {
req.getMinAmount(), req.getMinAmount(),
req.getBuyerSecurityDepositPct(), req.getBuyerSecurityDepositPct(),
req.getTriggerPrice(), req.getTriggerPrice(),
req.getSplitOutput(), req.getReserveExactAmount(),
req.getPaymentAccountId(), req.getPaymentAccountId(),
offer -> { offer -> {
// This result handling consumer's accept operation will return // This result handling consumer's accept operation will return

View File

@ -129,7 +129,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
@Getter @Getter
protected long triggerPrice; protected long triggerPrice;
@Getter @Getter
protected boolean splitOutput; protected boolean reserveExactAmount;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -167,7 +167,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
shortOfferId = Utilities.getShortId(offerId); shortOfferId = Utilities.getShortId(offerId);
addressEntry = xmrWalletService.getOrCreateAddressEntry(offerId, XmrAddressEntry.Context.OFFER_FUNDING); addressEntry = xmrWalletService.getOrCreateAddressEntry(offerId, XmrAddressEntry.Context.OFFER_FUNDING);
splitOutput = preferences.getSplitOfferOutput(); reserveExactAmount = preferences.getSplitOfferOutput();
useMarketBasedPrice.set(preferences.isUsePercentageBasedPrice()); useMarketBasedPrice.set(preferences.isUsePercentageBasedPrice());
buyerSecurityDepositPct.set(Restrictions.getMinBuyerSecurityDepositAsPercent()); buyerSecurityDepositPct.set(Restrictions.getMinBuyerSecurityDepositAsPercent());
@ -299,7 +299,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
openOfferManager.placeOffer(offer, openOfferManager.placeOffer(offer,
useSavingsWallet, useSavingsWallet,
triggerPrice, triggerPrice,
splitOutput, reserveExactAmount,
resultHandler, resultHandler,
errorMessageHandler); errorMessageHandler);
} }
@ -682,8 +682,8 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
this.triggerPrice = triggerPrice; this.triggerPrice = triggerPrice;
} }
public void setSplitOutput(boolean splitOutput) { public void setReserveExactAmount(boolean reserveExactAmount) {
this.splitOutput = splitOutput; this.reserveExactAmount = reserveExactAmount;
} }
public boolean isUsingRoundedAtmCashAccount() { public boolean isUsingRoundedAtmCashAccount() {

View File

@ -136,7 +136,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
private TextField currencyTextField; private TextField currencyTextField;
private AddressTextField addressTextField; private AddressTextField addressTextField;
private BalanceTextField balanceTextField; private BalanceTextField balanceTextField;
private CheckBox splitOutputCheckbox; private CheckBox reserveExactAmountCheckbox;
private FundsTextField totalToPayTextField; private FundsTextField totalToPayTextField;
private Label amountDescriptionLabel, priceCurrencyLabel, priceDescriptionLabel, volumeDescriptionLabel, private Label amountDescriptionLabel, priceCurrencyLabel, priceDescriptionLabel, volumeDescriptionLabel,
waitingForFundsLabel, marketBasedPriceLabel, percentagePriceDescriptionLabel, tradeFeeDescriptionLabel, waitingForFundsLabel, marketBasedPriceLabel, percentagePriceDescriptionLabel, tradeFeeDescriptionLabel,
@ -421,7 +421,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
qrCodeImageView.setVisible(true); qrCodeImageView.setVisible(true);
balanceTextField.setVisible(true); balanceTextField.setVisible(true);
cancelButton2.setVisible(true); cancelButton2.setVisible(true);
splitOutputCheckbox.setVisible(true); reserveExactAmountCheckbox.setVisible(true);
} }
private void updateOfferElementsStyle() { private void updateOfferElementsStyle() {
@ -1093,18 +1093,18 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
Res.get("shared.tradeWalletBalance")); Res.get("shared.tradeWalletBalance"));
balanceTextField.setVisible(false); balanceTextField.setVisible(false);
splitOutputCheckbox = FormBuilder.addLabelCheckBox(gridPane, ++gridRow, reserveExactAmountCheckbox = FormBuilder.addLabelCheckBox(gridPane, ++gridRow,
Res.get("shared.reserveExactAmount")); Res.get("shared.reserveExactAmount"));
GridPane.setHalignment(splitOutputCheckbox, HPos.LEFT); GridPane.setHalignment(reserveExactAmountCheckbox, HPos.LEFT);
splitOutputCheckbox.setVisible(false); reserveExactAmountCheckbox.setVisible(false);
splitOutputCheckbox.setSelected(preferences.getSplitOfferOutput()); reserveExactAmountCheckbox.setSelected(preferences.getSplitOfferOutput());
splitOutputCheckbox.setOnAction(event -> { reserveExactAmountCheckbox.setOnAction(event -> {
boolean selected = splitOutputCheckbox.isSelected(); boolean selected = reserveExactAmountCheckbox.isSelected();
if (selected != preferences.getSplitOfferOutput()) { if (selected != preferences.getSplitOfferOutput()) {
preferences.setSplitOfferOutput(selected); preferences.setSplitOfferOutput(selected);
model.dataModel.setSplitOutput(selected); model.dataModel.setReserveExactAmount(selected);
} }
}); });

View File

@ -115,7 +115,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
// If we would change the price representation in the domain we would not be backward compatible // 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 price = new SimpleStringProperty();
public final StringProperty triggerPrice = 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 tradeFee = new SimpleStringProperty();
final StringProperty tradeFeeInXmrWithFiat = new SimpleStringProperty(); final StringProperty tradeFeeInXmrWithFiat = new SimpleStringProperty();
final StringProperty tradeFeeCurrencyCode = new SimpleStringProperty(); final StringProperty tradeFeeCurrencyCode = new SimpleStringProperty();
@ -779,8 +779,8 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
} }
} }
public void onSplitOutputCheckboxChanged() { public void onReserveExactAmountCheckboxChanged() {
dataModel.setSplitOutput(splitOutput.get()); dataModel.setReserveExactAmount(reserveExactAmount.get());
} }
void onFixPriceToggleChange(boolean fixedPriceSelected) { void onFixPriceToggleChange(boolean fixedPriceSelected) {

View File

@ -82,7 +82,7 @@ class EditOfferViewModel extends MutableOfferViewModel<EditOfferDataModel> {
triggerPrice.set(""); triggerPrice.set("");
} }
onTriggerPriceTextFieldChanged(); onTriggerPriceTextFieldChanged();
onSplitOutputCheckboxChanged(); onReserveExactAmountCheckboxChanged();
} }
public void applyOpenOffer(OpenOffer openOffer) { public void applyOpenOffer(OpenOffer openOffer) {

View File

@ -498,7 +498,7 @@ message PostOfferRequest {
uint64 min_amount = 7 [jstype = JS_STRING]; uint64 min_amount = 7 [jstype = JS_STRING];
double buyer_security_deposit_pct = 8; double buyer_security_deposit_pct = 8;
string trigger_price = 9; string trigger_price = 9;
bool split_output = 10; bool reserve_exact_amount = 10;
string payment_account_id = 11; string payment_account_id = 11;
} }

View File

@ -1377,7 +1377,7 @@ message OpenOffer {
Offer offer = 1; Offer offer = 1;
State state = 2; State state = 2;
int64 trigger_price = 3; int64 trigger_price = 3;
bool split_output = 4; bool reserve_exact_amount = 4;
repeated string scheduled_tx_hashes = 5; repeated string scheduled_tx_hashes = 5;
string scheduled_amount = 6; // BigInteger string scheduled_amount = 6; // BigInteger
string split_output_tx_hash = 7; string split_output_tx_hash = 7;