package
0.23.5
Repository: https://github.com/bitweb-project/bted.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 bted, 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/bitweb-project/bted/btcutil"
	"github.com/bitweb-project/bted/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 := btcutil.NewAddressPubKeyHash(pubKeyHash, chainParams)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(addr)
}

Installation and Updating

$ go get -u github.com/bitweb-project/bted/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 bitweb-project 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.

# Functions

CustomSignetParams creates network parameters for a custom signet network from a challenge.
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.
NewMedianTimeDeploymentEnder returns a new instance of the MedianTimeDeploymentEnder anchored around the passed endTime.
NewMedianTimeDeploymentStarter returns a new instance of a MedianTimeDeploymentStarter for a given start time.
Register registers the network parameters for a Bitcoin 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.
DeploymentTaproot defines the rule change deployment ID for the Taproot (+Schnorr) soft-fork package.
DeploymentTestDummy defines the rule change deployment ID for testing purposes.
DeploymentTestDummyMinActivation defines the rule change deployment ID for testing purposes.

# Variables

These variables are the chain proof-of-work limit parameters for each default network.
DefaultSignetDNSSeeds is the list of seed nodes for the default (public, Taproot enabled) signet network.
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.
ErrInvalidHDKeyID describes an error where the provided hierarchical deterministic version bytes, or hd key id, is malformed.
ErrNoBlockClock is returned when an operation fails due to lack of synchornization with the current up to date block clock.
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.
SigNetParams defines the network parameters for the default public signet 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.
MedianTimeDeploymentEnder is a ClockConsensusDeploymentEnder that uses the median time past of a target block to determine if a deployment has ended.
MedianTimeDeploymentStarter is a ClockConsensusDeploymentStarter that uses the median time past of a target block node to determine if a deployment has started.
Params defines a Bitcoin network by its parameters.

# Interfaces

BlockClock is an abstraction over the past median time computation.
ClockConsensusDeploymentEnder is a more specialized version of the ConsensusDeploymentEnder that uses a BlockClock in order to determine if a deployment has started or not.
ClockConsensusDeploymentStarter is a more specialized version of the ConsensusDeploymentStarter that uses a BlockClock in order to determine if a deployment has started or not.
ConsensusDeploymentEnder determines if a given consensus deployment has ended.
ConsensusDeploymentStarter determines if a given consensus deployment has started.