Update btcscript import paths to new location.

This commit is contained in:
Dave Collins 2015-01-30 12:31:29 -06:00
parent 31149b88b9
commit 6d4889ffb0
10 changed files with 60 additions and 60 deletions

View file

@ -17,7 +17,7 @@
package main
import (
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/keystore"
@ -99,7 +99,7 @@ func (w *Wallet) addReceivedTx(tx *btcutil.Tx, block *txstore.Block) error {
for txOutIdx, txOut := range tx.MsgTx().TxOut {
// Errors don't matter here. If addrs is nil, the range below
// does nothing.
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txOut.PkScript,
_, addrs, _, _ := txscript.ExtractPkScriptAddrs(txOut.PkScript,
activeNet.Params)
insert := false
for _, addr := range addrs {

View file

@ -24,7 +24,7 @@ import (
"time"
"github.com/btcsuite/btcchain"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/keystore"
"github.com/btcsuite/btcwallet/txstore"
@ -275,7 +275,7 @@ func createTx(
// addChange adds a new output with the given amount and address, and
// randomizes the index (and returns it) of the newly added output.
func addChange(msgtx *btcwire.MsgTx, change btcutil.Amount, changeAddr btcutil.Address) (int, error) {
pkScript, err := btcscript.PayToAddrScript(changeAddr)
pkScript, err := txscript.PayToAddrScript(changeAddr)
if err != nil {
return 0, fmt.Errorf("cannot create txout script: %s", err)
}
@ -321,7 +321,7 @@ func addOutputs(msgtx *btcwire.MsgTx, pairs map[string]btcutil.Amount) (btcutil.
}
// Add output to spend amt to addr.
pkScript, err := btcscript.PayToAddrScript(addr)
pkScript, err := txscript.PayToAddrScript(addr)
if err != nil {
return minAmount, fmt.Errorf("cannot create txout script: %s", err)
}
@ -342,8 +342,8 @@ func (w *Wallet) findEligibleOutputs(minconf int, bs *keystore.BlockStamp) ([]tx
// signrawtransaction, and sendrawtransaction).
eligible := make([]txstore.Credit, 0, len(unspent))
for i := range unspent {
switch btcscript.GetScriptClass(unspent[i].TxOut().PkScript) {
case btcscript.PubKeyHashTy:
switch txscript.GetScriptClass(unspent[i].TxOut().PkScript) {
case txscript.PubKeyHashTy:
if !unspent[i].Confirmed(minconf, bs.Height) {
continue
}
@ -399,8 +399,8 @@ func signMsgTx(msgtx *btcwire.MsgTx, prevOutputs []txstore.Credit, store *keysto
return fmt.Errorf("cannot get private key: %v", err)
}
sigscript, err := btcscript.SignatureScript(
msgtx, i, output.TxOut().PkScript, btcscript.SigHashAll, privkey, ai.Compressed())
sigscript, err := txscript.SignatureScript(
msgtx, i, output.TxOut().PkScript, txscript.SigHashAll, privkey, ai.Compressed())
if err != nil {
return fmt.Errorf("cannot create sigscript: %s", err)
}
@ -411,13 +411,13 @@ func signMsgTx(msgtx *btcwire.MsgTx, prevOutputs []txstore.Credit, store *keysto
}
func validateMsgTx(msgtx *btcwire.MsgTx, prevOutputs []txstore.Credit) error {
flags := btcscript.ScriptCanonicalSignatures | btcscript.ScriptStrictMultiSig
bip16 := time.Now().After(btcscript.Bip16Activation)
flags := txscript.ScriptCanonicalSignatures | txscript.ScriptStrictMultiSig
bip16 := time.Now().After(txscript.Bip16Activation)
if bip16 {
flags |= btcscript.ScriptBip16
flags |= txscript.ScriptBip16
}
for i, txin := range msgtx.TxIn {
engine, err := btcscript.NewScript(
engine, err := txscript.NewScript(
txin.SignatureScript, prevOutputs[i].TxOut().PkScript, i, msgtx, flags)
if err != nil {
return fmt.Errorf("cannot create script engine: %s", err)

View file

@ -6,7 +6,7 @@ import (
"sort"
"testing"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/keystore"
"github.com/btcsuite/btcwallet/txstore"
@ -133,7 +133,7 @@ func checkOutputsMatch(t *testing.T, msgtx *btcwire.MsgTx, expected map[string]b
if err != nil {
t.Fatalf("Cannot decode address: %v", err)
}
pkScript, err := btcscript.PayToAddrScript(addr)
pkScript, err := txscript.PayToAddrScript(addr)
if err != nil {
t.Fatalf("Cannot create pkScript: %v", err)
}

View file

@ -12,7 +12,7 @@ package main
import (
"testing"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/tx"
"github.com/btcsuite/btcwire"
@ -97,7 +97,7 @@ func TestFakeTxs(t *testing.T) {
// Create and add a fake Utxo so we have some funds to spend.
//
// This will pass validation because btcscript is unaware of invalid
// This will pass validation because txcscript is unaware of invalid
// tx inputs, however, this example would fail in btcd.
utxo := &tx.Utxo{}
addr, err := w.NextChainedAddress(&keystore.BlockStamp{}, 100)
@ -111,7 +111,7 @@ func TestFakeTxs(t *testing.T) {
28, 29, 30, 31, 32})
out := btcwire.NewOutPoint(&ophash, 0)
utxo.Out = tx.OutPoint(*out)
ss, err := btcscript.PayToAddrScript(addr)
ss, err := txscript.PayToAddrScript(addr)
if err != nil {
t.Errorf("Could not create utxo PkScript: %s", err)
return

View file

@ -36,9 +36,9 @@ import (
"golang.org/x/crypto/ripemd160"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcec"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/rename"
"github.com/btcsuite/btcwire"
@ -2764,7 +2764,7 @@ func (a *p2SHScript) WriteTo(w io.Writer) (n int64, err error) {
type scriptAddress struct {
store *Store
address btcutil.Address
class btcscript.ScriptClass
class txscript.ScriptClass
addresses []btcutil.Address
reqSigs int
flags scriptFlags
@ -2782,7 +2782,7 @@ type ScriptAddress interface {
// Returns the script associated with the address.
Script() []byte
// Returns the class of the script associated with the address.
ScriptClass() btcscript.ScriptClass
ScriptClass() txscript.ScriptClass
// Returns the addresses that are required to sign transactions from the
// script address.
Addresses() []btcutil.Address
@ -2794,7 +2794,7 @@ type ScriptAddress interface {
// iv must be 16 bytes, or nil (in which case it is randomly generated).
func newScriptAddress(s *Store, script []byte, bs *BlockStamp) (addr *scriptAddress, err error) {
class, addresses, reqSigs, err :=
btcscript.ExtractPkScriptAddrs(script, s.netParams())
txscript.ExtractPkScriptAddrs(script, s.netParams())
if err != nil {
return nil, err
}
@ -2885,7 +2885,7 @@ func (sa *scriptAddress) ReadFrom(r io.Reader) (n int64, err error) {
}
class, addresses, reqSigs, err :=
btcscript.ExtractPkScriptAddrs(sa.script, sa.store.netParams())
txscript.ExtractPkScriptAddrs(sa.script, sa.store.netParams())
if err != nil {
return n, err
}
@ -2972,7 +2972,7 @@ func (sa *scriptAddress) Addresses() []btcutil.Address {
}
// ScriptClass returns the type of script the address is.
func (sa *scriptAddress) ScriptClass() btcscript.ScriptClass {
func (sa *scriptAddress) ScriptClass() txscript.ScriptClass {
return sa.class
}

View file

@ -23,9 +23,9 @@ import (
"reflect"
"testing"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcec"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire"
@ -98,8 +98,8 @@ func TestBtcAddressSerializer(t *testing.T) {
func TestScriptAddressSerializer(t *testing.T) {
fakeWallet := &Store{net: (*netParams)(tstNetParams)}
script := []byte{btcscript.OP_TRUE, btcscript.OP_DUP,
btcscript.OP_DROP}
script := []byte{txscript.OP_TRUE, txscript.OP_DUP,
txscript.OP_DROP}
addr, err := newScriptAddress(fakeWallet, script, makeBS(0))
if err != nil {
t.Error(err.Error())
@ -878,8 +878,8 @@ func TestImportScript(t *testing.T) {
return
}
script := []byte{btcscript.OP_TRUE, btcscript.OP_DUP,
btcscript.OP_DROP}
script := []byte{txscript.OP_TRUE, txscript.OP_DUP,
txscript.OP_DROP}
importHeight := int32(50)
stamp := makeBS(importHeight)
address, err := w.ImportScript(script, stamp)
@ -901,7 +901,7 @@ func TestImportScript(t *testing.T) {
return
}
if sinfo.ScriptClass() != btcscript.NonStandardTy {
if sinfo.ScriptClass() != txscript.NonStandardTy {
t.Error("script type incorrect.")
return
}

View file

@ -37,10 +37,10 @@ import (
"sync/atomic"
"time"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcec"
"github.com/btcsuite/btcjson"
"github.com/btcsuite/btcrpcclient"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/keystore"
@ -1570,7 +1570,7 @@ func makeMultiSigScript(w *Wallet, keys []string, nRequired int) ([]byte, error)
}
}
return btcscript.MultiSigScript(keysesPrecious, nRequired)
return txscript.MultiSigScript(keysesPrecious, nRequired)
}
// AddMultiSigAddress handles an addmultisigaddress request by adding a
@ -2699,24 +2699,24 @@ func SignRawTransaction(w *Wallet, chainSvr *chain.Client, icmd btcjson.Cmd) (in
}
}
hashType := btcscript.SigHashAll
hashType := txscript.SigHashAll
if cmd.Flags != "" {
switch cmd.Flags {
case "ALL":
hashType = btcscript.SigHashAll
hashType = txscript.SigHashAll
case "NONE":
hashType = btcscript.SigHashNone
hashType = txscript.SigHashNone
case "SINGLE":
hashType = btcscript.SigHashSingle
hashType = txscript.SigHashSingle
case "ALL|ANYONECANPAY":
hashType = btcscript.SigHashAll |
btcscript.SigHashAnyOneCanPay
hashType = txscript.SigHashAll |
txscript.SigHashAnyOneCanPay
case "NONE|ANYONECANPAY":
hashType = btcscript.SigHashNone |
btcscript.SigHashAnyOneCanPay
hashType = txscript.SigHashNone |
txscript.SigHashAnyOneCanPay
case "SINGLE|ANYONECANPAY":
hashType = btcscript.SigHashSingle |
btcscript.SigHashAnyOneCanPay
hashType = txscript.SigHashSingle |
txscript.SigHashAnyOneCanPay
default:
e := errors.New("Invalid sighash parameter")
return nil, InvalidParameterError{e}
@ -2762,9 +2762,9 @@ func SignRawTransaction(w *Wallet, chainSvr *chain.Client, icmd btcjson.Cmd) (in
txIn.PreviousOutPoint.Index)
}
// Set up our callbacks that we pass to btcscript so it can
// Set up our callbacks that we pass to txscript so it can
// look up the appropriate keys and scripts by address.
getKey := btcscript.KeyClosure(func(addr btcutil.Address) (
getKey := txscript.KeyClosure(func(addr btcutil.Address) (
*btcec.PrivateKey, bool, error) {
if len(keys) != 0 {
wif, ok := keys[addr.EncodeAddress()]
@ -2793,7 +2793,7 @@ func SignRawTransaction(w *Wallet, chainSvr *chain.Client, icmd btcjson.Cmd) (in
return key, pka.Compressed(), nil
})
getScript := btcscript.ScriptClosure(func(
getScript := txscript.ScriptClosure(func(
addr btcutil.Address) ([]byte, error) {
// If keys were provided then we can only use the
// scripts provided with our inputs, too.
@ -2824,10 +2824,10 @@ func SignRawTransaction(w *Wallet, chainSvr *chain.Client, icmd btcjson.Cmd) (in
// SigHashSingle inputs can only be signed if there's a
// corresponding output. However this could be already signed,
// so we always verify the output.
if (hashType&btcscript.SigHashSingle) !=
btcscript.SigHashSingle || i < len(msgTx.TxOut) {
if (hashType&txscript.SigHashSingle) !=
txscript.SigHashSingle || i < len(msgTx.TxOut) {
script, err := btcscript.SignTxOutput(activeNet.Params,
script, err := txscript.SignTxOutput(activeNet.Params,
msgTx, i, input, hashType, getKey,
getScript, txIn.SignatureScript)
// Failure to sign isn't an error, it just means that
@ -2841,9 +2841,9 @@ func SignRawTransaction(w *Wallet, chainSvr *chain.Client, icmd btcjson.Cmd) (in
// Either it was already signed or we just signed it.
// Find out if it is completely satisfied or still needs more.
flags := btcscript.ScriptBip16 | btcscript.ScriptCanonicalSignatures |
btcscript.ScriptStrictMultiSig
engine, err := btcscript.NewScript(txIn.SignatureScript, input,
flags := txscript.ScriptBip16 | txscript.ScriptCanonicalSignatures |
txscript.ScriptStrictMultiSig
engine, err := txscript.NewScript(txIn.SignatureScript, input,
i, msgTx, flags)
if err != nil || engine.Execute() != nil {
complete = false
@ -2905,7 +2905,7 @@ func ValidateAddress(w *Wallet, chainSvr *chain.Client, icmd btcjson.Cmd) (inter
class := sa.ScriptClass()
// script type
result.Script = class.String()
if class == btcscript.MultiSigTy {
if class == txscript.MultiSigTy {
result.SigsRequired = int32(sa.RequiredSigs())
}
}

View file

@ -18,9 +18,9 @@ package txstore
import (
"github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcjson"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil"
)
@ -69,7 +69,7 @@ func (d Debits) toJSON(account string, chainHeight int32,
for _, txOut := range msgTx.TxOut {
address := ""
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txOut.PkScript, net)
_, addrs, _, _ := txscript.ExtractPkScriptAddrs(txOut.PkScript, net)
if len(addrs) == 1 {
address = addrs[0].EncodeAddress()
}
@ -167,7 +167,7 @@ func (c Credit) toJSON(account string, chainHeight int32,
txout := msgTx.TxOut[c.OutputIndex]
var address string
_, addrs, _, _ := btcscript.ExtractPkScriptAddrs(txout.PkScript, net)
_, addrs, _, _ := txscript.ExtractPkScriptAddrs(txout.PkScript, net)
if len(addrs) == 1 {
address = addrs[0].EncodeAddress()
}

View file

@ -25,8 +25,8 @@ import (
"time"
"github.com/btcsuite/btcchain"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire"
)
@ -1420,7 +1420,7 @@ func (d Debits) Fee() btcutil.Amount {
// Addresses parses the pubkey script, extracting all addresses for a
// standard script.
func (c Credit) Addresses(net *btcnet.Params) (btcscript.ScriptClass,
func (c Credit) Addresses(net *btcnet.Params) (txscript.ScriptClass,
[]btcutil.Address, int, error) {
c.s.mtx.RLock()
@ -1428,7 +1428,7 @@ func (c Credit) Addresses(net *btcnet.Params) (btcscript.ScriptClass,
msgTx := c.Tx().MsgTx()
pkScript := msgTx.TxOut[c.OutputIndex].PkScript
return btcscript.ExtractPkScriptAddrs(pkScript, net)
return txscript.ExtractPkScriptAddrs(pkScript, net)
}
// Change returns whether the credit is the result of a change output.

View file

@ -20,7 +20,7 @@ import (
"fmt"
"sort"
"github.com/btcsuite/btcscript"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/btcsuite/btcwallet/waddrmgr"
@ -521,7 +521,7 @@ func (vp *Pool) DepositScript(seriesID, branch, index uint32) ([]byte, error) {
}
}
script, err := btcscript.MultiSigScript(pks, int(series.reqSigs))
script, err := txscript.MultiSigScript(pks, int(series.reqSigs))
if err != nil {
str := fmt.Sprintf("error while making multisig script hash, %d", len(pks))
return nil, managerError(waddrmgr.ErrScriptCreation, str, err)