44Seeds are available from https://github.com/bitcoin/bitcoin/blob/master/src/kernel/chainparams.cpp
55'''
66import subprocess
7+ from itertools import combinations
8+
9+ NODE_NONE = 0
10+ NODE_NETWORK = (1 << 0 )
11+ NODE_BLOOM = (1 << 2 )
12+ NODE_WITNESS = (1 << 3 )
13+ NODE_COMPACT_FILTERS = (1 << 6 )
14+ NODE_NETWORK_LIMITED = (1 << 10 )
15+ NODE_P2P_V2 = (1 << 11 )
16+
17+ DNS_SEED_PROVIDERS = [
18+ "seed.bitcoin.sipa.be." ,
19+ "dnsseed.bluematt.me." ,
20+ "dnsseed.bitcoin.dashjr.org." ,
21+ "seed.bitcoinstats.com." ,
22+ ]
723
824SEEDS_PER_NETWORK = {
925 'mainnet' : [
@@ -43,11 +59,55 @@ def check_seed(x):
4359 else :
4460 print (f"\x1b [91mFAIL\x1b [0m { x } " )
4561
46- if __name__ == '__main__' :
62+ def has_answer_section (domain ):
63+ """
64+ Executes a dig command for the given domain and checks for an answer section.
65+ """
66+ command = ["dig" , domain ]
67+ try :
68+ result = subprocess .run (command , capture_output = True , check = True )
69+ output = result .stdout .decode ("utf-8" )
70+ return "ANSWER SECTION" in output
71+ except subprocess .CalledProcessError :
72+ return False
73+
74+ def get_hex_from_combination (* flags ):
75+ """
76+ Calculates the hexadecimal representation of the combination value.
77+ """
78+ combination_value = sum (flags )
79+ hex_value = hex (combination_value )[2 :].upper ()
80+ return f"x{ hex_value } "
81+
82+ if __name__ == "__main__" :
83+ print ("\n Bitcoin Core DNS Seed Status Check:\n " )
84+
4785 for (network , seeds ) in SEEDS_PER_NETWORK .items ():
4886 print (f"\x1b [90m* \x1b [97m{ network } \x1b [0m" )
4987
5088 for hostname in seeds :
5189 check_seed (hostname )
5290
5391 print ()
92+
93+ print ("\n " )
94+
95+ all_flags = [NODE_NONE , NODE_NETWORK , NODE_BLOOM , NODE_WITNESS , NODE_COMPACT_FILTERS , NODE_NETWORK_LIMITED , NODE_P2P_V2 ]
96+ all_combinations = []
97+
98+ for i in range (1 , len (all_flags ) + 1 ):
99+ for combo in combinations (all_flags , i ):
100+ combination = sum (combo )
101+ hex_value = get_hex_from_combination (* combo )
102+ all_combinations .append ((combo , hex_value ))
103+
104+ print ("All possible combinations and their hexadecimal values:" )
105+ for combination , hex_value in all_combinations :
106+ combination_names = [flag_name for flag_name , flag_value in zip (["NODE_NONE" , "NODE_NETWORK" , "NODE_BLOOM" , "NODE_WITNESS" , "NODE_COMPACT_FILTERS" , "NODE_NETWORK_LIMITED" , "NODE_P2P_V2" ], combination ) if flag_value != 0 ]
107+ combination_string = ", " .join (combination_names )
108+ print (f"Combination: { combination_string } => Hexadecimal Value: { hex_value } " )
109+
110+ for provider in DNS_SEED_PROVIDERS :
111+ domain = f"{ hex_value } .{ provider } "
112+ has_answer = has_answer_section (domain )
113+ print (f" { domain } : { has_answer } " )
0 commit comments