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 70dce259190..6611284af90 100644 --- a/core/src/main/java/com/google/bitcoin/wallet/DefaultRiskAnalysis.java +++ b/core/src/main/java/com/google/bitcoin/wallet/DefaultRiskAnalysis.java @@ -27,6 +27,7 @@ import javax.annotation.Nullable; +import java.math.BigInteger; import java.util.List; import static com.google.common.base.Preconditions.checkState; @@ -39,6 +40,13 @@ public class DefaultRiskAnalysis implements RiskAnalysis { private static final Logger log = LoggerFactory.getLogger(DefaultRiskAnalysis.class); + /** + * Any standard output smaller than this value (in satoshis) will be considered risky, as it's most likely be + * rejected by the network. Currently it's 546 satoshis. This is different from {@link Transaction#MIN_NONDUST_OUTPUT} + * because of an upcoming fee change in Bitcoin Core 0.9. + */ + public static final BigInteger MIN_ANALYSIS_NONDUST_OUTPUT = BigInteger.valueOf(546); + protected final Transaction tx; protected final List dependencies; protected final Wallet wallet; @@ -115,7 +123,7 @@ public static RuleViolation isStandard(Transaction tx) { final List outputs = tx.getOutputs(); for (int i = 0; i < outputs.size(); i++) { TransactionOutput output = outputs.get(i); - if (output.getMinNonDustValue().compareTo(output.getValue()) > 0) { + if (MIN_ANALYSIS_NONDUST_OUTPUT.compareTo(output.getValue()) > 0) { log.warn("TX considered non-standard due to output {} being dusty", i); return RuleViolation.DUST; } diff --git a/core/src/test/java/com/google/bitcoin/wallet/DefaultRiskAnalysisTest.java b/core/src/test/java/com/google/bitcoin/wallet/DefaultRiskAnalysisTest.java index 95731ab6245..ce0cb9d8d3e 100644 --- a/core/src/test/java/com/google/bitcoin/wallet/DefaultRiskAnalysisTest.java +++ b/core/src/test/java/com/google/bitcoin/wallet/DefaultRiskAnalysisTest.java @@ -138,7 +138,7 @@ public void nonStandardDust() { Transaction edgeCaseTx = new Transaction(params); edgeCaseTx.addInput(params.getGenesisBlock().getTransactions().get(0).getOutput(0)); - edgeCaseTx.addOutput(dustTx.getOutput(0).getMinNonDustValue(), key1); // Dust threshold + edgeCaseTx.addOutput(DefaultRiskAnalysis.MIN_ANALYSIS_NONDUST_OUTPUT, key1); // Dust threshold assertEquals(RiskAnalysis.Result.OK, DefaultRiskAnalysis.FACTORY.create(wallet, edgeCaseTx, NO_DEPS).analyze()); } }