Skip to content

Commit

Permalink
Pivx support (kyuupichan#568)
Browse files Browse the repository at this point in the history
* Correct function doc string

* Add PIVX support
  • Loading branch information
erasmospunk authored and Neil committed Aug 11, 2018
1 parent 8d745f0 commit 05c9e6b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
39 changes: 39 additions & 0 deletions electrumx/lib/coins.py
Expand Up @@ -2100,3 +2100,42 @@ class GroestlcoinTestnet(Groestlcoin):
'7frvhgofuf522b5i.onion t',
'aocojvqcybdoxekv.onion t',
]


class Pivx(Coin):
NAME = "Pivx"
SHORTNAME = "PIVX"
NET = "mainnet"
XPUB_VERBYTES = bytes.fromhex("022D2533")
XPRV_VERBYTES = bytes.fromhex("0221312B")
P2PKH_VERBYTE = bytes.fromhex("1e")
P2SH_VERBYTES = [bytes.fromhex("0d")]
WIF_BYTE = bytes.fromhex("d4")
GENESIS_HASH = ('0000041e482b9b9691d98eefb4847340'
'5c0b8ec31b76df3797c74a78680ef818')
BASIC_HEADER_SIZE = 80
HDR_V4_SIZE = 112
HDR_V4_HEIGHT = 863787
HDR_V4_START_OFFSET = HDR_V4_HEIGHT * BASIC_HEADER_SIZE
TX_COUNT = 2930206
TX_COUNT_HEIGHT = 1299212
TX_PER_BLOCK = 2
RPC_PORT = 51473

@classmethod
def static_header_offset(cls, height):
assert cls.STATIC_BLOCK_HEADERS
if height >= cls.HDR_V4_HEIGHT:
relative_v4_offset = (height - cls.HDR_V4_HEIGHT) * cls.HDR_V4_SIZE
return cls.HDR_V4_START_OFFSET + relative_v4_offset
else:
return height * cls.BASIC_HEADER_SIZE

@classmethod
def header_hash(cls, header):
version, = struct.unpack('<I', header[:4])
if version >= 4:
return super().header_hash(header)
else:
import quark_hash
return quark_hash.getPoWHash(header)
4 changes: 1 addition & 3 deletions electrumx/server/db.py
Expand Up @@ -579,9 +579,7 @@ def set_flush_count(self, count):
self.write_utxo_state(batch)

async def all_utxos(self, hashX):
'''Return all UTXOs for an address sorted in no particular order. By
default yields at most 1000 entries.
'''
'''Return all UTXOs for an address sorted in no particular order.'''
def read_utxos():
utxos = []
utxos_append = utxos.append
Expand Down
14 changes: 14 additions & 0 deletions tests/blocks/pivx_mainnet_10000.json
@@ -0,0 +1,14 @@
{
"hash": "00000000003ce77135d15257a57f7508b8c5021372de2eae554f3142b60944cc",
"size": 231,
"height": 10000,
"merkleroot": "bd27e18a8abbd501b775d32fc6402a1a474a0517c1c8b04b9d487b0203f6b0f0",
"tx": [
"bd27e18a8abbd501b775d32fc6402a1a474a0517c1c8b04b9d487b0203f6b0f0"
],
"time": 1454814715,
"nonce": 14876727,
"bits": "1c06b486",
"previousblockhash": "00000000023fecac81bc148c7ab26a0190dbabeac2e8e260f62dff5205596f02",
"block": "03000000026f590552ff2df660e2e8c2eaabdb90016ab27a8c14bc81acec3f0200000000f0b0f603027b489d4bb0c8c117054a471a2a40c62fd375b701d5bb8a8ae127bdfbb5b65686b4061c3700e3000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1f02102704fbb5b65608380001169c6108000d2f6e6f64655374726174756d2f000000000200c817a8040000001976a91493d5f8ec14e203ef275ebfe942bc6a1e2784f95088ac00f2052a010000001976a914d6716d39693e034596a1e8546b4d65e4a06159cc88ac00000000"
}
15 changes: 15 additions & 0 deletions tests/blocks/pivx_mainnet_1000000.json
@@ -0,0 +1,15 @@
{
"hash": "bb6127b99bf96b150c86ac38fde17c47d6c95b460c462ef45fd5043a44479068",
"size": 461,
"height": 1000000,
"merkleroot": "ecafe8267cbc5e4b6f4aec0978b02f0ba47a19828b0f8780e25685184d61c9e2",
"tx": [
"290871d1dc1673069a4c3efef424278b377becbff0c776e20972d212daa4a3d4",
"e217611a8db9ec5994632e1f66727c53e0ba09c406f6c993c8d52f5474efe620"
],
"time": 1516510311,
"nonce": 0,
"bits": "1a7128a9",
"previousblockhash": "795ab132be197a0a173cbe3590660235d906e0011052a10206244e0eae4b5152",
"block": "0400000052514bae0e4e240602a1521001e006d93502669035be3c170a7a19be32b15a79e2c9614d188556e280870f8b82197aa40b2fb07809ec4a6f4b5ebc7c26e8afec671c645aa928711a000000004ff5c33f2832ca5fa5ecbefb33c068e32ad0ae6e47c71be916fc34615c299b8c0201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff060340420f0101ffffffff01000000000000000000000000000100000001eb79b426b80013c330e13e49764deeba311f8be69d0ec117d5b4f11d72215f3e0100000049483045022100f495580e30a64b4945582fe3e9a9118a60b53ca22c44232c170ff99a9fa7e8210220712921e4ddda1afe47b2481f2d1512759aaa0ab584f16ffe4b28771437c716be01ffffffff03000000000000000000500ae8470c0000002321037e0b96219461080ce2f837825fd3c52b08199c404a0d6d59f026a6a890dc4b15ac808ef20d000000001976a914f0364dfac5fca72abd79085c6b00f9e8f35bbff688ac0000000046304402203b270304b2fa14362d9718c16bf20e5c6ede49abfa7fe5fc5326b9f598d592d402203b32fda981ead1df35aebc1eca9b4766555dd2f200538f6b3d62d6ccc5180aa7"
}

0 comments on commit 05c9e6b

Please sign in to comment.