txscript; Use const for sighashall optimization.

This breaks the dependency on chaincfg.SigHashOptimization which is no
longer available in v2 of the chaincfg module.  The constant is set to
false to ensure the same semantics are kept and an additional comment
has been added regarding the status.
This commit is contained in:
Dave Collins 2019-06-18 23:49:32 -05:00
parent 7da223fd98
commit ad0d98ce75
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2
2 changed files with 7 additions and 4 deletions

View File

@ -16,7 +16,6 @@ import (
"golang.org/x/crypto/ripemd160"
"github.com/decred/dcrd/chaincfg"
"github.com/decred/dcrd/chaincfg/chainhash"
"github.com/decred/dcrd/dcrec"
"github.com/decred/dcrd/dcrec/edwards"
@ -25,7 +24,12 @@ import (
"github.com/decred/dcrd/wire"
)
var optimizeSigVerification = chaincfg.SigHashOptimization
// optimizeSigVerification is an optimization for verification of transactions
// that contain scripts with CHECKSIG operations with a hash type of SigHashAll.
//
// WARNING: This has not been properly vetted or tested, so it needs significant
// review to ensure it does not break consensus before being enabled.
const optimizeSigVerification = false
// An opcode defines the information related to a txscript opcode. opfunc, if
// present, is the function to call to perform the opcode on the script. The

View File

@ -10,7 +10,6 @@ import (
"fmt"
"math"
"github.com/decred/dcrd/chaincfg"
"github.com/decred/dcrd/chaincfg/chainhash"
"github.com/decred/dcrd/wire"
)
@ -299,7 +298,7 @@ func calcSignatureHash(signScript []byte, hashType SigHashType, tx *wire.MsgTx,
// can be reused because only the witness data has been modified, so
// the wasteful extra O(N^2) hash can be avoided.
var prefixHash chainhash.Hash
if chaincfg.SigHashOptimization && cachedPrefix != nil &&
if optimizeSigVerification && cachedPrefix != nil &&
hashType&sigHashMask == SigHashAll &&
hashType&SigHashAnyOneCanPay == 0 {