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.
This commit is contained in:
Dave Collins 2015-02-05 21:36:42 -06:00
parent 4dd7c939ed
commit 40df138193
9 changed files with 49 additions and 86 deletions

View file

@ -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

13
LICENSE
View file

@ -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.

View file

@ -1,19 +1,15 @@
btcnet chaincfg
====== ========
[![Build Status](http://img.shields.io/travis/btcsuite/btcnet.svg)] [![Build Status](http://img.shields.io/travis/btcsuite/btcd.svg)]
(https://travis-ci.org/btcsuite/btcnet) [![Coverage Status] (https://travis-ci.org/btcsuite/btcd) [![ISC License]
(https://img.shields.io/coveralls/btcsuite/btcnet.svg)]
(https://coveralls.io/r/btcsuite/btcnet?branch=master) [![ISC License]
(http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) (http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
Package btcnet defines the network parameters for the three standard Bitcoin Package chaincfg defines chain configuration parameters for the three standard
networks and provides the ability for callers to define their own custom Bitcoin networks and provides the ability for callers to define their own custom
Bitcoin networks. Bitcoin networks.
This package is one of the core packages from btcd, an alternative full-node Although this package was primarily written for btcd, it has intentionally been
implementation of Bitcoin which is under active development by Conformal.
Although it was primarily written for btcd, this package has intentionally been
designed so it can be used as a standalone package for any projects needing to 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 use parameters for the standard Bitcoin networks or for projects needing to
define their own network. define their own network.
@ -29,27 +25,27 @@ import (
"log" "log"
"github.com/btcsuite/btcutil" "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") var testnet = flag.Bool("testnet", false, "operate on the testnet Bitcoin network")
// By default (without -testnet), use mainnet. // By default (without -testnet), use mainnet.
var netParams = &btcnet.MainNetParams var chainParams = &chaincfg.MainNetParams
func main() { func main() {
flag.Parse() flag.Parse()
// Modify active network parameters if operating on testnet. // Modify active network parameters if operating on testnet.
if *testnet { if *testnet {
netParams = &btcnet.TestNet3Params chainParams = &chaincfg.TestNet3Params
} }
// later... // later...
// Create and print new payment address, specific to the active network. // Create and print new payment address, specific to the active network.
pubKeyHash := make([]byte, 20) pubKeyHash := make([]byte, 20)
addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, netParams) addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, chainParams)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -60,20 +56,20 @@ func main() {
## Documentation ## Documentation
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)] [![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 Full `go doc` style documentation for the project can be viewed online without
installing this package by using the GoDoc site 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 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 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 ## Installation
```bash ```bash
$ go get github.com/btcsuite/btcnet $ go get github.com/btcsuite/btcd/chaincfg
``` ```
## GPG Verification Key ## GPG Verification Key
@ -98,5 +94,5 @@ signature perform the following:
## License ## License
Package btcnet is licensed under the [copyfree](http://copyfree.org) ISC Package chaincfg is licensed under the [copyfree](http://copyfree.org) ISC
License. License.

View file

@ -1,6 +1,4 @@
// Package btcnet defines the network parameters for the three standard Bitcoin // Package chaincfg defines chain configuration parameters.
// networks and provides the ability for callers to define their own custom
// Bitcoin networks.
// //
// In addition to the main Bitcoin network, which is intended for the transfer // In addition to the main Bitcoin network, which is intended for the transfer
// of monetary value, there also exists two currently active standard networks: // 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 // handle errors where input intended for one network is used on an application
// instance running on a different network. // instance running on a different network.
// //
// For library packages, btcnet provides the ability to lookup chain parameters // For library packages, chaincfg provides the ability to lookup chain
// and encoding magics when passed a *Params. Older APIs not updated to the new // parameters and encoding magics when passed a *Params. Older APIs not updated
// convention of passing a *Params may lookup the parameters for a // 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 // 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 // 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. // one of the standard Param vars for use as the application's "active" network.
@ -28,27 +26,27 @@
// "log" // "log"
// //
// "github.com/btcsuite/btcutil" // "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") // var testnet = flag.Bool("testnet", false, "operate on the testnet Bitcoin network")
// //
// // By default (without -testnet), use mainnet. // // By default (without -testnet), use mainnet.
// var netParams = &btcnet.MainNetParams // var chainParams = &chaincfg.MainNetParams
// //
// func main() { // func main() {
// flag.Parse() // flag.Parse()
// //
// // Modify active network parameters if operating on testnet. // // Modify active network parameters if operating on testnet.
// if *testnet { // if *testnet {
// netParams = &btcnet.TestNet3Params // chainParams = &chaincfg.TestNet3Params
// } // }
// //
// // later... // // later...
// //
// // Create and print new payment address, specific to the active network. // // Create and print new payment address, specific to the active network.
// pubKeyHash := make([]byte, 20) // pubKeyHash := make([]byte, 20)
// addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, netParams) // addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, chainParams)
// if err != nil { // if err != nil {
// log.Fatal(err) // log.Fatal(err)
// } // }
@ -60,4 +58,4 @@
// non-standard network. As a general rule of thumb, all network parameters // non-standard network. As a general rule of thumb, all network parameters
// should be unique to the network, but parameter collisions can still occur // should be unique to the network, but parameter collisions can still occur
// (unfortunately, this is the case with regtest and testnet3 sharing magics). // (unfortunately, this is the case with regtest and testnet3 sharing magics).
package btcnet package chaincfg

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcnet package chaincfg
import ( import (
"time" "time"

View file

@ -2,13 +2,13 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcnet_test package chaincfg_test
import ( import (
"bytes" "bytes"
"testing" "testing"
"github.com/btcsuite/btcnet" "github.com/btcsuite/btcd/chaincfg"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
) )
@ -17,7 +17,7 @@ import (
func TestGenesisBlock(t *testing.T) { func TestGenesisBlock(t *testing.T) {
// Encode the genesis block to raw bytes. // Encode the genesis block to raw bytes.
var buf bytes.Buffer var buf bytes.Buffer
err := btcnet.MainNetParams.GenesisBlock.Serialize(&buf) err := chaincfg.MainNetParams.GenesisBlock.Serialize(&buf)
if err != nil { if err != nil {
t.Fatalf("TestGenesisBlock: %v", err) t.Fatalf("TestGenesisBlock: %v", err)
} }
@ -30,14 +30,14 @@ func TestGenesisBlock(t *testing.T) {
} }
// Check hash of the block against expected hash. // Check hash of the block against expected hash.
hash, err := btcnet.MainNetParams.GenesisBlock.BlockSha() hash, err := chaincfg.MainNetParams.GenesisBlock.BlockSha()
if err != nil { if err != nil {
t.Fatalf("BlockSha: %v", err) 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 "+ t.Fatalf("TestGenesisBlock: Genesis block hash does not "+
"appear valid - got %v, want %v", spew.Sdump(hash), "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) { func TestRegTestGenesisBlock(t *testing.T) {
// Encode the genesis block to raw bytes. // Encode the genesis block to raw bytes.
var buf bytes.Buffer var buf bytes.Buffer
err := btcnet.RegressionNetParams.GenesisBlock.Serialize(&buf) err := chaincfg.RegressionNetParams.GenesisBlock.Serialize(&buf)
if err != nil { if err != nil {
t.Fatalf("TestRegTestGenesisBlock: %v", err) t.Fatalf("TestRegTestGenesisBlock: %v", err)
} }
@ -60,14 +60,14 @@ func TestRegTestGenesisBlock(t *testing.T) {
} }
// Check hash of the block against expected hash. // Check hash of the block against expected hash.
hash, err := btcnet.RegressionNetParams.GenesisBlock.BlockSha() hash, err := chaincfg.RegressionNetParams.GenesisBlock.BlockSha()
if err != nil { if err != nil {
t.Errorf("BlockSha: %v", err) t.Errorf("BlockSha: %v", err)
} }
if !btcnet.RegressionNetParams.GenesisHash.IsEqual(&hash) { if !chaincfg.RegressionNetParams.GenesisHash.IsEqual(&hash) {
t.Fatalf("TestRegTestGenesisBlock: Genesis block hash does "+ t.Fatalf("TestRegTestGenesisBlock: Genesis block hash does "+
"not appear valid - got %v, want %v", spew.Sdump(hash), "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) { func TestTestNet3GenesisBlock(t *testing.T) {
// Encode the genesis block to raw bytes. // Encode the genesis block to raw bytes.
var buf bytes.Buffer var buf bytes.Buffer
err := btcnet.TestNet3Params.GenesisBlock.Serialize(&buf) err := chaincfg.TestNet3Params.GenesisBlock.Serialize(&buf)
if err != nil { if err != nil {
t.Fatalf("TestTestNet3GenesisBlock: %v", err) t.Fatalf("TestTestNet3GenesisBlock: %v", err)
} }
@ -90,14 +90,14 @@ func TestTestNet3GenesisBlock(t *testing.T) {
} }
// Check hash of the block against expected hash. // Check hash of the block against expected hash.
hash, err := btcnet.TestNet3Params.GenesisBlock.BlockSha() hash, err := chaincfg.TestNet3Params.GenesisBlock.BlockSha()
if err != nil { if err != nil {
t.Fatalf("BlockSha: %v", err) t.Fatalf("BlockSha: %v", err)
} }
if !btcnet.TestNet3Params.GenesisHash.IsEqual(&hash) { if !chaincfg.TestNet3Params.GenesisHash.IsEqual(&hash) {
t.Fatalf("TestTestNet3GenesisBlock: Genesis block hash does "+ t.Fatalf("TestTestNet3GenesisBlock: Genesis block hash does "+
"not appear valid - got %v, want %v", spew.Sdump(hash), "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) { func TestSimNetGenesisBlock(t *testing.T) {
// Encode the genesis block to raw bytes. // Encode the genesis block to raw bytes.
var buf bytes.Buffer var buf bytes.Buffer
err := btcnet.SimNetParams.GenesisBlock.Serialize(&buf) err := chaincfg.SimNetParams.GenesisBlock.Serialize(&buf)
if err != nil { if err != nil {
t.Fatalf("TestSimNetGenesisBlock: %v", err) t.Fatalf("TestSimNetGenesisBlock: %v", err)
} }
@ -120,14 +120,14 @@ func TestSimNetGenesisBlock(t *testing.T) {
} }
// Check hash of the block against expected hash. // Check hash of the block against expected hash.
hash, err := btcnet.SimNetParams.GenesisBlock.BlockSha() hash, err := chaincfg.SimNetParams.GenesisBlock.BlockSha()
if err != nil { if err != nil {
t.Fatalf("BlockSha: %v", err) t.Fatalf("BlockSha: %v", err)
} }
if !btcnet.SimNetParams.GenesisHash.IsEqual(&hash) { if !chaincfg.SimNetParams.GenesisHash.IsEqual(&hash) {
t.Fatalf("TestSimNetGenesisBlock: Genesis block hash does "+ t.Fatalf("TestSimNetGenesisBlock: Genesis block hash does "+
"not appear valid - got %v, want %v", spew.Sdump(hash), "not appear valid - got %v, want %v", spew.Sdump(hash),
spew.Sdump(btcnet.SimNetParams.GenesisHash)) spew.Sdump(chaincfg.SimNetParams.GenesisHash))
} }
} }

View file

@ -1,4 +1,4 @@
package btcnet package chaincfg
import ( import (
"testing" "testing"

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package btcnet package chaincfg
import ( import (
"errors" "errors"

View file

@ -1,11 +1,11 @@
package btcnet_test package chaincfg_test
import ( import (
"bytes" "bytes"
"reflect" "reflect"
"testing" "testing"
. "github.com/btcsuite/btcnet" . "github.com/btcsuite/btcd/chaincfg"
) )
// Define some of the required parameters for a user-registered // Define some of the required parameters for a user-registered