joinmarket/scripts/joinmarketd.py
Adam Gibson b6e2576c3a
BIP78 sender protocol via daemon
This PR creates a client-daemon protocol for
the BIP78 sender, using the base protocol
`HTTPPassThrough` which provides tor and non-tor
agents with POST and GET request functionality.
As for Joinmarket coinjoins, the use of an in-process
daemon is the default option, but it can be isolated
by changing the `[DAEMON]` section of the config.
The receiver side of BIP78 will be addressed in a
future PR.
2021-03-14 11:53:51 +00:00

43 lines
1.4 KiB
Python
Executable file

#!/usr/bin/env python3
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.SNICKERDaemonServerProtocolFactory(),
jmdaemon.BIP78ServerProtocolFactory()]
for factory in factories:
jmdaemon.start_daemon(host, port, factory, usessl,
'./ssl/key.pem', './ssl/cert.pem')
port -= 1000
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)