Skip to content

Commit

Permalink
Adjust MIN_NONDUST_OUTPUT down to 546 only for risk analysis. This is…
Browse files Browse the repository at this point in the history
… required because we start seeing more and more transactions using the new fee rules introduced with Bitcoin Core 0.9.
  • Loading branch information
schildbach committed Apr 18, 2014
1 parent 5c8cf6b commit 2708df5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import javax.annotation.Nullable;

import java.math.BigInteger;
import java.util.List;

import static com.google.common.base.Preconditions.checkState;
Expand All @@ -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<Transaction> dependencies;
protected final Wallet wallet;
Expand Down Expand Up @@ -115,7 +123,7 @@ public static RuleViolation isStandard(Transaction tx) {
final List<TransactionOutput> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 2708df5

Please sign in to comment.