diff --git a/lib/coins.py b/lib/coins.py index 8fe4b05..2f3726f 100644 --- a/lib/coins.py +++ b/lib/coins.py @@ -42,7 +42,8 @@ from lib.script import ScriptPubKey from lib.tx import Deserializer, DeserializerSegWit, DeserializerAuxPow, \ DeserializerZcash, DeserializerTxTime, DeserializerReddcoin from server.block_processor import BlockProcessor -from server.daemon import Daemon, DashDaemon, LegacyRPCDaemon, FujiDaemon +from server.daemon import Daemon, DashDaemon, LegacyRPCDaemon,\ + FakeEstimateFeeDaemon from server.session import ElectrumX, DashElectrumX @@ -917,6 +918,7 @@ class Monacoin(Coin): 'electrumx2.movsign.info t', ] + class Crown(AuxPowMixin, Coin): NAME = "Crown" SHORTNAME = "CRW" @@ -924,7 +926,7 @@ class Crown(AuxPowMixin, Coin): XPUB_VERBYTES = bytes.fromhex("0488b21e") XPRV_VERBYTES = bytes.fromhex("0488ade4") P2PKH_VERBYTE = bytes.fromhex("00") - P2SH_VERBYTES = [bytes.fromhex("05")] + P2SH_VERBYTES = [bytes.fromhex("1c")] WIF_BYTE = bytes.fromhex("80") GENESIS_HASH = ('0000000085370d5e122f64f4ab19c686' '14ff3df78c8d13cb814fd7e69a1dc6da') @@ -932,6 +934,8 @@ class Crown(AuxPowMixin, Coin): TX_COUNT_HEIGHT = 1268206 TX_PER_BLOCK = 10 RPC_PORT = 9341 + REORG_LIMIT = 1000 + class Fujicoin(Coin): NAME = "Fujicoin" @@ -944,10 +948,11 @@ class Fujicoin(Coin): WIF_BYTE = bytes.fromhex("a4") GENESIS_HASH = ('adb6d9cfd74075e7f91608add4bd2a2e' 'a636f70856183086842667a1597714a0') -# DESERIALIZER = DeserializerSegWit - DAEMON = FujiDaemon + ESTIMATE_FEE = 0.001 + RELAY_FEE = 0.001 + DAEMON = FakeEstimateFeeDaemon TX_COUNT = 170478 TX_COUNT_HEIGHT = 1521676 TX_PER_BLOCK = 1 RPC_PORT = 3776 -# REORG_LIMIT = 1000 + REORG_LIMIT = 1000 diff --git a/server/controller.py b/server/controller.py index 3de612b..8a13d5f 100644 --- a/server/controller.py +++ b/server/controller.py @@ -47,7 +47,8 @@ class Controller(util.LoggedClass): self.loop.set_default_executor(self.executor) self.start_time = time.time() self.coin = env.coin - self.daemon = self.coin.DAEMON(env.coin.daemon_urls(env.daemon_url)) + self.daemon = self.coin.DAEMON(self.coin, + env.coin.daemon_urls(env.daemon_url)) self.bp = self.coin.BLOCK_PROCESSOR(env, self, self.daemon) self.mempool = MemPool(self.bp, self) self.peer_mgr = PeerManager(env, self) diff --git a/server/daemon.py b/server/daemon.py index b078620..d39fa36 100644 --- a/server/daemon.py +++ b/server/daemon.py @@ -34,8 +34,9 @@ class Daemon(util.LoggedClass): class DaemonWarmingUpError(Exception): '''Raised when the daemon returns an error in its results.''' - def __init__(self, urls): + def __init__(self, coin, urls): super().__init__() + self.coin = coin self.set_urls(urls) self._height = None self._mempool_hashes = set() @@ -272,18 +273,17 @@ class DashDaemon(Daemon): '''Return the masternode status.''' return await self._send_single('masternodelist', params) -class FujiDaemon(Daemon): - '''This is a measure against coin daemon which does not have the 'estimatefee' command. - When the electrum is in 'Use dynamic fees' mode, the estimatefee does not return from electrum-X, so the user can not remit money. - See class Fujicoin() in lib/coins.py for usage.''' +class FakeEstimateFeeDaemon(Daemon): + '''Daemon that simulates estimatefee and relayfee RPC calls. Coin that + wants to use this daemon must define ESTIMATE_FEE & RELAY_FEE''' async def estimatefee(self, params): '''Return the fee estimate for the given parameters.''' - return 0.001 + return self.coin.ESTIMATE_FEE async def relayfee(self): '''The minimum fee a low-priority tx must pay in order to be accepted to the daemon's memory pool.''' - return 0.001 + return self.coin.RELAY_FEE class LegacyRPCDaemon(Daemon): '''Handles connections to a daemon at the given URL. @@ -297,7 +297,7 @@ class LegacyRPCDaemon(Daemon): async def raw_blocks(self, hex_hashes): '''Return the raw binary blocks with the given hex hashes.''' - params_iterable = ((h, False) for h in hex_hashes) + params_iterable = ((h, ) for h in hex_hashes) block_info = await self._send_vector('getblock', params_iterable) blocks = [] diff --git a/server/session.py b/server/session.py index a7e1701..0fc0fcd 100644 --- a/server/session.py +++ b/server/session.py @@ -394,13 +394,14 @@ class DashElectrumX(ElectrumX): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.electrumx_handlers['masternode.announce.broadcast'] = self.masternode_announce_broadcast - self.electrumx_handlers['masternode.subscribe'] = self.masternode_subscribe + self.electrumx_handlers['masternode.announce.broadcast'] =\ + self.masternode_announce_broadcast + self.electrumx_handlers['masternode.subscribe'] =\ + self.masternode_subscribe self.mns = set() async def notify(self, height, touched): '''Notify the client about changes in masternode list.''' - await super().notify(height, touched) for masternode in self.mns: @@ -418,7 +419,6 @@ class DashElectrumX(ElectrumX): Force version string response for Electrum-Dash 2.6.4 client caused by https://github.com/dashpay/electrum-dash/commit/638cf6c0aeb7be14a85ad98f873791cb7b49ee29 ''' - default_return = super().server_version(client_name, protocol_version) if self.client == '2.6.4': return '1.0' @@ -426,10 +426,11 @@ class DashElectrumX(ElectrumX): # Masternode command handlers async def masternode_announce_broadcast(self, signmnb): - '''Pass through the masternode announce message to be broadcast by the daemon.''' - + '''Pass through the masternode announce message to be broadcast + by the daemon.''' try: - mnb_info = await self.daemon.masternode_broadcast(['relay', signmnb]) + mnb_info = await self.daemon.masternode_broadcast( + ['relay', signmnb]) return mnb_info except DaemonError as e: error = e.args[0]