|
|
@ -396,7 +396,6 @@ class DashElectrumX(ElectrumX): |
|
|
|
super().__init__(*args, **kwargs) |
|
|
|
self.electrumx_handlers['masternode.announce.broadcast'] = self.masternode_announce_broadcast |
|
|
|
self.electrumx_handlers['masternode.subscribe'] = self.masternode_subscribe |
|
|
|
self.subscribe_mns = False |
|
|
|
self.mns = set() |
|
|
|
|
|
|
|
async def notify(self, height, touched): |
|
|
@ -404,20 +403,19 @@ class DashElectrumX(ElectrumX): |
|
|
|
|
|
|
|
await super().notify(height, touched) |
|
|
|
|
|
|
|
if self.subscribe_mns: |
|
|
|
for masternode in self.mns: |
|
|
|
status = await self.daemon.masternode_list(['status', masternode]) |
|
|
|
payload = { |
|
|
|
'id': None, |
|
|
|
'method': 'masternode.subscribe', |
|
|
|
'params': [masternode], |
|
|
|
'result': status.get(masternode), |
|
|
|
} |
|
|
|
self.send_binary(self.encode_payload(payload)) |
|
|
|
for masternode in self.mns: |
|
|
|
status = await self.daemon.masternode_list(['status', masternode]) |
|
|
|
payload = { |
|
|
|
'id': None, |
|
|
|
'method': 'masternode.subscribe', |
|
|
|
'params': [masternode], |
|
|
|
'result': status.get(masternode), |
|
|
|
} |
|
|
|
self.send_binary(self.encode_payload(payload)) |
|
|
|
|
|
|
|
def server_version(self, client_name=None, protocol_version=None): |
|
|
|
'''Returns the server version as a string. |
|
|
|
ForcE version string response for Electrum-Dash 2.6.4 |
|
|
|
Force version string response for Electrum-Dash 2.6.4 |
|
|
|
''' |
|
|
|
|
|
|
|
default_return = super().server_version(client_name, protocol_version) |
|
|
@ -427,15 +425,10 @@ class DashElectrumX(ElectrumX): |
|
|
|
|
|
|
|
# Masternode command handlers |
|
|
|
async def masternode_announce_broadcast(self, signmnb): |
|
|
|
'''Pass through the parameters to the daemon. |
|
|
|
'''Pass through the masternode announce message to be broadcast by the daemon.''' |
|
|
|
|
|
|
|
An ugly API: current Electrum clients only pass the masternode |
|
|
|
broadcast message in hex and expect error messages to be returned in |
|
|
|
the result field. And the server shouldn't be doing the client's |
|
|
|
user interface job here. |
|
|
|
''' |
|
|
|
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] |
|
|
@ -448,8 +441,8 @@ class DashElectrumX(ElectrumX): |
|
|
|
|
|
|
|
async def masternode_subscribe(self, vin): |
|
|
|
'''Returns the status of masternode.''' |
|
|
|
result = await self.daemon.masternode_list(['status',vin]) |
|
|
|
result = await self.daemon.masternode_list(['status', vin]) |
|
|
|
if result is not None: |
|
|
|
self.mns.add(vin) |
|
|
|
self.subscribe_mns = True |
|
|
|
return result.get(vin) |
|
|
|
return result.get(vin) |
|
|
|
return None |
|
|
|