@@ -0,0 +1,1100 @@
+package fi.bittiraha.walletd;%0A%0Aimport org.bitcoinj.wallet.DefaultCoinSelector;%0Aimport org.bitcoinj.core.*;%0A%0Apublic class BalanceCoinSelector extends DefaultCoinSelector %7B%0A    @Override%0A    protected boolean shouldSelect(Transaction tx) %7B%0A        if (tx != null) %7B%0A            return isSelectable(tx);%0A        %7D%0A        return true;%0A    %7D%0A    %0A    public static boolean isSelectable(Transaction tx) %7B%0A        // Only pick chain-included transactions, or transactions that are ours and pending.%0A        TransactionConfidence confidence = tx.getConfidence();%0A        TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();%0A        // BalanceCoinSelector doesn't require another peer to have seen the transaction%0A        // prior to selecting it, unlike DefaultCoinSelector. This is useful for calculating%0A        // wallet balance reliably.%0A        return type.equals(TransactionConfidence.ConfidenceType.BUILDING) %7C%7C%0A               type.equals(TransactionConfidence.ConfidenceType.PENDING) &&%0A               confidence.getSource().equals(TransactionConfidence.Source.SELF);%0A    %7D%0A%7D%0A

Add BalanceCoinSelector