Update btcnet path import paths to new location.

This commit is contained in:
Dave Collins 2015-02-05 23:18:27 -06:00
parent 76d84d4b40
commit c6bc8ac1eb
30 changed files with 244 additions and 239 deletions

View File

@ -111,8 +111,8 @@ func (b *BlockChain) maybeAcceptBlock(block *btcutil.Block, flags BehaviorFlags)
// upgraded. This is part of BIP0034. // upgraded. This is part of BIP0034.
if blockHeader.Version < 2 { if blockHeader.Version < 2 {
if b.isMajorityVersion(2, prevNode, if b.isMajorityVersion(2, prevNode,
b.netParams.BlockV1RejectNumRequired, b.chainParams.BlockV1RejectNumRequired,
b.netParams.BlockV1RejectNumToCheck) { b.chainParams.BlockV1RejectNumToCheck) {
str := "new blocks with version %d are no " + str := "new blocks with version %d are no " +
"longer valid" "longer valid"
@ -128,8 +128,8 @@ func (b *BlockChain) maybeAcceptBlock(block *btcutil.Block, flags BehaviorFlags)
if blockHeader.Version >= serializedHeightVersion { if blockHeader.Version >= serializedHeightVersion {
if b.isMajorityVersion(serializedHeightVersion, if b.isMajorityVersion(serializedHeightVersion,
prevNode, prevNode,
b.netParams.CoinbaseBlockHeightNumRequired, b.chainParams.CoinbaseBlockHeightNumRequired,
b.netParams.CoinbaseBlockHeightNumToCheck) { b.chainParams.CoinbaseBlockHeightNumToCheck) {
expectedHeight := int64(0) expectedHeight := int64(0)
if prevNode != nil { if prevNode != nil {

View File

@ -41,7 +41,7 @@ func (b *BlockChain) BlockLocatorFromHash(hash *wire.ShaHash) BlockLocator {
locator = append(locator, hash) locator = append(locator, hash)
// Nothing more to do if a locator for the genesis hash was requested. // Nothing more to do if a locator for the genesis hash was requested.
if hash.IsEqual(b.netParams.GenesisHash) { if hash.IsEqual(b.chainParams.GenesisHash) {
return locator return locator
} }
@ -124,7 +124,7 @@ func (b *BlockChain) BlockLocatorFromHash(hash *wire.ShaHash) BlockLocator {
} }
// Append the appropriate genesis block. // Append the appropriate genesis block.
locator = append(locator, b.netParams.GenesisHash) locator = append(locator, b.chainParams.GenesisHash)
return locator return locator
} }

View File

@ -13,9 +13,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -143,8 +143,8 @@ func removeChildNode(children []*blockNode, node *blockNode) []*blockNode {
// selection with reorganization. // selection with reorganization.
type BlockChain struct { type BlockChain struct {
db database.Db db database.Db
netParams *btcnet.Params chainParams *chaincfg.Params
checkpointsByHeight map[int64]*btcnet.Checkpoint checkpointsByHeight map[int64]*chaincfg.Checkpoint
notifications NotificationCallback notifications NotificationCallback
root *blockNode root *blockNode
bestChain *blockNode bestChain *blockNode
@ -157,7 +157,7 @@ type BlockChain struct {
blockCache map[wire.ShaHash]*btcutil.Block blockCache map[wire.ShaHash]*btcutil.Block
noVerify bool noVerify bool
noCheckpoints bool noCheckpoints bool
nextCheckpoint *btcnet.Checkpoint nextCheckpoint *chaincfg.Checkpoint
checkpointBlock *btcutil.Block checkpointBlock *btcutil.Block
} }
@ -507,7 +507,7 @@ func (b *BlockChain) getPrevNodeFromNode(node *blockNode) (*blockNode, error) {
} }
// Genesis block. // Genesis block.
if node.hash.IsEqual(b.netParams.GenesisHash) { if node.hash.IsEqual(b.chainParams.GenesisHash) {
return nil, nil return nil, nil
} }
@ -640,7 +640,7 @@ func (b *BlockChain) isMajorityVersion(minVer int32, startNode *blockNode, numRe
func (b *BlockChain) calcPastMedianTime(startNode *blockNode) (time.Time, error) { func (b *BlockChain) calcPastMedianTime(startNode *blockNode) (time.Time, error) {
// Genesis block. // Genesis block.
if startNode == nil { if startNode == nil {
return b.netParams.GenesisBlock.Header.Timestamp, nil return b.chainParams.GenesisBlock.Header.Timestamp, nil
} }
// Create a slice of the previous few block timestamps used to calculate // Create a slice of the previous few block timestamps used to calculate
@ -1069,11 +1069,11 @@ func (b *BlockChain) IsCurrent(timeSource MedianTimeSource) bool {
// Notification and NotificationType for details on the types and contents of // Notification and NotificationType for details on the types and contents of
// notifications. The provided callback can be nil if the caller is not // notifications. The provided callback can be nil if the caller is not
// interested in receiving notifications. // interested in receiving notifications.
func New(db database.Db, params *btcnet.Params, c NotificationCallback) *BlockChain { func New(db database.Db, params *chaincfg.Params, c NotificationCallback) *BlockChain {
// Generate a checkpoint by height map from the provided checkpoints. // Generate a checkpoint by height map from the provided checkpoints.
var checkpointsByHeight map[int64]*btcnet.Checkpoint var checkpointsByHeight map[int64]*chaincfg.Checkpoint
if len(params.Checkpoints) > 0 { if len(params.Checkpoints) > 0 {
checkpointsByHeight = make(map[int64]*btcnet.Checkpoint) checkpointsByHeight = make(map[int64]*chaincfg.Checkpoint)
for i := range params.Checkpoints { for i := range params.Checkpoints {
checkpoint := &params.Checkpoints[i] checkpoint := &params.Checkpoints[i]
checkpointsByHeight[checkpoint.Height] = checkpoint checkpointsByHeight[checkpoint.Height] = checkpoint
@ -1082,7 +1082,7 @@ func New(db database.Db, params *btcnet.Params, c NotificationCallback) *BlockCh
b := BlockChain{ b := BlockChain{
db: db, db: db,
netParams: params, chainParams: params,
checkpointsByHeight: checkpointsByHeight, checkpointsByHeight: checkpointsByHeight,
notifications: c, notifications: c,
root: nil, root: nil,

View File

@ -8,8 +8,8 @@ import (
"testing" "testing"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -81,7 +81,7 @@ func TestHaveBlock(t *testing.T) {
want bool want bool
}{ }{
// Genesis block should be present (in the main chain). // Genesis block should be present (in the main chain).
{hash: btcnet.MainNetParams.GenesisHash.String(), want: true}, {hash: chaincfg.MainNetParams.GenesisHash.String(), want: true},
// Block 3a should be present (on a side chain). // Block 3a should be present (on a side chain).
{hash: "00000000474284d20067a4d33f6a02284e6ef70764a3a26d6a5b9df52ef663dd", want: true}, {hash: "00000000474284d20067a4d33f6a02284e6ef70764a3a26d6a5b9df52ef663dd", want: true},

View File

@ -7,9 +7,9 @@ package blockchain
import ( import (
"fmt" "fmt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -36,23 +36,23 @@ func (b *BlockChain) DisableCheckpoints(disable bool) {
// Checkpoints returns a slice of checkpoints (regardless of whether they are // Checkpoints returns a slice of checkpoints (regardless of whether they are
// already known). When checkpoints are disabled or there are no checkpoints // already known). When checkpoints are disabled or there are no checkpoints
// for the active network, it will return nil. // for the active network, it will return nil.
func (b *BlockChain) Checkpoints() []btcnet.Checkpoint { func (b *BlockChain) Checkpoints() []chaincfg.Checkpoint {
if b.noCheckpoints || len(b.netParams.Checkpoints) == 0 { if b.noCheckpoints || len(b.chainParams.Checkpoints) == 0 {
return nil return nil
} }
return b.netParams.Checkpoints return b.chainParams.Checkpoints
} }
// LatestCheckpoint returns the most recent checkpoint (regardless of whether it // LatestCheckpoint returns the most recent checkpoint (regardless of whether it
// is already known). When checkpoints are disabled or there are no checkpoints // is already known). When checkpoints are disabled or there are no checkpoints
// for the active network, it will return nil. // for the active network, it will return nil.
func (b *BlockChain) LatestCheckpoint() *btcnet.Checkpoint { func (b *BlockChain) LatestCheckpoint() *chaincfg.Checkpoint {
if b.noCheckpoints || len(b.netParams.Checkpoints) == 0 { if b.noCheckpoints || len(b.chainParams.Checkpoints) == 0 {
return nil return nil
} }
checkpoints := b.netParams.Checkpoints checkpoints := b.chainParams.Checkpoints
return &checkpoints[len(checkpoints)-1] return &checkpoints[len(checkpoints)-1]
} }
@ -60,7 +60,7 @@ func (b *BlockChain) LatestCheckpoint() *btcnet.Checkpoint {
// match the hard-coded checkpoint data. It also returns true if there is no // match the hard-coded checkpoint data. It also returns true if there is no
// checkpoint data for the passed block height. // checkpoint data for the passed block height.
func (b *BlockChain) verifyCheckpoint(height int64, hash *wire.ShaHash) bool { func (b *BlockChain) verifyCheckpoint(height int64, hash *wire.ShaHash) bool {
if b.noCheckpoints || len(b.netParams.Checkpoints) == 0 { if b.noCheckpoints || len(b.chainParams.Checkpoints) == 0 {
return true return true
} }
@ -84,12 +84,12 @@ func (b *BlockChain) verifyCheckpoint(height int64, hash *wire.ShaHash) bool {
// associated block. It returns nil if a checkpoint can't be found (this should // associated block. It returns nil if a checkpoint can't be found (this should
// really only happen for blocks before the first checkpoint). // really only happen for blocks before the first checkpoint).
func (b *BlockChain) findPreviousCheckpoint() (*btcutil.Block, error) { func (b *BlockChain) findPreviousCheckpoint() (*btcutil.Block, error) {
if b.noCheckpoints || len(b.netParams.Checkpoints) == 0 { if b.noCheckpoints || len(b.chainParams.Checkpoints) == 0 {
return nil, nil return nil, nil
} }
// No checkpoints. // No checkpoints.
checkpoints := b.netParams.Checkpoints checkpoints := b.chainParams.Checkpoints
numCheckpoints := len(checkpoints) numCheckpoints := len(checkpoints)
if numCheckpoints == 0 { if numCheckpoints == 0 {
return nil, nil return nil, nil

View File

@ -14,11 +14,11 @@ import (
"strings" "strings"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcd/database/ldb" _ "github.com/btcsuite/btcd/database/ldb"
_ "github.com/btcsuite/btcd/database/memdb" _ "github.com/btcsuite/btcd/database/memdb"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -108,7 +108,7 @@ func chainSetup(dbName string) (*blockchain.BlockChain, func(), error) {
// Insert the main network genesis block. This is part of the initial // Insert the main network genesis block. This is part of the initial
// database setup. // database setup.
genesisBlock := btcutil.NewBlock(btcnet.MainNetParams.GenesisBlock) genesisBlock := btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock)
_, err := db.InsertBlock(genesisBlock) _, err := db.InsertBlock(genesisBlock)
if err != nil { if err != nil {
teardown() teardown()
@ -116,7 +116,7 @@ func chainSetup(dbName string) (*blockchain.BlockChain, func(), error) {
return nil, nil, err return nil, nil, err
} }
chain := blockchain.New(db, &btcnet.MainNetParams, nil) chain := blockchain.New(db, &chaincfg.MainNetParams, nil)
return chain, teardown, nil return chain, teardown, nil
} }

View File

@ -197,9 +197,9 @@ func (b *BlockChain) calcEasiestDifficulty(bits uint32, duration time.Duration)
// The test network rules allow minimum difficulty blocks after more // The test network rules allow minimum difficulty blocks after more
// than twice the desired amount of time needed to generate a block has // than twice the desired amount of time needed to generate a block has
// elapsed. // elapsed.
if b.netParams.ResetMinDifficulty { if b.chainParams.ResetMinDifficulty {
if durationVal > int64(targetSpacing)*2 { if durationVal > int64(targetSpacing)*2 {
return b.netParams.PowLimitBits return b.chainParams.PowLimitBits
} }
} }
@ -208,14 +208,14 @@ func (b *BlockChain) calcEasiestDifficulty(bits uint32, duration time.Duration)
// the number of retargets for the duration and starting difficulty // the number of retargets for the duration and starting difficulty
// multiplied by the max adjustment factor. // multiplied by the max adjustment factor.
newTarget := CompactToBig(bits) newTarget := CompactToBig(bits)
for durationVal > 0 && newTarget.Cmp(b.netParams.PowLimit) < 0 { for durationVal > 0 && newTarget.Cmp(b.chainParams.PowLimit) < 0 {
newTarget.Mul(newTarget, adjustmentFactor) newTarget.Mul(newTarget, adjustmentFactor)
durationVal -= maxRetargetTimespan durationVal -= maxRetargetTimespan
} }
// Limit new value to the proof of work limit. // Limit new value to the proof of work limit.
if newTarget.Cmp(b.netParams.PowLimit) > 0 { if newTarget.Cmp(b.chainParams.PowLimit) > 0 {
newTarget.Set(b.netParams.PowLimit) newTarget.Set(b.chainParams.PowLimit)
} }
return BigToCompact(newTarget) return BigToCompact(newTarget)
@ -228,7 +228,7 @@ func (b *BlockChain) findPrevTestNetDifficulty(startNode *blockNode) (uint32, er
// the special rule applied. // the special rule applied.
iterNode := startNode iterNode := startNode
for iterNode != nil && iterNode.height%BlocksPerRetarget != 0 && for iterNode != nil && iterNode.height%BlocksPerRetarget != 0 &&
iterNode.bits == b.netParams.PowLimitBits { iterNode.bits == b.chainParams.PowLimitBits {
// Get the previous block node. This function is used over // Get the previous block node. This function is used over
// simply accessing iterNode.parent directly as it will // simply accessing iterNode.parent directly as it will
@ -245,7 +245,7 @@ func (b *BlockChain) findPrevTestNetDifficulty(startNode *blockNode) (uint32, er
// Return the found difficulty or the minimum difficulty if no // Return the found difficulty or the minimum difficulty if no
// appropriate block was found. // appropriate block was found.
lastBits := b.netParams.PowLimitBits lastBits := b.chainParams.PowLimitBits
if iterNode != nil { if iterNode != nil {
lastBits = iterNode.bits lastBits = iterNode.bits
} }
@ -260,7 +260,7 @@ func (b *BlockChain) findPrevTestNetDifficulty(startNode *blockNode) (uint32, er
func (b *BlockChain) calcNextRequiredDifficulty(lastNode *blockNode, newBlockTime time.Time) (uint32, error) { func (b *BlockChain) calcNextRequiredDifficulty(lastNode *blockNode, newBlockTime time.Time) (uint32, error) {
// Genesis block. // Genesis block.
if lastNode == nil { if lastNode == nil {
return b.netParams.PowLimitBits, nil return b.chainParams.PowLimitBits, nil
} }
// Return the previous block's difficulty requirements if this block // Return the previous block's difficulty requirements if this block
@ -269,13 +269,13 @@ func (b *BlockChain) calcNextRequiredDifficulty(lastNode *blockNode, newBlockTim
// The test network rules allow minimum difficulty blocks after // The test network rules allow minimum difficulty blocks after
// more than twice the desired amount of time needed to generate // more than twice the desired amount of time needed to generate
// a block has elapsed. // a block has elapsed.
if b.netParams.ResetMinDifficulty { if b.chainParams.ResetMinDifficulty {
// Return minimum difficulty when more than twice the // Return minimum difficulty when more than twice the
// desired amount of time needed to generate a block has // desired amount of time needed to generate a block has
// elapsed. // elapsed.
allowMinTime := lastNode.timestamp.Add(targetSpacing * 2) allowMinTime := lastNode.timestamp.Add(targetSpacing * 2)
if newBlockTime.After(allowMinTime) { if newBlockTime.After(allowMinTime) {
return b.netParams.PowLimitBits, nil return b.chainParams.PowLimitBits, nil
} }
// The block was mined within the desired timeframe, so // The block was mined within the desired timeframe, so
@ -333,8 +333,8 @@ func (b *BlockChain) calcNextRequiredDifficulty(lastNode *blockNode, newBlockTim
newTarget.Div(newTarget, big.NewInt(int64(targetTimespan))) newTarget.Div(newTarget, big.NewInt(int64(targetTimespan)))
// Limit new value to the proof of work limit. // Limit new value to the proof of work limit.
if newTarget.Cmp(b.netParams.PowLimit) > 0 { if newTarget.Cmp(b.chainParams.PowLimit) > 0 {
newTarget.Set(b.netParams.PowLimit) newTarget.Set(b.chainParams.PowLimit)
} }
// Log new target difficulty and return it. The new target logging is // Log new target difficulty and return it. The new target logging is

View File

@ -9,9 +9,9 @@ import (
"math/big" "math/big"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcd/database/memdb" _ "github.com/btcsuite/btcd/database/memdb"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -35,7 +35,7 @@ func ExampleBlockChain_ProcessBlock() {
// Insert the main network genesis block. This is part of the initial // Insert the main network genesis block. This is part of the initial
// database setup. Like above, this typically would not be needed when // database setup. Like above, this typically would not be needed when
// opening an existing database. // opening an existing database.
genesisBlock := btcutil.NewBlock(btcnet.MainNetParams.GenesisBlock) genesisBlock := btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock)
_, err = db.InsertBlock(genesisBlock) _, err = db.InsertBlock(genesisBlock)
if err != nil { if err != nil {
fmt.Printf("Failed to insert genesis block: %v\n", err) fmt.Printf("Failed to insert genesis block: %v\n", err)
@ -44,7 +44,7 @@ func ExampleBlockChain_ProcessBlock() {
// Create a new BlockChain instance using the underlying database for // Create a new BlockChain instance using the underlying database for
// the main bitcoin network and ignore notifications. // the main bitcoin network and ignore notifications.
chain := blockchain.New(db, &btcnet.MainNetParams, nil) chain := blockchain.New(db, &chaincfg.MainNetParams, nil)
// Create a new median time source that is required by the upcoming // Create a new median time source that is required by the upcoming
// call to ProcessBlock. Ordinarily this would also add time values // call to ProcessBlock. Ordinarily this would also add time values

View File

@ -141,7 +141,7 @@ func (b *BlockChain) ProcessBlock(block *btcutil.Block, timeSource MedianTimeSou
} }
// Perform preliminary sanity checks on the block and its transactions. // Perform preliminary sanity checks on the block and its transactions.
err = checkBlockSanity(block, b.netParams.PowLimit, timeSource, flags) err = checkBlockSanity(block, b.chainParams.PowLimit, timeSource, flags)
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@ -11,10 +11,10 @@ import (
"math/big" "math/big"
"time" "time"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -172,13 +172,13 @@ func isBIP0030Node(node *blockNode) bool {
// //
// At the target block generation rate for the main network, this is // At the target block generation rate for the main network, this is
// approximately every 4 years. // approximately every 4 years.
func CalcBlockSubsidy(height int64, netParams *btcnet.Params) int64 { func CalcBlockSubsidy(height int64, chainParams *chaincfg.Params) int64 {
if netParams.SubsidyHalvingInterval == 0 { if chainParams.SubsidyHalvingInterval == 0 {
return baseSubsidy return baseSubsidy
} }
// Equivalent to: baseSubsidy / 2^(height/subsidyHalvingInterval) // Equivalent to: baseSubsidy / 2^(height/subsidyHalvingInterval)
return baseSubsidy >> uint(height/int64(netParams.SubsidyHalvingInterval)) return baseSubsidy >> uint(height/int64(chainParams.SubsidyHalvingInterval))
} }
// CheckTransactionSanity performs some preliminary checks on a transaction to // CheckTransactionSanity performs some preliminary checks on a transaction to
@ -786,7 +786,7 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block) er
// The coinbase for the Genesis block is not spendable, so just return // The coinbase for the Genesis block is not spendable, so just return
// now. // now.
if node.hash.IsEqual(b.netParams.GenesisHash) && b.bestChain == nil { if node.hash.IsEqual(b.chainParams.GenesisHash) && b.bestChain == nil {
return nil return nil
} }
@ -894,7 +894,7 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block) er
for _, txOut := range transactions[0].MsgTx().TxOut { for _, txOut := range transactions[0].MsgTx().TxOut {
totalSatoshiOut += txOut.Value totalSatoshiOut += txOut.Value
} }
expectedSatoshiOut := CalcBlockSubsidy(node.height, b.netParams) + expectedSatoshiOut := CalcBlockSubsidy(node.height, b.chainParams) +
totalFees totalFees
if totalSatoshiOut > expectedSatoshiOut { if totalSatoshiOut > expectedSatoshiOut {
str := fmt.Sprintf("coinbase transaction for block pays %v "+ str := fmt.Sprintf("coinbase transaction for block pays %v "+

View File

@ -11,8 +11,8 @@ import (
"time" "time"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -34,7 +34,7 @@ func TestCheckConnectBlock(t *testing.T) {
// The genesis block should fail to connect since it's already // The genesis block should fail to connect since it's already
// inserted. // inserted.
genesisBlock := btcnet.MainNetParams.GenesisBlock genesisBlock := chaincfg.MainNetParams.GenesisBlock
err = chain.CheckConnectBlock(btcutil.NewBlock(genesisBlock)) err = chain.CheckConnectBlock(btcutil.NewBlock(genesisBlock))
if err == nil { if err == nil {
t.Errorf("CheckConnectBlock: Did not received expected error") t.Errorf("CheckConnectBlock: Did not received expected error")
@ -44,7 +44,7 @@ func TestCheckConnectBlock(t *testing.T) {
// TestCheckBlockSanity tests the CheckBlockSanity function to ensure it works // TestCheckBlockSanity tests the CheckBlockSanity function to ensure it works
// as expected. // as expected.
func TestCheckBlockSanity(t *testing.T) { func TestCheckBlockSanity(t *testing.T) {
powLimit := btcnet.MainNetParams.PowLimit powLimit := chaincfg.MainNetParams.PowLimit
block := btcutil.NewBlock(&Block100000) block := btcutil.NewBlock(&Block100000)
timeSource := blockchain.NewMedianTime() timeSource := blockchain.NewMedianTime()
err := blockchain.CheckBlockSanity(block, powLimit, timeSource) err := blockchain.CheckBlockSanity(block, powLimit, timeSource)

View File

@ -14,9 +14,9 @@ import (
"time" "time"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -180,7 +180,7 @@ type blockManager struct {
headersFirstMode bool headersFirstMode bool
headerList *list.List headerList *list.List
startHeader *list.Element startHeader *list.Element
nextCheckpoint *btcnet.Checkpoint nextCheckpoint *chaincfg.Checkpoint
} }
// resetHeaderState sets the headers-first mode state to values appropriate for // resetHeaderState sets the headers-first mode state to values appropriate for
@ -221,13 +221,13 @@ func (b *blockManager) updateChainState(newestHash *wire.ShaHash, newestHeight i
// It returns nil when there is not one either because the height is already // It returns nil when there is not one either because the height is already
// later than the final checkpoint or some other reason such as disabled // later than the final checkpoint or some other reason such as disabled
// checkpoints. // checkpoints.
func (b *blockManager) findNextHeaderCheckpoint(height int64) *btcnet.Checkpoint { func (b *blockManager) findNextHeaderCheckpoint(height int64) *chaincfg.Checkpoint {
// There is no next checkpoint if checkpoints are disabled or there are // There is no next checkpoint if checkpoints are disabled or there are
// none for this current network. // none for this current network.
if cfg.DisableCheckpoints { if cfg.DisableCheckpoints {
return nil return nil
} }
checkpoints := b.server.netParams.Checkpoints checkpoints := b.server.chainParams.Checkpoints
if len(checkpoints) == 0 { if len(checkpoints) == 0 {
return nil return nil
} }
@ -1324,7 +1324,7 @@ func newBlockManager(s *server) (*blockManager, error) {
quit: make(chan struct{}), quit: make(chan struct{}),
} }
bm.progressLogger = newBlockProgressLogger("Processed", bmgrLog) bm.progressLogger = newBlockProgressLogger("Processed", bmgrLog)
bm.blockChain = blockchain.New(s.db, s.netParams, bm.handleNotifyMsg) bm.blockChain = blockchain.New(s.db, s.chainParams, bm.handleNotifyMsg)
bm.blockChain.DisableCheckpoints(cfg.DisableCheckpoints) bm.blockChain.DisableCheckpoints(cfg.DisableCheckpoints)
if !cfg.DisableCheckpoints { if !cfg.DisableCheckpoints {
// Initialize the next checkpoint based on the current height. // Initialize the next checkpoint based on the current height.

View File

@ -9,10 +9,10 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcd/database/ldb" _ "github.com/btcsuite/btcd/database/ldb"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
flags "github.com/btcsuite/go-flags" flags "github.com/btcsuite/go-flags"
) )
@ -27,7 +27,7 @@ var (
btcdHomeDir = btcutil.AppDataDir("btcd", false) btcdHomeDir = btcutil.AppDataDir("btcd", false)
defaultDataDir = filepath.Join(btcdHomeDir, "data") defaultDataDir = filepath.Join(btcdHomeDir, "data")
knownDbTypes = database.SupportedDBs() knownDbTypes = database.SupportedDBs()
activeNetParams = &btcnet.MainNetParams activeNetParams = &chaincfg.MainNetParams
) )
// config defines the configuration options for findcheckpoint. // config defines the configuration options for findcheckpoint.
@ -67,18 +67,18 @@ func validDbType(dbType string) bool {
// netName returns the name used when referring to a bitcoin network. At the // netName returns the name used when referring to a bitcoin network. At the
// time of writing, btcd currently places blocks for testnet version 3 in the // time of writing, btcd currently places blocks for testnet version 3 in the
// data and log directory "testnet", which does not match the Name field of the // data and log directory "testnet", which does not match the Name field of the
// btcnet parameters. This function can be used to override this directory name // chaincfg parameters. This function can be used to override this directory name
// as "testnet" when the passed active network matches wire.TestNet3. // as "testnet" when the passed active network matches wire.TestNet3.
// //
// A proper upgrade to move the data and log directories for this network to // A proper upgrade to move the data and log directories for this network to
// "testnet3" is planned for the future, at which point this function can be // "testnet3" is planned for the future, at which point this function can be
// removed and the network parameter's name used instead. // removed and the network parameter's name used instead.
func netName(netParams *btcnet.Params) string { func netName(chainParams *chaincfg.Params) string {
switch netParams.Net { switch chainParams.Net {
case wire.TestNet3: case wire.TestNet3:
return "testnet" return "testnet"
default: default:
return netParams.Name return chainParams.Name
} }
} }
@ -109,15 +109,15 @@ func loadConfig() (*config, []string, error) {
// while we're at it // while we're at it
if cfg.TestNet3 { if cfg.TestNet3 {
numNets++ numNets++
activeNetParams = &btcnet.TestNet3Params activeNetParams = &chaincfg.TestNet3Params
} }
if cfg.RegressionTest { if cfg.RegressionTest {
numNets++ numNets++
activeNetParams = &btcnet.RegressionNetParams activeNetParams = &chaincfg.RegressionNetParams
} }
if cfg.SimNet { if cfg.SimNet {
numNets++ numNets++
activeNetParams = &btcnet.SimNetParams activeNetParams = &chaincfg.SimNetParams
} }
if numNets > 1 { if numNets > 1 {
str := "%s: The testnet, regtest, and simnet params can't be " + str := "%s: The testnet, regtest, and simnet params can't be " +

View File

@ -11,11 +11,11 @@ import (
"path/filepath" "path/filepath"
"strconv" "strconv"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcd/database/ldb" _ "github.com/btcsuite/btcd/database/ldb"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btclog" "github.com/btcsuite/btclog"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
flags "github.com/btcsuite/go-flags" flags "github.com/btcsuite/go-flags"
) )
@ -33,7 +33,7 @@ var (
btcdHomeDir = btcutil.AppDataDir("btcd", false) btcdHomeDir = btcutil.AppDataDir("btcd", false)
defaultDataDir = filepath.Join(btcdHomeDir, "data") defaultDataDir = filepath.Join(btcdHomeDir, "data")
log btclog.Logger log btclog.Logger
activeNetParams = &btcnet.MainNetParams activeNetParams = &chaincfg.MainNetParams
) )
const ( const (
@ -44,18 +44,18 @@ const (
// netName returns the name used when referring to a bitcoin network. At the // netName returns the name used when referring to a bitcoin network. At the
// time of writing, btcd currently places blocks for testnet version 3 in the // time of writing, btcd currently places blocks for testnet version 3 in the
// data and log directory "testnet", which does not match the Name field of the // data and log directory "testnet", which does not match the Name field of the
// btcnet parameters. This function can be used to override this directory name // chaincfg parameters. This function can be used to override this directory name
// as "testnet" when the passed active network matches wire.TestNet3. // as "testnet" when the passed active network matches wire.TestNet3.
// //
// A proper upgrade to move the data and log directories for this network to // A proper upgrade to move the data and log directories for this network to
// "testnet3" is planned for the future, at which point this function can be // "testnet3" is planned for the future, at which point this function can be
// removed and the network parameter's name used instead. // removed and the network parameter's name used instead.
func netName(netParams *btcnet.Params) string { func netName(chainParams *chaincfg.Params) string {
switch netParams.Net { switch chainParams.Net {
case wire.TestNet3: case wire.TestNet3:
return "testnet" return "testnet"
default: default:
return netParams.Name return chainParams.Name
} }
} }
@ -85,15 +85,15 @@ func main() {
// while we're at it // while we're at it
if cfg.TestNet3 { if cfg.TestNet3 {
numNets++ numNets++
activeNetParams = &btcnet.TestNet3Params activeNetParams = &chaincfg.TestNet3Params
} }
if cfg.RegressionTest { if cfg.RegressionTest {
numNets++ numNets++
activeNetParams = &btcnet.RegressionNetParams activeNetParams = &chaincfg.RegressionNetParams
} }
if cfg.SimNet { if cfg.SimNet {
numNets++ numNets++
activeNetParams = &btcnet.SimNetParams activeNetParams = &chaincfg.SimNetParams
} }
if numNets > 1 { if numNets > 1 {
str := "%s: The testnet, regtest, and simnet params can't be " + str := "%s: The testnet, regtest, and simnet params can't be " +

View File

@ -9,10 +9,10 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcd/database/ldb" _ "github.com/btcsuite/btcd/database/ldb"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
flags "github.com/btcsuite/go-flags" flags "github.com/btcsuite/go-flags"
) )
@ -28,7 +28,7 @@ var (
btcdHomeDir = btcutil.AppDataDir("btcd", false) btcdHomeDir = btcutil.AppDataDir("btcd", false)
defaultDataDir = filepath.Join(btcdHomeDir, "data") defaultDataDir = filepath.Join(btcdHomeDir, "data")
knownDbTypes = database.SupportedDBs() knownDbTypes = database.SupportedDBs()
activeNetParams = &btcnet.MainNetParams activeNetParams = &chaincfg.MainNetParams
) )
// config defines the configuration options for findcheckpoint. // config defines the configuration options for findcheckpoint.
@ -58,18 +58,18 @@ func validDbType(dbType string) bool {
// netName returns the name used when referring to a bitcoin network. At the // netName returns the name used when referring to a bitcoin network. At the
// time of writing, btcd currently places blocks for testnet version 3 in the // time of writing, btcd currently places blocks for testnet version 3 in the
// data and log directory "testnet", which does not match the Name field of the // data and log directory "testnet", which does not match the Name field of the
// btcnet parameters. This function can be used to override this directory name // chaincfg parameters. This function can be used to override this directory name
// as "testnet" when the passed active network matches wire.TestNet3. // as "testnet" when the passed active network matches wire.TestNet3.
// //
// A proper upgrade to move the data and log directories for this network to // A proper upgrade to move the data and log directories for this network to
// "testnet3" is planned for the future, at which point this function can be // "testnet3" is planned for the future, at which point this function can be
// removed and the network parameter's name used instead. // removed and the network parameter's name used instead.
func netName(netParams *btcnet.Params) string { func netName(chainParams *chaincfg.Params) string {
switch netParams.Net { switch chainParams.Net {
case wire.TestNet3: case wire.TestNet3:
return "testnet" return "testnet"
default: default:
return netParams.Name return chainParams.Name
} }
} }
@ -99,15 +99,15 @@ func loadConfig() (*config, []string, error) {
// while we're at it // while we're at it
if cfg.TestNet3 { if cfg.TestNet3 {
numNets++ numNets++
activeNetParams = &btcnet.TestNet3Params activeNetParams = &chaincfg.TestNet3Params
} }
if cfg.RegressionTest { if cfg.RegressionTest {
numNets++ numNets++
activeNetParams = &btcnet.RegressionNetParams activeNetParams = &chaincfg.RegressionNetParams
} }
if cfg.SimNet { if cfg.SimNet {
numNets++ numNets++
activeNetParams = &btcnet.SimNetParams activeNetParams = &chaincfg.SimNetParams
} }
if numNets > 1 { if numNets > 1 {
str := "%s: The testnet, regtest, and simnet params can't be " + str := "%s: The testnet, regtest, and simnet params can't be " +

View File

@ -10,10 +10,10 @@ import (
"path/filepath" "path/filepath"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcd/database/ldb" _ "github.com/btcsuite/btcd/database/ldb"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
) )
const blockDbNamePrefix = "blocks" const blockDbNamePrefix = "blocks"
@ -44,7 +44,7 @@ func loadBlockDB() (database.Db, error) {
// candidates at the last checkpoint that is already hard coded into btcchain // candidates at the last checkpoint that is already hard coded into btcchain
// since there is no point in finding candidates before already existing // since there is no point in finding candidates before already existing
// checkpoints. // checkpoints.
func findCandidates(db database.Db, latestHash *wire.ShaHash) ([]*btcnet.Checkpoint, error) { func findCandidates(db database.Db, latestHash *wire.ShaHash) ([]*chaincfg.Checkpoint, error) {
// Start with the latest block of the main chain. // Start with the latest block of the main chain.
block, err := db.FetchBlockBySha(latestHash) block, err := db.FetchBlockBySha(latestHash)
if err != nil { if err != nil {
@ -78,7 +78,7 @@ func findCandidates(db database.Db, latestHash *wire.ShaHash) ([]*btcnet.Checkpo
defer fmt.Println() defer fmt.Println()
// Loop backwards through the chain to find checkpoint candidates. // Loop backwards through the chain to find checkpoint candidates.
candidates := make([]*btcnet.Checkpoint, 0, cfg.NumCandidates) candidates := make([]*chaincfg.Checkpoint, 0, cfg.NumCandidates)
numTested := int64(0) numTested := int64(0)
for len(candidates) < cfg.NumCandidates && block.Height() > requiredHeight { for len(candidates) < cfg.NumCandidates && block.Height() > requiredHeight {
// Display progress. // Display progress.
@ -99,7 +99,7 @@ func findCandidates(db database.Db, latestHash *wire.ShaHash) ([]*btcnet.Checkpo
if err != nil { if err != nil {
return nil, err return nil, err
} }
checkpoint := btcnet.Checkpoint{ checkpoint := chaincfg.Checkpoint{
Height: block.Height(), Height: block.Height(),
Hash: candidateHash, Hash: candidateHash,
} }
@ -119,7 +119,7 @@ func findCandidates(db database.Db, latestHash *wire.ShaHash) ([]*btcnet.Checkpo
// showCandidate display a checkpoint candidate using and output format // showCandidate display a checkpoint candidate using and output format
// determined by the configuration parameters. The Go syntax output // determined by the configuration parameters. The Go syntax output
// uses the format the btcchain code expects for checkpoints added to the list. // uses the format the btcchain code expects for checkpoints added to the list.
func showCandidate(candidateNum int, checkpoint *btcnet.Checkpoint) { func showCandidate(candidateNum int, checkpoint *chaincfg.Checkpoint) {
if cfg.UseGoOutput { if cfg.UseGoOutput {
fmt.Printf("Candidate %d -- {%d, newShaHashFromStr(\"%v\")},\n", fmt.Printf("Candidate %d -- {%d, newShaHashFromStr(\"%v\")},\n",
candidateNum, checkpoint.Height, checkpoint.Hash) candidateNum, checkpoint.Height, checkpoint.Hash)

View File

@ -14,11 +14,11 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcd/database/ldb" _ "github.com/btcsuite/btcd/database/ldb"
_ "github.com/btcsuite/btcd/database/memdb" _ "github.com/btcsuite/btcd/database/memdb"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -140,7 +140,7 @@ func setupDB(dbType, dbName string) (database.Db, func(), error) {
// Insert the main network genesis block. This is part of the initial // Insert the main network genesis block. This is part of the initial
// database setup. // database setup.
genesisBlock := btcutil.NewBlock(btcnet.MainNetParams.GenesisBlock) genesisBlock := btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock)
_, err = db.InsertBlock(genesisBlock) _, err = db.InsertBlock(genesisBlock)
if err != nil { if err != nil {
teardown() teardown()
@ -179,7 +179,7 @@ func loadBlocks(t *testing.T) ([]*btcutil.Block, error) {
// Set the first block as the genesis block. // Set the first block as the genesis block.
blocks := make([]*btcutil.Block, 0, 256) blocks := make([]*btcutil.Block, 0, 256)
genesis := btcutil.NewBlock(btcnet.MainNetParams.GenesisBlock) genesis := btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock)
blocks = append(blocks, genesis) blocks = append(blocks, genesis)
for height := int64(1); err == nil; height++ { for height := int64(1); err == nil; height++ {

View File

@ -7,9 +7,9 @@ package database_test
import ( import (
"fmt" "fmt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcd/database/memdb" _ "github.com/btcsuite/btcd/database/memdb"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -37,7 +37,7 @@ func ExampleCreateDB() {
defer db.Close() defer db.Close()
// Insert the main network genesis block. // Insert the main network genesis block.
genesis := btcutil.NewBlock(btcnet.MainNetParams.GenesisBlock) genesis := btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock)
newHeight, err := db.InsertBlock(genesis) newHeight, err := db.InsertBlock(genesis)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@ -58,7 +58,7 @@ func exampleLoadDB() (database.Db, error) {
} }
// Insert the main network genesis block. // Insert the main network genesis block.
genesis := btcutil.NewBlock(btcnet.MainNetParams.GenesisBlock) genesis := btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock)
_, err = db.InsertBlock(genesis) _, err = db.InsertBlock(genesis)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -14,10 +14,10 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"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 := txscript.ExtractPkScriptAddrs(testTx.MsgTx().TxOut[0].PkScript, &btcnet.MainNetParams) _, testAddrs, _, err := txscript.ExtractPkScriptAddrs(testTx.MsgTx().TxOut[0].PkScript, &chaincfg.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)
} }
@ -420,7 +420,7 @@ func loadBlocks(t *testing.T, file string) (blocks []*btcutil.Block, err error)
}() }()
// Set the first block as the genesis block. // Set the first block as the genesis block.
genesis := btcutil.NewBlock(btcnet.MainNetParams.GenesisBlock) genesis := btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock)
blocks = append(blocks, genesis) blocks = append(blocks, genesis)
var block *btcutil.Block var block *btcutil.Block
@ -523,7 +523,7 @@ func TestLimitAndSkipFetchTxsForAddr(t *testing.T) {
// Insert a block with some fake test transactions. The block will have // Insert a block with some fake test transactions. The block will have
// 10 copies of a fake transaction involving same address. // 10 copies of a fake transaction involving same address.
addrString := "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa" addrString := "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
targetAddr, err := btcutil.DecodeAddress(addrString, &btcnet.MainNetParams) targetAddr, err := btcutil.DecodeAddress(addrString, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Fatalf("Unable to decode test address: %v", err) t.Fatalf("Unable to decode test address: %v", err)
} }

View File

@ -8,10 +8,10 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/database/memdb" "github.com/btcsuite/btcd/database/memdb"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -25,7 +25,7 @@ func TestClosed(t *testing.T) {
t.Errorf("Failed to open test database %v", err) t.Errorf("Failed to open test database %v", err)
return return
} }
_, err = db.InsertBlock(btcutil.NewBlock(btcnet.MainNetParams.GenesisBlock)) _, err = db.InsertBlock(btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock))
if err != nil { if err != nil {
t.Errorf("InsertBlock: %v", err) t.Errorf("InsertBlock: %v", err)
} }
@ -33,7 +33,7 @@ func TestClosed(t *testing.T) {
t.Errorf("Close: unexpected error %v", err) t.Errorf("Close: unexpected error %v", err)
} }
genesisHash := btcnet.MainNetParams.GenesisHash genesisHash := chaincfg.MainNetParams.GenesisHash
if err := db.DropAfterBlockBySha(genesisHash); err != memdb.ErrDbClosed { if err := db.DropAfterBlockBySha(genesisHash); err != memdb.ErrDbClosed {
t.Errorf("DropAfterBlockBySha: unexpected error %v", err) t.Errorf("DropAfterBlockBySha: unexpected error %v", err)
} }
@ -54,7 +54,7 @@ func TestClosed(t *testing.T) {
t.Errorf("FetchHeightRange: unexpected error %v", err) t.Errorf("FetchHeightRange: unexpected error %v", err)
} }
genesisCoinbaseTx := btcnet.MainNetParams.GenesisBlock.Transactions[0] genesisCoinbaseTx := chaincfg.MainNetParams.GenesisBlock.Transactions[0]
coinbaseHash, err := genesisCoinbaseTx.TxSha() coinbaseHash, err := genesisCoinbaseTx.TxSha()
if err != nil { if err != nil {
t.Errorf("TxSha: unexpected error %v", err) t.Errorf("TxSha: unexpected error %v", err)

View File

@ -5,8 +5,8 @@
package main package main
import ( import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcnet"
) )
// activeNetParams is a pointer to the parameters specific to the // activeNetParams is a pointer to the parameters specific to the
@ -16,7 +16,7 @@ var activeNetParams = &mainNetParams
// params is used to group parameters for various networks such as the main // params is used to group parameters for various networks such as the main
// network and test networks. // network and test networks.
type params struct { type params struct {
*btcnet.Params *chaincfg.Params
rpcPort string rpcPort string
dnsSeeds []string dnsSeeds []string
} }
@ -28,7 +28,7 @@ type params struct {
// it does not handle on to btcd. This approach allows the wallet process // it does not handle on to btcd. This approach allows the wallet process
// to emulate the full reference implementation RPC API. // to emulate the full reference implementation RPC API.
var mainNetParams = params{ var mainNetParams = params{
Params: &btcnet.MainNetParams, Params: &chaincfg.MainNetParams,
rpcPort: "8334", rpcPort: "8334",
dnsSeeds: []string{ dnsSeeds: []string{
"seed.bitcoin.sipa.be", "seed.bitcoin.sipa.be",
@ -46,7 +46,7 @@ var mainNetParams = params{
// than the reference implementation - see the mainNetParams comment for // than the reference implementation - see the mainNetParams comment for
// details. // details.
var regressionNetParams = params{ var regressionNetParams = params{
Params: &btcnet.RegressionNetParams, Params: &chaincfg.RegressionNetParams,
rpcPort: "18334", rpcPort: "18334",
dnsSeeds: []string{}, dnsSeeds: []string{},
} }
@ -55,7 +55,7 @@ var regressionNetParams = params{
// (wire.TestNet3). NOTE: The RPC port is intentionally different than the // (wire.TestNet3). NOTE: The RPC port is intentionally different than the
// reference implementation - see the mainNetParams comment for details. // reference implementation - see the mainNetParams comment for details.
var testNet3Params = params{ var testNet3Params = params{
Params: &btcnet.TestNet3Params, Params: &chaincfg.TestNet3Params,
rpcPort: "18334", rpcPort: "18334",
dnsSeeds: []string{ dnsSeeds: []string{
"testnet-seed.alexykot.me", "testnet-seed.alexykot.me",
@ -68,7 +68,7 @@ var testNet3Params = params{
// simNetParams contains parameters specific to the simulation test network // simNetParams contains parameters specific to the simulation test network
// (wire.SimNet). // (wire.SimNet).
var simNetParams = params{ var simNetParams = params{
Params: &btcnet.SimNetParams, Params: &chaincfg.SimNetParams,
rpcPort: "18556", rpcPort: "18556",
dnsSeeds: []string{}, // NOTE: There must NOT be any seeds. dnsSeeds: []string{}, // NOTE: There must NOT be any seeds.
} }
@ -76,17 +76,17 @@ var simNetParams = params{
// netName returns the name used when referring to a bitcoin network. At the // netName returns the name used when referring to a bitcoin network. At the
// time of writing, btcd currently places blocks for testnet version 3 in the // time of writing, btcd currently places blocks for testnet version 3 in the
// data and log directory "testnet", which does not match the Name field of the // data and log directory "testnet", which does not match the Name field of the
// btcnet parameters. This function can be used to override this directory name // chaincfg parameters. This function can be used to override this directory
// as "testnet" when the passed active network matches wire.TestNet3. // name as "testnet" when the passed active network matches wire.TestNet3.
// //
// A proper upgrade to move the data and log directories for this network to // A proper upgrade to move the data and log directories for this network to
// "testnet3" is planned for the future, at which point this function can be // "testnet3" is planned for the future, at which point this function can be
// removed and the network parameter's name used instead. // removed and the network parameter's name used instead.
func netName(netParams *params) string { func netName(chainParams *params) string {
switch netParams.Net { switch chainParams.Net {
case wire.TestNet3: case wire.TestNet3:
return "testnet" return "testnet"
default: default:
return netParams.Name return chainParams.Name
} }
} }

View File

@ -1890,7 +1890,7 @@ func newPeerBase(s *server, inbound bool) *peer {
p := peer{ p := peer{
server: s, server: s,
protocolVersion: maxProtocolVersion, protocolVersion: maxProtocolVersion,
btcnet: s.netParams.Net, btcnet: s.chainParams.Net,
services: wire.SFNodeNetwork, services: wire.SFNodeNetwork,
inbound: inbound, inbound: inbound,
knownAddresses: make(map[string]struct{}), knownAddresses: make(map[string]struct{}),

View File

@ -27,12 +27,12 @@ import (
"time" "time"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcec" "github.com/btcsuite/btcec"
"github.com/btcsuite/btcjson" "github.com/btcsuite/btcjson"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/btcsuite/btcws" "github.com/btcsuite/btcws"
"github.com/btcsuite/fastsha256" "github.com/btcsuite/fastsha256"
@ -796,7 +796,7 @@ func handleCreateRawTransaction(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan
default: default:
return nil, btcjson.ErrInvalidAddressOrKey return nil, btcjson.ErrInvalidAddressOrKey
} }
if !addr.IsForNet(s.server.netParams) { if !addr.IsForNet(s.server.chainParams) {
return nil, btcjson.Error{ return nil, btcjson.Error{
Code: btcjson.ErrInvalidAddressOrKey.Code, Code: btcjson.ErrInvalidAddressOrKey.Code,
Message: fmt.Sprintf("%s: %q", Message: fmt.Sprintf("%s: %q",
@ -875,7 +875,7 @@ func createVinList(mtx *wire.MsgTx) []btcjson.Vin {
// createVoutList returns a slice of JSON objects for the outputs of the passed // createVoutList returns a slice of JSON objects for the outputs of the passed
// transaction. // transaction.
func createVoutList(mtx *wire.MsgTx, net *btcnet.Params) []btcjson.Vout { func createVoutList(mtx *wire.MsgTx, chainParams *chaincfg.Params) []btcjson.Vout {
voutList := make([]btcjson.Vout, len(mtx.TxOut)) voutList := make([]btcjson.Vout, len(mtx.TxOut))
for i, v := range mtx.TxOut { for i, v := range mtx.TxOut {
voutList[i].N = uint32(i) voutList[i].N = uint32(i)
@ -890,7 +890,8 @@ func createVoutList(mtx *wire.MsgTx, net *btcnet.Params) []btcjson.Vout {
// 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, _ := txscript.ExtractPkScriptAddrs(v.PkScript, net) scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(
v.PkScript, chainParams)
voutList[i].ScriptPubKey.Type = scriptClass.String() voutList[i].ScriptPubKey.Type = scriptClass.String()
voutList[i].ScriptPubKey.ReqSigs = int32(reqSigs) voutList[i].ScriptPubKey.ReqSigs = int32(reqSigs)
@ -909,8 +910,8 @@ func createVoutList(mtx *wire.MsgTx, net *btcnet.Params) []btcjson.Vout {
// createTxRawResult converts the passed transaction and associated parameters // createTxRawResult converts the passed transaction and associated parameters
// to a raw transaction JSON object. // to a raw transaction JSON object.
func createTxRawResult(net *btcnet.Params, txSha string, mtx *wire.MsgTx, func createTxRawResult(chainParams *chaincfg.Params, txSha string,
blk *btcutil.Block, maxidx int64, mtx *wire.MsgTx, blk *btcutil.Block, maxidx int64,
blksha *wire.ShaHash) (*btcjson.TxRawResult, error) { blksha *wire.ShaHash) (*btcjson.TxRawResult, error) {
mtxHex, err := messageToHex(mtx) mtxHex, err := messageToHex(mtx)
@ -921,7 +922,7 @@ func createTxRawResult(net *btcnet.Params, txSha string, mtx *wire.MsgTx,
txReply := &btcjson.TxRawResult{ txReply := &btcjson.TxRawResult{
Hex: mtxHex, Hex: mtxHex,
Txid: txSha, Txid: txSha,
Vout: createVoutList(mtx, net), Vout: createVoutList(mtx, chainParams),
Vin: createVinList(mtx), Vin: createVinList(mtx),
Version: mtx.Version, Version: mtx.Version,
LockTime: mtx.LockTime, LockTime: mtx.LockTime,
@ -974,7 +975,7 @@ func handleDecodeRawTransaction(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan
Version: mtx.Version, Version: mtx.Version,
Locktime: mtx.LockTime, Locktime: mtx.LockTime,
Vin: createVinList(&mtx), Vin: createVinList(&mtx),
Vout: createVoutList(&mtx, s.server.netParams), Vout: createVoutList(&mtx, s.server.chainParams),
} }
return txReply, nil return txReply, nil
} }
@ -1004,15 +1005,15 @@ func handleDecodeScript(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}
// 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 scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(script,
scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(script, net) s.server.chainParams)
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()
} }
// Convert the script itself to a pay-to-script-hash address. // Convert the script itself to a pay-to-script-hash address.
p2sh, err := btcutil.NewAddressScriptHash(script, net) p2sh, err := btcutil.NewAddressScriptHash(script, s.server.chainParams)
if err != nil { if err != nil {
return nil, btcjson.Error{ return nil, btcjson.Error{
Code: btcjson.ErrInternal.Code, Code: btcjson.ErrInternal.Code,
@ -1212,7 +1213,7 @@ func handleGetBlock(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (i
txSha := tx.Sha().String() txSha := tx.Sha().String()
mtx := tx.MsgTx() mtx := tx.MsgTx()
rawTxn, err := createTxRawResult(s.server.netParams, rawTxn, err := createTxRawResult(s.server.chainParams,
txSha, mtx, blk, maxidx, sha) txSha, mtx, blk, maxidx, sha)
if err != nil { if err != nil {
rpcsLog.Errorf("Cannot create TxRawResult for "+ rpcsLog.Errorf("Cannot create TxRawResult for "+
@ -2055,7 +2056,7 @@ func handleGetConnectionCount(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan st
// handleGetCurrentNet implements the getcurrentnet command. // handleGetCurrentNet implements the getcurrentnet command.
func handleGetCurrentNet(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (interface{}, error) { func handleGetCurrentNet(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (interface{}, error) {
return s.server.netParams.Net, nil return s.server.chainParams.Net, nil
} }
// handleGetDifficulty implements the getdifficulty command. // handleGetDifficulty implements the getdifficulty command.
@ -2402,7 +2403,7 @@ func handleGetRawTransaction(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan str
} }
} }
rawTxn, err := createTxRawResult(s.server.netParams, c.Txid, mtx, rawTxn, err := createTxRawResult(s.server.chainParams, c.Txid, mtx,
blk, maxidx, blksha) blk, maxidx, blksha)
if err != nil { if err != nil {
rpcsLog.Errorf("Cannot create TxRawResult for txSha=%s: %v", txSha, err) rpcsLog.Errorf("Cannot create TxRawResult for txSha=%s: %v", txSha, err)
@ -2525,8 +2526,8 @@ func handleGetTxOut(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (i
// 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 scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(script,
scriptClass, addrs, reqSigs, _ := txscript.ExtractPkScriptAddrs(script, net) s.server.chainParams)
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()
@ -2967,7 +2968,7 @@ func handleSearchRawTransactions(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan
c := cmd.(*btcjson.SearchRawTransactionsCmd) c := cmd.(*btcjson.SearchRawTransactionsCmd)
// Attempt to decode the supplied address. // Attempt to decode the supplied address.
addr, err := btcutil.DecodeAddress(c.Address, s.server.netParams) addr, err := btcutil.DecodeAddress(c.Address, s.server.chainParams)
if err != nil { if err != nil {
return nil, btcjson.Error{ return nil, btcjson.Error{
Code: btcjson.ErrInvalidAddressOrKey.Code, Code: btcjson.ErrInvalidAddressOrKey.Code,
@ -3052,7 +3053,7 @@ func handleSearchRawTransactions(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan
blkSha, _ = blk.Sha() blkSha, _ = blk.Sha()
} }
rawTxn, err := createTxRawResult(s.server.netParams, rawTxn, err := createTxRawResult(s.server.chainParams,
txSha, mtx, blk, maxidx, blkSha) txSha, mtx, blk, maxidx, blkSha)
if err != nil { if err != nil {
rpcsLog.Errorf("Cannot create TxRawResult for "+ rpcsLog.Errorf("Cannot create TxRawResult for "+

View File

@ -490,7 +490,7 @@ func (m *wsNotificationManager) notifyForNewTx(clients map[chan struct{}]*wsClie
for _, wsc := range clients { for _, wsc := range clients {
if wsc.verboseTxUpdates { if wsc.verboseTxUpdates {
if verboseNtfn == nil { if verboseNtfn == nil {
net := m.server.server.netParams net := m.server.server.chainParams
rawTx, err := createTxRawResult(net, txShaStr, rawTx, err := createTxRawResult(net, txShaStr,
mtx, nil, 0, nil) mtx, nil, 0, nil)
if err != nil { if err != nil {
@ -625,7 +625,7 @@ func (m *wsNotificationManager) notifyForTxOuts(ops map[wire.OutPoint]map[chan s
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 := txscript.ExtractPkScriptAddrs( _, txAddrs, _, err := txscript.ExtractPkScriptAddrs(
txOut.PkScript, m.server.server.netParams) txOut.PkScript, m.server.server.chainParams)
if err != nil { if err != nil {
continue continue
} }
@ -1513,7 +1513,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, _, _ := txscript.ExtractPkScriptAddrs( _, addrs, _, _ := txscript.ExtractPkScriptAddrs(
txout.PkScript, wsc.server.server.netParams) txout.PkScript, wsc.server.server.chainParams)
for _, addr := range addrs { for _, addr := range addrs {
switch a := addr.(type) { switch a := addr.(type) {

View File

@ -21,10 +21,10 @@ import (
"github.com/btcsuite/btcd/addrmgr" "github.com/btcsuite/btcd/addrmgr"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcjson" "github.com/btcsuite/btcjson"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -75,7 +75,7 @@ type relayMsg struct {
type server struct { type server struct {
nonce uint64 nonce uint64
listeners []net.Listener listeners []net.Listener
netParams *btcnet.Params chainParams *chaincfg.Params
started int32 // atomic started int32 // atomic
shutdown int32 // atomic shutdown int32 // atomic
shutdownSched int32 // atomic shutdownSched int32 // atomic
@ -1096,9 +1096,9 @@ out:
} }
// newServer returns a new btcd server configured to listen on addr for the // newServer returns a new btcd server configured to listen on addr for the
// bitcoin network type specified by netParams. Use start to begin accepting // bitcoin network type specified by chainParams. Use start to begin accepting
// connections from peers. // connections from peers.
func newServer(listenAddrs []string, db database.Db, netParams *btcnet.Params) (*server, error) { func newServer(listenAddrs []string, db database.Db, chainParams *chaincfg.Params) (*server, error) {
nonce, err := wire.RandomUint64() nonce, err := wire.RandomUint64()
if err != nil { if err != nil {
return nil, err return nil, err
@ -1233,7 +1233,7 @@ func newServer(listenAddrs []string, db database.Db, netParams *btcnet.Params) (
s := server{ s := server{
nonce: nonce, nonce: nonce,
listeners: listeners, listeners: listeners,
netParams: netParams, chainParams: chainParams,
addrManager: amgr, addrManager: amgr,
newPeers: make(chan *peer, cfg.MaxPeers), newPeers: make(chan *peer, cfg.MaxPeers),
donePeers: make(chan *peer, cfg.MaxPeers), donePeers: make(chan *peer, cfg.MaxPeers),

View File

@ -5,7 +5,7 @@
package txscript package txscript
import ( import (
"github.com/btcsuite/btcnet" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -13,7 +13,7 @@ import (
// signatures associated with the passed PkScript. Note that it only works for // signatures associated with the passed PkScript. Note that it only works for
// 'standard' transaction script types. Any data such as public keys which are // 'standard' transaction script types. Any data such as public keys which are
// invalid are omitted from the results. // invalid are omitted from the results.
func ExtractPkScriptAddrs(pkScript []byte, net *btcnet.Params) (ScriptClass, []btcutil.Address, int, error) { func ExtractPkScriptAddrs(pkScript []byte, chainParams *chaincfg.Params) (ScriptClass, []btcutil.Address, int, error) {
var addrs []btcutil.Address var addrs []btcutil.Address
var requiredSigs int var requiredSigs int
@ -32,7 +32,8 @@ func ExtractPkScriptAddrs(pkScript []byte, net *btcnet.Params) (ScriptClass, []b
// Therefore the pubkey hash is the 3rd item on the stack. // Therefore the pubkey hash is the 3rd item on the stack.
// Skip the pubkey hash if it's invalid for some reason. // Skip the pubkey hash if it's invalid for some reason.
requiredSigs = 1 requiredSigs = 1
addr, err := btcutil.NewAddressPubKeyHash(pops[2].data, net) addr, err := btcutil.NewAddressPubKeyHash(pops[2].data,
chainParams)
if err == nil { if err == nil {
addrs = append(addrs, addr) addrs = append(addrs, addr)
} }
@ -43,7 +44,7 @@ func ExtractPkScriptAddrs(pkScript []byte, net *btcnet.Params) (ScriptClass, []b
// Therefore the pubkey is the first item on the stack. // Therefore the pubkey is the first item on the stack.
// Skip the pubkey if it's invalid for some reason. // Skip the pubkey if it's invalid for some reason.
requiredSigs = 1 requiredSigs = 1
addr, err := btcutil.NewAddressPubKey(pops[0].data, net) addr, err := btcutil.NewAddressPubKey(pops[0].data, chainParams)
if err == nil { if err == nil {
addrs = append(addrs, addr) addrs = append(addrs, addr)
} }
@ -54,7 +55,8 @@ func ExtractPkScriptAddrs(pkScript []byte, net *btcnet.Params) (ScriptClass, []b
// Therefore the script hash is the 2nd item on the stack. // Therefore the script hash is the 2nd item on the stack.
// Skip the script hash if it's invalid for some reason. // Skip the script hash if it's invalid for some reason.
requiredSigs = 1 requiredSigs = 1
addr, err := btcutil.NewAddressScriptHashFromHash(pops[1].data, net) addr, err := btcutil.NewAddressScriptHashFromHash(pops[1].data,
chainParams)
if err == nil { if err == nil {
addrs = append(addrs, addr) addrs = append(addrs, addr)
} }
@ -71,7 +73,8 @@ func ExtractPkScriptAddrs(pkScript []byte, net *btcnet.Params) (ScriptClass, []b
// Extract the public keys while skipping any that are invalid. // Extract the public keys while skipping any that are invalid.
addrs = make([]btcutil.Address, 0, numPubKeys) addrs = make([]btcutil.Address, 0, numPubKeys)
for i := 0; i < numPubKeys; i++ { for i := 0; i < numPubKeys; i++ {
addr, err := btcutil.NewAddressPubKey(pops[i+1].data, net) addr, err := btcutil.NewAddressPubKey(pops[i+1].data,
chainParams)
if err == nil { if err == nil {
addrs = append(addrs, addr) addrs = append(addrs, addr)
} }

View File

@ -8,8 +8,8 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -32,7 +32,7 @@ func decodeHex(hexStr string) []byte {
// in the test source code. // in the test source code.
func newAddressPubKey(serializedPubKey []byte) btcutil.Address { func newAddressPubKey(serializedPubKey []byte) btcutil.Address {
addr, err := btcutil.NewAddressPubKey(serializedPubKey, addr, err := btcutil.NewAddressPubKey(serializedPubKey,
&btcnet.MainNetParams) &chaincfg.MainNetParams)
if err != nil { if err != nil {
panic("invalid public key in test source") panic("invalid public key in test source")
} }
@ -45,7 +45,7 @@ func newAddressPubKey(serializedPubKey []byte) btcutil.Address {
// as a helper since the only way it can fail is if there is an error in the // as a helper since the only way it can fail is if there is an error in the
// test source code. // test source code.
func newAddressPubKeyHash(pkHash []byte) btcutil.Address { func newAddressPubKeyHash(pkHash []byte) btcutil.Address {
addr, err := btcutil.NewAddressPubKeyHash(pkHash, &btcnet.MainNetParams) addr, err := btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams)
if err != nil { if err != nil {
panic("invalid public key hash in test source") panic("invalid public key hash in test source")
} }
@ -59,7 +59,7 @@ func newAddressPubKeyHash(pkHash []byte) btcutil.Address {
// test source code. // test source code.
func newAddressScriptHash(scriptHash []byte) btcutil.Address { func newAddressScriptHash(scriptHash []byte) btcutil.Address {
addr, err := btcutil.NewAddressScriptHashFromHash(scriptHash, addr, err := btcutil.NewAddressScriptHashFromHash(scriptHash,
&btcnet.MainNetParams) &chaincfg.MainNetParams)
if err != nil { if err != nil {
panic("invalid script hash in test source") panic("invalid script hash in test source")
} }
@ -340,7 +340,7 @@ func TestExtractPkScriptAddrs(t *testing.T) {
t.Logf("Running %d tests.", len(tests)) t.Logf("Running %d tests.", len(tests))
for i, test := range tests { for i, test := range tests {
class, addrs, reqSigs, err := txscript.ExtractPkScriptAddrs( class, addrs, reqSigs, err := txscript.ExtractPkScriptAddrs(
test.script, &btcnet.MainNetParams) test.script, &chaincfg.MainNetParams)
if err != nil { if err != nil {
} }

View File

@ -8,8 +8,8 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -22,7 +22,7 @@ func ExamplePayToAddrScript() {
// the address type. It is also required for the upcoming call to // the address type. It is also required for the upcoming call to
// PayToAddrScript. // PayToAddrScript.
addressStr := "12gpXQVcCL2qhTNQgyLVdCFG2Qs2px98nV" addressStr := "12gpXQVcCL2qhTNQgyLVdCFG2Qs2px98nV"
address, err := btcutil.DecodeAddress(addressStr, &btcnet.MainNetParams) address, err := btcutil.DecodeAddress(addressStr, &chaincfg.MainNetParams)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
@ -61,7 +61,7 @@ func ExampleExtractPkScriptAddrs() {
// Extract and print details from the script. // Extract and print details from the script.
scriptClass, addresses, reqSigs, err := txscript.ExtractPkScriptAddrs( scriptClass, addresses, reqSigs, err := txscript.ExtractPkScriptAddrs(
script, &btcnet.MainNetParams) script, &chaincfg.MainNetParams)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return

View File

@ -11,9 +11,9 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcec" "github.com/btcsuite/btcec"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -1193,11 +1193,12 @@ func signMultiSig(tx *wire.MsgTx, idx int, subScript []byte, hashType SigHashTyp
return script, signed == nRequired return script, signed == nRequired
} }
func sign(net *btcnet.Params, tx *wire.MsgTx, idx int, subScript []byte, func sign(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int,
hashType SigHashType, kdb KeyDB, sdb ScriptDB) ([]byte, ScriptClass, subScript []byte, hashType SigHashType, kdb KeyDB, sdb ScriptDB) ([]byte,
[]btcutil.Address, int, error) { ScriptClass, []btcutil.Address, int, error) {
class, addresses, nrequired, err := ExtractPkScriptAddrs(subScript, net) class, addresses, nrequired, err := ExtractPkScriptAddrs(subScript,
chainParams)
if err != nil { if err != nil {
return nil, NonStandardTy, nil, 0, err return nil, NonStandardTy, nil, 0, err
} }
@ -1257,7 +1258,7 @@ func sign(net *btcnet.Params, tx *wire.MsgTx, idx int, subScript []byte,
// The return value is the best effort merging of the two scripts. Calling this // The return value is the best effort merging of the two scripts. Calling this
// function with addresses, class and nrequired that do not match pkScript is // function with addresses, class and nrequired that do not match pkScript is
// an error and results in undefined behaviour. // an error and results in undefined behaviour.
func mergeScripts(net *btcnet.Params, tx *wire.MsgTx, idx int, func mergeScripts(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int,
pkScript []byte, class ScriptClass, addresses []btcutil.Address, pkScript []byte, class ScriptClass, addresses []btcutil.Address,
nRequired int, sigScript, prevScript []byte) []byte { nRequired int, sigScript, prevScript []byte) []byte {
@ -1284,15 +1285,15 @@ func mergeScripts(net *btcnet.Params, tx *wire.MsgTx, idx int,
// We already know this information somewhere up the stack. // We already know this information somewhere up the stack.
class, addresses, nrequired, err := class, addresses, nrequired, err :=
ExtractPkScriptAddrs(script, net) ExtractPkScriptAddrs(script, chainParams)
// regenerate scripts. // regenerate scripts.
sigScript, _ := unparseScript(sigPops) sigScript, _ := unparseScript(sigPops)
prevScript, _ := unparseScript(prevPops) prevScript, _ := unparseScript(prevPops)
// Merge // Merge
mergedScript := mergeScripts(net, tx, idx, script, class, mergedScript := mergeScripts(chainParams, tx, idx, script,
addresses, nrequired, sigScript, prevScript) class, addresses, nrequired, sigScript, prevScript)
// Reappend the script and return the result. // Reappend the script and return the result.
builder := NewScriptBuilder() builder := NewScriptBuilder()
@ -1469,20 +1470,20 @@ func (sc ScriptClosure) GetScript(address btcutil.Address) ([]byte, error) {
// getScript. If previousScript is provided then the results in previousScript // getScript. If previousScript is provided then the results in previousScript
// will be merged in a type-dependant manner with the newly generated. // will be merged in a type-dependant manner with the newly generated.
// signature script. // signature script.
func SignTxOutput(net *btcnet.Params, tx *wire.MsgTx, idx int, func SignTxOutput(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int,
pkScript []byte, hashType SigHashType, kdb KeyDB, sdb ScriptDB, pkScript []byte, hashType SigHashType, kdb KeyDB, sdb ScriptDB,
previousScript []byte) ([]byte, error) { previousScript []byte) ([]byte, error) {
sigScript, class, addresses, nrequired, err := sign(net, tx, idx, sigScript, class, addresses, nrequired, err := sign(chainParams, tx,
pkScript, hashType, kdb, sdb) idx, pkScript, hashType, kdb, sdb)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if class == ScriptHashTy { if class == ScriptHashTy {
// TODO keep the sub addressed and pass down to merge. // TODO keep the sub addressed and pass down to merge.
realSigScript, _, _, _, err := sign(net, tx, idx, sigScript, realSigScript, _, _, _, err := sign(chainParams, tx, idx,
hashType, kdb, sdb) sigScript, hashType, kdb, sdb)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1498,8 +1499,8 @@ func SignTxOutput(net *btcnet.Params, tx *wire.MsgTx, idx int,
} }
// Merge scripts. with any previous data, if any. // Merge scripts. with any previous data, if any.
mergedScript := mergeScripts(net, tx, idx, pkScript, class, addresses, mergedScript := mergeScripts(chainParams, tx, idx, pkScript, class,
nrequired, sigScript, previousScript) addresses, nrequired, sigScript, previousScript)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -10,10 +10,10 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcec" "github.com/btcsuite/btcec"
"github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -2963,7 +2963,7 @@ func (b *bogusAddress) ScriptAddress() []byte {
} }
// IsForNet lies blatantly to satisfy the btcutil.Address interface. // IsForNet lies blatantly to satisfy the btcutil.Address interface.
func (b *bogusAddress) IsForNet(net *btcnet.Params) bool { func (b *bogusAddress) IsForNet(chainParams *chaincfg.Params) bool {
return true // why not? return true // why not?
} }
@ -2980,7 +2980,7 @@ func TestPayToAddrScript(t *testing.T) {
p2pkhMain, err := btcutil.NewAddressPubKeyHash([]byte{ p2pkhMain, err := btcutil.NewAddressPubKeyHash([]byte{
0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc, 0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc,
0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84, 0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84,
}, &btcnet.MainNetParams) }, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Errorf("Unable to create public key hash address: %v", err) t.Errorf("Unable to create public key hash address: %v", err)
return return
@ -2991,7 +2991,7 @@ func TestPayToAddrScript(t *testing.T) {
p2shMain, _ := btcutil.NewAddressScriptHashFromHash([]byte{ p2shMain, _ := btcutil.NewAddressScriptHashFromHash([]byte{
0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37, 0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37,
0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4, 0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4,
}, &btcnet.MainNetParams) }, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Errorf("Unable to create script hash address: %v", err) t.Errorf("Unable to create script hash address: %v", err)
return return
@ -3002,7 +3002,7 @@ func TestPayToAddrScript(t *testing.T) {
0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
0x52, 0xc6, 0xb4}, &btcnet.MainNetParams) 0x52, 0xc6, 0xb4}, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Errorf("Unable to create pubkey address (compressed): %v", t.Errorf("Unable to create pubkey address (compressed): %v",
err) err)
@ -3012,7 +3012,7 @@ func TestPayToAddrScript(t *testing.T) {
0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
0xb1, 0x6e, 0x65}, &btcnet.MainNetParams) 0xb1, 0x6e, 0x65}, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Errorf("Unable to create pubkey address (compressed 2): %v", t.Errorf("Unable to create pubkey address (compressed 2): %v",
err) err)
@ -3026,7 +3026,7 @@ func TestPayToAddrScript(t *testing.T) {
0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc,
0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b,
0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43,
0xf6, 0x56, 0xb4, 0x12, 0xa3}, &btcnet.MainNetParams) 0xf6, 0x56, 0xb4, 0x12, 0xa3}, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Errorf("Unable to create pubkey address (uncompressed): %v", t.Errorf("Unable to create pubkey address (uncompressed): %v",
err) err)
@ -3137,7 +3137,7 @@ func TestMultiSigScript(t *testing.T) {
0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
0x52, 0xc6, 0xb4}, &btcnet.MainNetParams) 0x52, 0xc6, 0xb4}, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Errorf("Unable to create pubkey address (compressed): %v", t.Errorf("Unable to create pubkey address (compressed): %v",
err) err)
@ -3147,7 +3147,7 @@ func TestMultiSigScript(t *testing.T) {
0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
0xb1, 0x6e, 0x65}, &btcnet.MainNetParams) 0xb1, 0x6e, 0x65}, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Errorf("Unable to create pubkey address (compressed 2): %v", t.Errorf("Unable to create pubkey address (compressed 2): %v",
err) err)
@ -3161,7 +3161,7 @@ func TestMultiSigScript(t *testing.T) {
0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc, 0x90, 0x9a, 0x5c, 0xb2, 0xe0, 0xea, 0xdd, 0xfb, 0x84, 0xcc,
0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b,
0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43,
0xf6, 0x56, 0xb4, 0x12, 0xa3}, &btcnet.MainNetParams) 0xf6, 0x56, 0xb4, 0x12, 0xa3}, &chaincfg.MainNetParams)
if err != nil { if err != nil {
t.Errorf("Unable to create pubkey address (uncompressed): %v", t.Errorf("Unable to create pubkey address (uncompressed): %v",
err) err)
@ -3284,7 +3284,7 @@ func signAndCheck(msg string, tx *wire.MsgTx, idx int, pkScript []byte,
previousScript []byte) error { previousScript []byte) error {
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, idx, pkScript, hashType, &chaincfg.TestNet3Params, tx, idx, pkScript, hashType,
kdb, sdb, []byte{}) kdb, sdb, []byte{})
if err != nil { if err != nil {
return fmt.Errorf("failed to sign output %s: %v", msg, err) return fmt.Errorf("failed to sign output %s: %v", msg, err)
@ -3419,7 +3419,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeUncompressed() SerializeUncompressed()
address, err := btcutil.NewAddressPubKeyHash( address, err := btcutil.NewAddressPubKeyHash(
btcutil.Hash160(pk), &btcnet.TestNet3Params) btcutil.Hash160(pk), &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3456,7 +3456,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeUncompressed() SerializeUncompressed()
address, err := btcutil.NewAddressPubKeyHash( address, err := btcutil.NewAddressPubKeyHash(
btcutil.Hash160(pk), &btcnet.TestNet3Params) btcutil.Hash160(pk), &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3470,7 +3470,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, pkScript, &chaincfg.TestNet3Params, tx, i, pkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false}, address.EncodeAddress(): {key, false},
}), mkGetScript(nil), []byte{}) }), mkGetScript(nil), []byte{})
@ -3483,7 +3483,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign // by the above loop, this should be valid, now sign
// again and merge. // again and merge.
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, pkScript, &chaincfg.TestNet3Params, tx, i, pkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false}, address.EncodeAddress(): {key, false},
}), mkGetScript(nil), sigScript) }), mkGetScript(nil), sigScript)
@ -3517,7 +3517,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeCompressed() SerializeCompressed()
address, err := btcutil.NewAddressPubKeyHash( address, err := btcutil.NewAddressPubKeyHash(
btcutil.Hash160(pk), &btcnet.TestNet3Params) btcutil.Hash160(pk), &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3555,7 +3555,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeCompressed() SerializeCompressed()
address, err := btcutil.NewAddressPubKeyHash( address, err := btcutil.NewAddressPubKeyHash(
btcutil.Hash160(pk), &btcnet.TestNet3Params) btcutil.Hash160(pk), &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3569,7 +3569,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, pkScript, &chaincfg.TestNet3Params, tx, i, pkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true}, address.EncodeAddress(): {key, true},
}), mkGetScript(nil), []byte{}) }), mkGetScript(nil), []byte{})
@ -3582,7 +3582,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign // by the above loop, this should be valid, now sign
// again and merge. // again and merge.
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, pkScript, &chaincfg.TestNet3Params, tx, i, pkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true}, address.EncodeAddress(): {key, true},
}), mkGetScript(nil), sigScript) }), mkGetScript(nil), sigScript)
@ -3616,7 +3616,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeUncompressed() SerializeUncompressed()
address, err := btcutil.NewAddressPubKey(pk, address, err := btcutil.NewAddressPubKey(pk,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3654,7 +3654,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeUncompressed() SerializeUncompressed()
address, err := btcutil.NewAddressPubKey(pk, address, err := btcutil.NewAddressPubKey(pk,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3668,7 +3668,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, pkScript, &chaincfg.TestNet3Params, tx, i, pkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false}, address.EncodeAddress(): {key, false},
}), mkGetScript(nil), []byte{}) }), mkGetScript(nil), []byte{})
@ -3681,7 +3681,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign // by the above loop, this should be valid, now sign
// again and merge. // again and merge.
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, pkScript, &chaincfg.TestNet3Params, tx, i, pkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false}, address.EncodeAddress(): {key, false},
}), mkGetScript(nil), sigScript) }), mkGetScript(nil), sigScript)
@ -3715,7 +3715,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeCompressed() SerializeCompressed()
address, err := btcutil.NewAddressPubKey(pk, address, err := btcutil.NewAddressPubKey(pk,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3753,7 +3753,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeCompressed() SerializeCompressed()
address, err := btcutil.NewAddressPubKey(pk, address, err := btcutil.NewAddressPubKey(pk,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3767,7 +3767,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, pkScript, &chaincfg.TestNet3Params, tx, i, pkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true}, address.EncodeAddress(): {key, true},
}), mkGetScript(nil), []byte{}) }), mkGetScript(nil), []byte{})
@ -3780,7 +3780,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign // by the above loop, this should be valid, now sign
// again and merge. // again and merge.
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, pkScript, &chaincfg.TestNet3Params, tx, i, pkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true}, address.EncodeAddress(): {key, true},
}), mkGetScript(nil), sigScript) }), mkGetScript(nil), sigScript)
@ -3814,7 +3814,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeUncompressed() SerializeUncompressed()
address, err := btcutil.NewAddressPubKeyHash( address, err := btcutil.NewAddressPubKeyHash(
btcutil.Hash160(pk), &btcnet.TestNet3Params) btcutil.Hash160(pk), &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3829,7 +3829,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -3871,7 +3871,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeUncompressed() SerializeUncompressed()
address, err := btcutil.NewAddressPubKeyHash( address, err := btcutil.NewAddressPubKeyHash(
btcutil.Hash160(pk), &btcnet.TestNet3Params) btcutil.Hash160(pk), &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3886,7 +3886,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -3902,7 +3902,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false}, address.EncodeAddress(): {key, false},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -3917,7 +3917,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign // by the above loop, this should be valid, now sign
// again and merge. // again and merge.
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false}, address.EncodeAddress(): {key, false},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -3953,7 +3953,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeCompressed() SerializeCompressed()
address, err := btcutil.NewAddressPubKeyHash( address, err := btcutil.NewAddressPubKeyHash(
btcutil.Hash160(pk), &btcnet.TestNet3Params) btcutil.Hash160(pk), &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -3967,7 +3967,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -4010,7 +4010,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeCompressed() SerializeCompressed()
address, err := btcutil.NewAddressPubKeyHash( address, err := btcutil.NewAddressPubKeyHash(
btcutil.Hash160(pk), &btcnet.TestNet3Params) btcutil.Hash160(pk), &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -4024,7 +4024,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -4040,7 +4040,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true}, address.EncodeAddress(): {key, true},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -4055,7 +4055,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign // by the above loop, this should be valid, now sign
// again and merge. // again and merge.
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true}, address.EncodeAddress(): {key, true},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -4091,7 +4091,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeUncompressed() SerializeUncompressed()
address, err := btcutil.NewAddressPubKey(pk, address, err := btcutil.NewAddressPubKey(pk,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -4105,7 +4105,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -4148,7 +4148,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeUncompressed() SerializeUncompressed()
address, err := btcutil.NewAddressPubKey(pk, address, err := btcutil.NewAddressPubKey(pk,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -4162,7 +4162,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -4178,7 +4178,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false}, address.EncodeAddress(): {key, false},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -4193,7 +4193,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign // by the above loop, this should be valid, now sign
// again and merge. // again and merge.
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false}, address.EncodeAddress(): {key, false},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -4229,7 +4229,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeCompressed() SerializeCompressed()
address, err := btcutil.NewAddressPubKey(pk, address, err := btcutil.NewAddressPubKey(pk,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -4243,7 +4243,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -4286,7 +4286,7 @@ func TestSignTxOutput(t *testing.T) {
pk := (*btcec.PublicKey)(&key.PublicKey). pk := (*btcec.PublicKey)(&key.PublicKey).
SerializeCompressed() SerializeCompressed()
address, err := btcutil.NewAddressPubKey(pk, address, err := btcutil.NewAddressPubKey(pk,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -4300,7 +4300,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -4316,7 +4316,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true}, address.EncodeAddress(): {key, true},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -4331,7 +4331,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign // by the above loop, this should be valid, now sign
// again and merge. // again and merge.
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true}, address.EncodeAddress(): {key, true},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -4367,7 +4367,7 @@ func TestSignTxOutput(t *testing.T) {
pk1 := (*btcec.PublicKey)(&key1.PublicKey). pk1 := (*btcec.PublicKey)(&key1.PublicKey).
SerializeCompressed() SerializeCompressed()
address1, err := btcutil.NewAddressPubKey(pk1, address1, err := btcutil.NewAddressPubKey(pk1,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -4384,7 +4384,7 @@ func TestSignTxOutput(t *testing.T) {
pk2 := (*btcec.PublicKey)(&key2.PublicKey). pk2 := (*btcec.PublicKey)(&key2.PublicKey).
SerializeCompressed() SerializeCompressed()
address2, err := btcutil.NewAddressPubKey(pk2, address2, err := btcutil.NewAddressPubKey(pk2,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address 2 for %s: %v", t.Errorf("failed to make address 2 for %s: %v",
msg, err) msg, err)
@ -4400,7 +4400,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -4444,7 +4444,7 @@ func TestSignTxOutput(t *testing.T) {
pk1 := (*btcec.PublicKey)(&key1.PublicKey). pk1 := (*btcec.PublicKey)(&key1.PublicKey).
SerializeCompressed() SerializeCompressed()
address1, err := btcutil.NewAddressPubKey(pk1, address1, err := btcutil.NewAddressPubKey(pk1,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -4461,7 +4461,7 @@ func TestSignTxOutput(t *testing.T) {
pk2 := (*btcec.PublicKey)(&key2.PublicKey). pk2 := (*btcec.PublicKey)(&key2.PublicKey).
SerializeCompressed() SerializeCompressed()
address2, err := btcutil.NewAddressPubKey(pk2, address2, err := btcutil.NewAddressPubKey(pk2,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address 2 for %s: %v", t.Errorf("failed to make address 2 for %s: %v",
msg, err) msg, err)
@ -4477,7 +4477,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -4493,7 +4493,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address1.EncodeAddress(): {key1, true}, address1.EncodeAddress(): {key1, true},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -4514,7 +4514,7 @@ func TestSignTxOutput(t *testing.T) {
// Sign with the other key and merge // Sign with the other key and merge
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address2.EncodeAddress(): {key2, true}, address2.EncodeAddress(): {key2, true},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -4551,7 +4551,7 @@ func TestSignTxOutput(t *testing.T) {
pk1 := (*btcec.PublicKey)(&key1.PublicKey). pk1 := (*btcec.PublicKey)(&key1.PublicKey).
SerializeCompressed() SerializeCompressed()
address1, err := btcutil.NewAddressPubKey(pk1, address1, err := btcutil.NewAddressPubKey(pk1,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address for %s: %v", t.Errorf("failed to make address for %s: %v",
msg, err) msg, err)
@ -4568,7 +4568,7 @@ func TestSignTxOutput(t *testing.T) {
pk2 := (*btcec.PublicKey)(&key2.PublicKey). pk2 := (*btcec.PublicKey)(&key2.PublicKey).
SerializeCompressed() SerializeCompressed()
address2, err := btcutil.NewAddressPubKey(pk2, address2, err := btcutil.NewAddressPubKey(pk2,
&btcnet.TestNet3Params) &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make address 2 for %s: %v", t.Errorf("failed to make address 2 for %s: %v",
msg, err) msg, err)
@ -4584,7 +4584,7 @@ func TestSignTxOutput(t *testing.T) {
} }
scriptAddr, err := btcutil.NewAddressScriptHash( scriptAddr, err := btcutil.NewAddressScriptHash(
pkScript, &btcnet.TestNet3Params) pkScript, &chaincfg.TestNet3Params)
if err != nil { if err != nil {
t.Errorf("failed to make p2sh addr for %s: %v", t.Errorf("failed to make p2sh addr for %s: %v",
msg, err) msg, err)
@ -4600,7 +4600,7 @@ func TestSignTxOutput(t *testing.T) {
} }
sigScript, err := txscript.SignTxOutput( sigScript, err := txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address1.EncodeAddress(): {key1, true}, address1.EncodeAddress(): {key1, true},
}), mkGetScript(map[string][]byte{ }), mkGetScript(map[string][]byte{
@ -4621,7 +4621,7 @@ func TestSignTxOutput(t *testing.T) {
// Sign with the other key and merge // Sign with the other key and merge
sigScript, err = txscript.SignTxOutput( sigScript, err = txscript.SignTxOutput(
&btcnet.TestNet3Params, tx, i, scriptPkScript, &chaincfg.TestNet3Params, tx, i, scriptPkScript,
hashType, mkGetKey(map[string]addressToKey{ hashType, mkGetKey(map[string]addressToKey{
address1.EncodeAddress(): {key1, true}, address1.EncodeAddress(): {key1, true},
address2.EncodeAddress(): {key2, true}, address2.EncodeAddress(): {key2, true},