BtcWalletService.getFreshAddressEntry(): code clean up

This commit is contained in:
Oscar Guindzberg 2020-10-05 17:05:59 -03:00
parent b9e404f0e2
commit 5524ba3e97
No known key found for this signature in database
GPG Key ID: 209796BF2E1D4F75

View File

@ -614,7 +614,12 @@ public class BtcWalletService extends WalletService {
Optional<AddressEntry> addressEntry = getAddressEntryListAsImmutableList().stream()
.filter(e -> context == e.getContext())
.filter(e -> isAddressUnused(e.getAddress()))
.filter(e -> Script.ScriptType.P2WPKH.equals(e.getAddress().getOutputScriptType()) == segwit)
.filter(e -> {
boolean isSegwitOutputScriptType = Script.ScriptType.P2WPKH.equals(e.getAddress().getOutputScriptType());
// We need to ensure that we take only addressEntries which matches our segWit flag
boolean isMatchingOutputScriptType = isSegwitOutputScriptType == segwit;
return isMatchingOutputScriptType;
})
.findAny();
return getOrCreateAddressEntry(context, addressEntry, segwit);
}