Skip to content

Commit

Permalink
Merge pull request #4578 from chimp1984/show-if-maker-has-xmr-autocon…
Browse files Browse the repository at this point in the history
…f-enabled

Show if maker has xmr autoconf enabled
  • Loading branch information
ripcurlx committed Oct 1, 2020
2 parents 4d7e26d + 137d918 commit a1778ed
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 6 deletions.
4 changes: 3 additions & 1 deletion core/src/main/java/bisq/core/offer/CreateOfferService.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ public Offer createAndGetOffer(String offerId,
Map<String, String> extraDataMap = OfferUtil.getExtraDataMap(accountAgeWitnessService,
referralIdService,
paymentAccount,
currencyCode);
currencyCode,
preferences,
direction);

OfferUtil.validateOfferData(filterManager,
p2PService,
Expand Down
15 changes: 15 additions & 0 deletions core/src/main/java/bisq/core/offer/Offer.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,21 @@ public boolean isUseReOpenAfterAutoClose() {
return offerPayload.isUseReOpenAfterAutoClose();
}

public boolean isXmrAutoConf() {
if (!isXmr()) {
return false;
}
if (getExtraDataMap() == null || !getExtraDataMap().containsKey(OfferPayload.XMR_AUTO_CONF)) {
return false;
}

return getExtraDataMap().get(OfferPayload.XMR_AUTO_CONF).equals(OfferPayload.XMR_AUTO_CONF_ENABLED_VALUE);
}

public boolean isXmr() {
return getCurrencyCode().equals("XMR");
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/bisq/core/offer/OfferPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public static protobuf.OfferPayload.Direction toProtoMessage(Direction direction
// Capability.SIGNED_ACCOUNT_AGE_WITNESS is 11 and Capability.MEDIATION is 12 so if we want to signal that maker
// of the offer supports both capabilities we add "11, 12" to capabilities.
public static final String CAPABILITIES = "capabilities";
// If maker is seller and has xmrAutoConf enabled it is set to "1" otherwise it is not set
public static final String XMR_AUTO_CONF = "xmrAutoConf";
public static final String XMR_AUTO_CONF_ENABLED_VALUE = "1";


///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 11 additions & 1 deletion core/src/main/java/bisq/core/offer/OfferUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import bisq.core.provider.price.MarketPrice;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.statistics.ReferralIdService;
import bisq.core.user.AutoConfirmSettings;
import bisq.core.user.Preferences;
import bisq.core.util.coin.CoinFormatter;
import bisq.core.util.coin.CoinUtil;
Expand Down Expand Up @@ -333,7 +334,9 @@ private static Optional<Volume> getFeeInUserFiatCurrency(Coin makerFee, boolean
public static Map<String, String> getExtraDataMap(AccountAgeWitnessService accountAgeWitnessService,
ReferralIdService referralIdService,
PaymentAccount paymentAccount,
String currencyCode) {
String currencyCode,
Preferences preferences,
OfferPayload.Direction direction) {
Map<String, String> extraDataMap = new HashMap<>();
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
String myWitnessHashAsHex = accountAgeWitnessService.getMyWitnessHashAsHex(paymentAccount.getPaymentAccountPayload());
Expand All @@ -351,6 +354,13 @@ public static Map<String, String> getExtraDataMap(AccountAgeWitnessService accou

extraDataMap.put(OfferPayload.CAPABILITIES, Capabilities.app.toStringList());

if (currencyCode.equals("XMR") && direction == OfferPayload.Direction.SELL) {
preferences.getAutoConfirmSettingsList().stream()
.filter(e -> e.getCurrencyCode().equals("XMR"))
.filter(AutoConfirmSettings::isEnabled)
.forEach(e -> extraDataMap.put(OfferPayload.XMR_AUTO_CONF, OfferPayload.XMR_AUTO_CONF_ENABLED_VALUE));
}

return extraDataMap.isEmpty() ? null : extraDataMap;
}

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ offerbook.offerersAcceptedBankSeats=Accepted seat of bank countries (taker):\n {
offerbook.availableOffers=Available offers
offerbook.filterByCurrency=Filter by currency
offerbook.filterByPaymentMethod=Filter by payment method
offerbook.timeSinceSigning=Time since signing
offerbook.timeSinceSigning=Signed since
offerbook.timeSinceSigning.info=This account was verified and {0}
offerbook.timeSinceSigning.info.arbitrator=signed by an arbitrator and can sign peer accounts
offerbook.timeSinceSigning.info.peer=signed by a peer, waiting for limits to be lifted
Expand All @@ -347,6 +347,7 @@ offerbook.timeSinceSigning.info.signer=signed by peer and can sign peer accounts
offerbook.timeSinceSigning.info.banned=account was banned
offerbook.timeSinceSigning.daysSinceSigning={0} days
offerbook.timeSinceSigning.daysSinceSigning.long={0} since signing
offerbook.xmrAutoConf=Is auto-confirm enabled

offerbook.timeSinceSigning.help=When you successfully complete a trade with a peer who has a signed payment account, your payment account is signed.\n\
{0} days later, the initial limit of {1} is lifted and your account can sign other peers'' payment accounts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import javax.inject.Inject;
import javax.inject.Named;

import de.jensd.fx.fontawesome.AwesomeIcon;
import de.jensd.fx.glyphs.GlyphIcons;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;

Expand Down Expand Up @@ -867,7 +868,11 @@ public void updateItem(final OfferBookListItem item, boolean empty) {
if (model.isOfferBanned(item.getOffer())) {
setGraphic(new AutoTooltipLabel(model.getPaymentMethod(item)));
} else {
field = new HyperlinkWithIcon(model.getPaymentMethod(item));
if (item.getOffer().isXmrAutoConf()) {
field = new HyperlinkWithIcon(model.getPaymentMethod(item), AwesomeIcon.ROCKET);
} else {
field = new HyperlinkWithIcon(model.getPaymentMethod(item));
}
field.setOnAction(event -> offerDetailsWindow.show(item.getOffer()));
field.setTooltip(new Tooltip(model.getPaymentMethodToolTip(item)));
setGraphic(field);
Expand Down Expand Up @@ -937,6 +942,7 @@ private TableColumn<OfferBookListItem, OfferBookListItem> getActionColumn() {
setSortable(false);
}
};
column.getStyleClass().addAll("last-column", "avatar-column");
column.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
column.setCellFactory(
new Callback<>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,13 @@ String getPaymentMethodToolTip(OfferBookListItem item) {
result = Res.getWithCol("shared.paymentMethod") + " " + Res.get(offer.getPaymentMethod().getId());
result += "\n" + Res.getWithCol("shared.currency") + " " + CurrencyUtil.getNameAndCode(offer.getCurrencyCode());

if (offer.isXmr()) {
String isAutoConf = offer.isXmrAutoConf() ?
Res.get("shared.yes") :
Res.get("shared.no");
result += "\n" + Res.getWithCol("offerbook.xmrAutoConf") + " " + isAutoConf;
}

String countryCode = offer.getCountryCode();
if (isF2F(offer)) {
if (countryCode != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
///////////////////////////////////////////////////////////////////////////////////////////

@Inject
public OfferDetailsWindow(@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, User user, KeyRing keyRing,
public OfferDetailsWindow(@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
User user,
KeyRing keyRing,
Navigation navigation) {
this.formatter = formatter;
this.user = user;
Expand Down Expand Up @@ -163,6 +165,10 @@ private void addContent() {
if (isF2F)
rows += 2;

if (offer.isXmr()) {
rows++;
}

addTitledGroupBg(gridPane, ++rowIndex, rows, Res.get("shared.Offer"));

String fiatDirectionInfo = "";
Expand Down Expand Up @@ -255,6 +261,14 @@ else if (BankUtil.isBankNameRequired(countryCode))
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.paymentMethod"), method);
}
}

if (offer.isXmr()) {
String isAutoConf = offer.isXmrAutoConf() ?
Res.get("shared.yes") :
Res.get("shared.no");
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("offerbook.xmrAutoConf"), isAutoConf);
}

if (showAcceptedBanks) {
if (paymentMethod.equals(PaymentMethod.SAME_BANK)) {
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("offerDetailsWindow.bankId"), acceptedBanks.get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private void addContent() {
addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradingPeersOnion"),
trade.getTradingPeerNodeAddress().getFullAddress());

if (checkNotNull(trade.getOffer()).getCurrencyCode().equals("XMR") &&
if (checkNotNull(trade.getOffer()).isXmr() &&
trade.getAssetTxProofResult() != null &&
trade.getAssetTxProofResult() != AssetTxProofResult.UNDEFINED) {
// As the window is already overloaded we replace the tradingPeersPubKeyHash field with the auto-conf state
Expand Down

0 comments on commit a1778ed

Please sign in to comment.