1 // Package chaincfg defines chain configuration parameters. In addition to the main Bitcoin network, which is intended
2 // for the transfer of monetary value, there also exists two currently active standard networks: regression test and
3 // testnet (version 3). These networks are incompatible with each other (each sharing a different genesis block) and
4 // software should handle errors where input intended for one network is used on an application instance running on a
5 // different network.
6 //
7 // For library packages, chaincfg provides the ability to lookup chain parameters and encoding magics when passed a
8 // *Params. Older APIs not updated to the new convention of passing a *Params may lookup the parameters for a
9 // wire.BitcoinNet using ParamsForNet, but be aware that this usage is deprecated and will be removed from chaincfg in
10 // the future.
11 //
12 // For main packages, a (typically global) var may be assigned the address of one of the standard Param vars
13 // for use as the application's "active" network. When a network parameter is needed, it may then be looked up through
14 // this variable (either directly, or hidden in a library call).
15 //
16 // package main
17 // import (
18 // "flag"
19 // "fmt"
20 // "github.com/p9c/p9/pkg/util"
21 // "github.com/p9c/p9/pkg/chain/config"
22 // )
23 // var testnet = flag.Bool("testnet", false, "operate on the testnet Bitcoin network")
24 // // By default (without -testnet), use mainnet.
25 // var chainParams = &chaincfg.MainNetParams
26 // func main() {
27 // flag.Parse()
28 // // Modify active network parameters if operating on testnet.
29 // if *testnet {
30 // chainParams = &chaincfg.TestNet3Params
31 // }
32 // // later...
33 // // Create and print new payment address, specific to the active network.
34 // pubKeyHash := make([]byte, 20)
35 // addr, e := util.NewAddressPubKeyHash(pubKeyHash, chainParams)
36 // if e != nil {
37 // Log.Fatal <- err.Error()
38 // }
39 // fmt.Println(addr)
40 // }
41 //
42 // If an application does not use one of the three standard Bitcoin networks, a new Params struct may be created which
43 // defines the parameters for the non-standard network. As a general rule of thumb, all network parameters should be
44 // unique to the network, but parameter collisions can still occur (unfortunately, this is the case with regtest and
45 // testnet3 sharing magics).
46 package chaincfg
47