From f9afd44345365ac8df5b022152cd3ed9d8c58db8 Mon Sep 17 00:00:00 2001 From: woodser Date: Tue, 14 Nov 2023 08:20:33 -0500 Subject: [PATCH] synchronize on wallet lock getting address entries --- .../haveno/core/xmr/wallet/XmrWalletService.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index 104037a83a..d20d28c072 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -1026,15 +1026,17 @@ public class XmrWalletService { } public List getAddressEntryListAsImmutableList() { - List subaddresses = wallet.getSubaddresses(0); - for (MoneroSubaddress subaddress : subaddresses) { - boolean exists = xmrAddressEntryList.getAddressEntriesAsListImmutable().stream().filter(addressEntry -> addressEntry.getAddressString().equals(subaddress.getAddress())).findAny().isPresent(); - if (!exists) { - XmrAddressEntry entry = new XmrAddressEntry(subaddress.getIndex(), subaddress.getAddress(), subaddress.getIndex() == 0 ? XmrAddressEntry.Context.BASE_ADDRESS : XmrAddressEntry.Context.AVAILABLE, null, null); - xmrAddressEntryList.addAddressEntry(entry); + synchronized (walletLock) { + List subaddresses = wallet.getSubaddresses(0); + for (MoneroSubaddress subaddress : subaddresses) { + boolean exists = xmrAddressEntryList.getAddressEntriesAsListImmutable().stream().filter(addressEntry -> addressEntry.getAddressString().equals(subaddress.getAddress())).findAny().isPresent(); + if (!exists) { + 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 getUnusedAddressEntries() {