Browse Source

Add Groestlcoin (#544)

* Add Groestlcoin

* GRS: Add tests
patch-2
Kefkius 7 years ago
committed by Neil
parent
commit
9e3893b065
  1. 1
      .travis.yml
  2. 49
      electrumx/lib/coins.py
  3. 6
      electrumx/lib/tx.py
  4. 1
      setup.py
  5. 15
      tests/blocks/groestlcoin_mainnet_2000000.json
  6. 14
      tests/blocks/groestlcoin_testnet_600000.json

1
.travis.yml

@ -31,6 +31,7 @@ install:
- pip install x11_hash
- pip install xevan_hash
- pip install quark_hash
- pip install groestlcoin_hash
- pip install git+https://github.com/goacoincore/neoscrypt
- pip install git+https://github.com/motioncrypto/x16r_hash
# command to run tests

49
electrumx/lib/coins.py

@ -1978,3 +1978,52 @@ class Minexcoin(MinexcoinMixin, Coin):
'elex01-ams.turinex.eu s t',
'eu.minexpool.nl s t'
]
class Groestlcoin(Coin):
NAME = "Groestlcoin"
SHORTNAME = "GRS"
NET = "mainnet"
XPUB_VERBYTES = bytes.fromhex("0488b21e")
XPRV_VERBYTES = bytes.fromhex("0488ade4")
P2PKH_VERBYTE = bytes.fromhex("24")
P2SH_VERBYTES = [bytes.fromhex("05")]
WIF_BYTE = bytes.fromhex("80")
GENESIS_HASH = ('00000ac5927c594d49cc0bdb81759d0d'
'a8297eb614683d3acb62f0703b639023')
DESERIALIZER = lib_tx.DeserializerGroestlcoin
TX_COUNT = 115900
TX_COUNT_HEIGHT = 1601528
TX_PER_BLOCK = 5
RPC_PORT = 1441
PEERS = [
'electrum1.groestlcoin.org s t',
'electrum2.groestlcoin.org s t',
'6brsrbiinpc32tfc.onion t',
'xkj42efxrcy6vbfw.onion t',
]
@classmethod
def header_hash(cls, header):
'''Given a header return the hash.'''
import groestlcoin_hash
return groestlcoin_hash.getHash(header, len(header))
class GroestlcoinTestnet(Groestlcoin):
SHORTNAME = "TGRS"
NET = "testnet"
XPUB_VERBYTES = bytes.fromhex("043587cf")
XPRV_VERBYTES = bytes.fromhex("04358394")
P2PKH_VERBYTE = bytes.fromhex("6f")
P2SH_VERBYTES = [bytes.fromhex("c4")]
WIF_BYTE = bytes.fromhex("ef")
GENESIS_HASH = ('000000ffbb50fc9898cdd36ec163e6ba'
'23230164c0052a28876255b7dcf2cd36')
RPC_PORT = 17766
PEERS = [
'electrum-test1.groestlcoin.org s t',
'electrum-test2.groestlcoin.org s t',
'7frvhgofuf522b5i.onion t',
'aocojvqcybdoxekv.onion t',
]

6
electrumx/lib/tx.py

@ -30,7 +30,7 @@
from collections import namedtuple
from electrumx.lib.hash import double_sha256, hash_to_hex_str
from electrumx.lib.hash import sha256, double_sha256, hash_to_hex_str
from electrumx.lib.util import (
cachedproperty, unpack_int32_from, unpack_int64_from,
unpack_uint16_from, unpack_uint32_from, unpack_uint64_from
@ -415,6 +415,10 @@ class DeserializerBitcoinAtom(DeserializerSegWit):
return self._read_nbytes(header_len)
class DeserializerGroestlcoin(DeserializerSegWit):
TX_HASH_FN = staticmethod(sha256)
# Decred
class TxInputDcr(namedtuple("TxInput", "prev_hash prev_idx tree sequence")):
'''Class representing a Decred transaction input.'''

1
setup.py

@ -11,6 +11,7 @@ setuptools.setup(
# "tribus_hash" package is required to sync Denarius network.
# "blake256" package is required to sync Decred network.
# "xevan_hash" package is required to sync Xuez network.
# "groestlcoin_hash" package is required to sync Groestlcoin network.
install_requires=['aiorpcX == 0.5.9', 'attrs>=15',
'plyvel', 'pylru', 'aiohttp >= 2'],
packages=setuptools.find_packages(include=('electrumx*',)),

15
tests/blocks/groestlcoin_mainnet_2000000.json

@ -0,0 +1,15 @@
{
"hash": "00000000000434d5b8d1c3308df7b6e3fd773657dfb28f5dd2f70854ef94cc66",
"size": 551,
"height": 2000000,
"merkleroot": "3219c39319362135080e89cca168dd1e145145a22baae2b3512e0c3fd386da77",
"tx": [
"7a64cd89b9e0fd6b32be5deb349e460a90e6805278dee2fe301b347623f0806b",
"89ff39e83636359bace69725fe19e1d33b16918205eaaf77c37684ac557e5154"
],
"time": 1520891844,
"nonce": 846303402,
"bits": "1b14f5ec",
"previousblockhash": "000000000011b76534c258708119c1448a74ce458f8d0b5e05958dd10529962c",
"block": "000000202c962905d18d95055e0b8d8f45ce748a44c119817058c23465b711000000000077da86d33f0c2e51b3e2aa2ba24551141edd68a1cc890e083521361993c31932c4f7a65aecf5141baa90713202010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff4c0380841e04c4f7a65a08fabe6d6d33312d33302d383130325b6d36335b1b3691506e2a97a2c14df7e9bc6e94e540010000000000000060000413010200000d2f6e6f64655374726174756d2f00000000020000000000000000266a24aa21a9ed8dfe2e8f6eb7ff2d6e27732d11c6aaee5eab7d5ea67b6cf887ec9d4cd038e831a876cd1d000000001976a91442bbcfb1cd88dbbb4c56086f1d018f10a7ef760688ac01200000000000000000000000000000000000000000000000000000000000000000000000000100000001f7b346fc08b41de682b81b7ce729edb2aeddc2f587b759859031e3bf99e68779000000006b483045022100e00b07400fbe10ee9396242557026ff6d3e16ffb46add2ccc5d7ffd8ddbc1989022003cc6832c4d62e15478150748867ca71eca04655f4b2ce31773832353d571647012102d4ad38a64b4ec115a77a900d6fb7f44343aa761ab6fcf8b8613443fa7e24e5befeffffff026e539827000000001976a9145db12e800001e767f56a3dbb202d0666315d063288acb5162400000000001976a914bd7b0274f1ef4325d0e8e273ed5be328bc3d11d988ac4a841e00"
}

14
tests/blocks/groestlcoin_testnet_600000.json

@ -0,0 +1,14 @@
{
"hash": "0000006f6fe0a699fa886b686478757001e835ac5d14d3564853564070eaec80",
"size": 414,
"height": 600000,
"merkleroot": "8f319c349f022c55c2dee11c45a801fc4c3befff0da4716252da761ff1829ab8",
"tx": [
"8f319c349f022c55c2dee11c45a801fc4c3befff0da4716252da761ff1829ab8"
],
"time": 1527979101,
"nonce": 1015101440,
"bits": "1e00a292",
"previousblockhash": "0000000793af7147bb657a0c664d353dacbeda0ea308284f121e57e52e94f64e",
"block": "000000204ef6942ee5571e124f2808a30edabeac3d354d660c7a65bb4771af9307000000b89a82f11f76da526271a40dffef3b4cfc01a8451ce1dec2552c029f349c318f5d1c135b92a2001e0038813c01010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff0403c02709ffffffff050000000000000000266a24aa21a9ed92ac07c7b9e008effde0e4753064f2328b1c8cd3d0b488f4bf1bba8cb9338c36f90f5a2f000000001976a914de5853461d170e13ccb55b557d380b2ba311df0588ace19f6730000000001976a914edd383678438905630480a97dac76645766c86c188ac0200000000000000434104c5e6c406b804c7ea1f7c756297ed327dd12f6466b699536bbb85641d9daf9a1222a5a6e18bd203b96132371c7932cb4c999fc7039171a28d76695c5c055f2f33ac00000000000000002a6a28fc8e81ddd6d7c466bcceee57eea76e56dbfd211afed8d9945b4b3cfe54ed62b9000000000000000001205b5032506f6f6c5d5b5032506f6f6c5d5b5032506f6f6c5d5b5032506f6f6c5d00000000"
}
Loading…
Cancel
Save