use wallet lock with xmr address entries

This commit is contained in:
woodser 2024-01-25 06:16:52 -05:00
parent 153f708a7c
commit 8776fecef0

View File

@ -1206,9 +1206,11 @@ public class XmrWalletService {
}
public List<XmrAddressEntry> getFundedAvailableAddressEntries() {
synchronized (walletLock) {
List<MoneroSubaddress> subaddresses = wallet.getSubaddresses(0);
return getAvailableAddressEntries().stream().filter(addressEntry -> getBalanceForSubaddress(addressEntry.getSubaddressIndex(), subaddresses).compareTo(BigInteger.ZERO) > 0).collect(Collectors.toList());
}
}
public List<XmrAddressEntry> getAddressEntryListAsImmutableList() {
synchronized (walletLock) {
@ -1225,8 +1227,10 @@ public class XmrWalletService {
}
public List<XmrAddressEntry> getUnusedAddressEntries() {
synchronized (walletLock) {
return getUnusedAddressEntries(getTxsWithIncomingOutputs(), wallet.getSubaddresses(0));
}
}
public List<XmrAddressEntry> getUnusedAddressEntries(List<MoneroTxWallet> cachedTxs, List<MoneroSubaddress> cachedSubaddresses) {
return getAvailableAddressEntries().stream()
@ -1338,6 +1342,7 @@ public class XmrWalletService {
}
public Stream<XmrAddressEntry> getAddressEntriesForAvailableBalanceStream() {
synchronized (walletLock) {
Stream<XmrAddressEntry> available = getFundedAvailableAddressEntries().stream();
available = Stream.concat(available, getAddressEntries(XmrAddressEntry.Context.ARBITRATOR).stream());
available = Stream.concat(available, getAddressEntries(XmrAddressEntry.Context.OFFER_FUNDING).stream().filter(entry -> !tradeManager.getOpenOfferManager().getOpenOfferById(entry.getOfferId()).isPresent()));
@ -1345,6 +1350,7 @@ public class XmrWalletService {
List<MoneroSubaddress> subaddresses = wallet.getSubaddresses(0);
return available.filter(addressEntry -> getBalanceForSubaddress(addressEntry.getSubaddressIndex(), subaddresses).compareTo(BigInteger.ZERO) > 0);
}
}
public void addWalletListener(MoneroWalletListenerI listener) {
synchronized (walletListeners) {