|
| 1 | +# HOW TO SETUP ONION MESSAGE CHANNELS IN JOINMARKET |
| 2 | + |
| 3 | +### Contents |
| 4 | + |
| 5 | +1. [Overview](#overview) |
| 6 | + |
| 7 | +2. [Testing, configuring for signet](#testing) |
| 8 | + |
| 9 | +4. [Directory nodes](#directory) |
| 10 | + |
| 11 | +<a name="overview" /> |
| 12 | + |
| 13 | +## Overview |
| 14 | + |
| 15 | +This is a new way for Joinmarket bots to communicate, namely by serving and connecting to Tor onion services. This does not |
| 16 | +introduce any new requirements to your Joinmarket installation, technically, because the use of Payjoin already required the need |
| 17 | +to service such onion services, and connecting to IRC used a SOCKS5 proxy (by default, and used by almost all users) over Tor to |
| 18 | +a remote onion service. |
| 19 | + |
| 20 | +The purpose of this new type of message channel is as follows: |
| 21 | + |
| 22 | +* less reliance on any service external to Joinmarket |
| 23 | +* most of the transaction negotiation will be happening directly peer to peer, not passed over a central server ( |
| 24 | +albeit it was and remains E2E encrypted data, in either case) |
| 25 | +* the above can lead to better scalability at large numbers |
| 26 | +* a substantial increase in the speed of transaction negotiation; this is mostly related to the throttling of high bursts of traffic on IRC |
| 27 | + |
| 28 | +The configuration for a user is simple; in their `joinmarket.cfg` they will add a messaging section like this: |
| 29 | + |
| 30 | +``` |
| 31 | +[MESSAGING:onion1] |
| 32 | +type = onion |
| 33 | +onion_serving_port = 8082 |
| 34 | +# This is a comma separated list (comma can be omitted if only one item). |
| 35 | +# Each item has format host:port |
| 36 | +directory_nodes = rr6f6qtleiiwic45bby4zwmiwjrj3jsbmcvutwpqxjziaydjydkk5iad.onion:80 |
| 37 | +``` |
| 38 | + |
| 39 | +Here, I have deliberately omitted the several other settings in this section which will almost always be fine as default; |
| 40 | +see `jmclient/jmclient/configure.py` for what those defaults are, and the extensive comments explaining. |
| 41 | + |
| 42 | +The main point is the list of **directory nodes** (the one shown here is one being run on signet, right now), which will |
| 43 | +be comma separated if multiple directory nodes are configured (we expect there will be 2 or 3 as a normal situation). |
| 44 | +The `onion_serving_port` is on which port on the local machine the onion service is served. |
| 45 | +The `type` field must always be `onion` in this case, and distinguishes it from IRC message channels and others. |
| 46 | + |
| 47 | +### Can/should I still run IRC message channels? |
| 48 | + |
| 49 | +In short, yes. |
| 50 | + |
| 51 | +### Do I need to configure Tor, and if so, how? |
| 52 | + |
| 53 | +These message channels use both outbound and inbound connections to onion services (or "hidden services"). |
| 54 | + |
| 55 | +As previously mentioned, both of these features were already in use in Joinmarket. If you never served an |
| 56 | +onion service before, it should work fine as long as you have the Tor service running in the background, |
| 57 | +and the default control port 9051 (if not, change that value in the `joinmarket.cfg`, see above. |
| 58 | + |
| 59 | +#### Why not use Lightning based onions? |
| 60 | + |
| 61 | +(*Feel free to skip this section if you don't know what "Lightning based onions" refers to!*). The reason this architecture is |
| 62 | +proposed as an alternative to the previously suggested Lightning-node-based network (see |
| 63 | +[this PR](https://github.com/JoinMarket-Org/joinmarket-clientserver/pull/1000)), is mostly that: |
| 64 | + |
| 65 | +* the latter has a bunch of extra installation and maintenance dependencies (just one example: pyln-client requires coincurve, which we just |
| 66 | +removed) |
| 67 | +* the latter requires establishing a new node "identity" which can be refreshed, but that creates more concern |
| 68 | +* longer term ideas to integrate Lightning payments to the coinjoin workflow (and vice versa!) are not realizable yet |
| 69 | +* using multi-hop onion messaging in the LN network itself is also a way off, and a bit problematic |
| 70 | + |
| 71 | +So the short version is: the Lightning based alternative is certainly feasible, but has a lot more baggage that can't really be justified |
| 72 | +unless we're actually using it for something. |
| 73 | + |
| 74 | + |
| 75 | +<a name="testing" /> |
| 76 | + |
| 77 | +## Testing, and configuring for signet. |
| 78 | + |
| 79 | +This testing section focuses on signet since that will be the less troublesome way of getting involved in tests for |
| 80 | +the non-hardcore JM developer :) |
| 81 | + |
| 82 | +(For the latter, please use the regtest setup by running `test/e2e-coinjoin-test.py` under `pytest`, |
| 83 | +and pay attention to the settings in `regtest_joinmarket.cfg`.) |
| 84 | + |
| 85 | +There is no separate/special configuration for signet other than the configuration that is already needed for running |
| 86 | +Joinmarket against a signet backend (so e.g. RPC port of 38332). |
| 87 | + |
| 88 | +Add the `[MESSAGING:onion1]` message channel section to your `joinmarket.cfg`, as listed above, including the |
| 89 | +signet directory node listed above (rr6f6qtleiiwic45bby4zwmiwjrj3jsbmcvutwpqxjziaydjydkk5iad.onion:80), and, |
| 90 | +for the simplest test, remove the other `[MESSAGING:*]` sections that you have. |
| 91 | + |
| 92 | +Then just make sure your bot has some signet coins and try running as maker or taker or both. |
| 93 | + |
| 94 | +<a name="directory" /> |
| 95 | + |
| 96 | +## Directory nodes |
| 97 | + |
| 98 | +**This last section is for people with a lot of technical knowledge in this area, |
| 99 | +who would like to help by running a directory node. You can ignore it if that does not apply.**. |
| 100 | + |
| 101 | +This requires a long running bot. It should be on a server you can keep running permanently, so perhaps a VPS, |
| 102 | +but in any case, very high uptime. For reliability it also makes sense to configure to run as a systemd service. |
| 103 | + |
| 104 | +A note: in this early stage, the usage of Lightning is only really network-layer stuff, and the usage of bitcoin, is none; feel free to add elements that remove any need for a backend bitcoin blockchain, but beware: future upgrades *could* mean that the directory node really does need the bitcoin backend. |
| 105 | + |
| 106 | +#### Joinmarket-specific configuration |
| 107 | + |
| 108 | +Add `hidden_service_dir` to your `[MESSAGING:onion1]` with a directory accessible to your user. You may want to lock this down |
| 109 | +a bit! |
| 110 | +The point to understand is: Joinmarket's `jmbase.JMHiddenService` will, if configured with a non-empty `hidden_service_dir` |
| 111 | +field, actually start an *independent* instance of Tor specifically for serving this, under the current user. |
| 112 | +(our tor interface library `txtorcon` needs read access to the Tor HS dir, so it's troublesome to do this another way). |
| 113 | + |
| 114 | +##### Question: How to configure the `directory-nodes` list in our `joinmarket.cfg` for this directory node bot? |
| 115 | + |
| 116 | +Answer: **you must only enter your own node in this list!** (otherwise you may find your bot infinitely rebroadcasting messages). |
| 117 | + |
| 118 | + |
| 119 | +#### Suggested setup of a service: |
| 120 | + |
| 121 | +You will need two components: bitcoind, and Joinmarket itself, which you can run as a yg. |
| 122 | +Since this task is going to be attempted by someone with significant technical knowledge, |
| 123 | +only an outline is provided here; several details will need to be filled in. |
| 124 | +Here is a sketch of how the systemd service files can be set up for signet: |
| 125 | + |
| 126 | +If someone wants to put together a docker setup of this for a more "one-click install", that would be great. |
| 127 | + |
| 128 | +1. bitcoin-signet.service |
| 129 | + |
| 130 | +``` |
| 131 | +[Unit] |
| 132 | +Description=bitcoind signet |
| 133 | +After=network-online.target |
| 134 | +Wants=network-online.target |
| 135 | +
|
| 136 | +[Service] |
| 137 | +Type=simple |
| 138 | +ExecStart=/usr/local/bin/bitcoind -signet |
| 139 | +User=user |
| 140 | +
|
| 141 | +[Install] |
| 142 | +WantedBy=multi-user.target |
| 143 | +``` |
| 144 | + |
| 145 | +This is deliberately a super-basic setup (see above). Don't forget to setup your `bitcoin.conf` as usual, |
| 146 | +for the bitcoin user, and make it match (specifically in terms of RPC) what you set up for Lightning below. |
| 147 | + |
| 148 | + |
| 149 | +2. |
| 150 | + |
| 151 | +``` |
| 152 | +[Unit] |
| 153 | +Description=joinmarket directory node on signet |
| 154 | +Requires=bitcoin-signet.service |
| 155 | +After=bitcoin-signet.service |
| 156 | +
|
| 157 | +[Service] |
| 158 | +Type=simple |
| 159 | +ExecStart=/bin/bash -c 'cd /path/to/joinmarket-clientserver && source jmvenv/bin/activate && cd scripts && echo -n "password" | python yg-privacyenhanced.py --wallet-password-stdin --datadir=/custom/joinmarket-datadir some-signet-wallet.jmdat' |
| 160 | +User=user |
| 161 | +
|
| 162 | +[Install] |
| 163 | +WantedBy=multi-user.target |
| 164 | +``` |
| 165 | + |
| 166 | +To state the obvious, the idea here is that this second service will run the JM directory node and have a dependency on the previous one, |
| 167 | +to ensure they start up in the correct order. |
| 168 | + |
| 169 | +Re: password echo, obviously this kind of password entry is bad; |
| 170 | +for now we needn't worry as these nodes don't need to carry any real coins (and it's better they don't!). |
| 171 | +Later we may need to change that (though of course you can use standard measures to protect the box). |
| 172 | + |
| 173 | +TODO: add some material on network hardening/firewalls here, I guess. |
0 commit comments