1 from __future__ import division
3 TRANSITION_TIME = 1322804365
11 from twisted.python import log
14 from p2pool import skiplists
15 from p2pool.bitcoin import data as bitcoin_data, script, networks
16 from p2pool.util import memoize, expiring_dict, math
19 new_share_data_type = bitcoin_data.ComposedType([
20 ('previous_share_hash', bitcoin_data.PossiblyNoneType(0, bitcoin_data.HashType())),
21 ('coinbase', bitcoin_data.VarStrType()),
22 ('nonce', bitcoin_data.VarStrType()),
23 ('new_script', bitcoin_data.VarStrType()),
24 ('subsidy', bitcoin_data.StructType('<Q')),
25 ('donation', bitcoin_data.StructType('<H')),
26 ('stale_frac', bitcoin_data.StructType('<B')),
29 new_share_info_type = bitcoin_data.ComposedType([
30 ('new_share_data', new_share_data_type),
31 ('target', bitcoin_data.FloatingIntegerType()),
32 ('timestamp', bitcoin_data.StructType('<I')),
35 new_share1a_type = bitcoin_data.ComposedType([
36 ('header', bitcoin_data.block_header_type),
37 ('share_info', new_share_info_type),
38 ('merkle_branch', bitcoin_data.merkle_branch_type),
41 new_share1b_type = bitcoin_data.ComposedType([
42 ('header', bitcoin_data.block_header_type),
43 ('share_info', new_share_info_type),
44 ('other_txs', bitcoin_data.ListType(bitcoin_data.tx_type)),
51 new_share_type = bitcoin_data.ComposedType([
52 ('type', bitcoin_data.VarIntType()),
53 ('contents', bitcoin_data.VarStrType()),
56 class NewShare(object):
58 def from_share1a(cls, share1a, net):
59 return cls(net, **share1a)
62 def from_share1b(cls, share1b, net):
63 return cls(net, **share1b)
66 return dict(header=self.header, share_info=self.share_info, merkle_branch=self.merkle_branch)
69 if self.other_txs is None:
70 raise ValueError('share does not contain all txs')
72 return dict(header=self.header, share_info=self.share_info, other_txs=self.other_txs)
75 return '<Share %s>' % (' '.join('%s=%r' % (k, getattr(self, k)) for k in self.__slots__),)
77 __slots__ = 'header previous_block share_info merkle_branch other_txs timestamp share_data new_script subsidy previous_hash previous_share_hash target nonce pow_hash header_hash hash time_seen peer donation stale_frac'.split(' ')
80 def from_share(cls, share, net):
81 if share['type'] == 0:
82 res = cls.from_share1a(new_share1a_type.unpack(share['contents']), net)
83 if not (res.pow_hash > res.header['target']):
84 raise ValueError('invalid share type')
86 elif share['type'] == 1:
87 res = cls.from_share1b(new_share1b_type.unpack(share['contents']), net)
88 if not (res.pow_hash <= res.header['target']):
89 raise ValueError('invalid share type')
92 raise ValueError('unknown share type: %r' % (share['type'],))
95 if self.pow_hash > self.header['target']: # new_share1a
96 return dict(type=0, contents=new_share1a_type.pack(self.as_share1a()))
97 elif self.pow_hash <= self.header['target']: # new_share1b
98 return dict(type=1, contents=new_share1b_type.pack(self.as_share1b()))
100 raise AssertionError()
102 def __init__(self, net, header, share_info, merkle_branch=None, other_txs=None):
103 if merkle_branch is None and other_txs is None:
104 raise ValueError('need either merkle_branch or other_txs')
105 if other_txs is not None:
106 new_merkle_branch = bitcoin_data.calculate_merkle_branch([dict(version=0, tx_ins=[], tx_outs=[], lock_time=0)] + other_txs, 0)
107 if merkle_branch is not None:
108 if merke_branch != new_merkle_branch:
109 raise ValueError('invalid merkle_branch and other_txs')
110 merkle_branch = new_merkle_branch
112 if len(merkle_branch) > 16:
113 raise ValueError('merkle_branch too long!')
116 self.previous_block = header['previous_block']
117 self.share_info = share_info
118 self.merkle_branch = merkle_branch
119 self.other_txs = other_txs
121 self.share_data = self.share_info['new_share_data']
122 self.target = self.share_info['target']
123 self.timestamp = self.share_info['timestamp']
125 self.new_script = self.share_data['new_script']
126 self.subsidy = self.share_data['subsidy']
127 self.donation = self.share_data['donation']
129 if len(self.new_script) > 100:
130 raise ValueError('new_script too long!')
132 self.previous_hash = self.previous_share_hash = self.share_data['previous_share_hash']
133 self.nonce = self.share_data['nonce']
135 if len(self.nonce) > 100:
136 raise ValueError('nonce too long!')
138 if len(self.share_data['coinbase']) > 100:
139 raise ValueError('''coinbase too large! %i bytes''' % (len(self.share_data['coinbase']),))
141 self.pow_hash = net.BITCOIN_POW_FUNC(header)
142 self.header_hash = bitcoin_data.block_header_type.hash256(header)
144 self.hash = new_share1a_type.hash256(self.as_share1a())
146 if self.pow_hash > self.target:
147 print 'hash %x' % self.pow_hash
148 print 'targ %x' % self.target
149 raise ValueError('not enough work!')
151 if script.get_sigop_count(self.new_script) > 1:
152 raise ValueError('too many sigops!')
154 self.stale_frac = self.share_data['stale_frac']/254 if self.share_data['stale_frac'] != 255 else None
157 self.time_seen = time.time()
160 def check(self, tracker, now, net):
161 if self.header['timestamp'] <= TRANSITION_TIME - 3600:
162 raise AssertionError('transitioning...')
164 share_info, gentx = new_generate_transaction(tracker, self.share_info['new_share_data'], self.header['target'], self.share_info['timestamp'], net)
165 if share_info != self.share_info:
166 raise ValueError('share difficulty invalid')
168 if bitcoin_data.check_merkle_branch(gentx, 0, self.merkle_branch) != self.header['merkle_root']:
169 raise ValueError('''gentx doesn't match header via merkle_branch''')
171 def as_block(self, tracker, net):
172 if self.other_txs is None:
173 raise ValueError('share does not contain all txs')
175 share_info, gentx = new_generate_transaction(tracker, self.share_info['new_share_data'], self.header['target'], self.share_info['timestamp'], net)
176 assert share_info == self.share_info
178 return dict(header=self.header, txs=[gentx] + self.other_txs)
180 def get_pool_attempts_per_second(tracker, previous_share_hash, net, dist=None):
182 dist = net.TARGET_LOOKBEHIND
183 near = tracker.shares[previous_share_hash]
184 far = tracker.shares[tracker.get_nth_parent_hash(previous_share_hash, dist - 1)]
185 attempts = tracker.get_work(near.hash) - tracker.get_work(far.hash)
186 time = near.timestamp - far.timestamp
189 return attempts//time
191 def new_generate_transaction(tracker, new_share_data, block_target, desired_timestamp, net):
192 previous_share_hash = new_share_data['previous_share_hash']
193 new_script = new_share_data['new_script']
194 subsidy = new_share_data['subsidy']
195 donation = new_share_data['donation']
196 assert 0 <= donation <= 65535
198 if len(new_share_data['coinbase']) > 100:
199 raise ValueError('coinbase too long!')
201 previous_share = tracker.shares[previous_share_hash] if previous_share_hash is not None else None
203 height, last = tracker.get_height_and_last(previous_share_hash)
204 assert height >= net.CHAIN_LENGTH or last is None
205 if height < net.TARGET_LOOKBEHIND:
206 target = bitcoin_data.FloatingInteger.from_target_upper_bound(net.MAX_TARGET)
208 attempts_per_second = get_pool_attempts_per_second(tracker, previous_share_hash, net)
209 pre_target = 2**256//(net.SHARE_PERIOD*attempts_per_second) - 1
210 pre_target2 = math.clip(pre_target, (previous_share.target*9//10, previous_share.target*11//10))
211 pre_target3 = math.clip(pre_target2, (0, net.MAX_TARGET))
212 target = bitcoin_data.FloatingInteger.from_target_upper_bound(pre_target3)
214 attempts_to_block = bitcoin_data.target_to_average_attempts(block_target)
215 max_att = net.SPREAD * attempts_to_block
217 this_att = min(bitcoin_data.target_to_average_attempts(target), max_att)
218 other_weights, other_total_weight, other_donation_weight = tracker.get_cumulative_weights(previous_share_hash, min(height, net.CHAIN_LENGTH), 65535*max(0, max_att - this_att))
219 assert other_total_weight == sum(other_weights.itervalues()) + other_donation_weight, (other_total_weight, sum(other_weights.itervalues()) + other_donation_weight)
220 weights, total_weight, donation_weight = math.add_dicts([{new_script: this_att*(65535-donation)}, other_weights]), this_att*65535 + other_total_weight, this_att*donation + other_donation_weight
221 assert total_weight == sum(weights.itervalues()) + donation_weight, (total_weight, sum(weights.itervalues()) + donation_weight)
223 SCRIPT = '4104ffd03de44a6e11b9917f3a29f9443283d9871c9d743ef30d5eddcd37094b64d1b3d8090496b53256786bf5c82932ec23c3b74d9f05a6f95a8b5529352656664bac'.decode('hex')
225 # 1 satoshi is always donated so that a list of p2pool generated blocks can be easily found by looking at the donation address
226 amounts = dict((script, (subsidy-1)*(199*weight)//(200*total_weight)) for (script, weight) in weights.iteritems())
227 amounts[new_script] = amounts.get(new_script, 0) + (subsidy-1)//200
228 amounts[SCRIPT] = amounts.get(SCRIPT, 0) + (subsidy-1)*(199*donation_weight)//(200*total_weight)
229 amounts[SCRIPT] = amounts.get(SCRIPT, 0) + subsidy - sum(amounts.itervalues()) # collect any extra satoshis :P
231 if sum(amounts.itervalues()) != subsidy:
233 if any(x < 0 for x in amounts.itervalues()):
236 dests = sorted(amounts.iterkeys(), key=lambda script: (amounts[script], script))
237 dests = dests[-4000:] # block length limit, unlikely to ever be hit
240 new_share_data=new_share_data,
242 timestamp=math.clip(desired_timestamp, (previous_share.timestamp - 60, previous_share.timestamp + 60)) if previous_share is not None else desired_timestamp,
245 return share_info, dict(
248 previous_output=None,
250 script=new_share_data['coinbase'].ljust(2, '\x00'),
252 tx_outs=[dict(value=0, script='\x20' + bitcoin_data.HashType().pack(new_share_info_type.hash256(share_info)))] + [dict(value=amounts[script], script=script) for script in dests if amounts[script]],
257 class OkayTracker(bitcoin_data.Tracker):
258 def __init__(self, net):
259 bitcoin_data.Tracker.__init__(self)
261 self.verified = bitcoin_data.Tracker()
262 self.verified.get_nth_parent_hash = self.get_nth_parent_hash # self is a superset of self.verified
264 self.get_cumulative_weights = skiplists.WeightsSkipList(self)
266 def add(self, share, known_verified=False):
267 bitcoin_data.Tracker.add(self, share)
269 self.verified.add(share)
271 def attempt_verify(self, share, now):
272 if share.hash in self.verified.shares:
274 height, last = self.get_height_and_last(share.hash)
275 if height < self.net.CHAIN_LENGTH + 1 and last is not None:
276 raise AssertionError()
278 share.check(self, now, self.net)
280 log.err(None, 'Share check failed:')
283 self.verified.add(share)
286 def think(self, ht, previous_block, now):
290 # make 'unverified heads' set?
291 # for each overall head, attempt verification
292 # if it fails, attempt on parent, and repeat
293 # if no successful verification because of lack of parents, request parent
295 for head in set(self.heads) - set(self.verified.heads):
296 head_height, last = self.get_height_and_last(head)
298 for share in itertools.islice(self.get_chain_known(head), None if last is None else min(5, max(0, head_height - self.net.CHAIN_LENGTH))):
299 if self.attempt_verify(share, now):
301 if share.hash in self.heads:
305 desired.add((self.shares[random.choice(list(self.reverse_shares[last]))].peer, last))
307 assert bad not in self.verified.shares
308 assert bad in self.heads
313 # try to get at least CHAIN_LENGTH height for each verified head, requesting parents if needed
314 for head in list(self.verified.heads):
315 head_height, last_hash = self.verified.get_height_and_last(head)
316 last_height, last_last_hash = self.get_height_and_last(last_hash)
317 # XXX review boundary conditions
318 want = max(self.net.CHAIN_LENGTH - head_height, 0)
319 can = max(last_height - 1 - self.net.CHAIN_LENGTH, 0) if last_last_hash is not None else last_height
321 #print 'Z', head_height, last_hash is None, last_height, last_last_hash is None, want, can, get
322 for share in itertools.islice(self.get_chain_known(last_hash), get):
323 if not self.attempt_verify(share, now):
325 if head_height < self.net.CHAIN_LENGTH and last_last_hash is not None:
326 desired.add((self.verified.shares[random.choice(list(self.verified.reverse_shares[last_hash]))].peer, last_last_hash))
329 best_tail = max(self.verified.tails, key=lambda h: self.score(max(self.verified.tails[h], key=self.verified.get_height), ht)) if self.verified.tails else None
330 # decide best verified head
331 scores = sorted(self.verified.tails.get(best_tail, []), key=lambda h: (
332 self.verified.get_work(self.verified.get_nth_parent_hash(h, min(5, self.verified.get_height(h)))),
333 #self.verified.shares[h].peer is None,
334 ht.get_min_height(self.verified.shares[h].previous_block),
335 -self.verified.shares[h].time_seen
340 print len(self.verified.tails), "chain tails and", len(self.verified.tails.get(best_tail, [])), 'chain heads. Top 10 heads:'
343 for h in scores[-10:]:
344 print ' ', format_hash(h), format_hash(self.verified.shares[h].previous_hash), (
345 self.verified.get_work(self.verified.get_nth_parent_hash(h, min(5, self.verified.get_height(h)))),
346 self.verified.shares[h].peer is None,
347 ht.get_min_height(self.verified.shares[h].previous_block),
348 -self.verified.shares[h].time_seen
353 for i in xrange(1000):
355 for share_hash, tail in self.heads.iteritems():
356 if share_hash in scores[-5:]:
359 if self.shares[share_hash].time_seen > time.time() - 300:
362 if share_hash not in self.verified.shares and max(self.shares[after_tail_hash].time_seen for after_tail_hash in self.reverse_shares.get(tail)) > time.time() - 120: # XXX stupid
365 to_remove.add(share_hash)
368 for share_hash in to_remove:
369 self.remove(share_hash)
370 if share_hash in self.verified.shares:
371 self.verified.remove(share_hash)
372 #print "_________", to_remove
375 for i in xrange(1000):
377 for tail, heads in self.tails.iteritems():
378 if min(self.get_height(head) for head in heads) < 2*self.net.CHAIN_LENGTH + 10:
380 for aftertail in self.reverse_shares.get(tail, set()):
381 if len(self.reverse_shares[self.shares[aftertail].previous_hash]) > 1: # XXX
384 to_remove.add(aftertail)
387 # if removed from this, it must be removed from verified
389 for aftertail in to_remove:
390 if self.shares[aftertail].previous_hash not in self.tails:
391 print "erk", aftertail, self.shares[aftertail].previous_hash
393 self.remove(aftertail)
394 if aftertail in self.verified.shares:
395 self.verified.remove(aftertail)
397 #print "removed! %i %f" % (len(to_remove), (end - start)/len(to_remove))
399 best = scores[-1] if scores else None
402 best_share = self.verified.shares[best]
403 if ht.get_min_height(best_share.header['previous_block']) < ht.get_min_height(previous_block) and best_share.header_hash != previous_block and best_share.peer is not None:
405 print 'Stale detected! %x < %x' % (best_share.header['previous_block'], previous_block)
406 best = best_share.previous_hash
410 @memoize.memoize_with_backing(expiring_dict.ExpiringDict(5, get_touches=False))
411 def score(self, share_hash, ht):
412 head_height, last = self.verified.get_height_and_last(share_hash)
416 share2_hash = self.verified.get_nth_parent_hash(share_hash, min(self.net.CHAIN_LENGTH//2, head_height//2)) if last is not None else share_hash
417 for share in reversed(list(itertools.islice(self.verified.get_chain_known(share2_hash), self.net.CHAIN_LENGTH))):
418 max_height = max(max_height, ht.get_min_height(share.header['previous_block']))
419 attempts += bitcoin_data.target_to_average_attempts(share.target)
420 this_score = attempts//(ht.get_highest_height() - max_height + 1)
421 if this_score > score2:
423 return min(head_height, self.net.CHAIN_LENGTH), score2
428 return '%08x' % (x % 2**32)
430 class ShareStore(object):
431 def __init__(self, prefix, net):
432 self.filename = prefix
433 self.dirname = os.path.dirname(os.path.abspath(prefix))
434 self.filename = os.path.basename(os.path.abspath(prefix))
436 self.known = None # will be filename -> set of share hashes, set of verified hashes
438 def get_shares(self):
439 if self.known is not None:
440 raise AssertionError()
442 filenames, next = self.get_filenames_and_next()
443 for filename in filenames:
444 share_hashes, verified_hashes = known.setdefault(filename, (set(), set()))
445 with open(filename, 'rb') as f:
448 type_id_str, data_hex = line.strip().split(' ')
449 type_id = int(type_id_str)
455 verified_hash = int(data_hex, 16)
456 yield 'verified_hash', verified_hash
457 verified_hashes.add(verified_hash)
459 share = NewShare.from_share(new_share_type.unpack(data_hex.decode('hex')), self.net)
461 share_hashes.add(share.hash)
463 raise NotImplementedError("share type %i" % (type_id,))
465 log.err(None, "Error while reading saved shares, continuing where left off:")
468 def _add_line(self, line):
469 filenames, next = self.get_filenames_and_next()
470 if filenames and os.path.getsize(filenames[-1]) < 10e6:
471 filename = filenames[-1]
475 with open(filename, 'ab') as f:
480 def add_share(self, share):
481 type_id, data = 5, new_share_type.pack(share.as_share())
482 filename = self._add_line("%i %s" % (type_id, data.encode('hex')))
483 share_hashes, verified_hashes = self.known.setdefault(filename, (set(), set()))
484 share_hashes.add(share.hash)
486 def add_verified_hash(self, share_hash):
487 filename = self._add_line("%i %x" % (2, share_hash))
488 share_hashes, verified_hashes = self.known.setdefault(filename, (set(), set()))
489 verified_hashes.add(share_hash)
491 def get_filenames_and_next(self):
492 suffixes = sorted(int(x[len(self.filename):]) for x in os.listdir(self.dirname) if x.startswith(self.filename) and x[len(self.filename):].isdigit())
493 return [os.path.join(self.dirname, self.filename + str(suffix)) for suffix in suffixes], os.path.join(self.dirname, self.filename + (str(suffixes[-1] + 1) if suffixes else str(0)))
495 def forget_share(self, share_hash):
496 for filename, (share_hashes, verified_hashes) in self.known.iteritems():
497 if share_hash in share_hashes:
498 share_hashes.remove(share_hash)
501 def forget_verified_share(self, share_hash):
502 for filename, (share_hashes, verified_hashes) in self.known.iteritems():
503 if share_hash in verified_hashes:
504 verified_hashes.remove(share_hash)
507 def check_remove(self):
509 for filename, (share_hashes, verified_hashes) in self.known.iteritems():
510 #print filename, len(share_hashes) + len(verified_hashes)
511 if not share_hashes and not verified_hashes:
512 to_remove.add(filename)
513 for filename in to_remove:
514 self.known.pop(filename)
516 print "REMOVED", filename
518 class BitcoinMainnet(networks.BitcoinMainnet):
519 SHARE_PERIOD = 10 # seconds
520 CHAIN_LENGTH = 24*60*60//10//2 # shares
521 TARGET_LOOKBEHIND = 200 # shares
523 IDENTIFIER = 'fc70035c7a81bc6f'.decode('hex')
524 PREFIX = '2472ef181efcd37b'.decode('hex')
527 MAX_TARGET = 2**256//2**32 - 1
531 class BitcoinTestnet(networks.BitcoinTestnet):
532 SHARE_PERIOD = 1 # seconds
533 CHAIN_LENGTH = 24*60*60//10//2 # shares
534 TARGET_LOOKBEHIND = 200 # shares
536 IDENTIFIER = '5fc2be2d4f0d6bfb'.decode('hex')
537 PREFIX = '3f6057a15036f441'.decode('hex')
538 NAME = 'bitcoin_testnet'
540 MAX_TARGET = 2**256//2**32 - 1
544 class NamecoinMainnet(networks.NamecoinMainnet):
545 SHARE_PERIOD = 10 # seconds
546 CHAIN_LENGTH = 24*60*60//10 # shares
547 TARGET_LOOKBEHIND = 3600//10 # shares
549 IDENTIFIER = 'd5b1192062c4c454'.decode('hex')
550 PREFIX = 'b56f3d0fb24fc982'.decode('hex')
553 MAX_TARGET = 2**256//2**32 - 1
557 class NamecoinTestnet(networks.NamecoinTestnet):
558 SHARE_PERIOD = 1 # seconds
559 CHAIN_LENGTH = 24*60*60//5 # shares
560 TARGET_LOOKBEHIND = 200 # shares
562 IDENTIFIER = '8dd303d014a01a60'.decode('hex')
563 PREFIX = '4d6581d24f51acbf'.decode('hex')
564 NAME = 'namecoin_testnet'
566 MAX_TARGET = 2**256//2**20 - 1
570 class IxcoinMainnet(networks.IxcoinMainnet):
571 SHARE_PERIOD = 10 # seconds
572 CHAIN_LENGTH = 24*60*60//10 # shares
573 TARGET_LOOKBEHIND = 3600//10 # shares
575 IDENTIFIER = '27b564116e2a2666'.decode('hex')
576 PREFIX = '9dd6c4a619401f2f'.decode('hex')
579 MAX_TARGET = 2**256//2**32 - 1
583 class IxcoinTestnet(networks.IxcoinTestnet):
584 SHARE_PERIOD = 1 # seconds
585 CHAIN_LENGTH = 24*60*60//5 # shares
586 TARGET_LOOKBEHIND = 200 # shares
588 IDENTIFIER = '7430cbeb01249e44'.decode('hex')
589 PREFIX = '7cfffda946709c1f'.decode('hex')
590 NAME = 'ixcoin_testnet'
592 MAX_TARGET = 2**256//2**20 - 1
596 class I0coinMainnet(networks.I0coinMainnet):
597 SHARE_PERIOD = 10 # seconds
598 CHAIN_LENGTH = 24*60*60//10 # shares
599 TARGET_LOOKBEHIND = 3600//10 # shares
601 IDENTIFIER = 'b32e3f10c2ff221b'.decode('hex')
602 PREFIX = '6155537ed977a3b5'.decode('hex')
605 MAX_TARGET = 2**256//2**32 - 1
609 class I0coinTestnet(networks.I0coinTestnet):
610 SHARE_PERIOD = 1 # seconds
611 CHAIN_LENGTH = 24*60*60//5 # shares
612 TARGET_LOOKBEHIND = 200 # shares
614 IDENTIFIER = '7712c1a8181b5f2e'.decode('hex')
615 PREFIX = '792d2e7d770fbe68'.decode('hex')
616 NAME = 'i0coin_testnet'
618 MAX_TARGET = 2**256//2**20 - 1
622 class SolidcoinMainnet(networks.SolidcoinMainnet):
624 CHAIN_LENGTH = 24*60*60//10 # shares
625 TARGET_LOOKBEHIND = 3600//10 # shares
627 IDENTIFIER = '9cc9c421cca258cd'.decode('hex')
628 PREFIX = 'c059125b8070f00a'.decode('hex')
631 MAX_TARGET = 2**256//2**32 - 1
635 class LitecoinMainnet(networks.LitecoinMainnet):
636 SHARE_PERIOD = 10 # seconds
637 CHAIN_LENGTH = 24*60*60//10//2 # shares
638 TARGET_LOOKBEHIND = 200 # shares
640 IDENTIFIER = 'e037d5b8c6923410'.decode('hex')
641 PREFIX = '7208c1a53ef629b0'.decode('hex')
644 MAX_TARGET = 2**256//2**20 - 1
648 class LitecoinTestnet(networks.LitecoinTestnet):
649 SHARE_PERIOD = 1 # seconds
650 CHAIN_LENGTH = 24*60*60//5 # shares
651 TARGET_LOOKBEHIND = 200 # shares
653 IDENTIFIER = 'cca5e24ec6408b1e'.decode('hex')
654 PREFIX = 'ad9614f6466a39cf'.decode('hex')
655 NAME = 'litecoin_testnet'
657 MAX_TARGET = 2**256//2**17 - 1
661 nets = dict((net.NAME, net) for net in set([BitcoinMainnet, BitcoinTestnet, NamecoinMainnet, NamecoinTestnet, IxcoinMainnet, IxcoinTestnet, I0coinMainnet, I0coinTestnet, SolidcoinMainnet, LitecoinMainnet, LitecoinTestnet]))