3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 23:32:16 +00:00

Tweak DefaultCoinSelector.isSelectable to take a Transaction as a parameter.

Resolves issue 322.
This commit is contained in:
Mike Hearn 2013-03-06 14:47:30 +01:00
parent f7fa0cda72
commit 23aa1a9105

View File

@ -245,7 +245,7 @@ public class Wallet implements Serializable, BlockChainListener {
for (TransactionOutput output : sortedOutputs) {
if (total >= target) break;
// Only pick chain-included transactions, or transactions that are ours and pending.
if (!isSelectable(output)) continue;
if (!isSelectable(output.parentTransaction)) continue;
selected.add(output);
total += output.getValue().longValue();
}
@ -254,9 +254,9 @@ public class Wallet implements Serializable, BlockChainListener {
return new CoinSelection(BigInteger.valueOf(total), selected);
}
public static boolean isSelectable(TransactionOutput output) {
public static boolean isSelectable(Transaction tx) {
// Only pick chain-included transactions, or transactions that are ours and pending.
TransactionConfidence confidence = output.parentTransaction.getConfidence();
TransactionConfidence confidence = tx.getConfidence();
ConfidenceType type = confidence.getConfidenceType();
boolean pending = type.equals(ConfidenceType.NOT_SEEN_IN_CHAIN) ||
type.equals(ConfidenceType.NOT_IN_BEST_CHAIN);