diff --git a/core/src/main/java/bisq/core/btc/wallet/BtcWalletService.java b/core/src/main/java/bisq/core/btc/wallet/BtcWalletService.java index 1f6a02e4d61..9b6843e122f 100644 --- a/core/src/main/java/bisq/core/btc/wallet/BtcWalletService.java +++ b/core/src/main/java/bisq/core/btc/wallet/BtcWalletService.java @@ -579,20 +579,20 @@ public AddressEntry getOrCreateAddressEntry(String offerId, AddressEntry.Context if (addressEntry.isPresent()) { return addressEntry.get(); } else { -// Disable reusing unused AVAILABLE entries until segwit support in mandatory in Bisq // We try to use available and not yet used entries -// Optional emptyAvailableAddressEntry = getAddressEntryListAsImmutableList().stream() -// .filter(e -> AddressEntry.Context.AVAILABLE == e.getContext()) -// .filter(e -> isAddressUnused(e.getAddress())) -// .findAny(); -// if (emptyAvailableAddressEntry.isPresent()) { -// return addressEntryList.swapAvailableToAddressEntryWithOfferId(emptyAvailableAddressEntry.get(), context, offerId); -// } else { + Optional emptyAvailableAddressEntry = getAddressEntryListAsImmutableList().stream() + .filter(e -> AddressEntry.Context.AVAILABLE == e.getContext()) + .filter(e -> isAddressUnused(e.getAddress())) + .filter(e -> Script.ScriptType.P2PKH.equals(e.getAddress().getOutputScriptType())) + .findAny(); + if (emptyAvailableAddressEntry.isPresent()) { + return addressEntryList.swapAvailableToAddressEntryWithOfferId(emptyAvailableAddressEntry.get(), context, offerId); + } else { DeterministicKey key = (DeterministicKey) wallet.findKeyFromAddress(wallet.freshReceiveAddress(Script.ScriptType.P2PKH)); AddressEntry entry = new AddressEntry(key, context, offerId, false); addressEntryList.addAddressEntry(entry); return entry; -// } + } } }