Browse Source

Dash: return errors in JSON error field for protocol 1.1

master
Neil Booth 8 years ago
parent
commit
4f5a219438
  1. 34
      server/session.py

34
server/session.py

@ -468,12 +468,17 @@ class DashElectrumX(ElectrumX):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*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.mns = set() self.mns = set()
def set_protocol_handlers(self, ptuple):
super().set_protocol_handlers(ptuple)
mna_broadcast = (self.masternode_announce_broadcast if ptuple >= (1, 1)
else masternode_announce_broadcast_1_0)
self.electrumx_handlers.update({
'masternode.announce.broadcast': mna_broadcast,
'masternode.subscribe': self.masternode_subscribe,
})
async def notify(self, height, touched): async def notify(self, height, touched):
'''Notify the client about changes in masternode list.''' '''Notify the client about changes in masternode list.'''
await super().notify(height, touched) await super().notify(height, touched)
@ -503,17 +508,22 @@ class DashElectrumX(ElectrumX):
'''Pass through the masternode announce message to be broadcast '''Pass through the masternode announce message to be broadcast
by the daemon.''' by the daemon.'''
try: try:
mnb_info = await self.daemon.masternode_broadcast( return await self.daemon.masternode_broadcast(['relay', signmnb])
['relay', signmnb])
return mnb_info
except DaemonError as e: except DaemonError as e:
error = e.args[0] error, = e.args
message = error['message'] message = error['message']
self.log_info('masternode_broadcast: {}'.format(message)) self.log_info('masternode_broadcast: {}'.format(message))
return ( raise RPCError('the masternode broadcast was rejected.'
'The masternode broadcast was rejected. ({})\n[{}]' '\n\n{}\n[{}]'.format(message, signmnb))
.format(message, signmnb)
) async def masternode_announce_broadcast_1_0(self, signmnb):
'''Pass through the masternode announce message to be broadcast
by the daemon.'''
# An ugly API, like the old Electrum transaction broadcast API
try:
return await self.masternode_announce_broadcast(signmnb)
except RPCError as e:
return e.message
async def masternode_subscribe(self, vin): async def masternode_subscribe(self, vin):
'''Returns the status of masternode.''' '''Returns the status of masternode.'''

Loading…
Cancel
Save