Skip to content

Commit

Permalink
BtcWalletService.getFreshAddressEntry(): code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarguindzberg committed Oct 5, 2020
1 parent 70340ce commit 1155fc7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,12 @@ public AddressEntry getFreshAddressEntry(boolean segwit) {
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);
}
Expand Down

0 comments on commit 1155fc7

Please sign in to comment.