Trezarcoin Support (#670)
This commit is contained in:
parent
280914a861
commit
3e8f0e903d
@ -1309,6 +1309,50 @@ class Peercoin(Coin):
|
||||
REORG_LIMIT = 5000
|
||||
|
||||
|
||||
class Trezarcoin(Coin):
|
||||
NAME = "Trezarcoin"
|
||||
SHORTNAME = "TZC"
|
||||
NET = "mainnet"
|
||||
VALUE_PER_COIN = 1000000
|
||||
XPUB_VERBYTES = bytes.fromhex("0488B21E")
|
||||
XPRV_VERBYTES = bytes.fromhex("0488ADE4")
|
||||
P2PKH_VERBYTE = bytes.fromhex("42")
|
||||
P2SH_VERBYTES = [bytes.fromhex("08")]
|
||||
WIF_BYTE = bytes.fromhex("c2")
|
||||
GENESIS_HASH = ('24502ba55d673d2ee9170d83dae2d1ad'
|
||||
'b3bfb4718e4f200db9951382cc4f6ee6')
|
||||
DESERIALIZER = lib_tx.DeserializerTrezarcoin
|
||||
HEADER_HASH = lib_tx.DeserializerTrezarcoin.blake2s
|
||||
HEADER_HASH_GEN = lib_tx.DeserializerTrezarcoin.blake2s_gen
|
||||
BASIC_HEADER_SIZE = 80
|
||||
TX_COUNT = 742886
|
||||
TX_COUNT_HEIGHT = 643128
|
||||
TX_PER_BLOCK = 2
|
||||
RPC_PORT = 17299
|
||||
REORG_LIMIT = 2000
|
||||
PEERS = [
|
||||
'electrumx1.trezarcoin.com s t',
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def genesis_block(cls, block):
|
||||
'''Check the Genesis block is the right one for this coin.
|
||||
|
||||
Return the block less its unspendable coinbase.
|
||||
'''
|
||||
header = cls.block_header(block, 0)
|
||||
header_hex_hash = cls.HEADER_HASH_GEN(header)
|
||||
if header_hex_hash != cls.GENESIS_HASH:
|
||||
raise CoinError('genesis block has hash {} expected {}'
|
||||
.format(header_hex_hash, cls.GENESIS_HASH))
|
||||
return header + bytes(1)
|
||||
|
||||
@classmethod
|
||||
def header_hash(cls, header):
|
||||
'''Given a header return the hash.'''
|
||||
return cls.HEADER_HASH(header)
|
||||
|
||||
|
||||
class Reddcoin(Coin):
|
||||
NAME = "Reddcoin"
|
||||
SHORTNAME = "RDD"
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
'''Transaction-related classes and functions.'''
|
||||
|
||||
from collections import namedtuple
|
||||
from hashlib import blake2s
|
||||
|
||||
from electrumx.lib.hash import sha256, double_sha256, hash_to_hex_str
|
||||
from electrumx.lib.script import OpCodes
|
||||
@ -379,6 +380,62 @@ class DeserializerTxTime(Deserializer):
|
||||
)
|
||||
|
||||
|
||||
class TxTrezarcoin(
|
||||
namedtuple("Tx", "version time inputs outputs locktime txcomment")):
|
||||
'''Class representing transaction that has a time and txcomment field.'''
|
||||
|
||||
|
||||
class DeserializerTrezarcoin(Deserializer):
|
||||
|
||||
def read_tx(self):
|
||||
version = self._read_le_int32()
|
||||
time = self._read_le_uint32()
|
||||
inputs = self._read_inputs()
|
||||
outputs = self._read_outputs()
|
||||
locktime = self._read_le_uint32()
|
||||
if version >= 2:
|
||||
txcomment = self._read_varbytes()
|
||||
else:
|
||||
txcomment = b''
|
||||
return TxTrezarcoin(version, time, inputs, outputs, locktime,
|
||||
txcomment)
|
||||
|
||||
@staticmethod
|
||||
def blake2s_gen(data):
|
||||
version = data[0:1]
|
||||
keyOne = data[36:46]
|
||||
keyTwo = data[58:68]
|
||||
ntime = data[68:72]
|
||||
_nBits = data[72:76]
|
||||
_nonce = data[76:80]
|
||||
_full_merkle = data[36:68]
|
||||
_input112 = data + _full_merkle
|
||||
_key = keyTwo + ntime + _nBits + _nonce + keyOne
|
||||
'''Prepare 112Byte Header '''
|
||||
blake2s_hash = blake2s(key=_key, digest_size=32)
|
||||
blake2s_hash.update(_input112)
|
||||
'''TrezarFlips - Only for Genesis'''
|
||||
return ''.join(map(str.__add__, blake2s_hash.hexdigest()[-2::-2],
|
||||
blake2s_hash.hexdigest()[-1::-2]))
|
||||
|
||||
@staticmethod
|
||||
def blake2s(data):
|
||||
version = data[0:1]
|
||||
keyOne = data[36:46]
|
||||
keyTwo = data[58:68]
|
||||
ntime = data[68:72]
|
||||
_nBits = data[72:76]
|
||||
_nonce = data[76:80]
|
||||
_full_merkle = data[36:68]
|
||||
_input112 = data + _full_merkle
|
||||
_key = keyTwo + ntime + _nBits + _nonce + keyOne
|
||||
'''Prepare 112Byte Header '''
|
||||
blake2s_hash = blake2s(key=_key, digest_size=32)
|
||||
blake2s_hash.update(_input112)
|
||||
'''TrezarFlips'''
|
||||
return blake2s_hash.digest()
|
||||
|
||||
|
||||
class DeserializerReddcoin(Deserializer):
|
||||
def read_tx(self):
|
||||
version = self._read_le_int32()
|
||||
|
||||
16
tests/blocks/trezarcoin_mainnet_612581.json
Normal file
16
tests/blocks/trezarcoin_mainnet_612581.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"hash": "7fccc90aa5997b036d41ec079a2e8e2c52a0d1f64079b59aaa08c25e0e1e1a30",
|
||||
"size": 682,
|
||||
"height": 612581,
|
||||
"merkleroot": "7d9f01b60ab6718e97018b47cd0cf61ca85afe77bcf8d9c90e9709bb2aab9539",
|
||||
"tx": [
|
||||
"758012ea68d57bdc6e413a6d4195638b410df2ed8a3b2387343a854bb3a1c4b6",
|
||||
"c9f6d252f90f42884774d66d8ca17629333cda2871eeb3612307abeebb7e888d",
|
||||
"1354ba387c5f42f807889741a63704fc0ea87dc04f29834111c5f8d80ac0a70b"
|
||||
],
|
||||
"time": 1541864019,
|
||||
"nonce": 0,
|
||||
"bits": "1c092c62",
|
||||
"previousblockhash": "ac69b095cc53f7a0e9197a243fab2dfa49e7f0934fa79ec68f47993be813b33e",
|
||||
"block": "030000003eb313e83b99478fc69ea74f93f0e749fa2dab3f247a19e9a0f753cc95b069ac3995ab2abb09970ec9d9f8bc77fe5aa81cf60ccd478b01978e71b60ab6019f7d53fae65b622c091c00000000030200000053fae65b010000000000000000000000000000000000000000000000000000000000000000ffffffff0d03e558090130062f503253482fffffffff0100000000000000000000000000000200000053fae65b014f5dccf6592b950c707a5ae62c11644bf0cd1bd5777412a26c25e60015ce4f2001000000494830450220360d685960bd8fa30617beac5c952073e2d89be2528eeb11d475e43b894abdfd0221009b7cd6f2b5d8e2f8ad1919ea81b058ba1703e8c07180c09bacc974ec418a612b01ffffffff020000000000000000002059a4cd000000002321026b1af42e2ea1f61ca8bdb563a61787f8d69d7578de77229ef7bb2d2120b7f8f3ac000000000002000000d8f9e65b01b170ad1b81ac0164a637b6bd970c9897cc9be7d4f05b358ccd868a5d2adb2779010000006b483045022100bfffc1364ad5dfc2da6aedc8d8cdb31905d4e8fb7e4c7c5efafada7cbb18559502205a9cd74bba48fc60e142214917a6d66347aa5ca8f0d9664546e37955ca09c401012103765dbe24359bee468d2fde0ad714906bc0c15ce02e7170dbe98d42e663adb3a2feffffff0290aa0830000000001976a9149d864f487a38c872013901e463ea47a56967251888ac404b4c00000000001976a914690acc951705cd7668f6df688ba33c62cf15a3c288ace358090026746578743a536d696c6579476e6f6d6520697320612062616461737320676e6f6d65205e2e5e473045022100ef1ee96a60ce2d0368b371eccf92aea0d532ff5d447ff70b403130f0212b10ba022061c2c9d7b061035fa416303699768c8e99f3f27a470d3b63abc055181ea91350"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user