From d9cba7ca6abc7f12d2c187eec8c824498f7daafc Mon Sep 17 00:00:00 2001
From: David Hill <dhill@mindcry.org>
Date: Thu, 26 Feb 2015 15:21:12 -0500
Subject: [PATCH] txscript: export StandardVerifyFlags

By exporting StandardVerifyFlags, clients can ensure they create
transactions that btcd will accept into its mempool.

This flag doesn't belong in txscript.  It belongs in a
policy package.  However, this is currently the least worse place.
---
 mempool.go         |  2 +-
 mining.go          | 16 +---------------
 txscript/script.go | 17 +++++++++++++++++
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/mempool.go b/mempool.go
index 68cc8ae8..69497ef5 100644
--- a/mempool.go
+++ b/mempool.go
@@ -1216,7 +1216,7 @@ func (mp *txMemPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit boo
 	// Verify crypto signatures for each input and reject the transaction if
 	// any don't verify.
 	err = blockchain.ValidateTransactionScripts(tx, txStore,
-		standardScriptVerifyFlags)
+		txscript.StandardVerifyFlags)
 	if err != nil {
 		if cerr, ok := err.(blockchain.RuleError); ok {
 			return nil, chainRuleError(cerr)
diff --git a/mining.go b/mining.go
index d8ac0a06..f327a49d 100644
--- a/mining.go
+++ b/mining.go
@@ -38,20 +38,6 @@ const (
 	// and is used to monitor BIP16 support as well as blocks that are
 	// generated via btcd.
 	coinbaseFlags = "/P2SH/btcd/"
-
-	// standardScriptVerifyFlags are the script flags which are used when
-	// executing transaction scripts to enforce additional checks which
-	// are required for the script to be considered standard.  These checks
-	// help reduce issues related to transaction malleability as well as
-	// allow pay-to-script hash transactions.  Note these flags are
-	// different than what is required for the consensus rules in that they
-	// are more strict.
-	standardScriptVerifyFlags = txscript.ScriptBip16 |
-		txscript.ScriptVerifyDERSignatures |
-		txscript.ScriptVerifyStrictEncoding |
-		txscript.ScriptVerifyMinimalData |
-		txscript.ScriptStrictMultiSig |
-		txscript.ScriptDiscourageUpgradableNops
 )
 
 // txPrioItem houses a transaction along with extra information that allows the
@@ -667,7 +653,7 @@ mempoolLoop:
 			continue
 		}
 		err = blockchain.ValidateTransactionScripts(tx, blockTxStore,
-			standardScriptVerifyFlags)
+			txscript.StandardVerifyFlags)
 		if err != nil {
 			minrLog.Tracef("Skipping tx %s due to error in "+
 				"ValidateTransactionScripts: %v", tx.Sha(), err)
diff --git a/txscript/script.go b/txscript/script.go
index 4def0278..2149dfe8 100644
--- a/txscript/script.go
+++ b/txscript/script.go
@@ -634,6 +634,23 @@ const (
 	// ScriptVerifyStrictEncoding defines that signature scripts and
 	// public keys must follow the strict encoding requirements.
 	ScriptVerifyStrictEncoding
+
+	// StandardVerifyFlags are the script flags which are used when
+	// executing transaction scripts to enforce additional checks which
+	// are required for the script to be considered standard.  These checks
+	// help reduce issues related to transaction malleability as well as
+	// allow pay-to-script hash transactions.  Note these flags are
+	// different than what is required for the consensus rules in that they
+	// are more strict.
+	//
+	// TODO: These flags do not belong here.  These flags belong in a
+	// policy package.
+	StandardVerifyFlags = ScriptBip16 |
+		ScriptVerifyDERSignatures |
+		ScriptVerifyStrictEncoding |
+		ScriptVerifyMinimalData |
+		ScriptStrictMultiSig |
+		ScriptDiscourageUpgradableNops
 )
 
 // NewScript returns a new script engine for the provided tx and input idx with