The session needs to handle the version command.
This commit is contained in:
parent
b03a44ca5a
commit
9a8c598fa8
@ -95,7 +95,7 @@ class Controller(util.LoggedClass):
|
||||
'block.get_header block.get_chunk estimatefee relayfee '
|
||||
'transaction.get transaction.get_merkle utxo.get_address'),
|
||||
('server',
|
||||
'banner donation_address peers.subscribe version'),
|
||||
'banner donation_address peers.subscribe'),
|
||||
]
|
||||
self.electrumx_handlers = {'.'.join([prefix, suffix]):
|
||||
getattr(self, suffix.replace('.', '_'))
|
||||
@ -886,15 +886,3 @@ class Controller(util.LoggedClass):
|
||||
|
||||
Despite the name this is not currently treated as a subscription.'''
|
||||
return list(self.irc.peers.values())
|
||||
|
||||
async def version(self, client_name=None, protocol_version=None):
|
||||
'''Returns the server version as a string.
|
||||
|
||||
client_name: a string identifying the client
|
||||
protocol_version: the protocol version spoken by the client
|
||||
'''
|
||||
if client_name:
|
||||
self.client = str(client_name)[:15]
|
||||
if protocol_version is not None:
|
||||
self.protocol_version = protocol_version
|
||||
return VERSION
|
||||
|
||||
@ -13,6 +13,7 @@ import traceback
|
||||
|
||||
from lib.jsonrpc import JSONRPC, RPCError
|
||||
from server.daemon import DaemonError
|
||||
from server.version import VERSION
|
||||
|
||||
|
||||
class Session(JSONRPC):
|
||||
@ -123,6 +124,7 @@ class ElectrumX(Session):
|
||||
'blockchain.headers.subscribe': self.headers_subscribe,
|
||||
'blockchain.numblocks.subscribe': self.numblocks_subscribe,
|
||||
'blockchain.transaction.broadcast': self.transaction_broadcast,
|
||||
'server.version': self.version,
|
||||
}
|
||||
|
||||
def sub_count(self):
|
||||
@ -191,6 +193,18 @@ class ElectrumX(Session):
|
||||
self.hashX_subs[hashX] = address
|
||||
return status
|
||||
|
||||
async def version(self, client_name=None, protocol_version=None):
|
||||
'''Returns the server version as a string.
|
||||
|
||||
client_name: a string identifying the client
|
||||
protocol_version: the protocol version spoken by the client
|
||||
'''
|
||||
if client_name:
|
||||
self.client = str(client_name)[:15]
|
||||
if protocol_version is not None:
|
||||
self.protocol_version = protocol_version
|
||||
return VERSION
|
||||
|
||||
async def transaction_broadcast(self, raw_tx):
|
||||
'''Broadcast a raw transaction to the network.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user