Show XMR subaddress popup if user has non-subaddress account

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.
This commit is contained in:
Alva Swanson 2025-02-05 19:53:09 +00:00
parent 9f3e216fe1
commit 958661f25b
No known key found for this signature in database
GPG key ID: 004760E77F753090

View file

@ -26,6 +26,7 @@ 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;
@ -44,6 +45,7 @@ import javafx.collections.SetChangeListener;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;
import java.util.stream.Collectors;
class AltCoinAccountsDataModel extends ActivatableDataModel {
@ -79,14 +81,17 @@ class AltCoinAccountsDataModel extends ActivatableDataModel {
user.getPaymentAccountsAsObservable().addListener(setChangeListener);
fillAndSortPaymentAccounts();
paymentAccounts.stream().filter(e -> e.getSingleTradeCurrency().getCode().equals("XMR"))
.findAny().ifPresent(e -> {
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();
}
});
}
@ -99,6 +104,21 @@ class AltCoinAccountsDataModel extends ActivatableDataModel {
}
}
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);