返回比特币网络上完整节点IP地址的DNS服务器,用于协助发现节点。
我们在bitcoinj
库中,params
文件夹内为网络相关的配置文件
打开文件MainNetParams
,查看文件内容
/*
* Copyright 2013 Google Inc.
* Copyright 2015 Andreas Schildbach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.params;
import org.bitcoinj.core.*;
import org.bitcoinj.net.discovery.*;
import java.net.*;
import static com.google.common.base.Preconditions.*;
/**
* Parameters for the main production network on which people trade goods and services.
*/
public class MainNetParams extends AbstractBitcoinNetParams {
public static final int MAINNET_MAJORITY_WINDOW = 1000;
public static final int MAINNET_MAJORITY_REJECT_BLOCK_OUTDATED = 950;
public static final int MAINNET_MAJORITY_ENFORCE_BLOCK_UPGRADE = 750;
public MainNetParams() {
super();
interval = INTERVAL;
targetTimespan = TARGET_TIMESPAN;
maxTarget = Utils.decodeCompactBits(0x1d00ffffL);
dumpedPrivateKeyHeader = 128;
addressHeader = 0;
p2shHeader = 5;
acceptableAddressCodes = new int[] { addressHeader, p2shHeader };
port = 8333;
packetMagic = 0xf9beb4d9L;
bip32HeaderPub = 0x0488B21E; //The 4 byte header that serializes in base58 to "xpub".
bip32HeaderPriv = 0x0488ADE4; //The 4 byte header that serializes in base58 to "xprv"
majorityEnforceBlockUpgrade = MAINNET_MAJORITY_ENFORCE_BLOCK_UPGRADE;
majorityRejectBlockOutdated = MAINNET_MAJORITY_REJECT_BLOCK_OUTDATED;
majorityWindow = MAINNET_MAJORITY_WINDOW;
genesisBlock.setDifficultyTarget(0x1d00ffffL);
genesisBlock.setTime(1231006505L);
genesisBlock.setNonce(2083236893);
id = ID_MAINNET;
subsidyDecreaseBlockCount = 210000;
spendableCoinbaseDepth = 100;
String genesisHash = genesisBlock.getHashAsString();
checkState(genesisHash.equals("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"),
genesisHash);
// This contains (at a minimum) the blocks which are not BIP30 compliant. BIP30 changed how duplicate
// transactions are handled. Duplicated transactions could occur in the case where a coinbase had the same
// extraNonce and the same outputs but appeared at different heights, and greatly complicated re-org handling.
// Having these here simplifies block connection logic considerably.
checkpoints.put(91722, Sha256Hash.wrap("00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e"));
checkpoints.put(91812, Sha256Hash.wrap("00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f"));
checkpoints.put(91842, Sha256Hash.wrap("00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec"));
checkpoints.put(91880, Sha256Hash.wrap("00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"));
checkpoints.put(200000, Sha256Hash.wrap("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf"));
dnsSeeds = new String[] {
"seed.bitcoin.sipa.be", // Pieter Wuille
"dnsseed.bluematt.me", // Matt Corallo
"dnsseed.bitcoin.dashjr.org", // Luke Dashjr
"seed.bitcoinstats.com", // Chris Decker
"seed.bitnodes.io", // Addy Yeow
"bitseed.xf2.org", // Jeff Garzik
"seed.bitcoin.jonasschnelli.ch",// Jonas Schnelli
"bitcoin.bloqseeds.net", // Bloq
};
httpSeeds = new HttpDiscovery.Details[] {
// Andreas Schildbach
new HttpDiscovery.Details(
ECKey.fromPublicOnly(Utils.HEX.decode("0238746c59d46d5408bf8b1d0af5740fe1a6e1703fcb56b2953f0b965c740d256f")),
URI.create("http://httpseed.bitcoin.schildbach.de/peers")
)
};
addrSeeds = new int[] {
0x1ddb1032, 0x6242ce40, 0x52d6a445, 0x2dd7a445, 0x8a53cd47, 0x73263750, 0xda23c257, 0xecd4ed57,
0x0a40ec59, 0x75dce160, 0x7df76791, 0x89370bad, 0xa4f214ad, 0x767700ae, 0x638b0418, 0x868a1018,
0xcd9f332e, 0x0129653e, 0xcc92dc3e, 0x96671640, 0x56487e40, 0x5b66f440, 0xb1d01f41, 0xf1dc6041,
0xc1d12b42, 0x86ba1243, 0x6be4df43, 0x6d4cef43, 0xd18e0644, 0x1ab0b344, 0x6584a345, 0xe7c1a445,
0x58cea445, 0xc5daa445, 0x21dda445, 0x3d3b5346, 0x13e55347, 0x1080d24a, 0x8e611e4b, 0x81518e4b,
0x6c839e4b, 0xe2ad0a4c, 0xfbbc0a4c, 0x7f5b6e4c, 0x7244224e, 0x1300554e, 0x20690652, 0x5a48b652,
0x75c5c752, 0x4335cc54, 0x340fd154, 0x87c07455, 0x087b2b56, 0x8a133a57, 0xac23c257, 0x70374959,
0xfb63d45b, 0xb9a1685c, 0x180d765c, 0x674f645d, 0x04d3495e, 0x1de44b5e, 0x4ee8a362, 0x0ded1b63,
0xc1b04b6d, 0x8d921581, 0x97b7ea82, 0x1cf83a8e, 0x91490bad, 0x09dc75ae, 0x9a6d79ae, 0xa26d79ae,
0x0fd08fae, 0x0f3e3fb2, 0x4f944fb2, 0xcca448b8, 0x3ecd6ab8, 0xa9d5a5bc, 0x8d0119c1, 0x045997d5,
0xca019dd9, 0x0d526c4d, 0xabf1ba44, 0x66b1ab55, 0x1165f462, 0x3ed7cbad, 0xa38fae6e, 0x3bd2cbad,
0xd36f0547, 0x20df7840, 0x7a337742, 0x549f8e4b, 0x9062365c, 0xd399f562, 0x2b5274a1, 0x8edfa153,
0x3bffb347, 0x7074bf58, 0xb74fcbad, 0x5b5a795b, 0x02fa29ce, 0x5a6738d4, 0xe8a1d23e, 0xef98c445,
0x4b0f494c, 0xa2bc1e56, 0x7694ad63, 0xa4a800c3, 0x05fda6cd, 0x9f22175e, 0x364a795b, 0x536285d5,
0xac44c9d4, 0x0b06254d, 0x150c2fd4, 0x32a50dcc, 0xfd79ce48, 0xf15cfa53, 0x66c01e60, 0x6bc26661,
0xc03b47ae, 0x4dda1b81, 0x3285a4c1, 0x883ca96d, 0x35d60a4c, 0xdae09744, 0x2e314d61, 0x84e247cf,
0x6c814552, 0x3a1cc658, 0x98d8f382, 0xe584cb5b, 0x15e86057, 0x7b01504e, 0xd852dd48, 0x56382f56,
0x0a5df454, 0xa0d18d18, 0x2e89b148, 0xa79c114c, 0xcbdcd054, 0x5523bc43, 0xa9832640, 0x8a066144,
0x3894c3bc, 0xab76bf58, 0x6a018ac1, 0xfebf4f43, 0x2f26c658, 0x31102f4e, 0x85e929d5, 0x2a1c175e,
0xfc6c2cd1, 0x27b04b6d, 0xdf024650, 0x161748b8, 0x28be6580, 0x57be6580, 0x1cee677a, 0xaa6bb742,
0x9a53964b, 0x0a5a2d4d, 0x2434c658, 0x9a494f57, 0x1ebb0e48, 0xf610b85d, 0x077ecf44, 0x085128bc,
0x5ba17a18, 0x27ca1b42, 0xf8a00b56, 0xfcd4c257, 0xcf2fc15e, 0xd897e052, 0x4cada04f, 0x2f35f6d5,
0x382ce8c9, 0xe523984b, 0x3f946846, 0x60c8be43, 0x41da6257, 0xde0be142, 0xae8a544b, 0xeff0c254,
0x1e0f795b, 0xaeb28890, 0xca16acd9, 0x1e47ddd8, 0x8c8c4829, 0xd27dc747, 0xd53b1663, 0x4096b163,
0x9c8dd958, 0xcb12f860, 0x9e79305c, 0x40c1a445, 0x4a90c2bc, 0x2c3a464d, 0x2727f23c, 0x30b04b6d,
0x59024cb8, 0xa091e6ad, 0x31b04b6d, 0xc29d46a6, 0x63934fb2, 0xd9224dbe, 0x9f5910d8, 0x7f530a6b,
0x752e9c95, 0x65453548, 0xa484be46, 0xce5a1b59, 0x710e0718, 0x46a13d18, 0xdaaf5318, 0xc4a8ff53,
0x87abaa52, 0xb764cf51, 0xb2025d4a, 0x6d351e41, 0xc035c33e, 0xa432c162, 0x61ef34ae, 0xd16fddbc,
0x0870e8c1, 0x3070e8c1, 0x9c71e8c1, 0xa4992363, 0x85a1f663, 0x4184e559, 0x18d96ed8, 0x17b8dbd5,
0x60e7cd18, 0xe5ee104c, 0xab17ac62, 0x1e786e1b, 0x5d23b762, 0xf2388fae, 0x88270360, 0x9e5b3d80,
0x7da518b2, 0xb5613b45, 0x1ad41f3e, 0xd550854a, 0x8617e9a9, 0x925b229c, 0xf2e92542, 0x47af0544,
0x73b5a843, 0xb9b7a0ad, 0x03a748d0, 0x0a6ff862, 0x6694df62, 0x3bfac948, 0x8e098f4f, 0x746916c3,
0x02f38e4f, 0x40bb1243, 0x6a54d162, 0x6008414b, 0xa513794c, 0x514aa343, 0x63781747, 0xdbb6795b,
0xed065058, 0x42d24b46, 0x1518794c, 0x9b271681, 0x73e4ffad, 0x0654784f, 0x438dc945, 0x641846a6,
0x2d1b0944, 0x94b59148, 0x8d369558, 0xa5a97662, 0x8b705b42, 0xce9204ae, 0x8d584450, 0x2df61555,
0xeebff943, 0x2e75fb4d, 0x3ef8fc57, 0x9921135e, 0x8e31042e, 0xb5afad43, 0x89ecedd1, 0x9cfcc047,
0x8fcd0f4c, 0xbe49f5ad, 0x146a8d45, 0x98669ab8, 0x98d9175e, 0xd1a8e46d, 0x839a3ab8, 0x40a0016c,
0x6d27c257, 0x977fffad, 0x7baa5d5d, 0x1213be43, 0xb167e5a9, 0x640fe8ca, 0xbc9ea655, 0x0f820a4c,
0x0f097059, 0x69ac957c, 0x366d8453, 0xb1ba2844, 0x8857f081, 0x70b5be63, 0xc545454b, 0xaf36ded1,
0xb5a4b052, 0x21f062d1, 0x72ab89b2, 0x74a45318, 0x8312e6bc, 0xb916965f, 0x8aa7c858, 0xfe7effad,
};
}
private static MainNetParams instance;
public static synchronized MainNetParams get() {
if (instance == null) {
instance = new MainNetParams();
}
return instance;
}
@Override
public String getPaymentProtocolId() {
return PAYMENT_PROTOCOL_ID_MAINNET;
}
}
我们能看到三种seed
这三种,都可以得到比特币的节点列表,本文主要讲第一种。
这里需要用到一个开源项目,项目地址
https://github.com/sipa/bitcoin-seeder
下面开始进行具体操作。
我们用的dns是seed.bitcoin.sipa.be
xiaoyu@xiaoyu-Parallels-Virtual-Platform:~/bitcoin-seeder$ dig -t NS testnet-seed.bitcoin.jonasschnelli.ch
; <<>> DiG 9.10.3-P4-Ubuntu <<>> -t NS testnet-seed.bitcoin.jonasschnelli.ch
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21280
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;testnet-seed.bitcoin.jonasschnelli.ch. IN NS
;; ANSWER SECTION:
testnet-seed.bitcoin.jonasschnelli.ch. 40000 IN NS testnet.bitcoin.jonasschnelli.ch.
;; Query time: 544 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Thu Dec 07 16:20:37 CST 2017
;; MSG SIZE rcvd: 88
xiaoyu@xiaoyu-Parallels-Virtual-Platform:~/bitcoin-seeder$ ./dnsseed -h testnet-seed.bitcoin.jonasschnelli.ch -n testnet.bitcoin.jonasschnelli.ch -m 316708138.qq.com
Supporting whitelisted filters: 0x1,0x5,0x9,0xd
Loading dnsseed.dat...done
Starting 4 DNS threads for testnet-seed.bitcoin.jonasschnelli.ch on testnet.bitcoin.jonasschnelli.ch (port 53).......done
Starting seeder...done
Starting 96 crawler threads...done
[17-12-07 16:22:23] 1545/90962 available (53561 tried in 707167s, 35865 new, 1536 active), 0 banned; 0
接下来就是跑解析数据
再次查看项目文件夹,发现多了两个文件
dnsseed.dat
dnsseed.dump
查看dnsseed.dump
文件
xiaoyu@xiaoyu-Parallels-Virtual-Platform:~/bitcoin-seeder$ cat dnsseed.dump
# address good lastSuccess %(2h) %(8h) %(1d) %(7d) %(30d) blocks svcs version
217.23.5.68:8333 1 1512636638 100.00% 100.00% 99.97% 69.13% 23.99% 498056 0800000d 70015 "/Satoshi:0.14.0/"
177.207.216.35:8333 1 1512636636 100.00% 100.00% 99.97% 69.13% 23.99% 498056 0000000d 70015 "/Satoshi:0.15.0.1/"
176.9.46.231:12121 0 1512636626 100.00% 100.00% 99.97% 69.13% 23.99% 498055 0000000d 70015 "/Satoshi:0.14.2/"
212.24.108.3:8333 1 1512636647 100.00% 100.00% 99.97% 69.13% 23.98% 498056 0000000d 70015 "/Satoshi:0.15.0/"
69.5.114.92:8333 1 1512636634 100.00% 100.00% 99.97% 69.13% 23.98% 498056 0000000d 70015 "/Satoshi:0.15.0.1(NO2X)/"
144.76.253.10:8333 1 1512636609 100.00% 100.00% 99.97% 69.13% 23.98% 498055 0000000d 70015 "/Satoshi:0.15.1/"
62.210.93.229:28333 0 1512636621 100.00% 100.00% 99.97% 69.13% 23.98% 507381 0000003d 80003 "/BUCash:1.1.2(EB16; AD12)/"
18.102.222.235:8333 1 1512636604 100.00% 100.00% 99.97% 69.13% 23.98% 498055 0000002d 70015 "/Satoshi:0.15.1/"
71.34.70.114:8333 1 1512636613 100.00% 100.00% 99.97% 69.13% 23.98% 498056 0000000d 70015 "/Satoshi:0.15.1/"
184.154.94.219:8333 1 1512636603 100.00% 100.00% 99.97% 69.13% 23.98% 498056 00000009 70015 "/Satoshi:0.15.0.1(UASF-SegWit-BIP148)/"
162.219.176.251:31720 0 1512636561 100.00% 100.00% 99.97% 69.13% 23.98% 498055 0800001f 70015 "/Satoshi:0.15.1/"
121.74.71.130:8333 1 1512636583 100.00% 100.00% 99.97% 69.12% 23.98% 498055 0000000d 70015 "/Satoshi:0.15.1/"
95.191.130.100:8333 1 1512636562 100.00% 100.00% 99.97% 69.12% 23.98% 498055 0000000d 70014 "/Satoshi:0.13.1/"
92.42.106.123:38333 0 1512636520 100.00% 100.00% 99.97% 69.12% 23.98% 498055 0000002d 70015 "/Satoshi:0.15.0.1/"
151.106.4.122:18333 0 1512636545 100.00% 100.00% 99.97% 69.12% 23.98% 498055 0000000d 70015 "/Satoshi:0.15.1/"
100.8.67.166:8333 1 1512636528 100.00% 100.00% 99.97% 69.12% 23.98% 498055 0800000d 70015 "/Satoshi:0.15.0.1/"
185.51.192.40:8333 1 1512636518 100.00% 100.00% 99.97% 69.12% 23.98% 498055 0000001d 70015 "/Satoshi:0.15.1/"
47.94.85.57:8333 1 1512636507 100.00% 100.00% 99.97% 69.12% 23.98% 498055 0000000d 70015 "/Satoshi:0.15.0/"
82.15.90.132:8333 1 1512636477 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.14.2/"
46.166.148.218:8333 1 1512636483 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.1/"
165.227.155.83:8333 0 1512636474 100.00% 100.00% 99.97% 69.12% 23.98% 284726 0000000d 70013 "/btcwire:0.5.0/btcd:0.12.0/"
86.3.108.228:8333 1 1512636441 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.1/"
176.9.31.76:8333 1 1512636434 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.0.1/"
116.110.220.45:8333 1 1512636418 100.00% 100.00% 99.97% 69.12% 23.98% 498053 0000000d 70015 "/Satoshi:0.15.0/"
134.119.193.162:18333 0 1512636411 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.1/"
24.187.152.137:8333 1 1512636400 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.14.2(!BIP148=)/Knots:20170618/"
35.176.123.143:8333 1 1512636382 100.00% 100.00% 99.97% 69.12% 23.98% 494782 0000008d 70015 "/Satoshi:1.15.1(2x)/"
92.222.183.198:8333 1 1512636364 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0800003d 70015 "/Satoshi:0.15.0.1/"
83.252.66.29:8333 1 1512636341 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70014 "/Satoshi:0.13.1/"
166.62.42.210:8333 1 1512636344 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70012 "/Satoshi:0.12.1(bitcore)/"
193.248.51.236:8333 1 1512636331 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.1/"
39.106.143.253:8333 1 1512636338 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.0/"
18.85.35.80:8333 1 1512636341 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000003d 70015 "/Satoshi:0.15.0/"
76.117.212.119:8333 1 1512636335 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.1/"
96.126.103.213:8333 1 1512636300 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.1/"
216.126.193.163:8333 1 1512636325 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0800002d 70015 "/Satoshi:0.14.1/"
24.120.235.185:8333 1 1512636308 100.00% 100.00% 99.97% 69.12% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.0/"
91.64.2.234:8333 1 1512636295 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.1/"
98.14.231.12:8333 1 1512636312 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000001d 70015 "/Satoshi:0.15.1/"
85.170.232.245:8333 1 1512636295 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.1/"
108.58.252.82:8333 1 1512636275 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000008d 70015 "/Satoshi:0.15.0/"
149.202.208.160:8333 1 1512636301 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.0.1/"
206.123.11.139:8333 1 1512636269 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.1/"
37.187.132.223:8333 1 1512636262 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.14.2/"
108.28.225.149:8333 1 1512636258 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.0/"
88.202.180.233:8333 1 1512636229 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.14.2/"
174.138.82.68:8333 0 1512636247 100.00% 100.00% 99.97% 69.11% 23.98% 24865 0000000d 70012 "/Satoshi:0.12.1/"
212.24.98.70:8333 1 1512636237 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.0.1/"
138.197.145.133:8333 1 1512636227 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.14.2/"
103.60.221.142:8333 1 1512636214 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.99/"
120.78.198.135:8333 1 1512636181 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.0.1/"
70.29.89.100:50000 0 1512636181 100.00% 100.00% 99.97% 69.11% 23.98% 498054 0000000d 70015 "/Satoshi:0.15.0/"
39.106.249.33:8333 1 1512636158 100.00% 100.00% 99.97% 69.11% 23.97% 498054 0000000d 70015 "/Satoshi:0.15.1/"
83.219.30.162:8333 1 1512636156 100.00% 100.00% 99.97% 69.11% 23.97% 498054 0800003d 70015 "/Satoshi:0.14.1/"
这样就得到了节点列表。
dns seed数据是硬编码到项目中,这也就解决了分布式系统的关于鸡生蛋还是蛋生鸡的问题。