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:
parent
4dd7c939ed
commit
40df138193
9 changed files with 49 additions and 86 deletions
18
.travis.yml
18
.travis.yml
|
@ -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
13
LICENSE
|
@ -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.
|
|
@ -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.
|
|
@ -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
|
|
@ -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"
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package btcnet
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
"testing"
|
|
@ -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"
|
|
@ -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
|
Loading…
Reference in a new issue