From 264c89099f75a591ab7dc94c97bbc98d9eb3d2a3 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 19 Feb 2014 19:22:02 -0600 Subject: [PATCH] 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. --- mempool.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mempool.go b/mempool.go index bc867b97a..83fe19054 100644 --- a/mempool.go +++ b/mempool.go @@ -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