diff --git a/core/src/main/java/com/google/bitcoin/wallet/DefaultRiskAnalysis.java b/core/src/main/java/com/google/bitcoin/wallet/DefaultRiskAnalysis.java index 74658b44..70dce259 100644 --- a/core/src/main/java/com/google/bitcoin/wallet/DefaultRiskAnalysis.java +++ b/core/src/main/java/com/google/bitcoin/wallet/DefaultRiskAnalysis.java @@ -22,6 +22,8 @@ import com.google.bitcoin.core.Transaction; import com.google.bitcoin.core.TransactionConfidence; import com.google.bitcoin.core.TransactionOutput; import com.google.bitcoin.core.Wallet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.Nullable; @@ -30,10 +32,13 @@ import java.util.List; import static com.google.common.base.Preconditions.checkState; /** - * The default risk analysis. Currently, it only is concerned with whether a tx/dependency is non-final or not. Outside - * of specialised protocols you should not encounter non-final transactions. + *
The default risk analysis. Currently, it only is concerned with whether a tx/dependency is non-final or not, and + * whether a tx/dependency violates the dust rules. Outside of specialised protocols you should not encounter non-final + * transactions.
*/ public class DefaultRiskAnalysis implements RiskAnalysis { + private static final Logger log = LoggerFactory.getLogger(DefaultRiskAnalysis.class); + protected final Transaction tx; protected final ListNote that this method currently only implements a minimum of checks. More to be added later.
- * - * @return Either null if the transaction is standard, or the first transaction found which is considered nonstandard */ - public Transaction isStandard(Transaction tx) { - if (tx.getVersion() > 1 || tx.getVersion() < 1) - return tx; - - for (TransactionOutput output : tx.getOutputs()) { - if (output.getMinNonDustValue().compareTo(output.getValue()) > 0) - return tx; + public static RuleViolation isStandard(Transaction tx) { + // TODO: Finish this function off. + if (tx.getVersion() > 1 || tx.getVersion() < 1) { + log.warn("TX considered non-standard due to unknown version number {}", tx.getVersion()); + return RuleViolation.VERSION; } - return null; + final List