Changes for BTG (#409)
* Implemented electrum_header for BTG to include solution (needed for validation on clientside) Add RPC_PORT for BTG node * Added node regtest compatibility * Updated unittests * Changed chunksize and regtest rpc port * Changed bits transfer format to decimal * Add testnet v3 params and corrected coin name
This commit is contained in:
parent
fe0f109b08
commit
0f4f51d932
55
lib/coins.py
55
lib/coins.py
@ -440,6 +440,7 @@ class BitcoinSegwit(BitcoinMixin, Coin):
|
||||
|
||||
|
||||
class BitcoinGold(EquihashMixin, BitcoinMixin, Coin):
|
||||
CHUNK_SIZE = 252
|
||||
NAME = "BitcoinGold"
|
||||
SHORTNAME = "BTG"
|
||||
FORK_HEIGHT = 491407
|
||||
@ -450,6 +451,7 @@ class BitcoinGold(EquihashMixin, BitcoinMixin, Coin):
|
||||
TX_COUNT_HEIGHT = 499923
|
||||
TX_PER_BLOCK = 50
|
||||
REORG_LIMIT = 1000
|
||||
RPC_PORT = 8338
|
||||
|
||||
@classmethod
|
||||
def header_hash(cls, header):
|
||||
@ -461,6 +463,54 @@ class BitcoinGold(EquihashMixin, BitcoinMixin, Coin):
|
||||
else:
|
||||
return double_sha256(header[:68] + header[100:112])
|
||||
|
||||
@classmethod
|
||||
def electrum_header(cls, header, height):
|
||||
h = dict(
|
||||
block_height=height,
|
||||
version=struct.unpack('<I', header[:4])[0],
|
||||
prev_block_hash=hash_to_str(header[4:36]),
|
||||
merkle_root=hash_to_str(header[36:68]),
|
||||
timestamp=struct.unpack('<I', header[100:104])[0],
|
||||
reserved=hash_to_str(header[72:100]),
|
||||
bits=struct.unpack('<I', header[104:108])[0],
|
||||
nonce=hash_to_str(header[108:140]),
|
||||
solution=hash_to_str(header[140:])
|
||||
)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class BitcoinGoldTestnet(BitcoinGold):
|
||||
FORK_HEIGHT = 1
|
||||
SHORTNAME = "TBTG"
|
||||
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")
|
||||
TX_COUNT = 0
|
||||
TX_COUNT_HEIGHT = 1
|
||||
NET = 'testnet'
|
||||
RPC_PORT = 18338
|
||||
GENESIS_HASH = ('00000000e0781ebe24b91eedc293adfe'
|
||||
'a2f557b53ec379e78959de3853e6f9f6')
|
||||
|
||||
|
||||
class BitcoinGoldRegtest(BitcoinGold):
|
||||
FORK_HEIGHT = 2000
|
||||
SHORTNAME = "TBTG"
|
||||
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")
|
||||
TX_COUNT = 0
|
||||
TX_COUNT_HEIGHT = 1
|
||||
NET = 'regtest'
|
||||
RPC_PORT = 18444
|
||||
GENESIS_HASH = ('0f9188f13cb7b2c71f2a335e3a4fc328'
|
||||
'bf5beb436012afca590b1a11466e2206')
|
||||
|
||||
|
||||
class Emercoin(Coin):
|
||||
NAME = "Emercoin"
|
||||
@ -537,11 +587,6 @@ class BitcoinSegwitTestnet(BitcoinTestnetMixin, Coin):
|
||||
]
|
||||
|
||||
|
||||
class BitcoinGoldTestnet(BitcoinTestnetMixin, BitcoinGold):
|
||||
NAME = "BitcoinGold"
|
||||
FORK_HEIGHT = 1210320
|
||||
|
||||
|
||||
class BitcoinSegwitRegtest(BitcoinSegwitTestnet):
|
||||
NAME = "BitcoinSegwit"
|
||||
NET = "regtest"
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from lib.coins import Litecoin, BitcoinCash, Zcash, Emercoin
|
||||
from lib.coins import Litecoin, BitcoinCash, Zcash, Emercoin, BitcoinGold
|
||||
from lib.hash import Base58
|
||||
|
||||
addresses = [
|
||||
@ -34,6 +34,10 @@ addresses = [
|
||||
"206168f5322583ff37f8e55665a4789ae8963532", "b8cb80b26e8932f5b12a7e"),
|
||||
(BitcoinCash, "3GxRZWkJufR5XA8hnNJgQ2gkASSheoBcmW",
|
||||
"a773db925b09add367dcc253c1f9bbc1d11ec6fd", "062d8515e50cb92b8a3a73"),
|
||||
(BitcoinGold, "GZjH8pETu5xXd5DTt5VAqS9giooLNoHjnJ",
|
||||
"ae40655d7006806fd668248d10e7822c0b774dab", "3a1af301b378ad92493b17"),
|
||||
(BitcoinGold, "AXfENBm9FP1PMa8AWnVPZZ4tHEwBiqNZav",
|
||||
"ae40655d7006806fd668248d10e7822c0b774dab", "cb3db4271432c0ac9f88d5"),
|
||||
(Emercoin, "ELAeVHQg2mmdTTrTrZSzMgAQyXfC9TSRys",
|
||||
"210c4482ad8eacb0d349992973608300677adb15", "d71f2df4ef1b397088d731"),
|
||||
(Litecoin, "LNBAaWuZmipg29WXfz5dtAm1pjo8FEH8yg",
|
||||
|
||||
@ -92,6 +92,16 @@ def test_COIN_NET():
|
||||
os.environ['NET'] = 'testnet'
|
||||
e = Env()
|
||||
assert e.coin == lib_coins.LitecoinTestnet
|
||||
os.environ.pop('NET')
|
||||
os.environ['COIN'] = ' BitcoinGold '
|
||||
e = Env()
|
||||
assert e.coin == lib_coins.BitcoinGold
|
||||
os.environ['NET'] = 'testnet'
|
||||
e = Env()
|
||||
assert e.coin == lib_coins.BitcoinGoldTestnet
|
||||
os.environ['NET'] = 'regtest'
|
||||
e = Env()
|
||||
assert e.coin == lib_coins.BitcoinGoldRegtest
|
||||
|
||||
def test_CACHE_MB():
|
||||
assert_integer('CACHE_MB', 'cache_MB', 1200)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user