Update btcscript import paths to new location.

This commit is contained in:
Dave Collins 2015-01-30 12:14:33 -06:00
parent be11f23e14
commit 3b1a15d0d5
7 changed files with 40 additions and 40 deletions

View file

@ -15,8 +15,8 @@ import (
"testing" "testing"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcnet" "github.com/btcsuite/btcnet"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire" "github.com/btcsuite/btcwire"
"golang.org/x/crypto/ripemd160" "golang.org/x/crypto/ripemd160"
@ -110,7 +110,7 @@ func testAddrIndexOperations(t *testing.T, db database.Db, newestBlock *btcutil.
} }
// Extract the dest addr from the tx. // Extract the dest addr from the tx.
_, testAddrs, _, err := btcscript.ExtractPkScriptAddrs(testTx.MsgTx().TxOut[0].PkScript, &btcnet.MainNetParams) _, testAddrs, _, err := txscript.ExtractPkScriptAddrs(testTx.MsgTx().TxOut[0].PkScript, &btcnet.MainNetParams)
if err != nil { if err != nil {
t.Fatalf("Unable to decode tx output, err %v", err) t.Fatalf("Unable to decode tx output, err %v", err)
} }
@ -527,7 +527,7 @@ func TestLimitAndSkipFetchTxsForAddr(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Unable to decode test address: %v", err) t.Fatalf("Unable to decode test address: %v", err)
} }
outputScript, err := btcscript.PayToAddrScript(targetAddr) outputScript, err := txscript.PayToAddrScript(targetAddr)
if err != nil { if err != nil {
t.Fatalf("Unable make test pkScript %v", err) t.Fatalf("Unable make test pkScript %v", err)
} }

View file

@ -199,7 +199,7 @@ information.
wire protocol wire protocol
* [btcchain](https://github.com/btcsuite/btcchain) - Implements Bitcoin * [btcchain](https://github.com/btcsuite/btcchain) - Implements Bitcoin
block handling and chain selection rules block handling and chain selection rules
* [btcscript](https://github.com/btcsuite/btcscript) - Implements the * [txscript](https://github.com/btcsuite/btcd/txscript) - Implements the
Bitcoin transaction scripting language Bitcoin transaction scripting language
* [btcec](https://github.com/btcsuite/btcec) - Implements support for the * [btcec](https://github.com/btcsuite/btcec) - Implements support for the
elliptic curve cryptographic functions needed for the Bitcoin scripts elliptic curve cryptographic functions needed for the Bitcoin scripts

4
log.go
View file

@ -14,8 +14,8 @@ import (
"github.com/btcsuite/btcchain" "github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btclog" "github.com/btcsuite/btclog"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcwire" "github.com/btcsuite/btcwire"
"github.com/btcsuite/seelog" "github.com/btcsuite/seelog"
) )
@ -126,7 +126,7 @@ func useLogger(subsystemID string, logger btclog.Logger) {
case "SCRP": case "SCRP":
scrpLog = logger scrpLog = logger
btcscript.UseLogger(logger) txscript.UseLogger(logger)
case "SRVR": case "SRVR":
srvrLog = logger srvrLog = logger

View file

@ -15,7 +15,7 @@ import (
"github.com/btcsuite/btcchain" "github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire" "github.com/btcsuite/btcwire"
) )
@ -172,10 +172,10 @@ func isDust(txOut *btcwire.TxOut) bool {
// A standard public key script is one that is a recognized form, and for // A standard public key script is one that is a recognized form, and for
// multi-signature scripts, only contains from 1 to maxStandardMultiSigKeys // multi-signature scripts, only contains from 1 to maxStandardMultiSigKeys
// public keys. // public keys.
func checkPkScriptStandard(pkScript []byte, scriptClass btcscript.ScriptClass) error { func checkPkScriptStandard(pkScript []byte, scriptClass txscript.ScriptClass) error {
switch scriptClass { switch scriptClass {
case btcscript.MultiSigTy: case txscript.MultiSigTy:
numPubKeys, numSigs, err := btcscript.CalcMultiSigStats(pkScript) numPubKeys, numSigs, err := txscript.CalcMultiSigStats(pkScript)
if err != nil { if err != nil {
str := fmt.Sprintf("multi-signature script parse "+ str := fmt.Sprintf("multi-signature script parse "+
"failure: %v", err) "failure: %v", err)
@ -209,7 +209,7 @@ func checkPkScriptStandard(pkScript []byte, scriptClass btcscript.ScriptClass) e
return txRuleError(btcwire.RejectNonstandard, str) return txRuleError(btcwire.RejectNonstandard, str)
} }
case btcscript.NonStandardTy: case txscript.NonStandardTy:
return txRuleError(btcwire.RejectNonstandard, return txRuleError(btcwire.RejectNonstandard,
"non-standard script form") "non-standard script form")
} }
@ -268,7 +268,7 @@ func checkTransactionStandard(tx *btcutil.Tx, height int64) error {
// Each transaction input signature script must only contain // Each transaction input signature script must only contain
// opcodes which push data onto the stack. // opcodes which push data onto the stack.
if !btcscript.IsPushOnlyScript(txIn.SignatureScript) { if !txscript.IsPushOnlyScript(txIn.SignatureScript) {
str := fmt.Sprintf("transaction input %d: signature "+ str := fmt.Sprintf("transaction input %d: signature "+
"script is not push only", i) "script is not push only", i)
return txRuleError(btcwire.RejectNonstandard, str) return txRuleError(btcwire.RejectNonstandard, str)
@ -278,7 +278,7 @@ func checkTransactionStandard(tx *btcutil.Tx, height int64) error {
// canonical data pushes. A canonical data push is one where // canonical data pushes. A canonical data push is one where
// the minimum possible number of bytes is used to represent // the minimum possible number of bytes is used to represent
// the data push as possible. // the data push as possible.
if !btcscript.HasCanonicalPushes(txIn.SignatureScript) { if !txscript.HasCanonicalPushes(txIn.SignatureScript) {
str := fmt.Sprintf("transaction input %d: signature "+ str := fmt.Sprintf("transaction input %d: signature "+
"script has a non-canonical data push", i) "script has a non-canonical data push", i)
return txRuleError(btcwire.RejectNonstandard, str) return txRuleError(btcwire.RejectNonstandard, str)
@ -289,7 +289,7 @@ func checkTransactionStandard(tx *btcutil.Tx, height int64) error {
// be "dust" (except when the script is a null data script). // be "dust" (except when the script is a null data script).
numNullDataOutputs := 0 numNullDataOutputs := 0
for i, txOut := range msgTx.TxOut { for i, txOut := range msgTx.TxOut {
scriptClass := btcscript.GetScriptClass(txOut.PkScript) scriptClass := txscript.GetScriptClass(txOut.PkScript)
err := checkPkScriptStandard(txOut.PkScript, scriptClass) err := checkPkScriptStandard(txOut.PkScript, scriptClass)
if err != nil { if err != nil {
// Attempt to extract a reject code from the error so // Attempt to extract a reject code from the error so
@ -306,7 +306,7 @@ func checkTransactionStandard(tx *btcutil.Tx, height int64) error {
// Accumulate the number of outputs which only carry data. For // Accumulate the number of outputs which only carry data. For
// all other script types, ensure the output value is not // all other script types, ensure the output value is not
// "dust". // "dust".
if scriptClass == btcscript.NullDataTy { if scriptClass == txscript.NullDataTy {
numNullDataOutputs++ numNullDataOutputs++
} else if isDust(txOut) { } else if isDust(txOut) {
str := fmt.Sprintf("transaction output %d: payment "+ str := fmt.Sprintf("transaction output %d: payment "+
@ -346,7 +346,7 @@ func checkInputsStandard(tx *btcutil.Tx, txStore btcchain.TxStore) error {
originPkScript := originTx.TxOut[prevOut.Index].PkScript originPkScript := originTx.TxOut[prevOut.Index].PkScript
// Calculate stats for the script pair. // Calculate stats for the script pair.
scriptInfo, err := btcscript.CalcScriptInfo(txIn.SignatureScript, scriptInfo, err := txscript.CalcScriptInfo(txIn.SignatureScript,
originPkScript, true) originPkScript, true)
if err != nil { if err != nil {
str := fmt.Sprintf("transaction input #%d script parse "+ str := fmt.Sprintf("transaction input #%d script parse "+

View file

@ -12,7 +12,7 @@ import (
"github.com/btcsuite/btcchain" "github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire" "github.com/btcsuite/btcwire"
) )
@ -46,10 +46,10 @@ const (
// allow pay-to-script hash transactions. Note these flags are // allow pay-to-script hash transactions. Note these flags are
// different than what is required for the consensus rules in that they // different than what is required for the consensus rules in that they
// are more strict. // are more strict.
standardScriptVerifyFlags = btcscript.ScriptBip16 | standardScriptVerifyFlags = txscript.ScriptBip16 |
btcscript.ScriptCanonicalSignatures | txscript.ScriptCanonicalSignatures |
btcscript.ScriptStrictMultiSig | txscript.ScriptStrictMultiSig |
btcscript.ScriptDiscourageUpgradableNops txscript.ScriptDiscourageUpgradableNops
) )
// txPrioItem houses a transaction along with extra information that allows the // txPrioItem houses a transaction along with extra information that allows the
@ -202,7 +202,7 @@ func mergeTxStore(txStoreA btcchain.TxStore, txStoreB btcchain.TxStore) {
// it starts with the block height that is required by version 2 blocks and adds // it starts with the block height that is required by version 2 blocks and adds
// the extra nonce as well as additional coinbase flags. // the extra nonce as well as additional coinbase flags.
func standardCoinbaseScript(nextBlockHeight int64, extraNonce uint64) ([]byte, error) { func standardCoinbaseScript(nextBlockHeight int64, extraNonce uint64) ([]byte, error) {
return btcscript.NewScriptBuilder().AddInt64(nextBlockHeight). return txscript.NewScriptBuilder().AddInt64(nextBlockHeight).
AddUint64(extraNonce).AddData([]byte(coinbaseFlags)).Script() AddUint64(extraNonce).AddData([]byte(coinbaseFlags)).Script()
} }
@ -219,14 +219,14 @@ func createCoinbaseTx(coinbaseScript []byte, nextBlockHeight int64, addr btcutil
var pkScript []byte var pkScript []byte
if addr != nil { if addr != nil {
var err error var err error
pkScript, err = btcscript.PayToAddrScript(addr) pkScript, err = txscript.PayToAddrScript(addr)
if err != nil { if err != nil {
return nil, err return nil, err
} }
} else { } else {
var err error var err error
scriptBuilder := btcscript.NewScriptBuilder() scriptBuilder := txscript.NewScriptBuilder()
pkScript, err = scriptBuilder.AddOp(btcscript.OP_TRUE).Script() pkScript, err = scriptBuilder.AddOp(txscript.OP_TRUE).Script()
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -28,10 +28,10 @@ import (
"github.com/btcsuite/btcchain" "github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcec" "github.com/btcsuite/btcec"
"github.com/btcsuite/btcjson" "github.com/btcsuite/btcjson"
"github.com/btcsuite/btcnet" "github.com/btcsuite/btcnet"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire" "github.com/btcsuite/btcwire"
"github.com/btcsuite/btcws" "github.com/btcsuite/btcws"
@ -92,7 +92,7 @@ var (
// overhead of creating a new object on every invocation for constant // overhead of creating a new object on every invocation for constant
// data. // data.
gbtCoinbaseAux = &btcjson.GetBlockTemplateResultAux{ gbtCoinbaseAux = &btcjson.GetBlockTemplateResultAux{
Flags: hex.EncodeToString(builderScript(btcscript. Flags: hex.EncodeToString(builderScript(txscript.
NewScriptBuilder().AddData([]byte(coinbaseFlags)))), NewScriptBuilder().AddData([]byte(coinbaseFlags)))),
} }
@ -214,7 +214,7 @@ var rpcUnimplemented = map[string]struct{}{}
// scripts built with the script builder. Any errors are converted to a panic // scripts built with the script builder. Any errors are converted to a panic
// since it is only, and must only, be used with hard-coded, and therefore, // since it is only, and must only, be used with hard-coded, and therefore,
// known good, scripts. // known good, scripts.
func builderScript(builder *btcscript.ScriptBuilder) []byte { func builderScript(builder *txscript.ScriptBuilder) []byte {
script, err := builder.Script() script, err := builder.Script()
if err != nil { if err != nil {
panic(err) panic(err)
@ -805,7 +805,7 @@ func handleCreateRawTransaction(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan
} }
// Create a new script which pays to the provided address. // Create a new script which pays to the provided address.
pkScript, err := btcscript.PayToAddrScript(addr) pkScript, err := txscript.PayToAddrScript(addr)
if err != nil { if err != nil {
return nil, btcjson.Error{ return nil, btcjson.Error{
Code: btcjson.ErrInternal.Code, Code: btcjson.ErrInternal.Code,
@ -861,7 +861,7 @@ func createVinList(mtx *btcwire.MsgTx) []btcjson.Vin {
// The disassembled string will contain [error] inline // The disassembled string will contain [error] inline
// if the script doesn't fully parse, so ignore the // if the script doesn't fully parse, so ignore the
// error here. // error here.
disbuf, _ := btcscript.DisasmString(v.SignatureScript) disbuf, _ := txscript.DisasmString(v.SignatureScript)
vinList[i].ScriptSig = new(btcjson.ScriptSig) vinList[i].ScriptSig = new(btcjson.ScriptSig)
vinList[i].ScriptSig.Asm = disbuf vinList[i].ScriptSig.Asm = disbuf
vinList[i].ScriptSig.Hex = hex.EncodeToString(v.SignatureScript) vinList[i].ScriptSig.Hex = hex.EncodeToString(v.SignatureScript)
@ -882,14 +882,14 @@ func createVoutList(mtx *btcwire.MsgTx, net *btcnet.Params) []btcjson.Vout {
// The disassembled string will contain [error] inline if the // The disassembled string will contain [error] inline if the
// script doesn't fully parse, so ignore the error here. // script doesn't fully parse, so ignore the error here.
disbuf, _ := btcscript.DisasmString(v.PkScript) disbuf, _ := txscript.DisasmString(v.PkScript)
voutList[i].ScriptPubKey.Asm = disbuf voutList[i].ScriptPubKey.Asm = disbuf
voutList[i].ScriptPubKey.Hex = hex.EncodeToString(v.PkScript) voutList[i].ScriptPubKey.Hex = hex.EncodeToString(v.PkScript)
// Ignore the error here since an error means the script // Ignore the error here since an error means the script
// couldn't parse and there is no additional information about // couldn't parse and there is no additional information about
// it anyways. // it anyways.
scriptClass, addrs, reqSigs, _ := btcscript.ExtractPkScriptAddrs(v.PkScript, net) scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(v.PkScript, net)
voutList[i].ScriptPubKey.Type = scriptClass.String() voutList[i].ScriptPubKey.Type = scriptClass.String()
voutList[i].ScriptPubKey.ReqSigs = int32(reqSigs) voutList[i].ScriptPubKey.ReqSigs = int32(reqSigs)
@ -998,13 +998,13 @@ func handleDecodeScript(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}
// The disassembled string will contain [error] inline if the script // The disassembled string will contain [error] inline if the script
// doesn't fully parse, so ignore the error here. // doesn't fully parse, so ignore the error here.
disbuf, _ := btcscript.DisasmString(script) disbuf, _ := txscript.DisasmString(script)
// Get information about the script. // Get information about the script.
// Ignore the error here since an error means the script couldn't parse // Ignore the error here since an error means the script couldn't parse
// and there is no additinal information about it anyways. // and there is no additinal information about it anyways.
net := s.server.netParams net := s.server.netParams
scriptClass, addrs, reqSigs, _ := btcscript.ExtractPkScriptAddrs(script, net) scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(script, net)
addresses := make([]string, len(addrs)) addresses := make([]string, len(addrs))
for i, addr := range addrs { for i, addr := range addrs {
addresses[i] = addr.EncodeAddress() addresses[i] = addr.EncodeAddress()
@ -1512,7 +1512,7 @@ func (state *gbtWorkState) updateBlockTemplate(s *rpcServer, useCoinbaseValue bo
// Update the block coinbase output of the template to // Update the block coinbase output of the template to
// pay to the randomly selected payment address. // pay to the randomly selected payment address.
pkScript, err := btcscript.PayToAddrScript(payToAddr) pkScript, err := txscript.PayToAddrScript(payToAddr)
if err != nil { if err != nil {
return btcjson.Error{ return btcjson.Error{
Code: btcjson.ErrInternal.Code, Code: btcjson.ErrInternal.Code,
@ -2519,13 +2519,13 @@ func handleGetTxOut(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (i
// The disassembled string will contain [error] inline if the script // The disassembled string will contain [error] inline if the script
// doesn't fully parse, so ignore the error here. // doesn't fully parse, so ignore the error here.
script := txOut.PkScript script := txOut.PkScript
disbuf, _ := btcscript.DisasmString(script) disbuf, _ := txscript.DisasmString(script)
// Get further info about the script. // Get further info about the script.
// Ignore the error here since an error means the script couldn't parse // Ignore the error here since an error means the script couldn't parse
// and there is no additional information about it anyways. // and there is no additional information about it anyways.
net := s.server.netParams net := s.server.netParams
scriptClass, addrs, reqSigs, _ := btcscript.ExtractPkScriptAddrs(script, net) scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(script, net)
addresses := make([]string, len(addrs)) addresses := make([]string, len(addrs))
for i, addr := range addrs { for i, addr := range addrs {
addresses[i] = addr.EncodeAddress() addresses[i] = addr.EncodeAddress()

View file

@ -20,8 +20,8 @@ import (
"golang.org/x/crypto/ripemd160" "golang.org/x/crypto/ripemd160"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcjson" "github.com/btcsuite/btcjson"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire" "github.com/btcsuite/btcwire"
"github.com/btcsuite/btcws" "github.com/btcsuite/btcws"
@ -624,7 +624,7 @@ func (m *wsNotificationManager) notifyForTxOuts(ops map[btcwire.OutPoint]map[cha
txHex := "" txHex := ""
wscNotified := make(map[chan struct{}]struct{}) wscNotified := make(map[chan struct{}]struct{})
for i, txOut := range tx.MsgTx().TxOut { for i, txOut := range tx.MsgTx().TxOut {
_, txAddrs, _, err := btcscript.ExtractPkScriptAddrs( _, txAddrs, _, err := txscript.ExtractPkScriptAddrs(
txOut.PkScript, m.server.server.netParams) txOut.PkScript, m.server.server.netParams)
if err != nil { if err != nil {
continue continue
@ -1512,7 +1512,7 @@ func rescanBlock(wsc *wsClient, lookups *rescanKeys, blk *btcutil.Block) {
} }
for txOutIdx, txout := range tx.MsgTx().TxOut { for txOutIdx, txout := range tx.MsgTx().TxOut {
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs( _, addrs, _, _ := txscript.ExtractPkScriptAddrs(
txout.PkScript, wsc.server.server.netParams) txout.PkScript, wsc.server.server.netParams)
for _, addr := range addrs { for _, addr := range addrs {