Skip to content

Commit

Permalink
Update btcscript import paths to new location.
Browse files Browse the repository at this point in the history
  • Loading branch information
davecgh committed Jan 30, 2015
1 parent be11f23 commit 3b1a15d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions database/ldb/operational_test.go
Expand Up @@ -15,8 +15,8 @@ import (
"testing"

"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"
"golang.org/x/crypto/ripemd160"
Expand Down Expand Up @@ -110,7 +110,7 @@ func testAddrIndexOperations(t *testing.T, db database.Db, newestBlock *btcutil.
}

// 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 {
t.Fatalf("Unable to decode tx output, err %v", err)
}
Expand Down Expand Up @@ -527,7 +527,7 @@ func TestLimitAndSkipFetchTxsForAddr(t *testing.T) {
if err != nil {
t.Fatalf("Unable to decode test address: %v", err)
}
outputScript, err := btcscript.PayToAddrScript(targetAddr)
outputScript, err := txscript.PayToAddrScript(targetAddr)
if err != nil {
t.Fatalf("Unable make test pkScript %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Expand Up @@ -199,7 +199,7 @@ information.
wire protocol
* [btcchain](https://github.com/btcsuite/btcchain) - Implements Bitcoin
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
* [btcec](https://github.com/btcsuite/btcec) - Implements support for the
elliptic curve cryptographic functions needed for the Bitcoin scripts
Expand Down
4 changes: 2 additions & 2 deletions log.go
Expand Up @@ -14,8 +14,8 @@ import (

"github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btclog"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcwire"
"github.com/btcsuite/seelog"
)
Expand Down Expand Up @@ -126,7 +126,7 @@ func useLogger(subsystemID string, logger btclog.Logger) {

case "SCRP":
scrpLog = logger
btcscript.UseLogger(logger)
txscript.UseLogger(logger)

case "SRVR":
srvrLog = logger
Expand Down
20 changes: 10 additions & 10 deletions mempool.go
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire"
)
Expand Down Expand Up @@ -172,10 +172,10 @@ func isDust(txOut *btcwire.TxOut) bool {
// A standard public key script is one that is a recognized form, and for
// multi-signature scripts, only contains from 1 to maxStandardMultiSigKeys
// public keys.
func checkPkScriptStandard(pkScript []byte, scriptClass btcscript.ScriptClass) error {
func checkPkScriptStandard(pkScript []byte, scriptClass txscript.ScriptClass) error {
switch scriptClass {
case btcscript.MultiSigTy:
numPubKeys, numSigs, err := btcscript.CalcMultiSigStats(pkScript)
case txscript.MultiSigTy:
numPubKeys, numSigs, err := txscript.CalcMultiSigStats(pkScript)
if err != nil {
str := fmt.Sprintf("multi-signature script parse "+
"failure: %v", err)
Expand Down Expand Up @@ -209,7 +209,7 @@ func checkPkScriptStandard(pkScript []byte, scriptClass btcscript.ScriptClass) e
return txRuleError(btcwire.RejectNonstandard, str)
}

case btcscript.NonStandardTy:
case txscript.NonStandardTy:
return txRuleError(btcwire.RejectNonstandard,
"non-standard script form")
}
Expand Down Expand Up @@ -268,7 +268,7 @@ func checkTransactionStandard(tx *btcutil.Tx, height int64) error {

// Each transaction input signature script must only contain
// opcodes which push data onto the stack.
if !btcscript.IsPushOnlyScript(txIn.SignatureScript) {
if !txscript.IsPushOnlyScript(txIn.SignatureScript) {
str := fmt.Sprintf("transaction input %d: signature "+
"script is not push only", i)
return txRuleError(btcwire.RejectNonstandard, str)
Expand All @@ -278,7 +278,7 @@ func checkTransactionStandard(tx *btcutil.Tx, height int64) error {
// 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) {
if !txscript.HasCanonicalPushes(txIn.SignatureScript) {
str := fmt.Sprintf("transaction input %d: signature "+
"script has a non-canonical data push", i)
return txRuleError(btcwire.RejectNonstandard, str)
Expand All @@ -289,7 +289,7 @@ func checkTransactionStandard(tx *btcutil.Tx, height int64) error {
// be "dust" (except when the script is a null data script).
numNullDataOutputs := 0
for i, txOut := range msgTx.TxOut {
scriptClass := btcscript.GetScriptClass(txOut.PkScript)
scriptClass := txscript.GetScriptClass(txOut.PkScript)
err := checkPkScriptStandard(txOut.PkScript, scriptClass)
if err != nil {
// Attempt to extract a reject code from the error so
Expand All @@ -306,7 +306,7 @@ func checkTransactionStandard(tx *btcutil.Tx, height int64) error {
// Accumulate the number of outputs which only carry data. For
// all other script types, ensure the output value is not
// "dust".
if scriptClass == btcscript.NullDataTy {
if scriptClass == txscript.NullDataTy {
numNullDataOutputs++
} else if isDust(txOut) {
str := fmt.Sprintf("transaction output %d: payment "+
Expand Down Expand Up @@ -346,7 +346,7 @@ func checkInputsStandard(tx *btcutil.Tx, txStore btcchain.TxStore) error {
originPkScript := originTx.TxOut[prevOut.Index].PkScript

// Calculate stats for the script pair.
scriptInfo, err := btcscript.CalcScriptInfo(txIn.SignatureScript,
scriptInfo, err := txscript.CalcScriptInfo(txIn.SignatureScript,
originPkScript, true)
if err != nil {
str := fmt.Sprintf("transaction input #%d script parse "+
Expand Down
18 changes: 9 additions & 9 deletions mining.go
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire"
)
Expand Down Expand Up @@ -46,10 +46,10 @@ const (
// 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 = btcscript.ScriptBip16 |
btcscript.ScriptCanonicalSignatures |
btcscript.ScriptStrictMultiSig |
btcscript.ScriptDiscourageUpgradableNops
standardScriptVerifyFlags = txscript.ScriptBip16 |
txscript.ScriptCanonicalSignatures |
txscript.ScriptStrictMultiSig |
txscript.ScriptDiscourageUpgradableNops
)

// txPrioItem houses a transaction along with extra information that allows the
Expand Down Expand Up @@ -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
// the extra nonce as well as additional coinbase flags.
func standardCoinbaseScript(nextBlockHeight int64, extraNonce uint64) ([]byte, error) {
return btcscript.NewScriptBuilder().AddInt64(nextBlockHeight).
return txscript.NewScriptBuilder().AddInt64(nextBlockHeight).
AddUint64(extraNonce).AddData([]byte(coinbaseFlags)).Script()
}

Expand All @@ -219,14 +219,14 @@ func createCoinbaseTx(coinbaseScript []byte, nextBlockHeight int64, addr btcutil
var pkScript []byte
if addr != nil {
var err error
pkScript, err = btcscript.PayToAddrScript(addr)
pkScript, err = txscript.PayToAddrScript(addr)
if err != nil {
return nil, err
}
} else {
var err error
scriptBuilder := btcscript.NewScriptBuilder()
pkScript, err = scriptBuilder.AddOp(btcscript.OP_TRUE).Script()
scriptBuilder := txscript.NewScriptBuilder()
pkScript, err = scriptBuilder.AddOp(txscript.OP_TRUE).Script()
if err != nil {
return nil, err
}
Expand Down
24 changes: 12 additions & 12 deletions rpcserver.go
Expand Up @@ -28,10 +28,10 @@ import (

"github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcec"
"github.com/btcsuite/btcjson"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire"
"github.com/btcsuite/btcws"
Expand Down Expand Up @@ -92,7 +92,7 @@ var (
// overhead of creating a new object on every invocation for constant
// data.
gbtCoinbaseAux = &btcjson.GetBlockTemplateResultAux{
Flags: hex.EncodeToString(builderScript(btcscript.
Flags: hex.EncodeToString(builderScript(txscript.
NewScriptBuilder().AddData([]byte(coinbaseFlags)))),
}

Expand Down Expand Up @@ -214,7 +214,7 @@ var rpcUnimplemented = map[string]struct{}{}
// 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,
// known good, scripts.
func builderScript(builder *btcscript.ScriptBuilder) []byte {
func builderScript(builder *txscript.ScriptBuilder) []byte {
script, err := builder.Script()
if err != nil {
panic(err)
Expand Down Expand Up @@ -805,7 +805,7 @@ func handleCreateRawTransaction(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan
}

// Create a new script which pays to the provided address.
pkScript, err := btcscript.PayToAddrScript(addr)
pkScript, err := txscript.PayToAddrScript(addr)
if err != nil {
return nil, btcjson.Error{
Code: btcjson.ErrInternal.Code,
Expand Down Expand Up @@ -861,7 +861,7 @@ func createVinList(mtx *btcwire.MsgTx) []btcjson.Vin {
// The disassembled string will contain [error] inline
// if the script doesn't fully parse, so ignore the
// error here.
disbuf, _ := btcscript.DisasmString(v.SignatureScript)
disbuf, _ := txscript.DisasmString(v.SignatureScript)
vinList[i].ScriptSig = new(btcjson.ScriptSig)
vinList[i].ScriptSig.Asm = disbuf
vinList[i].ScriptSig.Hex = hex.EncodeToString(v.SignatureScript)
Expand All @@ -882,14 +882,14 @@ func createVoutList(mtx *btcwire.MsgTx, net *btcnet.Params) []btcjson.Vout {

// The disassembled string will contain [error] inline if the
// 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.Hex = hex.EncodeToString(v.PkScript)

// Ignore the error here since an error means the script
// couldn't parse and there is no additional information about
// 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.ReqSigs = int32(reqSigs)

Expand Down Expand Up @@ -998,13 +998,13 @@ func handleDecodeScript(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}

// The disassembled string will contain [error] inline if the script
// doesn't fully parse, so ignore the error here.
disbuf, _ := btcscript.DisasmString(script)
disbuf, _ := txscript.DisasmString(script)

// Get information about the script.
// Ignore the error here since an error means the script couldn't parse
// and there is no additinal information about it anyways.
net := s.server.netParams
scriptClass, addrs, reqSigs, _ := btcscript.ExtractPkScriptAddrs(script, net)
scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(script, net)
addresses := make([]string, len(addrs))
for i, addr := range addrs {
addresses[i] = addr.EncodeAddress()
Expand Down Expand Up @@ -1512,7 +1512,7 @@ func (state *gbtWorkState) updateBlockTemplate(s *rpcServer, useCoinbaseValue bo

// Update the block coinbase output of the template to
// pay to the randomly selected payment address.
pkScript, err := btcscript.PayToAddrScript(payToAddr)
pkScript, err := txscript.PayToAddrScript(payToAddr)
if err != nil {
return btcjson.Error{
Code: btcjson.ErrInternal.Code,
Expand Down Expand Up @@ -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
// doesn't fully parse, so ignore the error here.
script := txOut.PkScript
disbuf, _ := btcscript.DisasmString(script)
disbuf, _ := txscript.DisasmString(script)

// Get further info about the script.
// Ignore the error here since an error means the script couldn't parse
// and there is no additional information about it anyways.
net := s.server.netParams
scriptClass, addrs, reqSigs, _ := btcscript.ExtractPkScriptAddrs(script, net)
scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(script, net)
addresses := make([]string, len(addrs))
for i, addr := range addrs {
addresses[i] = addr.EncodeAddress()
Expand Down
6 changes: 3 additions & 3 deletions rpcwebsocket.go
Expand Up @@ -20,8 +20,8 @@ import (
"golang.org/x/crypto/ripemd160"

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

for txOutIdx, txout := range tx.MsgTx().TxOut {
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(
_, addrs, _, _ := txscript.ExtractPkScriptAddrs(
txout.PkScript, wsc.server.server.netParams)

for _, addr := range addrs {
Expand Down

0 comments on commit 3b1a15d

Please sign in to comment.