text: /*!
   * network.js - bitcoin networks for bcoin
   * Copyright (c) 2014-2015, Fedor Indutny (MIT License)
   * Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
   * https://github.com/bcoin-org/bcoin
   */
  
  'use strict';
  
  /**
   * @module protocol/networks
   */
  
  const BN = require('../crypto/bn');
  
  const network = exports;
  
  /**
   * Network type list.
   * @memberof module:protocol/networks
   * @const {String[]}
   * @default
   */
  
  network.types = ['main', 'testnet', 'regtest', 'simnet'];
  
  /**
   * Mainnet
   * @static
   * @lends module:protocol/networks
   * @type {Object}
   */
  
  const main = {};
  
  /**
   * Symbolic network type.
   * @const {String}
   * @default
   */
  
  main.type = 'main';
  
  /**
   * Default DNS seeds.
   * @const {String[]}
   * @default
   */
  
  main.seeds = [
    'seed.seeder.btc'
  ];
  
  /**
   * Packet magic number.
   * @const {Number}
   * @default
   */
  
  main.magic = 0xd9b4bef9;
  
  /**
   * Default network port.
   * @const {Number}
   * @default
   */
  
  main.port = 8333;
  
  /**
   * Checkpoint block list.
   * @const {Object}
   */
  
  main.checkpointMap = {};
  
  /**
   * Last checkpoint height.
   * @const {Number}
   * @default
   */
  
  main.lastCheckpoint = 0;
  
  /**
   * @const {Number}
   * @default
   */
  
  main.halvingInterval = 210000;
  
  /**
   * Genesis block header.
   * @const {NakedBlock}
   */
  
  main.genesis = {
    version: 1,
    hash: '6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000',
    prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
    merkleRoot:
      '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a',
    time: 1231006505,
    bits: 486604799,
    nonce: 2083236893,
    height: 0
  };
  
  /**
   * The network's genesis block in a hex string.
   * @const {String}
   */
  
  main.genesisBlock =
    '0100000000000000000000000000000000000000000000000000000000000000000000'
    + '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab'
    + '5f49ffff001d1dac2b7c01010000000100000000000000000000000000000000000000'
    + '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573'
    + '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66'
    + '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01'
    + '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f'
    + '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f'
    + 'ac00000000';
  
  /**
   * POW-related constants.
   * @enum {Number}
   * @default
   */
  
  main.pow = {
    /**
     * Default target.
     * @const {BN}
     */
  
    limit: new BN(
      '00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
      'hex'
    ),
  
    /**
     * Compact pow limit.
     * @const {Number}
     * @default
     */
  
    bits: 486604799,
  
    /**
     * Minimum chainwork for best chain.
     * @const {BN}
     */
  
    chainwork: new BN(
      '0000000000000000000000000000000000000000000000000000000000000002',
      'hex'
    ),
  
    /**
     * Desired retarget period in seconds.
     * @const {Number}
     * @default
     */
  
    targetTimespan: 14 * 24 * 60 * 60,
  
    /**
     * Average block time.
     * @const {Number}
     * @default
     */
  
    targetSpacing: 10 * 60,
  
    /**
     * Retarget interval in blocks.
     * @const {Number}
     * @default
     */
  
    retargetInterval: 2016,
  
    /**
     * Whether to reset target if a block
     * has not been mined recently.
     * @const {Boolean}
     * @default
     */
  
    targetReset: false,
  
    /**
     * Do not allow retargetting.
     * @const {Boolean}
     * @default
     */
  
    noRetargeting: false
  };
  
  /**
   * Block constants.
   * @enum {Number}
   * @default
   */
  
  main.block = {
    /**
     * Height at which bip34 was activated.
     * Used for avoiding bip30 checks.
     */
  
    bip34height: 0,
  
    /**
     * Hash of the block that activated bip34.
     */
  
    bip34hash: '6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000',
  
    /**
     * Height at which bip65 was activated.
     */
  
    bip65height: 0,
  
    /**
     * Hash of the block that activated bip65.
     */
  
    bip65hash: '6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000',
  
    /**
     * Height at which bip66 was activated.
     */
  
    bip66height: 0,
  
    /**
     * Hash of the block that activated bip66.
     */
  
    bip66hash: '6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000',
  
    /**
     * Safe height to start pruning.
     */
  
    pruneAfterHeight: 1000,
  
    /**
     * Safe number of blocks to keep.
     */
  
    keepBlocks: 288,
  
    /**
     * Age used for the time delta to
     * determine whether the chain is synced.
     */
  
    maxTipAge: 24 * 60 * 60,
  
    /**
     * Height at which block processing is
     * slow enough that we can output
     * logs without spamming.
     */
  
    slowHeight: 0
  };
  
  /**
   * Map of historical blocks which create duplicate transactions hashes.
   * @see https://github.com/bitcoin/bips/blob/master/bip-0030.mediawiki
   * @const {Object}
   * @default
   */
  
  main.bip30 = {};
  
  /**
   * For versionbits.
   * @const {Number}
   * @default
   */
  
  main.activationThreshold = 1916; // 95% of 2016
  
  /**
   * Confirmation window for versionbits.
   * @const {Number}
   * @default
   */
  
  main.minerWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
  
  /**
   * Deployments for versionbits.
   * @const {Object}
   * @default
   */
  
  main.deployments = {
    csv: {
      name: 'csv',
      bit: 0,
      startTime: 0,
      timeout: 0xffffffff,
      threshold: -1,
      window: -1,
      required: false,
      force: true
    },
    segwit: {
      name: 'segwit',
      bit: 1,
      startTime: 0,
      timeout: 0xffffffff,
      threshold: -1,
      window: -1,
      required: true,
      force: false
    },
    segsignal: {
      name: 'segsignal',
      bit: 4,
      startTime: 0xffffffff,
      timeout: 0xffffffff,
      threshold: 269, // 80%
      window: 336, // ~2.33 days
      required: false,
      force: false
    },
    testdummy: {
      name: 'testdummy',
      bit: 28,
      startTime: 0,
      timeout: 0xffffffff,
      threshold: -1,
      window: -1,
      required: false,
      force: true
    }
  };
  
  /**
   * Deployments for versionbits (array form, sorted).
   * @const {Array}
   * @default
   */
  
  main.deploys = [
    main.deployments.csv,
    main.deployments.segwit,
    main.deployments.segsignal,
    main.deployments.testdummy
  ];
  
  /**
   * Key prefixes.
   * @enum {Number}
   * @default
   */
  
  main.keyPrefix = {
    privkey: 0x80,
    xpubkey: 0x0488b21e,
    xprivkey: 0x0488ade4,
    xpubkey58: 'xpub',
    xprivkey58: 'xprv',
    coinType: 0
  };
  
  /**
   * {@link Address} prefixes.
   * @enum {Number}
   */
  
  main.addressPrefix = {
    pubkeyhash: 0x00,
    scripthash: 0x05,
    witnesspubkeyhash: 0x06,
    witnessscripthash: 0x0a,
    bech32: 'bc'
  };
  
  /**
   * Default value for whether the mempool
   * accepts non-standard transactions.
   * @const {Boolean}
   * @default
   */
  
  main.requireStandard = true;
  
  /**
   * Default http port.
   * @const {Number}
   * @default
   */
  
  main.rpcPort = 8332;
  
  /**
   * Default min relay rate.
   * @const {Rate}
   * @default
   */
  
  main.minRelay = 1000;
  
  /**
   * Default normal relay rate.
   * @const {Rate}
   * @default
   */
  
  main.feeRate = 100000;
  
  /**
   * Maximum normal relay rate.
   * @const {Rate}
   * @default
   */
  
  main.maxFeeRate = 400000;
  
  /**
   * Whether to allow self-connection.
   * @const {Boolean}
   */
  
  main.selfConnect = false;
  
  /**
   * Whether to request mempool on sync.
   * @const {Boolean}
   */
  
  main.requestMempool = false;
  
  /*
   * Testnet (v3)
   * https://en.bitcoin.it/wiki/Testnet
   */
  
  const testnet = {};
  
  testnet.type = 'testnet';
  
  testnet.seeds = [
    'seed.seeder.btc'
  ];
  
  testnet.magic = 0x0709110b;
  
  testnet.port = 18333;
  
  testnet.checkpointMap = {};
  
  testnet.lastCheckpoint = 0;
  
  testnet.halvingInterval = 210000;
  
  testnet.genesis = {
    version: 1,
    hash: '43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000',
    prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
    merkleRoot:
      '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a',
    time: 1296688602,
    bits: 486604799,
    nonce: 414098458,
    height: 0
  };
  
  testnet.genesisBlock =
    '0100000000000000000000000000000000000000000000000000000000000000000000'
    + '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5'
    + '494dffff001d1aa4ae1801010000000100000000000000000000000000000000000000'
    + '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573'
    + '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66'
    + '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01'
    + '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f'
    + '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f'
    + 'ac00000000';
  
  testnet.pow = {
    limit: new BN(
      '00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
      'hex'
    ),
    bits: 486604799,
    chainwork: new BN(
      '0000000000000000000000000000000000000000000000000000000000000002',
      'hex'
    ),
    targetTimespan: 14 * 24 * 60 * 60,
    targetSpacing: 10 * 60,
    retargetInterval: 2016,
    targetReset: true,
    noRetargeting: false
  };
  
  testnet.block = {
    bip34height: 0,
    bip34hash: '43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000',
    bip65height: 0,
    bip65hash: '43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000',
    bip66height: 0,
    bip66hash: '43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000',
    pruneAfterHeight: 1000,
    keepBlocks: 10000,
    maxTipAge: 24 * 60 * 60,
    slowHeight: 0
  };
  
  testnet.bip30 = {};
  
  testnet.activationThreshold = 1512; // 75% for testchains
  
  testnet.minerWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
  
  testnet.deployments = {
    csv: {
      name: 'csv',
      bit: 0,
      startTime: 0,
      timeout: 0xffffffff,
      threshold: -1,
      window: -1,
      required: false,
      force: true
    },
    segwit: {
      name: 'segwit',
      bit: 1,
      startTime: 0,
      timeout: 0xffffffff,
      threshold: -1,
      window: -1,
      required: true,
      force: false
    },
    segsignal: {
      name: 'segsignal',
      bit: 4,
      startTime: 0xffffffff,
      timeout: 0xffffffff,
      threshold: 269,
      window: 336,
      required: false,
      force: false
    },
    testdummy: {
      name: 'testdummy',
      bit: 28,
      startTime: 0,
      timeout: 0xffffffff,
      threshold: -1,
      window: -1,
      required: false,
      force: true
    }
  };
  
  testnet.deploys = [
    testnet.deployments.csv,
    testnet.deployments.segwit,
    testnet.deployments.segsignal,
    testnet.deployments.testdummy
  ];
  
  testnet.keyPrefix = {
    privkey: 0xef,
    xpubkey: 0x043587cf,
    xprivkey: 0x04358394,
    xpubkey58: 'tpub',
    xprivkey58: 'tprv',
    coinType: 1
  };
  
  testnet.addressPrefix = {
    pubkeyhash: 0x6f,
    scripthash: 0xc4,
    witnesspubkeyhash: 0x03,
    witnessscripthash: 0x28,
    bech32: 'tb'
  };
  
  testnet.requireStandard = false;
  
  testnet.rpcPort = 18332;
  
  testnet.minRelay = 1000;
  
  testnet.feeRate = 20000;
  
  testnet.maxFeeRate = 60000;
  
  testnet.selfConnect = false;
  
  testnet.requestMempool = false;
  
  /*
   * Regtest
   */
  
  const regtest = {};
  
  regtest.type = 'regtest';
  
  regtest.seeds = [
    '127.0.0.1'
  ];
  
  regtest.magic = 0xdab5bffa;
  
  regtest.port = 48444;
  
  regtest.checkpointMap = {};
  regtest.lastCheckpoint = 0;
  
  regtest.halvingInterval = 150;
  
  regtest.genesis = {
    version: 1,
    hash: '06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f',
    prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
    merkleRoot:
      '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a',
    time: 1296688602,
    bits: 545259519,
    nonce: 2,
    height: 0
  };
  
  regtest.genesisBlock =
    '0100000000000000000000000000000000000000000000000000000000000000000000'
    + '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5'
    + '494dffff7f200200000001010000000100000000000000000000000000000000000000'
    + '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573'
    + '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66'
    + '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01'
    + '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f'
    + '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f'
    + 'ac00000000';
  
  regtest.pow = {
    limit: new BN(
      '7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
      'hex'
    ),
    bits: 545259519,
    chainwork: new BN(
      '0000000000000000000000000000000000000000000000000000000000000002',
      'hex'
    ),
    targetTimespan: 14 * 24 * 60 * 60,
    targetSpacing: 10 * 60,
    retargetInterval: 2016,
    targetReset: true,
    noRetargeting: true
  };
  
  regtest.block = {
    bip34height: 100000000,
    bip34hash: null,
    bip65height: 1351,
    bip65hash: null,
    bip66height: 1251,
    bip66hash: null,
    pruneAfterHeight: 1000,
    keepBlocks: 10000,
    maxTipAge: 0xffffffff,
    slowHeight: 0
  };
  
  regtest.bip30 = {};
  
  regtest.activationThreshold = 108; // 75% for testchains
  
  regtest.minerWindow = 144; // Faster than normal for regtest
  
  regtest.deployments = {
    csv: {
      name: 'csv',
      bit: 0,
      startTime: 0,
      timeout: 0xffffffff,
      threshold: -1,
      window: -1,
      required: false,
      force: true
    },
    segwit: {
      name: 'segwit',
      bit: 1,
      startTime: 0,
      timeout: 0xffffffff,
      threshold: -1,
      window: -1,
      required: true,
      force: false
    },
    segsignal: {
      name: 'segsignal',
      bit: 4,
      startTime: 0xffffffff,
      timeout: 0xffffffff,
      threshold: 269,
      window: 336,
      required: false,
      force: false
    },
    testdummy: {
      name: 'testdummy',
      bit: 28,
      startTime: 0,
      timeout: 0xffffffff,
      threshold: -1,
      window: -1,
      required: false,
      force: true
    }
  };
  
  regtest.deploys = [
    regtest.deployments.csv,
    regtest.deployments.segwit,
    regtest.deployments.segsignal,
    regtest.deployments.testdummy
  ];
  
  regtest.keyPrefix = {
    privkey: 0x5a,
    xpubkey: 0xeab4fa05,
    xprivkey: 0xeab404c7,
    xpubkey58: 'rpub',
    xprivkey58: 'rprv',
    coinType: 1
  };
  
  regtest.addressPrefix = {
    pubkeyhash: 0x3c,
    scripthash: 0x26,
    witnesspubkeyhash: 0x7a,
    witnessscripthash: 0x14,
    bech32: 'rb'
  };
  
  regtest.requireStandard = false;
  
  regtest.rpcPort = 48332;
  
  regtest.minRelay = 1000;
  
  regtest.feeRate = 20000;
  
  regtest.maxFeeRate = 60000;
  
  regtest.selfConnect = true;
  
  regtest.requestMempool = true;
  
  /*
   * Simnet (btcd)
   */
  
  const simnet = {};
  
  simnet.type = 'simnet';
  
  simnet.seeds = [
    '127.0.0.1'
  ];
  
  simnet.magic = 0x12141c16;
  
  simnet.port = 18555;
  
  simnet.checkpointMap = {};
  
  simnet.lastCheckpoint = 0;
  
  simnet.halvingInterval = 210000;
  
  simnet.genesis = {
    version: 1,
    hash: 'f67ad7695d9b662a72ff3d8edbbb2de0bfa67b13974bb9910d116d5cbd863e68',
    prevBlock: '0000000000000000000000000000000000000000000000000000000000000000',
    merkleRoot:
      '3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a',
    time: 1401292357,
    bits: 545259519,
    nonce: 2,
    height: 0
  };
  
  simnet.genesisBlock =
    '0100000000000000000000000000000000000000000000000000000000000000000000'
    + '003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a4506'
    + '8653ffff7f200200000001010000000100000000000000000000000000000000000000'
    + '00000000000000000000000000ffffffff4d04ffff001d0104455468652054696d6573'
    + '2030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66'
    + '207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01'
    + '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f'
    + '61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f'
    + 'ac00000000';
  
  simnet.pow = {
    limit: new BN(
      // High target of 0x207fffff (545259519)
      '7fffff0000000000000000000000000000000000000000000000000000000000',
      'hex'
    ),
    bits: 545259519,
    chainwork: new BN(
      '0000000000000000000000000000000000000000000000000000000000000002',
      'hex'
    ),
    targetTimespan: 14 * 24 * 60 * 60,
    targetSpacing: 10 * 60,
    retargetInterval: 2016,
    targetReset: true,
    noRetargeting: false
  };
  
  simnet.block = {
    bip34height: 0,
    bip34hash: 'f67ad7695d9b662a72ff3d8edbbb2de0bfa67b13974bb9910d116d5cbd863e68',
    bip65height: 0,
    bip65hash: 'f67ad7695d9b662a72ff3d8edbbb2de0bfa67b13974bb9910d116d5cbd863e68',
    bip66height: 0,
    bip66hash: 'f67ad7695d9b662a72ff3d8edbbb2de0bfa67b13974bb9910d116d5cbd863e68',
    pruneAfterHeight: 1000,
    keepBlocks: 10000,
    maxTipAge: 0xffffffff,
    slowHeight: 0
  };
  
  simnet.bip30 = {};
  
  simnet.activationThreshold = 75; // 75% for testchains
  
  simnet.minerWindow = 100; // nPowTargetTimespan / nPowTargetSpacing
  
  simnet.deployments = {
    csv: {
      name: 'csv',
      bit: 0,
      startTime: 0, // March 1st, 2016
      timeout: 0xffffffff, // May 1st, 2017
      threshold: -1,
      window: -1,
      required: false,
      force: true
    },
    segwit: {
      name: 'segwit',
      bit: 1,
      startTime: 0, // May 1st 2016
      timeout: 0xffffffff, // May 1st 2017
      threshold: -1,
      window: -1,
      required: true,
      force: false
    },
    segsignal: {
      name: 'segsignal',
      bit: 4,
      startTime: 0xffffffff,
      timeout: 0xffffffff,
      threshold: 269,
      window: 336,
      required: false,
      force: false
    },
    testdummy: {
      name: 'testdummy',
      bit: 28,
      startTime: 1199145601, // January 1, 2008
      timeout: 1230767999, // December 31, 2008
      threshold: -1,
      window: -1,
      required: false,
      force: true
    }
  };
  
  simnet.deploys = [
    simnet.deployments.csv,
    simnet.deployments.segwit,
    simnet.deployments.segsignal,
    simnet.deployments.testdummy
  ];
  
  simnet.keyPrefix = {
    privkey: 0x64,
    xpubkey: 0x0420bd3a,
    xprivkey: 0x0420b900,
    xpubkey58: 'spub',
    xprivkey58: 'sprv',
    coinType: 115
  };
  
  simnet.addressPrefix = {
    pubkeyhash: 0x3f,
    scripthash: 0x7b,
    witnesspubkeyhash: 0x19,
    witnessscripthash: 0x28,
    bech32: 'sc'
  };
  
  simnet.requireStandard = false;
  
  simnet.rpcPort = 18556;
  
  simnet.minRelay = 1000;
  
  simnet.feeRate = 20000;
  
  simnet.maxFeeRate = 60000;
  
  simnet.selfConnect = false;
  
  simnet.requestMempool = false;
  
  /*
   * Expose
   */
  
  network.main = main;
  network.testnet = testnet;
  network.regtest = regtest;
  network.simnet = simnet;
  