mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-05 03:26:43 +00:00
dont consider height when selecting
This commit is contained in:
parent
e8bb733ea8
commit
0fbce035a3
1 changed files with 11 additions and 2 deletions
|
@ -14,8 +14,17 @@ public class PresetUtxoSelector implements UtxoSelector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<BlockTransactionHashIndex> select(long targetValue, Collection<OutputGroup> candidates) {
|
public Collection<BlockTransactionHashIndex> select(long targetValue, Collection<OutputGroup> candidates) {
|
||||||
List<BlockTransactionHashIndex> utxos = new ArrayList<>(presetUtxos);
|
List<BlockTransactionHashIndex> flattenedCandidates = candidates.stream().flatMap(outputGroup -> outputGroup.getUtxos().stream()).collect(Collectors.toList());
|
||||||
utxos.retainAll(candidates.stream().flatMap(outputGroup -> outputGroup.getUtxos().stream()).collect(Collectors.toList()));
|
List<BlockTransactionHashIndex> utxos = new ArrayList<>();
|
||||||
|
|
||||||
|
//Don't use equals() here as we don't want to consider height which may change as txes are confirmed
|
||||||
|
for(BlockTransactionHashIndex candidate : flattenedCandidates) {
|
||||||
|
for(BlockTransactionHashIndex presetUtxo : presetUtxos) {
|
||||||
|
if(candidate.getHash().equals(presetUtxo.getHash()) && candidate.getIndex() == presetUtxo.getIndex()) {
|
||||||
|
utxos.add(candidate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return utxos;
|
return utxos;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue