StratisBitcoinFullNode
StratisBitcoinFullNode copied to clipboard
ElectrumX compatibilty
We have been trying unsuccessfully to use StratisBitcoinFullNode with (electrumx).
add at the end of electrumx/electrumx/lib/coins.py
class Stratis(Coin):
NAME = "Stratis"
SHORTNAME = "STRAT"
NET = "mainnet"
XPUB_VERBYTES = bytes.fromhex("0488C21E")
XPRV_VERBYTES = bytes.fromhex("0488B2DD")
P2PKH_VERBYTE = bytes.fromhex("3f")
P2SH_VERBYTES = [bytes.fromhex("7d")]
WIF_BYTE = bytes.fromhex("bf")
GENESIS_HASH = ('0000066e91e46e5a264d42c89e120496'
'3b2ee6be230b443e9159020539d972af')
DESERIALIZER = lib_tx.DeserializerTxTime
DAEMON = daemon.LegacyRPCDaemon
TX_COUNT = 1
TX_COUNT_HEIGHT = 1
TX_PER_BLOCK = 1
RPC_PORT = 26174
REORG_LIMIT = 5000
@classmethod
def header_hash(cls, header):
return pow_hash.x13(header)
I've managed to start the syncing process by modifying the daemon.py
and coins.py
on the ElectrumX side and removing charset header from the Stratis FullNode response. I suppose that PR #3923 might have also played a role.
I have installed a python module x13-hash in addition to the recommended modules.
Currently I can see that the genesis block have been validated and there are no errors being printed to the console.
INFO:electrumx:ElectrumX server starting
INFO:electrumx:logging level: INFO
INFO:Controller:Python version: 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
INFO:Controller:software version: ElectrumX 1.12
INFO:Controller:aiorpcX version: 0.18.3
INFO:Controller:supported protocol versions: 1.4-1.4.2
INFO:Controller:event loop policy: None
INFO:Controller:reorg limit is 500 blocks
INFO:LegacyRPCDaemon:daemon #1 at 10.0.75.1:16174/ (current)
INFO:DB:switching current directory to /root/database
INFO:DB:using leveldb for DB backend
INFO:DB:created new database
INFO:DB:creating metadata directory
INFO:DB:DB version: 6
INFO:DB:coin: Stratis
INFO:DB:network: mainnet
INFO:DB:height: -1
INFO:DB:tip: 0000000000000000000000000000000000000000000000000000000000000000
INFO:DB:tx count: 0
INFO:DB:flushing DB cache at 1,200 MB
INFO:DB:sync time so far: 00s
INFO:History:history DB version: 0
INFO:History:flush count: 0
INFO:Prefetcher:catching up to daemon height 17,899 (17,900 blocks behind)
INFO:Prefetcher:verified genesis block with hash 0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af
WARNING:BlockProcessor:daemon blocks do not form a chain; resetting the prefetcher
Stratis FullNode change https://github.com/stratisproject/StratisBitcoinFullNode/blob/eea4aee1629c4fb85e2841ee9345f84433d09a4d/src/Stratis.Bitcoin.Features.RPC/RPCMiddleware.cs#L205
ElectrumX changes
File daemon.py
index ff6366a..7d5630b 100644
--- a/electrumx/server/daemon.py
+++ b/electrumx/server/daemon.py
@@ -371,7 +371,7 @@ class LegacyRPCDaemon(Daemon):
def timestamp_safe(self, t):
if isinstance(t, int):
return t
- return timegm(time.strptime(t, "%Y-%m-%d %H:%M:%S %Z"))
+ return int(t)
class DecredDaemon(Daemon):
File coins.py
NAME = "Stratis"
SHORTNAME = "STRAT"
NET = "mainnet"
XPUB_VERBYTES = bytes.fromhex("0488C21E")
XPRV_VERBYTES = bytes.fromhex("0488B2DD")
P2PKH_VERBYTE = bytes.fromhex("3f")
P2SH_VERBYTES = [bytes.fromhex("7d")]
WIF_BYTE = bytes.fromhex("bf")
GENESIS_HASH = ('0000066e91e46e5a264d42c89e120496'
'3b2ee6be230b443e9159020539d972af')
DESERIALIZER = lib_tx.DeserializerTxTime
DAEMON = daemon.LegacyRPCDaemon
TX_COUNT = 1
TX_COUNT_HEIGHT = 1
TX_PER_BLOCK = 1
RPC_PORT = 16174
REORG_LIMIT = 500
@classmethod
def header_hash(cls, header):
import x13_hash
return x13_hash.getPoWHash(header)
I solved this: httpContext.Response.ContentType = "application/json; charset=utf-8";
by changing electrumx/server/daemon.py from
kind = resp.headers.get('Content-Type', None)
if kind == 'application/json':
to
kind = resp.headers.get('Content-Type', None)
if 'application/json' in kind:
if 'application/json' in kind:
seems more correct in anycase
I've managed to start the syncing process by modifying the
daemon.py
andcoins.py
on the ElectrumX side and removing charset header from the Stratis FullNode response. I suppose that PR #3923 might have also played a role.I have installed a python module x13-hash in addition to the recommended modules.
Currently I can see that the genesis block have been validated and there are no errors being printed to the console.
INFO:electrumx:ElectrumX server starting INFO:electrumx:logging level: INFO INFO:Controller:Python version: 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] INFO:Controller:software version: ElectrumX 1.12 INFO:Controller:aiorpcX version: 0.18.3 INFO:Controller:supported protocol versions: 1.4-1.4.2 INFO:Controller:event loop policy: None INFO:Controller:reorg limit is 500 blocks INFO:LegacyRPCDaemon:daemon #1 at 10.0.75.1:16174/ (current) INFO:DB:switching current directory to /root/database INFO:DB:using leveldb for DB backend INFO:DB:created new database INFO:DB:creating metadata directory INFO:DB:DB version: 6 INFO:DB:coin: Stratis INFO:DB:network: mainnet INFO:DB:height: -1 INFO:DB:tip: 0000000000000000000000000000000000000000000000000000000000000000 INFO:DB:tx count: 0 INFO:DB:flushing DB cache at 1,200 MB INFO:DB:sync time so far: 00s INFO:History:history DB version: 0 INFO:History:flush count: 0 INFO:Prefetcher:catching up to daemon height 17,899 (17,900 blocks behind) INFO:Prefetcher:verified genesis block with hash 0000066e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af WARNING:BlockProcessor:daemon blocks do not form a chain; resetting the prefetcher
2019-09-05 22:00:18,896:INFO:Prefetcher:catching up to daemon height 1,454,116 (
1,454,117 blocks behind)
2019-09-05 22:00:18,969:INFO:Prefetcher:verified genesis block with hash 0000066
e91e46e5a264d42c89e1204963b2ee6be230b443e9159020539d972af
2019-09-05 22:00:18,972:WARNING:BlockProcessor:daemon blocks do not form a chain
; resetting the prefetcher
2019-09-05 22:00:18,993:INFO:BlockProcessor:flushing to DB for a clean shutdown.
..
2019-09-05 22:00:18,993:INFO:SessionManager:closing down RPC listening servers
ERROR:root:task crashed: <Task finished coro=<Controller.serve() done, defined a
t /electrumx/electrumx/server/controller.py:81> exception=TypeError('str
ing indices must be integers',)>
@onnateldome You need to patch daemon.py as per my diff above.
The RPC call returns a time in Unix epoch and you try to parse it as a string. I realise that my solution will need to be extended to cater for other node types but it stands to demonstrate a valid solution.