AltCoinAccountsDataModel: Handle XMR detection NullPointerException

The PaymentAccount.getSingleTradeCurrency(...) method can return null
in certain cases.
This commit is contained in:
Alva Swanson 2025-02-05 19:55:12 +00:00
parent 861f655ae7
commit 93985137a0
No known key found for this signature in database
GPG key ID: 004760E77F753090

View file

@ -81,7 +81,7 @@ class AltCoinAccountsDataModel extends ActivatableDataModel {
fillAndSortPaymentAccounts();
paymentAccounts.stream()
.filter(e -> e.getSingleTradeCurrency().getCode().equals("XMR"))
.filter(this::isXmrPaymentAccount)
.forEach(e -> {
if (!xmrAccountUsesSubAddresses(e)) {
XmrForm.showXmrSubAddressPopup();
@ -98,6 +98,11 @@ class AltCoinAccountsDataModel extends ActivatableDataModel {
}
}
private boolean isXmrPaymentAccount(PaymentAccount paymentAccount) {
TradeCurrency tradeCurrency = paymentAccount.getSingleTradeCurrency();
return tradeCurrency != null && tradeCurrency.getCode().equals("XMR");
}
private boolean xmrAccountUsesSubAddresses(PaymentAccount paymentAccount) {
if (paymentAccount instanceof CryptoCurrencyAccount) {
CryptoCurrencyAccount account = (CryptoCurrencyAccount) paymentAccount;