chaincfg+integration: add BIP0009 deployment parameters for segwit

This commit adds set of BIP0009 (Version Bits) deployment parameters
for all networks detailing the activation parameters for the segwit
soft-fork.

Additionally, the BIP0009 integration test has been updated to test for
the proper transitioning of version bits state for the segwit soft
fork. Finally, the `getblockchaininfo` test has also been updated to
properly display the state of segwit.
This commit is contained in:
Olaoluwa Osuntokun 2017-01-03 21:06:34 -08:00 committed by Dave Collins
parent 1244c45b88
commit b1893ed228
3 changed files with 31 additions and 0 deletions

View file

@ -91,6 +91,11 @@ const (
// 68, 112, and 113.
DeploymentCSV
// DeploymentSegwit defines the rule change deployment ID for the
// Segragated Witness (segwit) soft-fork package. The segwit package
// includes the deployment of BIPS 141, 142, 144, 145, 147 and 173.
DeploymentSegwit
// NOTE: DefinedDeployments must always come last since it is used to
// determine how many defined deployments there currently are.
@ -286,6 +291,11 @@ var MainNetParams = Params{
StartTime: 1462060800, // May 1st, 2016
ExpireTime: 1493596800, // May 1st, 2017
},
DeploymentSegwit: {
BitNumber: 1,
StartTime: 1479168000, // November 15, 2016 UTC
ExpireTime: 1510704000, // November 15, 2017 UTC.
},
},
// Mempool parameters
@ -357,6 +367,11 @@ var RegressionNetParams = Params{
StartTime: 0, // Always available for vote
ExpireTime: math.MaxInt64, // Never expires
},
DeploymentSegwit: {
BitNumber: 1,
StartTime: 0, // Always available for vote
ExpireTime: math.MaxInt64, // Never expires.
},
},
// Mempool parameters
@ -443,6 +458,11 @@ var TestNet3Params = Params{
StartTime: 1456790400, // March 1st, 2016
ExpireTime: 1493596800, // May 1st, 2017
},
DeploymentSegwit: {
BitNumber: 1,
StartTime: 1462060800, // May 1, 2016 UTC
ExpireTime: 1493596800, // May 1, 2017 UTC.
},
},
// Mempool parameters
@ -518,6 +538,11 @@ var SimNetParams = Params{
StartTime: 0, // Always available for vote
ExpireTime: math.MaxInt64, // Never expires
},
DeploymentSegwit: {
BitNumber: 1,
StartTime: 0, // Always available for vote
ExpireTime: math.MaxInt64, // Never expires.
},
},
// Mempool parameters

View file

@ -299,6 +299,7 @@ func TestBIP0009(t *testing.T) {
t.Parallel()
testBIP0009(t, "dummy", chaincfg.DeploymentTestDummy)
testBIP0009(t, "segwit", chaincfg.DeploymentSegwit)
}
// TestBIP0009Mining ensures blocks built via btcd's CPU miner follow the rules

View file

@ -1207,8 +1207,13 @@ func handleGetBlockChainInfo(s *rpcServer, cmd interface{}, closeChan <-chan str
switch deployment {
case chaincfg.DeploymentTestDummy:
forkName = "dummy"
case chaincfg.DeploymentCSV:
forkName = "csv"
case chaincfg.DeploymentSegwit:
forkName = "segwit"
default:
return nil, &btcjson.RPCError{
Code: btcjson.ErrRPCInternal.Code,