mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
add PayServer settings to settings_dialog
This commit is contained in:
parent
96d3c36e4a
commit
28da62f51b
3 changed files with 80 additions and 30 deletions
|
@ -185,9 +185,9 @@ class HttpServer(Logger):
|
||||||
await self.pending[key].set()
|
await self.pending[key].set()
|
||||||
|
|
||||||
async def run(self):
|
async def run(self):
|
||||||
host = self.config.get('http_host', 'localhost')
|
host = self.config.get('payserver_host', 'localhost')
|
||||||
port = self.config.get('http_port')
|
port = self.config.get('payserver_port')
|
||||||
root = self.config.get('http_root', '/r')
|
root = self.config.get('payserver_root', '/r')
|
||||||
ssl_keyfile = self.config.get('ssl_keyfile')
|
ssl_keyfile = self.config.get('ssl_keyfile')
|
||||||
ssl_certfile = self.config.get('ssl_certfile')
|
ssl_certfile = self.config.get('ssl_certfile')
|
||||||
if ssl_keyfile and ssl_certfile:
|
if ssl_keyfile and ssl_certfile:
|
||||||
|
@ -289,7 +289,7 @@ class Daemon(Logger):
|
||||||
if listen_jsonrpc:
|
if listen_jsonrpc:
|
||||||
jobs.append(self.start_jsonrpc(config, fd))
|
jobs.append(self.start_jsonrpc(config, fd))
|
||||||
# request server
|
# request server
|
||||||
if self.config.get('http_port'):
|
if self.config.get('payserver_port'):
|
||||||
self.http_server = HttpServer(self)
|
self.http_server = HttpServer(self)
|
||||||
jobs.append(self.http_server.run())
|
jobs.append(self.http_server.run())
|
||||||
# server-side watchtower
|
# server-side watchtower
|
||||||
|
|
|
@ -181,29 +181,38 @@ class SettingsDialog(WindowModalDialog):
|
||||||
self.alias_e.editingFinished.connect(self.on_alias_edit)
|
self.alias_e.editingFinished.connect(self.on_alias_edit)
|
||||||
oa_widgets.append((alias_label, self.alias_e))
|
oa_widgets.append((alias_label, self.alias_e))
|
||||||
|
|
||||||
# SSL certificate
|
# PayServer
|
||||||
msg = ' '.join([
|
ssl_cert = self.config.get('ssl_certfile')
|
||||||
_('SSL certificate used to sign payment requests.'),
|
ssl_cert_label = HelpLabel(_('SSL cert file') + ':', 'certificate file, with intermediate certificates if needed')
|
||||||
_('Use setconfig to set ssl_chain and ssl_privkey.'),
|
self.ssl_cert_e = QPushButton(ssl_cert)
|
||||||
])
|
self.ssl_cert_e.clicked.connect(self.select_ssl_certfile)
|
||||||
if self.config.get('ssl_keyfile') and self.config.get('ssl_certfile'):
|
server_widgets.append((ssl_cert_label, self.ssl_cert_e))
|
||||||
try:
|
|
||||||
SSL_identity = paymentrequest.check_ssl_config(self.config)
|
|
||||||
SSL_error = None
|
|
||||||
except BaseException as e:
|
|
||||||
SSL_identity = "error"
|
|
||||||
SSL_error = repr(e)
|
|
||||||
else:
|
|
||||||
SSL_identity = ""
|
|
||||||
SSL_error = None
|
|
||||||
SSL_id_label = HelpLabel(_('SSL certificate') + ':', msg)
|
|
||||||
SSL_id_e = QLineEdit(SSL_identity)
|
|
||||||
SSL_id_e.setStyleSheet((ColorScheme.RED if SSL_error else ColorScheme.GREEN).as_stylesheet(True) if SSL_identity else '')
|
|
||||||
if SSL_error:
|
|
||||||
SSL_id_e.setToolTip(SSL_error)
|
|
||||||
SSL_id_e.setReadOnly(True)
|
|
||||||
server_widgets.append((SSL_id_label, SSL_id_e))
|
|
||||||
|
|
||||||
|
ssl_privkey = self.config.get('ssl_keyfile')
|
||||||
|
ssl_privkey_label = HelpLabel(_('SSL key file') + ':', '')
|
||||||
|
self.ssl_privkey_e = QPushButton(ssl_privkey)
|
||||||
|
self.ssl_cert_e.clicked.connect(self.select_ssl_certfile)
|
||||||
|
server_widgets.append((ssl_privkey_label, self.ssl_privkey_e))
|
||||||
|
|
||||||
|
ssl_domain_label = HelpLabel(_('SSL domain') + ':', '')
|
||||||
|
self.ssl_domain_e = QLineEdit('')
|
||||||
|
self.ssl_domain_e.setReadOnly(True)
|
||||||
|
server_widgets.append((ssl_domain_label, self.ssl_domain_e))
|
||||||
|
|
||||||
|
payserver_host = self.config.get('payserver_host', 'localhost')
|
||||||
|
payserver_host_label = HelpLabel(_('Hostname') + ':', 'must match your ssl domain')
|
||||||
|
self.payserver_host_e = QLineEdit(payserver_host)
|
||||||
|
self.payserver_host_e.editingFinished.connect(self.on_payserver_host)
|
||||||
|
server_widgets.append((payserver_host_label, self.payserver_host_e))
|
||||||
|
|
||||||
|
payserver_port = self.config.get('payserver_port')
|
||||||
|
payserver_port_label = HelpLabel(_('Port') + ':', msg)
|
||||||
|
self.payserver_port_e = QLineEdit(str(payserver_port))
|
||||||
|
self.payserver_port_e.editingFinished.connect(self.on_payserver_port)
|
||||||
|
server_widgets.append((payserver_port_label, self.payserver_port_e))
|
||||||
|
self.check_ssl_config()
|
||||||
|
|
||||||
|
# units
|
||||||
units = base_units_list
|
units = base_units_list
|
||||||
msg = (_('Base unit of your wallet.')
|
msg = (_('Base unit of your wallet.')
|
||||||
+ '\n1 BTC = 1000 mBTC. 1 mBTC = 1000 bits. 1 bit = 100 sat.\n'
|
+ '\n1 BTC = 1000 mBTC. 1 mBTC = 1000 bits. 1 bit = 100 sat.\n'
|
||||||
|
@ -498,3 +507,44 @@ class SettingsDialog(WindowModalDialog):
|
||||||
self.config.set_key('alias', alias, True)
|
self.config.set_key('alias', alias, True)
|
||||||
if alias:
|
if alias:
|
||||||
self.window.fetch_alias()
|
self.window.fetch_alias()
|
||||||
|
|
||||||
|
def select_ssl_certfile(self, b):
|
||||||
|
name = self.config.get('ssl_certfile', '')
|
||||||
|
filename, __ = QFileDialog.getOpenFileName(self, "Select your SSL certificate file", name)
|
||||||
|
if filename:
|
||||||
|
self.config.set_key('ssl_certfile', filename)
|
||||||
|
self.ssl_cert_e.setText(filename)
|
||||||
|
self.check_ssl_config()
|
||||||
|
|
||||||
|
def select_ssl_privkey(self, b):
|
||||||
|
name = self.config.get('ssl_privkey', '')
|
||||||
|
filename, __ = QFileDialog.getOpenFileName(self, "Select your SSL private key file", name)
|
||||||
|
if filename:
|
||||||
|
self.config.set_key('ssl_privkey', filename)
|
||||||
|
self.ssl_cert_e.setText(filename)
|
||||||
|
self.check_ssl_config()
|
||||||
|
|
||||||
|
def check_ssl_config(self):
|
||||||
|
if self.config.get('ssl_keyfile') and self.config.get('ssl_certfile'):
|
||||||
|
try:
|
||||||
|
SSL_identity = paymentrequest.check_ssl_config(self.config)
|
||||||
|
SSL_error = None
|
||||||
|
except BaseException as e:
|
||||||
|
SSL_identity = "error"
|
||||||
|
SSL_error = repr(e)
|
||||||
|
else:
|
||||||
|
SSL_identity = ""
|
||||||
|
SSL_error = None
|
||||||
|
self.ssl_domain_e.setText(SSL_identity)
|
||||||
|
s = (ColorScheme.RED if SSL_error else ColorScheme.GREEN).as_stylesheet(True) if SSL_identity else ''
|
||||||
|
self.ssl_domain_e.setStyleSheet(s)
|
||||||
|
if SSL_error:
|
||||||
|
self.ssl_domain_e.setToolTip(SSL_error)
|
||||||
|
|
||||||
|
def on_payserver_host(self):
|
||||||
|
hostname = str(self.payserver_host_e.text())
|
||||||
|
self.config.set_key('payserver_host', hostname, True)
|
||||||
|
|
||||||
|
def on_payserver_port(self):
|
||||||
|
port = int(self.payserver_port_e.text())
|
||||||
|
self.config.set_key('payserver_port', port, True)
|
||||||
|
|
|
@ -1329,10 +1329,10 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||||
req = self.lnworker.get_request(key)
|
req = self.lnworker.get_request(key)
|
||||||
if not req:
|
if not req:
|
||||||
return
|
return
|
||||||
if config.get('http_port'):
|
if config.get('payserver_port'):
|
||||||
host = config.get('http_host', 'localhost')
|
host = config.get('payserver_host', 'localhost')
|
||||||
port = config.get('http_port')
|
port = config.get('payserver_port')
|
||||||
root = config.get('http_root', '/r')
|
root = config.get('payserver_root', '/r')
|
||||||
use_ssl = bool(config.get('ssl_keyfile'))
|
use_ssl = bool(config.get('ssl_keyfile'))
|
||||||
protocol = 'https' if use_ssl else 'http'
|
protocol = 'https' if use_ssl else 'http'
|
||||||
base = '%s://%s:%d'%(protocol, host, port)
|
base = '%s://%s:%d'%(protocol, host, port)
|
||||||
|
|
Loading…
Add table
Reference in a new issue