# README
chaincfg
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.
Although this package was primarily written for bchd, 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 Cash networks or for projects needing to define their own network.
Sample Use
package main
import (
"flag"
"fmt"
"log"
"github.com/aviator-coding/bchutil"
"github.com/aviator-coding/bchd/chaincfg"
)
var testnet = flag.Bool("testnet", false, "operate on the testnet Bitcoin network")
// By default (without -testnet), use mainnet.
var chainParams = &chaincfg.MainNetParams
func main() {
flag.Parse()
// Modify active network parameters if operating on testnet.
if *testnet {
chainParams = &chaincfg.TestNet3Params
}
// later...
// Create and print new payment address, specific to the active network.
pubKeyHash := make([]byte, 20)
addr, err := bchutil.NewAddressPubKeyHash(pubKeyHash, chainParams)
if err != nil {
log.Fatal(err)
}
fmt.Println(addr)
}
Installation and Updating
$ go get -u github.com/aviator-coding/bchd/chaincfg
License
Package chaincfg is licensed under the copyfree ISC License.
# Packages
Package chainhash provides abstracted hash functionality.
# Functions
HDPrivateKeyToPublicKeyID accepts a private hierarchical deterministic extended key id and returns the associated public key id.
IsCashAddressPrefix returns whether the prefix is a known prefix for the cashaddress on any default or registered network.
IsPubKeyHashAddrID returns whether the id is an identifier known to prefix a pay-to-pubkey-hash address on any default or registered network.
IsScriptHashAddrID returns whether the id is an identifier known to prefix a pay-to-script-hash address on any default or registered network.
Register registers the network parameters for a Bitcoin network.
# Constants
DefinedDeployments is the number of currently defined deployments.
DeploymentCSV defines the rule change deployment ID for the CSV soft-fork package.
DeploymentTestDummy defines the rule change deployment ID for testing purposes.
# Variables
ErrDuplicateNet describes an error where the parameters for a Bitcoin network could not be set due to the network already being a standard network or previously-registered into this package.
ErrUnknownHDKeyID describes an error where the provided id which is intended to identify the network for a hierarchical deterministic private extended key is not registered.
MainNetParams defines the network parameters for the main Bitcoin network.
RegressionNetParams defines the network parameters for the regression test Bitcoin network.
SimNetParams defines the network parameters for the simulation test Bitcoin network.
TestNet3Params defines the network parameters for the test Bitcoin network (version 3).
# Structs
Checkpoint identifies a known good point in the block chain.
ConsensusDeployment defines details related to a specific consensus rule change that is voted in.
DNSSeed identifies a DNS seed.
Params defines a Bitcoin network by its parameters.