From b6be653f4f2da392b336786068054bfb028d23a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6nig?= Date: Sun, 19 Feb 2017 11:03:21 +0100 Subject: [PATCH] Adding FairCoin (#122) * Adding FairCoin * remove redundant 'header_len' function * removed serializer added missing commas removed assertion from read_block and replaced it with a comment --- lib/coins.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++- lib/tx.py | 2 +- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/lib/coins.py b/lib/coins.py index c9ad2ea..ed290e5 100644 --- a/lib/coins.py +++ b/lib/coins.py @@ -468,7 +468,7 @@ class Dash(Coin): IRC_PREFIX = "D_" IRC_CHANNEL = "#electrum-dash" PEERS = [ - 'electrum.dash.org s t' + 'electrum.dash.org s t', 'electrum.masternode.io s t', 'electrum-drk.club s t', 'dashcrypto.space s t', @@ -566,3 +566,59 @@ class DigiByteTestnet(DigiByte): IRC_CHANNEL = "#electrum-dgb" RPC_PORT = 15022 REORG_LIMIT = 2000 + + +class FairCoin(Coin): + NAME = "FairCoin" + SHORTNAME = "FAIR" + NET = "mainnet" + XPUB_VERBYTES = bytes.fromhex("0488b21e") + XPRV_VERBYTES = bytes.fromhex("0488ade4") + P2PKH_VERBYTE = 0x5f + P2SH_VERBYTE = 0x24 + WIF_BYTE = 0xdf + GENESIS_HASH=('1f701f2b8de1339dc0ec908f3fb6e9b0' + 'b870b6f20ba893e120427e42bbc048d7') + TX_COUNT = 1000 + TX_COUNT_HEIGHT = 1000 + TX_PER_BLOCK = 1 + IRC_PREFIX = "E_" + IRC_CHANNEL = "#fairlectrum" + RPC_PORT = 40405 + PEER_DEFAULT_PORTS = {'t': '51811', 's': '51812'} + PEERS = [ + 'fairlectrum.fair-coin.net s', + 'fairlectrum.fair.to s', + ] + + @classmethod + def header_offset(cls, height): + '''Given a header height return its offset in the headers file. + If header sizes change at some point, this is the only code + that needs updating.''' + return height * 108 + + @classmethod + def block_txs(cls, block, height): + '''Returns a list of (deserialized_tx, tx_hash) pairs given a + block and its height.''' + + if height == 0: + return [] + + deserializer = cls.deserializer() + return deserializer(block[cls.header_len(height):]).read_block() + + @classmethod + def electrum_header(cls, header, height): + version, = struct.unpack('