From cd4a0cc96438040beb58f7cd2fa6a8c989e97e3b Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 8 Jan 2017 22:38:41 -0800 Subject: [PATCH] network: remove segnet3 support. --- lib/blockchain/chain.js | 16 ----- lib/net/peer.js | 22 +----- lib/protocol/network.js | 1 - lib/protocol/networks.js | 148 +-------------------------------------- 4 files changed, 5 insertions(+), 182 deletions(-) diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index 0203085c..b9bdbe9b 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -454,13 +454,6 @@ Chain.prototype.getDeployments = co(function* getDeployments(block, prev) { if (block.version < 4 && height >= this.network.block.bip65height) throw new VerifyError(block, 'obsolete', 'bad-version', 0); - // Only allow version 5 blocks (bip141 - segnet3) - // once the majority of blocks are using it. - if (this.options.witness && this.network.oldWitness) { - if (block.version < 5 && height >= this.network.block.bip141height) - throw new VerifyError(block, 'obsolete', 'bad-version', 0); - } - // For some reason bitcoind has p2sh in the // mandatory flags by default, when in reality // it wasn't activated until march 30th 2012. @@ -484,15 +477,6 @@ Chain.prototype.getDeployments = co(function* getDeployments(block, prev) { if (height >= this.network.block.bip65height) state.flags |= Script.flags.VERIFY_CHECKLOCKTIMEVERIFY; - // Segregrated witness is now usable (bip141 - segnet3) - if (this.options.witness && this.network.oldWitness) { - if (height >= this.network.block.bip141height) - state.flags |= Script.flags.VERIFY_WITNESS; - } - - if (this.network.oldWitness) - return state; - // CHECKSEQUENCEVERIFY and median time // past locktimes are now usable (bip9 & bip113). active = yield this.isActive(prev, deployments.csv); diff --git a/lib/net/peer.js b/lib/net/peer.js index 6b37e96f..552a4678 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -614,14 +614,6 @@ Peer.prototype.finalize = co(function* finalize() { this.send(new packets.SendHeadersPacket()); } - // Let them know we support segwit (old - // segwit3 nodes require this instead - // of service bits). - if (this.options.witness && this.network.oldWitness) { - if (this.version.version >= 70012) - this.send(new packets.HaveWitnessPacket()); - } - // We want compact blocks! if (this.options.compact) { if (this.version.version >= 70014) @@ -1860,6 +1852,9 @@ Peer.prototype.handleVersion = co(function* handleVersion(packet) { this.version = packet; this.noRelay = packet.noRelay; + if (this.options.witness) + this.haveWitness = packet.hasWitness(); + if (!this.network.selfConnect) { if (util.equal(packet.nonce, this.pool.localNonce)) throw new Error('We connected to ourself. Oops.'); @@ -1868,17 +1863,6 @@ Peer.prototype.handleVersion = co(function* handleVersion(packet) { if (packet.version < common.MIN_VERSION) throw new Error('Peer does not support required protocol version.'); - if (this.options.witness) { - this.haveWitness = packet.hasWitness(); - if (!this.haveWitness && this.network.oldWitness) { - try { - yield this.wait(packetTypes.HAVEWITNESS, 10000); - } catch (err) { - ; - } - } - } - if (this.outbound) { if (!packet.hasNetwork()) throw new Error('Peer does not support network services.'); diff --git a/lib/protocol/network.js b/lib/protocol/network.js index a2130934..02e150d0 100644 --- a/lib/protocol/network.js +++ b/lib/protocol/network.js @@ -39,7 +39,6 @@ function Network(options) { this.block = options.block; this.bip30 = options.bip30; this.witness = options.witness; - this.oldWitness = options.oldWitness; this.activationThreshold = options.activationThreshold; this.minerWindow = options.minerWindow; this.deployments = options.deployments; diff --git a/lib/protocol/networks.js b/lib/protocol/networks.js index 1576434a..6aec2e4a 100644 --- a/lib/protocol/networks.js +++ b/lib/protocol/networks.js @@ -14,7 +14,7 @@ var BN = require('bn.js'); */ var network = exports; -var main, testnet, regtest, segnet3, segnet4, simnet; +var main, testnet, regtest, segnet4, simnet; /** * Network type list. @@ -23,7 +23,7 @@ var main, testnet, regtest, segnet3, segnet4, simnet; * @default */ -network.types = ['main', 'testnet', 'regtest', 'segnet3', 'segnet4', 'simnet']; +network.types = ['main', 'testnet', 'regtest', 'segnet4', 'simnet']; /** * Main @@ -313,14 +313,6 @@ main.bip30 = { main.witness = true; -/** - * Whether to use segnet3-style segwit. - * @const {Boolean} - * @default - */ - -main.oldWitness = false; - /** * For versionbits. * @const {Number} @@ -584,8 +576,6 @@ testnet.bip30 = {}; testnet.witness = true; -testnet.oldWitness = false; - testnet.activationThreshold = 1512; // 75% for testchains testnet.minerWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing @@ -744,8 +734,6 @@ regtest.bip30 = {}; regtest.witness = false; -regtest.oldWitness = false; - regtest.activationThreshold = 108; // 75% for testchains regtest.minerWindow = 144; // Faster than normal for regtest (144 instead of 2016) @@ -822,134 +810,6 @@ regtest.batchSize = [ [500] ]; -/* - * segnet3 - */ - -segnet3 = network.segnet3 = {}; - -segnet3.type = 'segnet3'; - -segnet3.seeds = [ - '104.243.38.34', - '104.155.1.158', - '119.246.245.241', - '46.101.235.82' -]; - -segnet3.magic = 0xcaea962e; - -segnet3.port = 28333; - -segnet3.alertKey = new Buffer( - '0300000000000000000000003b78ce563f89a0ed9414f5aa28ad0d96d6795f9c63', - 'hex'); - -segnet3.checkpoints = {}; -segnet3.checkpoints.lastHeight = 0; - -segnet3.halvingInterval = 210000; - -segnet3.genesis = { - version: 1, - hash: 'aa022fd26404d3a1f6ac348fc049996a52f40d833017c7ca3f05df8d519c5b0d', - prevBlock: '0000000000000000000000000000000000000000000000000000000000000000', - merkleRoot: '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a', - ts: 1452831101, - bits: 486604799, - nonce: 0, - height: 0 -}; - -segnet3.genesisBlock = - '0100000000000000000000000000000000000000000000000000000000000000000000' - + '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a7d71' - + '9856ffff001d0000000001010000000100000000000000000000000000000000000000' - + '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573' - + '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66' - + '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01' - + '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f' - + '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f' - + 'ac00000000'; - -segnet3.pow = { - limit: new BN( - '00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff', - 'hex' - ), - bits: 486604799, - targetTimespan: 14 * 24 * 60 * 60, // two weeks - targetSpacing: 10 * 60, - retargetInterval: 2016, - difficultyReset: true, - noRetargeting: false -}; - -segnet3.block = { - bip34height: 8, - bip34hash: '1c2a2898cebca152f872fa71b756903711ad778c7d63ba6b73c140f800000000', - bip65height: 8, - bip65hash: '1c2a2898cebca152f872fa71b756903711ad778c7d63ba6b73c140f800000000', - bip66height: 8, - bip66hash: '1c2a2898cebca152f872fa71b756903711ad778c7d63ba6b73c140f800000000', - bip141height: 8, - bip141hash: '1c2a2898cebca152f872fa71b756903711ad778c7d63ba6b73c140f800000000', - pruneAfterHeight: 1000, - keepBlocks: 10000, - // maxTipAge: 0x7fffffff, - maxTipAge: 24 * 60 * 60, - slowHeight: 0x7fffffff -}; - -segnet3.bip30 = {}; - -segnet3.witness = true; - -segnet3.oldWitness = true; - -segnet3.activationThreshold = 108; - -segnet3.minerWindow = 144; - -segnet3.deployments = {}; - -segnet3.deploys = []; - -segnet3.keyPrefix = { - privkey: 0x9e, - xpubkey: 0x053587cf, - xprivkey: 0x05358394, - xprivkey58: '2791', - xpubkey58: '2793', - coinType: 1 -}; - -segnet3.addressPrefix = { - pubkeyhash: 0x1e, - scripthash: 0x32, - witnesspubkeyhash: 0x03, - witnessscripthash: 0x28 -}; - -segnet3.requireStandard = false; - -segnet3.rpcPort = 28332; - -segnet3.minRelay = 1000; - -segnet3.feeRate = 20000; - -segnet3.maxFeeRate = 60000; - -segnet3.selfConnect = false; - -segnet3.requestMempool = true; - -segnet3.batchSize = [ - [20000, 500], - [250] -]; - /* * segnet4 */ @@ -1030,8 +890,6 @@ segnet4.bip30 = {}; segnet4.witness = true; -segnet4.oldWitness = false; - segnet4.activationThreshold = 108; segnet4.minerWindow = 144; @@ -1183,8 +1041,6 @@ simnet.bip30 = {}; simnet.witness = false; -simnet.oldWitness = false; - simnet.activationThreshold = 1512; // 75% for testchains simnet.minerWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing