mirror of
https://github.com/JoinMarket-Org/joinmarket-clientserver.git
synced 2026-08-17 13:07:51 +02:00
Prior to this commit, running joinmarketd as an isolated process only supported serving the Joinmarket protocol; attempting PayJoin would result in silent failure as the receiver would reject the !pubkey message. After this commit, the joinmarketd daemon serves both protocols with the PayJoin protocol being served at port+1
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
from __future__ import (absolute_import, division,
|
|
print_function, unicode_literals)
|
|
from builtins import * # noqa: F401
|
|
import sys
|
|
from twisted.internet import reactor
|
|
from twisted.python.log import startLogging
|
|
import jmdaemon
|
|
|
|
def startup_joinmarketd(host, port, usessl, factories=None,
|
|
finalizer=None, finalizer_args=None):
|
|
"""Start event loop for joinmarket daemon here.
|
|
Args:
|
|
port : port over which to serve the daemon
|
|
finalizer: a function which is called after the reactor has shut down.
|
|
finalizer_args : arguments to finalizer function.
|
|
"""
|
|
startLogging(sys.stdout)
|
|
if not factories:
|
|
factories = [jmdaemon.JMDaemonServerProtocolFactory(),
|
|
jmdaemon.P2EPDaemonServerProtocolFactory()]
|
|
for factory in factories:
|
|
jmdaemon.start_daemon(host, port, factory, usessl,
|
|
'./ssl/key.pem', './ssl/cert.pem')
|
|
port += 1
|
|
if finalizer:
|
|
reactor.addSystemEventTrigger("after", "shutdown", finalizer,
|
|
finalizer_args)
|
|
reactor.run()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2:
|
|
port = 27183
|
|
else:
|
|
port = int(sys.argv[1])
|
|
usessl = False
|
|
if len(sys.argv) > 2:
|
|
if int(sys.argv[2]) != 0:
|
|
usessl = True
|
|
if len(sys.argv) > 3:
|
|
host = sys.argv[3]
|
|
else:
|
|
host = 'localhost'
|
|
startup_joinmarketd(host, port, usessl)
|