Skip to content

Commit

Permalink
Enable reusing unused AVAILABLE entries
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarguindzberg committed Oct 1, 2020
1 parent f3f919e commit f09d829
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions core/src/main/java/bisq/core/btc/wallet/BtcWalletService.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,20 +578,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<AddressEntry> 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<AddressEntry> 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;
// }
}
}
}

Expand Down

0 comments on commit f09d829

Please sign in to comment.