synchronize on wallet lock getting address entries

This commit is contained in:
woodser 2023-11-14 08:20:33 -05:00
parent e2369480b2
commit f9afd44345

View File

@ -1026,15 +1026,17 @@ public class XmrWalletService {
} }
public List<XmrAddressEntry> getAddressEntryListAsImmutableList() { public List<XmrAddressEntry> getAddressEntryListAsImmutableList() {
List<MoneroSubaddress> subaddresses = wallet.getSubaddresses(0); synchronized (walletLock) {
for (MoneroSubaddress subaddress : subaddresses) { List<MoneroSubaddress> subaddresses = wallet.getSubaddresses(0);
boolean exists = xmrAddressEntryList.getAddressEntriesAsListImmutable().stream().filter(addressEntry -> addressEntry.getAddressString().equals(subaddress.getAddress())).findAny().isPresent(); for (MoneroSubaddress subaddress : subaddresses) {
if (!exists) { boolean exists = xmrAddressEntryList.getAddressEntriesAsListImmutable().stream().filter(addressEntry -> addressEntry.getAddressString().equals(subaddress.getAddress())).findAny().isPresent();
XmrAddressEntry entry = new XmrAddressEntry(subaddress.getIndex(), subaddress.getAddress(), subaddress.getIndex() == 0 ? XmrAddressEntry.Context.BASE_ADDRESS : XmrAddressEntry.Context.AVAILABLE, null, null); if (!exists) {
xmrAddressEntryList.addAddressEntry(entry); XmrAddressEntry entry = new XmrAddressEntry(subaddress.getIndex(), subaddress.getAddress(), subaddress.getIndex() == 0 ? XmrAddressEntry.Context.BASE_ADDRESS : XmrAddressEntry.Context.AVAILABLE, null, null);
xmrAddressEntryList.addAddressEntry(entry);
}
} }
return xmrAddressEntryList.getAddressEntriesAsListImmutable();
} }
return xmrAddressEntryList.getAddressEntriesAsListImmutable();
} }
public List<XmrAddressEntry> getUnusedAddressEntries() { public List<XmrAddressEntry> getUnusedAddressEntries() {