mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 10:15:52 +00:00
DefaultRiskAnalysis: extract output testing into a separate method also, and add a (presently unused) new rule violation type.
This commit is contained in:
parent
5fc98d2c07
commit
a8f85d1158
@ -107,7 +107,8 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
|
|||||||
NONE,
|
NONE,
|
||||||
VERSION,
|
VERSION,
|
||||||
DUST,
|
DUST,
|
||||||
SHORTEST_POSSIBLE_PUSHDATA
|
SHORTEST_POSSIBLE_PUSHDATA,
|
||||||
|
NONEMPTY_STACK // Not yet implemented (for post 0.12)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,16 +127,10 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
|
|||||||
final List<TransactionOutput> outputs = tx.getOutputs();
|
final List<TransactionOutput> outputs = tx.getOutputs();
|
||||||
for (int i = 0; i < outputs.size(); i++) {
|
for (int i = 0; i < outputs.size(); i++) {
|
||||||
TransactionOutput output = outputs.get(i);
|
TransactionOutput output = outputs.get(i);
|
||||||
if (MIN_ANALYSIS_NONDUST_OUTPUT.compareTo(output.getValue()) > 0) {
|
RuleViolation violation = isOutputStandard(output);
|
||||||
log.warn("TX considered non-standard due to output {} being dusty", i);
|
if (violation != RuleViolation.NONE) {
|
||||||
return RuleViolation.DUST;
|
log.warn("TX considered non-standard due to output {} violating rule {}", i, violation);
|
||||||
}
|
return violation;
|
||||||
for (ScriptChunk chunk : output.getScriptPubKey().getChunks()) {
|
|
||||||
if (chunk.isPushData() && !chunk.isShortestPossiblePushData()) {
|
|
||||||
log.warn("TX considered non-standard due to output {} having a longer than necessary data push: {}",
|
|
||||||
i, chunk);
|
|
||||||
return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,6 +147,19 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
|
|||||||
return RuleViolation.NONE;
|
return RuleViolation.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the output to see if the script violates a standardness rule. Not complete.
|
||||||
|
*/
|
||||||
|
public static RuleViolation isOutputStandard(TransactionOutput output) {
|
||||||
|
if (MIN_ANALYSIS_NONDUST_OUTPUT.compareTo(output.getValue()) > 0)
|
||||||
|
return RuleViolation.DUST;
|
||||||
|
for (ScriptChunk chunk : output.getScriptPubKey().getChunks()) {
|
||||||
|
if (chunk.isPushData() && !chunk.isShortestPossiblePushData())
|
||||||
|
return RuleViolation.SHORTEST_POSSIBLE_PUSHDATA;
|
||||||
|
}
|
||||||
|
return RuleViolation.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/** Checks if the given input passes some of the AreInputsStandard checks. Not complete. */
|
/** Checks if the given input passes some of the AreInputsStandard checks. Not complete. */
|
||||||
public static RuleViolation isInputStandard(TransactionInput input) {
|
public static RuleViolation isInputStandard(TransactionInput input) {
|
||||||
for (ScriptChunk chunk : input.getScriptSig().getChunks()) {
|
for (ScriptChunk chunk : input.getScriptSig().getChunks()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user