# README
chaincfg
Package chaincfg defines chain configuration parameters for the three standard Parallelcoin networks and provides the ability for callers to define their own custom networks.
Although this package was primarily written for pod, 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/p9c/pod/pkg/chain/config/netparams"
"git.parallelcoin.io/util"
"github.com/p9c/pod/pkg/chain/config"
)
var testnet = flag.Bool("testnet", false, "operate on the testnet Bitcoin network")
// By default (without -testnet), use mainnet.
var chainParams = &netparams.MainNetParams
func main() {
flag.Parse()
// Modify active network parameters if operating on testnet.
if *testnet {
chainParams = &netparams.TestNet3Params
}
// later...
// Create and print new payment address, specific to the active network.
pubKeyHash := make([]byte, 20)
addr, e := util.NewAddressPubKeyHash(pubKeyHash, chainParams)
if e != nil {
L. }
log.Println(addr)
}
Installation and Updating
$ go get -u github.com/p9c/pod/chaincfg
License
Package chaincfg is licensed under the copyfree ISC License.
# Functions
BigToCompact converts a whole number N to a compact representation using an unsigned 32-bit number.
CompactToBig converts a compact representation of a whole number N to an unsigned 32-bit number.
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 Bitcoin network.
# Variables
AveragingInterval is the number of blocks to average (per algorithm).
AveragingTargetTimespan is how many seconds for the averaging target interval.
No description provided by the author
No description provided by the author
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.
No description provided by the author
No description provided by the author
Interval is the number of blocks in the averaging window.
MainNetParams defines the network parameters for the main Bitcoin network.
MainPowLimit is the pre-hardfork pow limit.
MainPowLimitBits is the bits version of the above.
MaxAdjustDown is the percentage hard limit for downwards difficulty adjustment (ie 90%).
MaxAdjustUp is the percentage hard limit for upwards (ie 120%).
RegressionTestParams defines the network parameters for the regression test Bitcoin network.
ScryptPowLimit is the pre-hardfork maximum hash for Scrypt algorithm.
ScryptPowLimitBits is the bits version of the above.
SimNetParams defines the network parameters for the simulation test Bitcoin network.
No description provided by the author
TargetTimePerBlock is the pre hardfork target time for blocks.
TargetTimespan is the base for adjustment.
TestNet3Params defines the network parameters for the test Bitcoin network (version 3).
TestnetAveragingInterval is the number of blocks to average (per algorithm).
TestnetAveragingTargetTimespan is how many seconds for the averaging target interval.
TestnetInterval is the number of blocks in the averaging window.
TestnetMaxAdjustDown is the percentage hard limit for downwards difficulty adjustment (ie 90%).
TestnetMaxAdjustUp is the percentage hard limit for upwards (ie 120%).
TestnetTargetTimePerBlock is the pre hardfork target time for blocks.
TestnetTargetTimespan is the base for adjustment.
No description provided by the author
# Structs
Checkpoint identifies a known good point in the block chain.
DNSSeed identifies a DNS seed.
Params defines a Bitcoin network by its parameters.