Make non-canoncial data pushes non-standard.

This commit makes use of the new btcscript.HasCanonicalPushes to enforce
canonical data pushes for transactions that are considered standard.

A canonical data push is one where the fewest number of bytes possible to
encode the size of the data being pushed is used.  This includes using the
small integer opcodes for single byte data that can be represented
directly.
This commit is contained in:
Dave Collins 2014-02-19 19:22:02 -06:00
parent cb1f3cf48c
commit 264c89099f

View file

@ -271,6 +271,16 @@ func checkTransactionStandard(tx *btcutil.Tx, height int64) error {
"script is not push only", i)
return TxRuleError(str)
}
// Each transaction input signature script must only contain
// canonical data pushes. A canonical data push is one where
// the minimum possible number of bytes is used to represent
// the data push as possible.
if !btcscript.HasCanonicalPushes(txIn.SignatureScript) {
str := fmt.Sprintf("transaction input %d: signature "+
"script has a non-canonical data push", i)
return TxRuleError(str)
}
}
// None of the output public key scripts can be a non-standard script or