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

View file

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

View file

@ -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<String> 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()),

View file

@ -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);

View file

@ -56,7 +56,7 @@ public class MakerReserveOfferFunds extends Task<PlaceOfferModel> {
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?

View file

@ -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<String> reservedKeyImages = new ArrayList<String>();

View file

@ -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

View file

@ -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() {

View file

@ -136,7 +136,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> 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<M extends MutableOfferViewModel<?>> 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<M extends MutableOfferViewModel<?>> 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);
}
});

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
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<M extends MutableOfferDataModel> ext
}
}
public void onSplitOutputCheckboxChanged() {
dataModel.setSplitOutput(splitOutput.get());
public void onReserveExactAmountCheckboxChanged() {
dataModel.setReserveExactAmount(reserveExactAmount.get());
}
void onFixPriceToggleChange(boolean fixedPriceSelected) {

View file

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

View file

@ -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;
}

View file

@ -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;