@Test public void identicalInputs() throws Exception { Transaction t = new Transaction(params); java.util.List<TransactionOutput> outputs = Arrays.asList( new TransactionOutput(params, t, Coin.valueOf(3030), myAddress), new TransactionOutput(params, t, Coin.valueOf(3030), myAddress), new TransactionOutput(params, t, Coin.valueOf(3030), myAddress), new TransactionOutput(params, t, Coin.valueOf(3030), myAddress) ); t.getConfidence().setConfidenceType(TransactionConfidence.ConfidenceType.BUILDING); DefaultCoinSelector selector = new DefaultCoinSelector(); CoinSelection selection = selector.select(COIN.multiply(2), outputs); assertEquals(4, selection.gathered.size()); }
@Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals(NetworkParameters.MAX_MONEY)) { sortOutputs(sortedOutputs); } long total = 0; for (TransactionOutput output : sortedOutputs) { if (total >= target.value) break; if (!shouldSelect(output.getParentTransaction())) continue; selected.add(output); total += output.getValue().value; } return new CoinSelection(Coin.valueOf(total), selected); }
DefaultCoinSelector implements CoinSelector { @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals(NetworkParameters.MAX_MONEY)) { sortOutputs(sortedOutputs); } long total = 0; for (TransactionOutput output : sortedOutputs) { if (total >= target.value) break; if (!shouldSelect(output.getParentTransaction())) continue; selected.add(output); total += output.getValue().value; } return new CoinSelection(Coin.valueOf(total), selected); } }
DefaultCoinSelector implements CoinSelector { @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals(NetworkParameters.MAX_MONEY)) { sortOutputs(sortedOutputs); } long total = 0; for (TransactionOutput output : sortedOutputs) { if (total >= target.value) break; if (!shouldSelect(output.getParentTransaction())) continue; selected.add(output); total += output.getValue().value; } return new CoinSelection(Coin.valueOf(total), selected); }  }
DefaultCoinSelector implements CoinSelector { @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals(NetworkParameters.MAX_MONEY)) { sortOutputs(sortedOutputs); } long total = 0; for (TransactionOutput output : sortedOutputs) { if (total >= target.value) break; if (!shouldSelect(output.getParentTransaction())) continue; selected.add(output); total += output.getValue().value; } return new CoinSelection(Coin.valueOf(total), selected); }  @Override CoinSelection select(Coin target, List<TransactionOutput> candidates); static boolean isSelectable(Transaction tx); }
DefaultCoinSelector implements CoinSelector { @Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { ArrayList<TransactionOutput> selected = new ArrayList<TransactionOutput>(); ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates); if (!target.equals(NetworkParameters.MAX_MONEY)) { sortOutputs(sortedOutputs); } long total = 0; for (TransactionOutput output : sortedOutputs) { if (total >= target.value) break; if (!shouldSelect(output.getParentTransaction())) continue; selected.add(output); total += output.getValue().value; } return new CoinSelection(Coin.valueOf(total), selected); }  @Override CoinSelection select(Coin target, List<TransactionOutput> candidates); static boolean isSelectable(Transaction tx);  }