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

Adjust MIN_NONDUST_OUTPUT down to 546 only for risk analysis. This is required because we start seeing more and more transactions using the new fee rules introduced with Bitcoin Core 0.9.

This commit is contained in:
Andreas Schildbach 2014-04-18 11:51:15 +02:00
parent 5c8cf6bc38
commit 2708df58b3
2 changed files with 10 additions and 2 deletions

View File

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.math.BigInteger;
import java.util.List;
import static com.google.common.base.Preconditions.checkState;
@ -39,6 +40,13 @@ import static com.google.common.base.Preconditions.checkState;
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;
@ -115,7 +123,7 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
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;
}

View File

@ -138,7 +138,7 @@ public class DefaultRiskAnalysisTest {
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());
}
}