Skip to content

Commit d9a8a2f

Browse files
committed
Add chipnet support
1 parent d6c1f09 commit d9a8a2f

4 files changed

Lines changed: 108 additions & 3 deletions

File tree

chaincfg/params.go

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ type Params struct {
138138
BIP0065Height int32
139139
BIP0066Height int32
140140

141-
// Only testnet4 uses CSV activation by height. All the others use the
141+
// Only testnet4 and chipnet uses CSV activation by height. All the others use the
142142
// deployment schedule. If this value is set to anything other than zero
143143
// then it will activate at this height.
144144
CSVHeight int32
@@ -262,7 +262,7 @@ var MainNetParams = Params{
262262
Name: "mainnet",
263263
Net: wire.MainNet,
264264
DefaultPort: "8333",
265-
DNSSeeds: []DNSSeed{
265+
DNSSeeds: []DNSSeed{ // TODO change this to proper dns seed
266266
{"seed.bchd.cash", true},
267267
{"btccash-seeder.bitcoinunlimited.info", true},
268268
{"seed.bch.loping.net", true},
@@ -623,6 +623,94 @@ var TestNet3Params = Params{
623623
SlpAddressPrefix: "slptest",
624624
}
625625

626+
var ChipNetParams = Params{
627+
Name: "chipnet",
628+
Net: wire.ChipNet,
629+
DefaultPort: "48333",
630+
DNSSeeds: []DNSSeed{
631+
{"chipnet.bitjson.com", true},
632+
},
633+
634+
// Chain parameters
635+
GenesisBlock: &testNet4GenesisBlock, // Same value as testnet4
636+
GenesisHash: &testNet4GenesisHash, // Same value as testnet4
637+
PowLimit: testNet3PowLimit, // Same value as testnet3
638+
PowLimitBits: 0x1d00ffff,
639+
BIP0034Height: 2,
640+
BIP0065Height: 3,
641+
BIP0066Height: 4,
642+
CSVHeight: 5,
643+
644+
UahfForkHeight: 5,
645+
DaaForkHeight: 3000,
646+
MagneticAnonomalyForkHeight: 3999,
647+
GreatWallForkHeight: 0,
648+
GravitonForkHeight: 4999,
649+
PhononForkHeight: 0,
650+
AxionActivationHeight: 16844,
651+
652+
CosmicInflationActivationTime: 1637694000,
653+
654+
CoinbaseMaturity: 100,
655+
SubsidyReductionInterval: 210000,
656+
TargetTimespan: time.Hour * 24 * 14, // 14 days
657+
TargetTimePerBlock: time.Minute * 10, // 10 minutes
658+
RetargetAdjustmentFactor: 4, // 25% less, 400% more
659+
ReduceMinDifficulty: true,
660+
NoDifficultyAdjustment: false,
661+
MinDiffReductionTime: time.Minute * 20, // TargetTimePerBlock * 2
662+
AsertDifficultyHalflife: 3600, // 1 hour
663+
AsertDifficultyAnchorHeight: 16844,
664+
AsertDifficultyAnchorParentTimestamp: 1605451779,
665+
AsertDifficultyAnchorBits: 0x1d00ffff,
666+
GenerateSupported: false,
667+
668+
// Checkpoints ordered from oldest to newest.
669+
Checkpoints: []Checkpoint{},
670+
671+
// Consensus rule change deployments.
672+
//
673+
// The miner confirmation window is defined as:
674+
// target proof of work timespan / target proof of work spacing
675+
RuleChangeActivationThreshold: 1512, // 75% of MinerConfirmationWindow
676+
MinerConfirmationWindow: 2016,
677+
Deployments: [DefinedDeployments]ConsensusDeployment{
678+
DeploymentTestDummy: {
679+
BitNumber: 28,
680+
StartTime: 1199145601, // January 1, 2008 UTC
681+
ExpireTime: 1230767999, // December 31, 2008 UTC
682+
},
683+
DeploymentCSV: {
684+
BitNumber: 0,
685+
StartTime: 1456790400, // March 1st, 2016
686+
ExpireTime: 1493596800, // May 1st, 2017
687+
},
688+
},
689+
690+
// Mempool parameters
691+
RelayNonStdTxs: false,
692+
693+
// The prefix for the cashaddress
694+
CashAddressPrefix: "bchtest", // always bchtest for testnet
695+
696+
// Address encoding magics
697+
LegacyPubKeyHashAddrID: 0x6f, // starts with m or n
698+
LegacyScriptHashAddrID: 0xc4, // starts with 2
699+
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
700+
701+
// BIP32 hierarchical deterministic extended key magics
702+
HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with tprv
703+
HDPublicKeyID: [4]byte{0x04, 0x35, 0x87, 0xcf}, // starts with tpub
704+
705+
// BIP44 coin type used in the hierarchical deterministic path for
706+
// address generation.
707+
HDCoinType: 1, // all coins use 1
708+
709+
// slp indexer parameters
710+
SlpIndexStartHeight: 0,
711+
SlpAddressPrefix: "slptest",
712+
}
713+
626714
// TestNet4Params defines the network parameters for the test Bitcoin network
627715
// (version 4). Not to be confused with the regression test network, this
628716
// network is sometimes simply called "testnet".

config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ type config struct {
156156
TorIsolation bool `long:"torisolation" description:"Enable Tor stream isolation by randomizing user credentials for each connection."`
157157
TestNet3 bool `long:"testnet" description:"Use the test network"`
158158
TestNet4 bool `long:"testnet4" description:"Use the test 4 network"`
159+
ChipNet bool `long:"chipnet" description:"Use the chip network"`
159160
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
160161
RegressionTestAnyHost bool `long:"regtestanyhost" description:"In regression test mode, allow connections from any host, not just localhost"`
161162
RegressionTestNoReset bool `long:"regtestnoreset" description:"In regression test mode, don't reset the network db on node restart"`
@@ -595,6 +596,10 @@ func loadConfig() (*config, []string, error) {
595596
numNets++
596597
activeNetParams = &testNet4Params
597598
}
599+
if cfg.ChipNet {
600+
numNets++
601+
activeNetParams = &chipNetParams
602+
}
598603
if cfg.RegressionTest {
599604
numNets++
600605
activeNetParams = &regressionNetParams
@@ -606,7 +611,7 @@ func loadConfig() (*config, []string, error) {
606611
cfg.DisableDNSSeed = true
607612
}
608613
if numNets > 1 {
609-
str := "%s: The testnet, regtest, segnet, and simnet params " +
614+
str := "%s: The testnet, chipnet, regtest, segnet, and simnet params " +
610615
"can't be used together -- choose one of the four"
611616
err := fmt.Errorf(str, funcName)
612617
fmt.Fprintln(os.Stderr, err)

params.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ var testNet4Params = params{
6161
gRRPPort: "18335",
6262
}
6363

64+
// chipNetParams contains parameters specific to the chip network
65+
// (wire.ChipNet). NOTE: The RPC port is intentionally different than the
66+
// reference implementation - see the mainNetParams comment for details.
67+
var chipNetParams = params{
68+
Params: &chaincfg.ChipNetParams,
69+
rpcPort: "18334",
70+
gRRPPort: "18335",
71+
}
72+
6473
// simNetParams contains parameters specific to the simulation test network
6574
// (wire.SimNet).
6675
var simNetParams = params{

wire/protocol.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ const (
188188
// TestNet4 represents the test network (version 4).
189189
TestNet4 BitcoinNet = 0xafdab7e2
190190

191+
// ChipNet represents the chip network.
192+
ChipNet BitcoinNet = 0xafdab7e2
193+
191194
// SimNet represents the simulation test network.
192195
SimNet BitcoinNet = 0x12141c16
193196
)

0 commit comments

Comments
 (0)