diff --git a/checkpoints.go b/checkpoints.go index 2a1f44cd..394b3fa6 100644 --- a/checkpoints.go +++ b/checkpoints.go @@ -7,8 +7,8 @@ package btcchain import ( "fmt" + "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcnet" - "github.com/btcsuite/btcscript" "github.com/btcsuite/btcutil" "github.com/btcsuite/btcwire" ) @@ -192,8 +192,8 @@ func isNonstandardTransaction(tx *btcutil.Tx) bool { // Check all of the output public key scripts for non-standard scripts. for _, txOut := range tx.MsgTx().TxOut { - scriptClass := btcscript.GetScriptClass(txOut.PkScript) - if scriptClass == btcscript.NonStandardTy { + scriptClass := txscript.GetScriptClass(txOut.PkScript) + if scriptClass == txscript.NonStandardTy { return true } } diff --git a/scriptval.go b/scriptval.go index 20bef703..22d0ea20 100644 --- a/scriptval.go +++ b/scriptval.go @@ -9,7 +9,7 @@ import ( "math" "runtime" - "github.com/btcsuite/btcscript" + "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcutil" "github.com/btcsuite/btcwire" ) @@ -29,7 +29,7 @@ type txValidator struct { quitChan chan struct{} resultChan chan error txStore TxStore - flags btcscript.ScriptFlags + flags txscript.ScriptFlags } // sendResult sends the result of a script pair validation on the internal @@ -83,7 +83,7 @@ out: // Create a new script engine for the script pair. sigScript := txIn.SignatureScript pkScript := originMsgTx.TxOut[originTxIndex].PkScript - engine, err := btcscript.NewScript(sigScript, pkScript, + engine, err := txscript.NewScript(sigScript, pkScript, txVI.txInIndex, txVI.tx.MsgTx(), v.flags) if err != nil { str := fmt.Sprintf("failed to parse input "+ @@ -179,7 +179,7 @@ func (v *txValidator) Validate(items []*txValidateItem) error { // newTxValidator returns a new instance of txValidator to be used for // validating transaction scripts asynchronously. -func newTxValidator(txStore TxStore, flags btcscript.ScriptFlags) *txValidator { +func newTxValidator(txStore TxStore, flags txscript.ScriptFlags) *txValidator { return &txValidator{ validateChan: make(chan *txValidateItem), quitChan: make(chan struct{}), @@ -191,7 +191,7 @@ func newTxValidator(txStore TxStore, flags btcscript.ScriptFlags) *txValidator { // ValidateTransactionScripts validates the scripts for the passed transaction // using multiple goroutines. -func ValidateTransactionScripts(tx *btcutil.Tx, txStore TxStore, flags btcscript.ScriptFlags) error { +func ValidateTransactionScripts(tx *btcutil.Tx, txStore TxStore, flags txscript.ScriptFlags) error { // Collect all of the transaction inputs and required information for // validation. txIns := tx.MsgTx().TxIn @@ -224,9 +224,9 @@ func ValidateTransactionScripts(tx *btcutil.Tx, txStore TxStore, flags btcscript func checkBlockScripts(block *btcutil.Block, txStore TxStore) error { // Setup the script validation flags. Blocks created after the BIP0016 // activation time need to have the pay-to-script-hash checks enabled. - var flags btcscript.ScriptFlags - if block.MsgBlock().Header.Timestamp.After(btcscript.Bip16Activation) { - flags |= btcscript.ScriptBip16 + var flags txscript.ScriptFlags + if block.MsgBlock().Header.Timestamp.After(txscript.Bip16Activation) { + flags |= txscript.ScriptBip16 } // Collect all of the transaction inputs and required information for diff --git a/validate.go b/validate.go index f878d953..488d4b8b 100644 --- a/validate.go +++ b/validate.go @@ -12,8 +12,8 @@ import ( "time" "github.com/btcsuite/btcd/database" + "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcnet" - "github.com/btcsuite/btcscript" "github.com/btcsuite/btcutil" "github.com/btcsuite/btcwire" ) @@ -331,7 +331,7 @@ func CheckProofOfWork(block *btcutil.Block, powLimit *big.Int) error { // CountSigOps returns the number of signature operations for all transaction // input and output scripts in the provided transaction. This uses the // quicker, but imprecise, signature operation counting mechanism from -// btcscript. +// txscript. func CountSigOps(tx *btcutil.Tx) int { msgTx := tx.MsgTx() @@ -339,14 +339,14 @@ func CountSigOps(tx *btcutil.Tx) int { // inputs. totalSigOps := 0 for _, txIn := range msgTx.TxIn { - numSigOps := btcscript.GetSigOpCount(txIn.SignatureScript) + numSigOps := txscript.GetSigOpCount(txIn.SignatureScript) totalSigOps += numSigOps } // Accumulate the number of signature operations in all transaction // outputs. for _, txOut := range msgTx.TxOut { - numSigOps := btcscript.GetSigOpCount(txOut.PkScript) + numSigOps := txscript.GetSigOpCount(txOut.PkScript) totalSigOps += numSigOps } @@ -355,8 +355,8 @@ func CountSigOps(tx *btcutil.Tx) int { // CountP2SHSigOps returns the number of signature operations for all input // transactions which are of the pay-to-script-hash type. This uses the -// precise, signature operation counting mechanism from btcscript which requires -// access to the input transaction scripts. +// precise, signature operation counting mechanism from the script engine which +// requires access to the input transaction scripts. func CountP2SHSigOps(tx *btcutil.Tx, isCoinBaseTx bool, txStore TxStore) (int, error) { // Coinbase transactions have no interesting inputs. if isCoinBaseTx { @@ -392,14 +392,14 @@ func CountP2SHSigOps(tx *btcutil.Tx, isCoinBaseTx bool, txStore TxStore) (int, e // We're only interested in pay-to-script-hash types, so skip // this input if it's not one. pkScript := originMsgTx.TxOut[originTxIndex].PkScript - if !btcscript.IsPayToScriptHash(pkScript) { + if !txscript.IsPayToScriptHash(pkScript) { continue } // Count the precise number of signature operations in the // referenced public key script. sigScript := txIn.SignatureScript - numSigOps := btcscript.GetPreciseSigOpCount(sigScript, pkScript, + numSigOps := txscript.GetPreciseSigOpCount(sigScript, pkScript, true) // We could potentially overflow the accumulator so check for @@ -817,10 +817,10 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block) er // BIP0016 describes a pay-to-script-hash type that is considered a // "standard" type. The rules for this BIP only apply to transactions - // after the timestamp defined by btcscript.Bip16Activation. See + // after the timestamp defined by txscript.Bip16Activation. See // https://en.bitcoin.it/wiki/BIP_0016 for more details. enforceBIP0016 := false - if node.timestamp.After(btcscript.Bip16Activation) { + if node.timestamp.After(txscript.Bip16Activation) { enforceBIP0016 = true }