Skip to content

Commit

Permalink
Show XMR subaddress popup if user has non-subaddress account
Browse files Browse the repository at this point in the history
Before PR #7123, we showed the XMR subaddress popup whenever the user
naviated to the account tab. After PR #7123, we show the XMR subaddress
popup if the user has an XMR account. However, it's better show the
popup if the user has a non-subaddress XMR account.
  • Loading branch information
alvasw committed Feb 5, 2025
1 parent 9f3e216 commit 958661f
Showing 1 changed file with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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 +45,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 +81,17 @@ 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)) {
new Popup()
.headLine(Res.get("account.altcoin.popup.xmr.dataDirWarningHeadline"))
.backgroundInfo(Res.get("account.altcoin.popup.xmr.dataDirWarning"))
.dontShowAgainId("accountSubAddressInfo")
.width(700)
.show();
}
});
}

Expand All @@ -99,6 +104,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

0 comments on commit 958661f

Please sign in to comment.