Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve XMR subaddress popup behaviour #7378

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ public void addFormForAddAccount() {
setFieldManagement(xmrAccountDelegate.isUsingSubAddresses());
addLimitations(false);
addAccountNameTextFieldWithAutoFillToggleButton();

showXmrSubAddressPopup();
}

void setFieldManagement(boolean useSubAddresses) {
Expand Down Expand Up @@ -362,6 +364,15 @@ public void updateAllInputsValid() {
}
}

public static void showXmrSubAddressPopup() {
new Popup()
.headLine(Res.get("account.altcoin.popup.xmr.dataDirWarningHeadline"))
.backgroundInfo(Res.get("account.altcoin.popup.xmr.dataDirWarning"))
.dontShowAgainId("accountSubAddressInfo")
.width(700)
.show();
}

private void maybeShowXmrSubAddressInfo() {
String key = "xmrSubAddressInfo";
if (DontShowAgainLookup.showAgain(key)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
package bisq.desktop.main.account.content.altcoinaccounts;

import bisq.desktop.common.model.ActivatableDataModel;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.components.paymentmethods.XmrForm;
import bisq.desktop.util.GUIUtil;

import bisq.core.locale.CryptoCurrency;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.offer.OpenOfferManager;
import bisq.core.payment.AssetAccount;
import bisq.core.payment.CryptoCurrencyAccount;
import bisq.core.payment.PaymentAccount;
import bisq.core.trade.TradeManager;
import bisq.core.user.Preferences;
Expand All @@ -44,6 +44,7 @@

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;
import java.util.stream.Collectors;

class AltCoinAccountsDataModel extends ActivatableDataModel {
Expand Down Expand Up @@ -79,14 +80,12 @@ protected void activate() {
user.getPaymentAccountsAsObservable().addListener(setChangeListener);
fillAndSortPaymentAccounts();

paymentAccounts.stream().filter(e -> e.getSingleTradeCurrency().getCode().equals("XMR"))
.findAny().ifPresent(e -> {
new Popup()
.headLine(Res.get("account.altcoin.popup.xmr.dataDirWarningHeadline"))
.backgroundInfo(Res.get("account.altcoin.popup.xmr.dataDirWarning"))
.dontShowAgainId("accountSubAddressInfo")
.width(700)
.show();
paymentAccounts.stream()
.filter(e -> e.getSingleTradeCurrency().getCode().equals("XMR"))
.forEach(e -> {
if (!xmrAccountUsesSubAddresses(e)) {
XmrForm.showXmrSubAddressPopup();
}
});
}

Expand All @@ -99,6 +98,21 @@ private void fillAndSortPaymentAccounts() {
}
}

private boolean xmrAccountUsesSubAddresses(PaymentAccount paymentAccount) {
if (paymentAccount instanceof CryptoCurrencyAccount) {
CryptoCurrencyAccount account = (CryptoCurrencyAccount) paymentAccount;
Map<String, String> extraData = account.getExtraData();
if (extraData == null) {
return false;
}

String useXMmrSubAddresses = extraData.get("UseXMmrSubAddresses");
return useXMmrSubAddresses != null && useXMmrSubAddresses.equals("1");
}

return false;
}

@Override
protected void deactivate() {
user.getPaymentAccountsAsObservable().removeListener(setChangeListener);
Expand Down
Loading