/** * Returns a list of the outputs that can potentially be spent, i.e. that we have the keys for and are unspent * according to our knowledge of the block chain. */ public List<TransactionOutput> calculateAllSpendCandidates() { return calculateAllSpendCandidates(true, true); }
/** * Returns a list of the outputs that can potentially be spent, i.e. that we have the keys for and are unspent * according to our knowledge of the block chain. */ public List<TransactionOutput> calculateAllSpendCandidates() { return calculateAllSpendCandidates(true, true); }
/** * Returns a list of the outputs that can potentially be spent, i.e. that we have the keys for and are unspent * according to our knowledge of the block chain. */ public List<TransactionOutput> calculateAllSpendCandidates() { return calculateAllSpendCandidates(true, true); }
/** * Returns a list of the outputs that can potentially be spent, i.e. that we have the keys for and are unspent * according to our knowledge of the block chain. */ public List<TransactionOutput> calculateAllSpendCandidates() { return calculateAllSpendCandidates(true, true); }
/** @deprecated Use {@link #calculateAllSpendCandidates(boolean, boolean)} or the zero-parameter form instead. */ @Deprecated public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases) { return calculateAllSpendCandidates(excludeImmatureCoinbases, true); }
/** @deprecated Use {@link #calculateAllSpendCandidates(boolean, boolean)} or the zero-parameter form instead. */ @Deprecated public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases) { return calculateAllSpendCandidates(excludeImmatureCoinbases, true); }
/** @deprecated Use {@link #calculateAllSpendCandidates(boolean, boolean)} or the zero-parameter form instead. */ @Deprecated public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases) { return calculateAllSpendCandidates(excludeImmatureCoinbases, true); }
/** @deprecated Use {@link #calculateAllSpendCandidates(boolean, boolean)} or the zero-parameter form instead. */ @Deprecated public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases) { return calculateAllSpendCandidates(excludeImmatureCoinbases, true); }
/** * Returns the balance that would be considered spendable by the given coin selector, including watched outputs * (i.e. balance includes outputs we don't have the private keys for). Just asks it to select as many coins as * possible and returns the total. */ public Coin getBalance(CoinSelector selector) { lock.lock(); try { checkNotNull(selector); List<TransactionOutput> candidates = calculateAllSpendCandidates(true, false); CoinSelection selection = selector.select(params.getMaxMoney(), candidates); return selection.valueGathered; } finally { lock.unlock(); } }
/** * Returns the balance that would be considered spendable by the given coin selector, including watched outputs * (i.e. balance includes outputs we don't have the private keys for). Just asks it to select as many coins as * possible and returns the total. */ public Coin getBalance(CoinSelector selector) { lock.lock(); try { checkNotNull(selector); List<TransactionOutput> candidates = calculateAllSpendCandidates(true, false); CoinSelection selection = selector.select(params.getMaxMoney(), candidates); return selection.valueGathered; } finally { lock.unlock(); } }
/** * Returns the balance that would be considered spendable by the given coin selector, including watched outputs * (i.e. balance includes outputs we don't have the private keys for). Just asks it to select as many coins as * possible and returns the total. */ public Coin getBalance(CoinSelector selector) { lock.lock(); try { checkNotNull(selector); List<TransactionOutput> candidates = calculateAllSpendCandidates(true, false); CoinSelection selection = selector.select(params.getMaxMoney(), candidates); return selection.valueGathered; } finally { lock.unlock(); } }
/** * Returns the balance that would be considered spendable by the given coin selector, including watched outputs * (i.e. balance includes outputs we don't have the private keys for). Just asks it to select as many coins as * possible and returns the total. */ public Coin getBalance(CoinSelector selector) { lock.lock(); try { checkNotNull(selector); List<TransactionOutput> candidates = calculateAllSpendCandidates(true, false); CoinSelection selection = selector.select(params.getMaxMoney(), candidates); return selection.valueGathered; } finally { lock.unlock(); } }
/** * Returns the balance of this wallet as calculated by the provided balanceType. */ public Coin getBalance(BalanceType balanceType) { lock.lock(); try { if (balanceType == BalanceType.AVAILABLE || balanceType == BalanceType.AVAILABLE_SPENDABLE) { List<TransactionOutput> candidates = calculateAllSpendCandidates(true, balanceType == BalanceType.AVAILABLE_SPENDABLE); CoinSelection selection = coinSelector.select(NetworkParameters.MAX_MONEY, candidates); return selection.valueGathered; } else if (balanceType == BalanceType.ESTIMATED || balanceType == BalanceType.ESTIMATED_SPENDABLE) { List<TransactionOutput> all = calculateAllSpendCandidates(false, balanceType == BalanceType.ESTIMATED_SPENDABLE); Coin value = Coin.ZERO; for (TransactionOutput out : all) value = value.add(out.getValue()); return value; } else { throw new AssertionError("Unknown balance type"); // Unreachable. } } finally { lock.unlock(); } }
/** * Returns the balance of this wallet as calculated by the provided balanceType. */ public Coin getBalance(BalanceType balanceType) { lock.lock(); try { if (balanceType == BalanceType.AVAILABLE || balanceType == BalanceType.AVAILABLE_SPENDABLE) { List<TransactionOutput> candidates = calculateAllSpendCandidates(true, balanceType == BalanceType.AVAILABLE_SPENDABLE); CoinSelection selection = coinSelector.select(NetworkParameters.MAX_MONEY, candidates); return selection.valueGathered; } else if (balanceType == BalanceType.ESTIMATED || balanceType == BalanceType.ESTIMATED_SPENDABLE) { List<TransactionOutput> all = calculateAllSpendCandidates(false, balanceType == BalanceType.ESTIMATED_SPENDABLE); Coin value = Coin.ZERO; for (TransactionOutput out : all) value = value.add(out.getValue()); return value; } else { throw new AssertionError("Unknown balance type"); // Unreachable. } } finally { lock.unlock(); } }
/** * Returns the balance of this wallet as calculated by the provided balanceType. */ public Coin getBalance(BalanceType balanceType) { lock.lock(); try { if (balanceType == BalanceType.AVAILABLE || balanceType == BalanceType.AVAILABLE_SPENDABLE) { List<TransactionOutput> candidates = calculateAllSpendCandidates(true, balanceType == BalanceType.AVAILABLE_SPENDABLE); CoinSelection selection = coinSelector.select(NetworkParameters.MAX_MONEY, candidates); return selection.valueGathered; } else if (balanceType == BalanceType.ESTIMATED || balanceType == BalanceType.ESTIMATED_SPENDABLE) { List<TransactionOutput> all = calculateAllSpendCandidates(false, balanceType == BalanceType.ESTIMATED_SPENDABLE); Coin value = Coin.ZERO; for (TransactionOutput out : all) value = value.add(out.getValue()); return value; } else { throw new AssertionError("Unknown balance type"); // Unreachable. } } finally { lock.unlock(); } }
/** * Returns the balance of this wallet as calculated by the provided balanceType. */ public Coin getBalance(BalanceType balanceType) { lock.lock(); try { if (balanceType == BalanceType.AVAILABLE || balanceType == BalanceType.AVAILABLE_SPENDABLE) { List<TransactionOutput> candidates = calculateAllSpendCandidates(true, balanceType == BalanceType.AVAILABLE_SPENDABLE); CoinSelection selection = coinSelector.select(NetworkParameters.MAX_MONEY, candidates); return selection.valueGathered; } else if (balanceType == BalanceType.ESTIMATED || balanceType == BalanceType.ESTIMATED_SPENDABLE) { List<TransactionOutput> all = calculateAllSpendCandidates(false, balanceType == BalanceType.ESTIMATED_SPENDABLE); Coin value = Coin.ZERO; for (TransactionOutput out : all) value = value.add(out.getValue()); return value; } else { throw new AssertionError("Unknown balance type"); // Unreachable. } } finally { lock.unlock(); } }
selector.excludeOutputsSpentBy(other); CoinSelection toMove = selector.select(Coin.ZERO, calculateAllSpendCandidates()); if (toMove.valueGathered.equals(Coin.ZERO)) return null; // Nothing to do. maybeUpgradeToHD(aesKey);
selector.excludeOutputsSpentBy(other); CoinSelection toMove = selector.select(Coin.ZERO, calculateAllSpendCandidates()); if (toMove.valueGathered.equals(Coin.ZERO)) return null; // Nothing to do. maybeUpgradeToHD(aesKey);
selector.excludeOutputsSpentBy(other); CoinSelection toMove = selector.select(Coin.ZERO, calculateAllSpendCandidates()); if (toMove.valueGathered.equals(Coin.ZERO)) return null; // Nothing to do. maybeUpgradeToHD(aesKey);
@Test public void depthOrdering() throws Exception { // Send two transactions in two blocks on top of each other. Transaction t1 = checkNotNull(sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, COIN)); Transaction t2 = checkNotNull(sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, COIN)); // Check we selected just the oldest one. DefaultCoinSelector selector = new DefaultCoinSelector(); CoinSelection selection = selector.select(COIN, wallet.calculateAllSpendCandidates()); assertTrue(selection.gathered.contains(t1.getOutputs().get(0))); assertEquals(COIN, selection.valueGathered); // Check we ordered them correctly (by depth). ArrayList<TransactionOutput> candidates = new ArrayList<>(); candidates.add(t2.getOutput(0)); candidates.add(t1.getOutput(0)); DefaultCoinSelector.sortOutputs(candidates); assertEquals(t1.getOutput(0), candidates.get(0)); assertEquals(t2.getOutput(0), candidates.get(1)); }