commit 7cecf2f6906774f4ecaa234516b4f9f769c10113
parent ca12144acb227a3d27bdf8d54d3c49aac64df114
Author: parazyd <parazyd@dyne.org>
Date: Wed, 7 Apr 2021 20:52:10 +0200
Implement server.features
Diffstat:
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/electrumobelisk/protocol.py b/electrumobelisk/protocol.py
@@ -330,7 +330,25 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902
return {"result": DONATION_ADDR}
async def server_features(self, query):
- return
+ cfg = self.server_cfg
+ return {
+ "result": {
+ "genesis_hash": self.genesis,
+ "hosts": {
+ cfg["server_hostname"]: {
+ "tcp_port":
+ None if cfg["using_tls"] else cfg["server_port"],
+ "ssl_port":
+ cfg["server_port"] if cfg["using_tls"] else None,
+ },
+ },
+ "protocol_max": SERVER_PROTO_MAX,
+ "protocol_min": SERVER_PROTO_MIN,
+ "pruning": None,
+ "server_version": f"obelisk {VERSION}",
+ "hash_function": "sha256",
+ }
+ }
async def server_peers_subscribe(self, query): # pylint: disable=W0613
# Help wanted
diff --git a/obelisk.py b/obelisk.py
@@ -75,8 +75,9 @@ async def run_electrum_server(config, chain):
log = getLogger("obelisk")
host = config.get("obelisk", "host")
port = int(config.get("obelisk", "port"))
+ usetls = config.getboolean("obelisk", "usetls", fallback=False)
- if config.getboolean("obelisk", "usetls", fallback=True):
+ if usetls:
certfile, keyfile = get_certs(config)
log.debug("Using TLS with keypair: %s , %s", certfile, keyfile)
@@ -95,6 +96,9 @@ async def run_electrum_server(config, chain):
server_cfg = {}
server_cfg["torhostport"] = (tor_host, tor_port)
server_cfg["broadcast_method"] = broadcast_method
+ server_cfg["server_hostname"] = "localhost" # TODO: <- should be public?
+ server_cfg["server_port"] = port
+ server_cfg["using_tls"] = usetls
protocol = ElectrumProtocol(log, chain, endpoints, server_cfg)