From fde39a7135a77e4a2142d138ad6e2cb3b13e2676 Mon Sep 17 00:00:00 2001 From: nixbitcoin Date: Mon, 19 Oct 2020 12:54:10 +0000 Subject: [PATCH] payjoin: make tor control host configurable --- jmclient/jmclient/configure.py | 9 ++++++++- jmclient/jmclient/payjoin.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/jmclient/jmclient/configure.py b/jmclient/jmclient/configure.py index b1adfe5..2ebb1c9 100644 --- a/jmclient/jmclient/configure.py +++ b/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() \ No newline at end of file + reactor.run() diff --git a/jmclient/jmclient/payjoin.py b/jmclient/jmclient/payjoin.py index 002311a..100c258 100644 --- a/jmclient/jmclient/payjoin.py +++ b/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