Browse Source

payjoin: make tor control host configurable

master
nixbitcoin 5 years ago
parent
commit
fde39a7135
No known key found for this signature in database
GPG Key ID: DD11F9AD5308B3BA
  1. 7
      jmclient/jmclient/configure.py
  2. 10
      jmclient/jmclient/payjoin.py

7
jmclient/jmclient/configure.py

@ -329,6 +329,13 @@ min_fee_rate = 1.1
# for payjoins to hidden service endpoints, the socks5 configuration: # for payjoins to hidden service endpoints, the socks5 configuration:
onion_socks5_host = localhost onion_socks5_host = localhost
onion_socks5_port = 9050 onion_socks5_port = 9050
# for payjoin onion service creation, the tor control configuration:
tor_control_host = localhost
# or, to use a UNIX socket
# control_host = unix:/var/run/tor/control
tor_control_port = 9051
# in some exceptional case the HS may be SSL configured, # in some exceptional case the HS may be SSL configured,
# this feature is not yet implemented in code, but here for the # this feature is not yet implemented in code, but here for the
# future: # future:

10
jmclient/jmclient/payjoin.py

@ -8,7 +8,7 @@ from twisted.web.resource import Resource, ErrorPage
from twisted.web.iweb import IPolicyForHTTPS from twisted.web.iweb import IPolicyForHTTPS
from twisted.internet.ssl import CertificateOptions from twisted.internet.ssl import CertificateOptions
from twisted.internet.error import ConnectionRefusedError, ConnectionLost from twisted.internet.error import ConnectionRefusedError, ConnectionLost
from twisted.internet.endpoints import TCP4ClientEndpoint from twisted.internet.endpoints import TCP4ClientEndpoint, UNIXClientEndpoint
from twisted.web.http_headers import Headers from twisted.web.http_headers import Headers
import txtorcon import txtorcon
from txtorcon.web import tor_agent from txtorcon.web import tor_agent
@ -1159,7 +1159,13 @@ class JMBIP78ReceiverManager(object):
of starting the hidden service and returning/ of starting the hidden service and returning/
printing the BIP21 URI: printing the BIP21 URI:
""" """
d = txtorcon.connect(reactor) control_host = jm_single().config.get("PAYJOIN", "tor_control_host")
control_port = int(jm_single().config.get("PAYJOIN", "tor_control_port"))
if str(control_host).startswith('unix:'):
control_endpoint = UNIXClientEndpoint(reactor, control_host[5:])
else:
control_endpoint = TCP4ClientEndpoint(reactor, control_host, control_port)
d = txtorcon.connect(reactor, control_endpoint)
d.addCallback(self.create_onion_ep) d.addCallback(self.create_onion_ep)
d.addErrback(self.setup_failed) d.addErrback(self.setup_failed)
# TODO: add errbacks to the next two calls in # TODO: add errbacks to the next two calls in

Loading…
Cancel
Save