mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +00:00
shuffle utxos within input sets
This commit is contained in:
parent
6ac593f161
commit
8ac3f47380
1 changed files with 6 additions and 2 deletions
|
@ -932,8 +932,12 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
|
||||||
Map<BlockTransactionHashIndex, WalletNode> utxos = getWalletUtxos(includeSpentMempoolOutputs);
|
Map<BlockTransactionHashIndex, WalletNode> utxos = getWalletUtxos(includeSpentMempoolOutputs);
|
||||||
for(Collection<BlockTransactionHashIndex> selectedInputs : selectedInputSets) {
|
for(Collection<BlockTransactionHashIndex> selectedInputs : selectedInputSets) {
|
||||||
total += selectedInputs.stream().mapToLong(BlockTransactionHashIndex::getValue).sum();
|
total += selectedInputs.stream().mapToLong(BlockTransactionHashIndex::getValue).sum();
|
||||||
Map<BlockTransactionHashIndex, WalletNode> selectedInputsMap = new TreeMap<>(utxos);
|
Map<BlockTransactionHashIndex, WalletNode> selectedInputsMap = new LinkedHashMap<>();
|
||||||
selectedInputsMap.keySet().retainAll(selectedInputs);
|
List<BlockTransactionHashIndex> shuffledInputs = new ArrayList<>(selectedInputs);
|
||||||
|
Collections.shuffle(shuffledInputs);
|
||||||
|
for(BlockTransactionHashIndex shuffledInput : shuffledInputs) {
|
||||||
|
selectedInputsMap.put(shuffledInput, utxos.get(shuffledInput));
|
||||||
|
}
|
||||||
selectedInputSetsList.add(selectedInputsMap);
|
selectedInputSetsList.add(selectedInputsMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue