mirror of
https://github.com/boldsuck/haveno.git
synced 2024-12-23 04:29:22 +00:00
getNewAddressEntry() recovers and gets new subaddress if offline
This commit is contained in:
parent
55edf10635
commit
4aa13bffff
1 changed files with 8 additions and 3 deletions
|
@ -844,9 +844,14 @@ public class XmrWalletService {
|
||||||
public synchronized XmrAddressEntry getNewAddressEntry(String offerId, XmrAddressEntry.Context context) {
|
public synchronized XmrAddressEntry getNewAddressEntry(String offerId, XmrAddressEntry.Context context) {
|
||||||
|
|
||||||
// try to use available and not yet used entries
|
// try to use available and not yet used entries
|
||||||
|
try {
|
||||||
List<MoneroTxWallet> incomingTxs = getIncomingTxs(); // prefetch all incoming txs to avoid query per subaddress
|
List<MoneroTxWallet> incomingTxs = getIncomingTxs(); // prefetch all incoming txs to avoid query per subaddress
|
||||||
Optional<XmrAddressEntry> emptyAvailableAddressEntry = getAddressEntryListAsImmutableList().stream().filter(e -> XmrAddressEntry.Context.AVAILABLE == e.getContext()).filter(e -> isSubaddressUnused(e.getSubaddressIndex(), incomingTxs)).findAny();
|
Optional<XmrAddressEntry> emptyAvailableAddressEntry = getAddressEntryListAsImmutableList().stream().filter(e -> XmrAddressEntry.Context.AVAILABLE == e.getContext()).filter(e -> isSubaddressUnused(e.getSubaddressIndex(), incomingTxs)).findAny();
|
||||||
if (emptyAvailableAddressEntry.isPresent()) return xmrAddressEntryList.swapAvailableToAddressEntryWithOfferId(emptyAvailableAddressEntry.get(), context, offerId);
|
if (emptyAvailableAddressEntry.isPresent()) return xmrAddressEntryList.swapAvailableToAddressEntryWithOfferId(emptyAvailableAddressEntry.get(), context, offerId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Error getting new address entriy based on incoming transactions");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
// create new subaddress and entry
|
// create new subaddress and entry
|
||||||
MoneroSubaddress subaddress = wallet.createSubaddress(0);
|
MoneroSubaddress subaddress = wallet.createSubaddress(0);
|
||||||
|
|
Loading…
Reference in a new issue