/ vendor / github.com / btcsuite / btcd / params.go
params.go
 1  // Copyright (c) 2013-2016 The btcsuite developers
 2  // Use of this source code is governed by an ISC
 3  // license that can be found in the LICENSE file.
 4  
 5  package main
 6  
 7  import (
 8  	"github.com/btcsuite/btcd/chaincfg"
 9  	"github.com/btcsuite/btcd/wire"
10  )
11  
12  // activeNetParams is a pointer to the parameters specific to the
13  // currently active bitcoin network.
14  var activeNetParams = &mainNetParams
15  
16  // params is used to group parameters for various networks such as the main
17  // network and test networks.
18  type params struct {
19  	*chaincfg.Params
20  	rpcPort string
21  }
22  
23  // mainNetParams contains parameters specific to the main network
24  // (wire.MainNet).  NOTE: The RPC port is intentionally different than the
25  // reference implementation because btcd does not handle wallet requests.  The
26  // separate wallet process listens on the well-known port and forwards requests
27  // it does not handle on to btcd.  This approach allows the wallet process
28  // to emulate the full reference implementation RPC API.
29  var mainNetParams = params{
30  	Params:  &chaincfg.MainNetParams,
31  	rpcPort: "8334",
32  }
33  
34  // regressionNetParams contains parameters specific to the regression test
35  // network (wire.TestNet).  NOTE: The RPC port is intentionally different
36  // than the reference implementation - see the mainNetParams comment for
37  // details.
38  var regressionNetParams = params{
39  	Params:  &chaincfg.RegressionNetParams,
40  	rpcPort: "18334",
41  }
42  
43  // testNet3Params contains parameters specific to the test network (version 3)
44  // (wire.TestNet3).  NOTE: The RPC port is intentionally different than the
45  // reference implementation - see the mainNetParams comment for details.
46  var testNet3Params = params{
47  	Params:  &chaincfg.TestNet3Params,
48  	rpcPort: "18334",
49  }
50  
51  // simNetParams contains parameters specific to the simulation test network
52  // (wire.SimNet).
53  var simNetParams = params{
54  	Params:  &chaincfg.SimNetParams,
55  	rpcPort: "18556",
56  }
57  
58  // netName returns the name used when referring to a bitcoin network.  At the
59  // time of writing, btcd currently places blocks for testnet version 3 in the
60  // data and log directory "testnet", which does not match the Name field of the
61  // chaincfg parameters.  This function can be used to override this directory
62  // name as "testnet" when the passed active network matches wire.TestNet3.
63  //
64  // A proper upgrade to move the data and log directories for this network to
65  // "testnet3" is planned for the future, at which point this function can be
66  // removed and the network parameter's name used instead.
67  func netName(chainParams *params) string {
68  	switch chainParams.Net {
69  	case wire.TestNet3:
70  		return "testnet"
71  	default:
72  		return chainParams.Name
73  	}
74  }