Track Bitcoin versionbits deployments (BIP9)
npm install versionbits
// import versionbits parameters for Bitcoinvar params = versionbitsvar VersionBits =var vbits = params db // db is a LevelUp instance// `chain` is a Blockchain instance from the `blockchain-spv` modulechain
BIP9 is a specification that allows Bitcoin miners to use the
version field in blocks as a bitfield in order to specify which soft-fork changes they support. Once a certain number of blocks have a certain bit set, the soft-fork change is activated and the new rules come into effect. This module checks the status of these soft-fork deployments.
var vbits = new VersionBits(params, db)
VersionBits instance which keeps track of the state of each versionbits deployment.
params should be the versionbits parameters for the blockchain you wish to use. Parameters for Bitcoin are available at
require('webcoin-bitcoin').versionbits. For more info about params you can use, see the Parameters section.
db should be a
LevelUp instance where state data will be stored. The db should not be shared.
Returns the state of the deployment with the given
Returns an array of all deployments currently being tracked.
cb with the hash of the most recently processed block. Use this to figure out which block to start streaming from when piping blocks from a
Emitted when the status of a deployment changes (e.g. when a deployment goes from
Emitted whenever the state of a deployment changes (e.g. when the bit count is incremented).
Emitted when an error occurs.
Parameters specify known versionbits deployments. Parameters should contain the following:
// number of blocks for the confirmation period// usually the same as the retarget period (in Bitcoin it is 2016)confirmationWindow: Number// number of blocks in the period that must set the bit for a deployment// to make it "lock in"activationThreshold: Number// an array of deployments to trackdeployments:bit: 0name: 'csv'start: 1462060800timeout: 1493596800
For some examples, see these parameter repos: