package
0.0.0-20210318104704-f96be6a78305
Repository: https://github.com/nyodeco/pind.git
Documentation: pkg.go.dev

# README

chaincfg

Build Status ISC License GoDoc

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 pind, 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.

Sample Use

package main

import (
	"flag"
	"fmt"
	"log"

	"github.com/nyodeco/pinutil"
	"github.com/nyodeco/pind/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 := pinutil.NewAddressPubKeyHash(pubKeyHash, chainParams)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(addr)
}

Installation and Updating

$ go get -u github.com/nyodeco/pind/chaincfg

GPG Verification Key

All official release tags are signed by Conformal so users can ensure the code has not been tampered with and is coming from the btcsuite developers. To verify the signature perform the following:

  • Download the public key from the Conformal website at https://opensource.conformal.com/GIT-GPG-KEY-conformal.txt

  • Import the public key into your GPG keyring:

    gpg --import GIT-GPG-KEY-conformal.txt
    
  • Verify the release tag with the following command where TAG_NAME is a placeholder for the specific tag:

    git tag -v TAG_NAME
    

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.
IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit addresses 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 PIN network.
RegisterHDKeyID registers a public and private hierarchical deterministic extended key ID pair.

# Constants

DefinedDeployments is the number of currently defined deployments.
DeploymentCSV defines the rule change deployment ID for the CSV soft-fork package.
DeploymentSegwit defines the rule change deployment ID for the Segregated Witness (segwit) soft-fork package.
DeploymentTestDummy defines the rule change deployment ID for testing purposes.

# Variables

ErrDuplicateNet describes an error where the parameters for a PIN network could not be set due to the network already being a standard network or previously-registered into this package.
ErrInvalidHDKeyID describes an error where the provided hierarchical deterministic version bytes, or hd key id, is malformed.
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 PIN network.
RegressionNetParams defines the network parameters for the regression test PIN network.
SimNetParams defines the network parameters for the simulation test PIN network.
TestNet3Params defines the network parameters for the test PIN 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 PIN network by its parameters.