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. 9
      jmclient/jmclient/configure.py
  2. 10
      jmclient/jmclient/payjoin.py

9
jmclient/jmclient/configure.py

@ -329,6 +329,13 @@ min_fee_rate = 1.1
# for payjoins to hidden service endpoints, the socks5 configuration:
onion_socks5_host = localhost
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,
# this feature is not yet implemented in code, but here for the
# future:
@ -686,4 +693,4 @@ def process_shutdown(mode="command-line"):
def process_startup():
from twisted.internet import reactor
reactor.run()
reactor.run()

10
jmclient/jmclient/payjoin.py

@ -8,7 +8,7 @@ from twisted.web.resource import Resource, ErrorPage
from twisted.web.iweb import IPolicyForHTTPS
from twisted.internet.ssl import CertificateOptions
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
import txtorcon
from txtorcon.web import tor_agent
@ -1159,7 +1159,13 @@ class JMBIP78ReceiverManager(object):
of starting the hidden service and returning/
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.addErrback(self.setup_failed)
# TODO: add errbacks to the next two calls in

Loading…
Cancel
Save