From 40df13819310d10cd86191e9a48f4e9cf877053b Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Thu, 5 Feb 2015 21:36:42 -0600 Subject: [PATCH] Import btcnet repo into chaincfg directory. This commit contains the entire btcnet repository along with several changes needed to move all of the files into the chaincfg directory in order to prepare it for merging. This does NOT update btcd or any of the other packages to use the new location as that will be done separately. - All import paths in the old btcnet test files have been changed to the new location - All references to btcnet as the package name have been changed to chaincfg - The coveralls badge has been removed since it unfortunately doesn't support coverage of sub-packages This is ongoing work toward #214. --- .travis.yml | 18 ---------- LICENSE | 13 ------- README.md => chaincfg/README.md | 36 +++++++++---------- doc.go => chaincfg/doc.go | 22 ++++++------ genesis.go => chaincfg/genesis.go | 2 +- genesis_test.go => chaincfg/genesis_test.go | 36 +++++++++---------- internal_test.go => chaincfg/internal_test.go | 2 +- params.go => chaincfg/params.go | 2 +- register_test.go => chaincfg/register_test.go | 4 +-- 9 files changed, 49 insertions(+), 86 deletions(-) delete mode 100644 .travis.yml delete mode 100644 LICENSE rename README.md => chaincfg/README.md (63%) rename doc.go => chaincfg/doc.go (75%) rename genesis.go => chaincfg/genesis.go (99%) rename genesis_test.go => chaincfg/genesis_test.go (93%) rename internal_test.go => chaincfg/internal_test.go (92%) rename params.go => chaincfg/params.go (99%) rename register_test.go => chaincfg/register_test.go (99%) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7e9d7381..00000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: go -go: - - release - - tip -sudo: false -before_install: - - gocleandeps=c16c849abae90c23419d - - git clone https://gist.github.com/$gocleandeps.git - - goclean=71d0380287747d956a26 - - git clone https://gist.github.com/$goclean.git -install: - - go get -d -t -v ./... - - bash $gocleandeps/gocleandeps.sh -script: - - export PATH=$PATH:$HOME/gopath/bin - - bash $goclean/goclean.sh -after_success: - - goveralls -coverprofile=profile.cov -service=travis-ci diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 405e51cd..00000000 --- a/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2014 Conformal Systems LLC. - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/chaincfg/README.md similarity index 63% rename from README.md rename to chaincfg/README.md index 60b25d62..c61aaab0 100644 --- a/README.md +++ b/chaincfg/README.md @@ -1,19 +1,15 @@ -btcnet -====== +chaincfg +======== -[![Build Status](http://img.shields.io/travis/btcsuite/btcnet.svg)] -(https://travis-ci.org/btcsuite/btcnet) [![Coverage Status] -(https://img.shields.io/coveralls/btcsuite/btcnet.svg)] -(https://coveralls.io/r/btcsuite/btcnet?branch=master) [![ISC License] +[![Build Status](http://img.shields.io/travis/btcsuite/btcd.svg)] +(https://travis-ci.org/btcsuite/btcd) [![ISC License] (http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -Package btcnet defines the network parameters for the three standard Bitcoin -networks and provides the ability for callers to define their own custom +Package chaincfg defines chain configuration parameters for the three standard +Bitcoin networks and provides the ability for callers to define their own custom Bitcoin networks. -This package is one of the core packages from btcd, an alternative full-node -implementation of Bitcoin which is under active development by Conformal. -Although it was primarily written for btcd, this package has intentionally been +Although this package was primarily written for btcd, it has intentionally been designed so it can be used as a standalone package for any projects needing to use parameters for the standard Bitcoin networks or for projects needing to define their own network. @@ -29,27 +25,27 @@ import ( "log" "github.com/btcsuite/btcutil" - "github.com/btcsuite/btcnet" + "github.com/btcsuite/btcd/chaincfg" ) var testnet = flag.Bool("testnet", false, "operate on the testnet Bitcoin network") // By default (without -testnet), use mainnet. -var netParams = &btcnet.MainNetParams +var chainParams = &chaincfg.MainNetParams func main() { flag.Parse() // Modify active network parameters if operating on testnet. if *testnet { - netParams = &btcnet.TestNet3Params + chainParams = &chaincfg.TestNet3Params } // later... // Create and print new payment address, specific to the active network. pubKeyHash := make([]byte, 20) - addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, netParams) + addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, chainParams) if err != nil { log.Fatal(err) } @@ -60,20 +56,20 @@ func main() { ## Documentation [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)] -(http://godoc.org/github.com/btcsuite/btcnet) +(http://godoc.org/github.com/btcsuite/btcd/chaincfg) Full `go doc` style documentation for the project can be viewed online without installing this package by using the GoDoc site -[here](http://godoc.org/github.com/btcsuite/btcnet). +[here](http://godoc.org/github.com/btcsuite/btcd/chaincfg). You can also view the documentation locally once the package is installed with the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to -http://localhost:6060/pkg/github.com/btcsuite/btcnet +http://localhost:6060/pkg/github.com/btcsuite/btcd/chaincfg ## Installation ```bash -$ go get github.com/btcsuite/btcnet +$ go get github.com/btcsuite/btcd/chaincfg ``` ## GPG Verification Key @@ -98,5 +94,5 @@ signature perform the following: ## License -Package btcnet is licensed under the [copyfree](http://copyfree.org) ISC +Package chaincfg is licensed under the [copyfree](http://copyfree.org) ISC License. diff --git a/doc.go b/chaincfg/doc.go similarity index 75% rename from doc.go rename to chaincfg/doc.go index cda9e445..3659adbf 100644 --- a/doc.go +++ b/chaincfg/doc.go @@ -1,6 +1,4 @@ -// Package btcnet defines the network parameters for the three standard Bitcoin -// networks and provides the ability for callers to define their own custom -// Bitcoin networks. +// Package chaincfg defines chain configuration parameters. // // In addition to the main Bitcoin network, which is intended for the transfer // of monetary value, there also exists two currently active standard networks: @@ -9,11 +7,11 @@ // handle errors where input intended for one network is used on an application // instance running on a different network. // -// For library packages, btcnet provides the ability to lookup chain parameters -// and encoding magics when passed a *Params. Older APIs not updated to the new -// convention of passing a *Params may lookup the parameters for a +// For library packages, chaincfg provides the ability to lookup chain +// parameters and encoding magics when passed a *Params. Older APIs not updated +// to the new convention of passing a *Params may lookup the parameters for a // wire.BitcoinNet using ParamsForNet, but be aware that this usage is -// deprecated and will be removed from btcnet in the future. +// deprecated and will be removed from chaincfg in the future. // // For main packages, a (typically global) var may be assigned the address of // one of the standard Param vars for use as the application's "active" network. @@ -28,27 +26,27 @@ // "log" // // "github.com/btcsuite/btcutil" -// "github.com/btcsuite/btcnet" +// "github.com/btcsuite/btcd/chaincfg" // ) // // var testnet = flag.Bool("testnet", false, "operate on the testnet Bitcoin network") // // // By default (without -testnet), use mainnet. -// var netParams = &btcnet.MainNetParams +// var chainParams = &chaincfg.MainNetParams // // func main() { // flag.Parse() // // // Modify active network parameters if operating on testnet. // if *testnet { -// netParams = &btcnet.TestNet3Params +// chainParams = &chaincfg.TestNet3Params // } // // // later... // // // Create and print new payment address, specific to the active network. // pubKeyHash := make([]byte, 20) -// addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, netParams) +// addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, chainParams) // if err != nil { // log.Fatal(err) // } @@ -60,4 +58,4 @@ // non-standard network. As a general rule of thumb, all network parameters // should be unique to the network, but parameter collisions can still occur // (unfortunately, this is the case with regtest and testnet3 sharing magics). -package btcnet +package chaincfg diff --git a/genesis.go b/chaincfg/genesis.go similarity index 99% rename from genesis.go rename to chaincfg/genesis.go index 69021bc6..ffdaaa0f 100644 --- a/genesis.go +++ b/chaincfg/genesis.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcnet +package chaincfg import ( "time" diff --git a/genesis_test.go b/chaincfg/genesis_test.go similarity index 93% rename from genesis_test.go rename to chaincfg/genesis_test.go index bf060d69..39304108 100644 --- a/genesis_test.go +++ b/chaincfg/genesis_test.go @@ -2,13 +2,13 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcnet_test +package chaincfg_test import ( "bytes" "testing" - "github.com/btcsuite/btcnet" + "github.com/btcsuite/btcd/chaincfg" "github.com/davecgh/go-spew/spew" ) @@ -17,7 +17,7 @@ import ( func TestGenesisBlock(t *testing.T) { // Encode the genesis block to raw bytes. var buf bytes.Buffer - err := btcnet.MainNetParams.GenesisBlock.Serialize(&buf) + err := chaincfg.MainNetParams.GenesisBlock.Serialize(&buf) if err != nil { t.Fatalf("TestGenesisBlock: %v", err) } @@ -30,14 +30,14 @@ func TestGenesisBlock(t *testing.T) { } // Check hash of the block against expected hash. - hash, err := btcnet.MainNetParams.GenesisBlock.BlockSha() + hash, err := chaincfg.MainNetParams.GenesisBlock.BlockSha() if err != nil { t.Fatalf("BlockSha: %v", err) } - if !btcnet.MainNetParams.GenesisHash.IsEqual(&hash) { + if !chaincfg.MainNetParams.GenesisHash.IsEqual(&hash) { t.Fatalf("TestGenesisBlock: Genesis block hash does not "+ "appear valid - got %v, want %v", spew.Sdump(hash), - spew.Sdump(btcnet.MainNetParams.GenesisHash)) + spew.Sdump(chaincfg.MainNetParams.GenesisHash)) } } @@ -46,7 +46,7 @@ func TestGenesisBlock(t *testing.T) { func TestRegTestGenesisBlock(t *testing.T) { // Encode the genesis block to raw bytes. var buf bytes.Buffer - err := btcnet.RegressionNetParams.GenesisBlock.Serialize(&buf) + err := chaincfg.RegressionNetParams.GenesisBlock.Serialize(&buf) if err != nil { t.Fatalf("TestRegTestGenesisBlock: %v", err) } @@ -60,14 +60,14 @@ func TestRegTestGenesisBlock(t *testing.T) { } // Check hash of the block against expected hash. - hash, err := btcnet.RegressionNetParams.GenesisBlock.BlockSha() + hash, err := chaincfg.RegressionNetParams.GenesisBlock.BlockSha() if err != nil { t.Errorf("BlockSha: %v", err) } - if !btcnet.RegressionNetParams.GenesisHash.IsEqual(&hash) { + if !chaincfg.RegressionNetParams.GenesisHash.IsEqual(&hash) { t.Fatalf("TestRegTestGenesisBlock: Genesis block hash does "+ "not appear valid - got %v, want %v", spew.Sdump(hash), - spew.Sdump(btcnet.RegressionNetParams.GenesisHash)) + spew.Sdump(chaincfg.RegressionNetParams.GenesisHash)) } } @@ -76,7 +76,7 @@ func TestRegTestGenesisBlock(t *testing.T) { func TestTestNet3GenesisBlock(t *testing.T) { // Encode the genesis block to raw bytes. var buf bytes.Buffer - err := btcnet.TestNet3Params.GenesisBlock.Serialize(&buf) + err := chaincfg.TestNet3Params.GenesisBlock.Serialize(&buf) if err != nil { t.Fatalf("TestTestNet3GenesisBlock: %v", err) } @@ -90,14 +90,14 @@ func TestTestNet3GenesisBlock(t *testing.T) { } // Check hash of the block against expected hash. - hash, err := btcnet.TestNet3Params.GenesisBlock.BlockSha() + hash, err := chaincfg.TestNet3Params.GenesisBlock.BlockSha() if err != nil { t.Fatalf("BlockSha: %v", err) } - if !btcnet.TestNet3Params.GenesisHash.IsEqual(&hash) { + if !chaincfg.TestNet3Params.GenesisHash.IsEqual(&hash) { t.Fatalf("TestTestNet3GenesisBlock: Genesis block hash does "+ "not appear valid - got %v, want %v", spew.Sdump(hash), - spew.Sdump(btcnet.TestNet3Params.GenesisHash)) + spew.Sdump(chaincfg.TestNet3Params.GenesisHash)) } } @@ -106,7 +106,7 @@ func TestTestNet3GenesisBlock(t *testing.T) { func TestSimNetGenesisBlock(t *testing.T) { // Encode the genesis block to raw bytes. var buf bytes.Buffer - err := btcnet.SimNetParams.GenesisBlock.Serialize(&buf) + err := chaincfg.SimNetParams.GenesisBlock.Serialize(&buf) if err != nil { t.Fatalf("TestSimNetGenesisBlock: %v", err) } @@ -120,14 +120,14 @@ func TestSimNetGenesisBlock(t *testing.T) { } // Check hash of the block against expected hash. - hash, err := btcnet.SimNetParams.GenesisBlock.BlockSha() + hash, err := chaincfg.SimNetParams.GenesisBlock.BlockSha() if err != nil { t.Fatalf("BlockSha: %v", err) } - if !btcnet.SimNetParams.GenesisHash.IsEqual(&hash) { + if !chaincfg.SimNetParams.GenesisHash.IsEqual(&hash) { t.Fatalf("TestSimNetGenesisBlock: Genesis block hash does "+ "not appear valid - got %v, want %v", spew.Sdump(hash), - spew.Sdump(btcnet.SimNetParams.GenesisHash)) + spew.Sdump(chaincfg.SimNetParams.GenesisHash)) } } diff --git a/internal_test.go b/chaincfg/internal_test.go similarity index 92% rename from internal_test.go rename to chaincfg/internal_test.go index bb470dcc..6db2da14 100644 --- a/internal_test.go +++ b/chaincfg/internal_test.go @@ -1,4 +1,4 @@ -package btcnet +package chaincfg import ( "testing" diff --git a/params.go b/chaincfg/params.go similarity index 99% rename from params.go rename to chaincfg/params.go index 752c9e7b..b0225615 100644 --- a/params.go +++ b/chaincfg/params.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcnet +package chaincfg import ( "errors" diff --git a/register_test.go b/chaincfg/register_test.go similarity index 99% rename from register_test.go rename to chaincfg/register_test.go index 2d742620..b5ac392b 100644 --- a/register_test.go +++ b/chaincfg/register_test.go @@ -1,11 +1,11 @@ -package btcnet_test +package chaincfg_test import ( "bytes" "reflect" "testing" - . "github.com/btcsuite/btcnet" + . "github.com/btcsuite/btcd/chaincfg" ) // Define some of the required parameters for a user-registered