Debian Codegraph @

README.md

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 # Monero
2
3 Copyright (c) 2014-2022 The Monero Project.
4 Portions Copyright (c) 2012-2013 The Cryptonote developers.
5
6 ## Table of Contents
7
8 - [Development resources](#development-resources)
9 - [Vulnerability response](#vulnerability-response)
10 - [Research](#research)
11 - [Announcements](#announcements)
12 - [Translations](#translations)
13 - [Introduction](#introduction)
14 - [About this project](#about-this-project)
15 - [Supporting the project](#supporting-the-project)
16 - [License](#license)
17 - [Contributing](#contributing)
18 - [Scheduled software upgrades](#scheduled-software-upgrades)
19 - [Release staging schedule and protocol](#release-staging-schedule-and-protocol)
20 - [Compiling Monero from source](#compiling-monero-from-source)
21 - [Dependencies](#dependencies)
22 - [Internationalization](#Internationalization)
23 - [Using Tor](#using-tor)
24 - [Pruning](#Pruning)
25 - [Debugging](#Debugging)
26 - [Known issues](#known-issues)
27
28 ## Development resources
29
30 - Web: [getmonero.org](https://getmonero.org)
31 - Forum: [forum.getmonero.org](https://forum.getmonero.org)
32 - Mail: [[email protected]](mailto:[email protected])
33 - GitHub: [https://github.com/monero-project/monero](https://github.com/monero-project/monero)
34 - IRC: [#monero-dev on Libera](https://web.libera.chat/#monero-dev)
35 - It is HIGHLY recommended that you join the #monero-dev IRC channel if you are developing software that uses Monero. Due to the nature of this open source software project, joining this channel and idling is the best way to stay updated on best practices and new developments in the Monero ecosystem. All you need to do is join the IRC channel and idle to stay updated with the latest in Monero development. If you do not, you risk wasting resources on developing integrations that are not compatible with the Monero network. The Monero core team and community continuously make efforts to communicate updates, developments, and documentation via other platforms – but for the best information, you need to talk to other Monero developers, and they are on IRC. #monero-dev is about Monero development, not getting help about using Monero, or help about development of other software, including yours, unless it also pertains to Monero code itself. For these cases, checkout #monero.
36
37 ## Vulnerability response
38
39 - Our [Vulnerability Response Process](https://github.com/monero-project/meta/blob/master/VULNERABILITY_RESPONSE_PROCESS.md) encourages responsible disclosure
40 - We are also available via [HackerOne](https://hackerone.com/monero)
41
42 ## Research
43
44 The [Monero Research Lab](https://src.getmonero.org/resources/research-lab/) is an open forum where the community coordinates research into Monero cryptography, protocols, fungibility, analysis, and more. We welcome collaboration and contributions from outside researchers! Because not all Lab work and publications are distributed as traditional preprints or articles, they may be easy to miss if you are conducting literature reviews for your own Monero research. You are encouraged to get in touch with the Monero research community if you have questions, wish to collaborate, or would like guidance to help avoid unnecessarily duplicating earlier or known work.
45
46 The Monero research community is available on IRC in [#monero-research-lab on Libera](https://web.libera.chat/#monero-research-lab), which is also accessible via Matrix.
47
48 ## Announcements
49
50 - You can subscribe to an [announcement listserv](https://lists.getmonero.org) to get critical announcements from the Monero core team. The announcement list can be very helpful for knowing when software updates are needed.
51
52 ## Translations
53 The CLI wallet is available in different languages. If you want to help translate it, see our self-hosted localization platform, Weblate, on [translate.getmonero.org]( https://translate.getmonero.org/projects/monero/cli-wallet/). Every translation *must* be uploaded on the platform, pull requests directly editing the code in this repository will be closed. If you need help with Weblate, you can find a guide with screenshots [here](https://github.com/monero-ecosystem/monero-translations/blob/master/weblate.md).
54  
55
56 If you need help/support/info about translations, contact the localization workgroup. You can find the complete list of contacts on the repository of the workgroup: [monero-translations](https://github.com/monero-ecosystem/monero-translations#contacts).
57
58 ## Introduction
59
60 Monero is a private, secure, untraceable, decentralised digital currency. You are your bank, you control your funds, and nobody can trace your transfers unless you allow them to do so.
61
62 **Privacy:** Monero uses a cryptographically sound system to allow you to send and receive funds without your transactions being easily revealed on the blockchain (the ledger of transactions that everyone has). This ensures that your purchases, receipts, and all transfers remain private by default.
63
64 **Security:** Using the power of a distributed peer-to-peer consensus network, every transaction on the network is cryptographically secured. Individual wallets have a 25-word mnemonic seed that is only displayed once and can be written down to backup the wallet. Wallet files should be encrypted with a strong passphrase to ensure they are useless if ever stolen.
65
66 **Untraceability:** By taking advantage of ring signatures, a special property of a certain type of cryptography, Monero is able to ensure that transactions are not only untraceable but have an optional measure of ambiguity that ensures that transactions cannot easily be tied back to an individual user or computer.
67
68 **Decentralization:** The utility of Monero depends on its decentralised peer-to-peer consensus network - anyone should be able to run the monero software, validate the integrity of the blockchain, and participate in all aspects of the monero network using consumer-grade commodity hardware. Decentralization of the monero network is maintained by software development that minimizes the costs of running the monero software and inhibits the proliferation of specialized, non-commodity hardware.
69
70 ## About this project
71
72 This is the core implementation of Monero. It is open source and completely free to use without restrictions, except for those specified in the license agreement below. There are no restrictions on anyone creating an alternative implementation of Monero that uses the protocol and network in a compatible manner.
73
74 As with many development projects, the repository on GitHub is considered to be the "staging" area for the latest changes. Before changes are merged into that branch on the main repository, they are tested by individual developers in their own branches, submitted as a pull request, and then subsequently tested by contributors who focus on testing and code reviews. That having been said, the repository should be carefully considered before using it in a production environment, unless there is a patch in the repository for a particular show-stopping issue you are experiencing. It is generally a better idea to use a tagged release for stability.
75
76 **Anyone is welcome to contribute to Monero's codebase!** If you have a fix or code change, feel free to submit it as a pull request directly to the "master" branch. In cases where the change is relatively small or does not affect other parts of the codebase, it may be merged in immediately by any one of the collaborators. On the other hand, if the change is particularly large or complex, it is expected that it will be discussed at length either well in advance of the pull request being submitted, or even directly on the pull request.
77
78 ## Supporting the project
79
80 Monero is a 100% community-sponsored endeavor. If you want to join our efforts, the easiest thing you can do is support the project financially. Both Monero and Bitcoin donations can be made to **donate.getmonero.org** if using a client that supports the [OpenAlias](https://openalias.org) standard. Alternatively, you can send XMR to the Monero donation address via the `donate` command (type `help` in the command-line wallet for details).
81
82 The Monero donation address is:
83 `888tNkZrPN6JsEgekjMnABU4TBzc2Dt29EPAvkRxbANsAnjyPbb3iQ1YBRk1UXcdRsiKc9dhwMVgN5S9cQUiyoogDavup3H`
84 Viewkey:
85 `f359631075708155cc3d92a32b75a7d02a5dcf27756707b47a2b31b21c389501`
86 Base address for restoring with address and viewkey:
87 `44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A`
88
89 The Bitcoin donation address is:
90 `1KTexdemPdxSBcG55heUuTjDRYqbC5ZL8H`
91
92 Core development funding and/or some supporting services are also graciously provided by [sponsors](https://www.getmonero.org/community/sponsorships/):
93
•94 - <https://tarilabs.com/>
95 - <https://globee.com/>
96 - <https://symas.com/>
97 - <http://www.forked.net/>
98 - <https://www.macstadium.com/>
99
100 There are also several mining pools that kindly donate a portion of their fees, [a list of them can be found on our Bitcointalk post](https://bitcointalk.org/index.php?topic=583449.0).
101
102 ## License
103
104 See [LICENSE](LICENSE).
105
106 ## Contributing
107
108 If you want to help out, see [CONTRIBUTING](docs/CONTRIBUTING.md) for a set of guidelines.
109
110 ## Scheduled software upgrades
111
112 Monero uses a fixed-schedule software upgrade (hard fork) mechanism to implement new features. This means that users of Monero (end users and service providers) should run current versions and upgrade their software on a regular schedule. Software upgrades occur during the months of April and October. The required software for these upgrades will be available prior to the scheduled date. Please check the repository prior to this date for the proper Monero software version. Below is the historical schedule and the projected schedule for the next upgrade.
113 Dates are provided in the format YYYY-MM-DD.
114
115
116 | Software upgrade block height | Date | Fork version | Minimum Monero version | Recommended Monero version | Details |
117 | ------------------------------ | -----------| ----------------- | ---------------------- | -------------------------- | ---------------------------------------------------------------------------------- |
118 | 1009827 | 2016-03-22 | v2 | v0.9.4 | v0.9.4 | Allow only >= ringsize 3, blocktime = 120 seconds, fee-free blocksize 60 kb |
119 | 1141317 | 2016-09-21 | v3 | v0.9.4 | v0.10.0 | Splits coinbase into denominations |
120 | 1220516 | 2017-01-05 | v4 | v0.10.1 | v0.10.2.1 | Allow normal and RingCT transactions |
121 | 1288616 | 2017-04-15 | v5 | v0.10.3.0 | v0.10.3.1 | Adjusted minimum blocksize and fee algorithm |
122 | 1400000 | 2017-09-16 | v6 | v0.11.0.0 | v0.11.0.0 | Allow only RingCT transactions, allow only >= ringsize 5 |
123 | 1546000 | 2018-04-06 | v7 | v0.12.0.0 | v0.12.3.0 | Cryptonight variant 1, ringsize >= 7, sorted inputs
124 | 1685555 | 2018-10-18 | v8 | v0.13.0.0 | v0.13.0.4 | max transaction size at half the penalty free block size, bulletproofs enabled, cryptonight variant 2, fixed ringsize [11](https://youtu.be/KOO5S4vxi0o)
125 | 1686275 | 2018-10-19 | v9 | v0.13.0.0 | v0.13.0.4 | bulletproofs required
126 | 1788000 | 2019-03-09 | v10 | v0.14.0.0 | v0.14.1.2 | New PoW based on Cryptonight-R, new block weight algorithm, slightly more efficient RingCT format
127 | 1788720 | 2019-03-10 | v11 | v0.14.0.0 | v0.14.1.2 | forbid old RingCT transaction format
128 | 1978433 | 2019-11-30 | v12 | v0.15.0.0 | v0.16.0.0 | New PoW based on RandomX, only allow >= 2 outputs, change to the block median used to calculate penalty, v1 coinbases are forbidden, rct sigs in coinbase forbidden, 10 block lock time for incoming outputs
129 | 2210000 | 2020-10-17 | v13 | v0.17.0.0 | v0.17.3.2 | New CLSAG transaction format
130 | 2210720 | 2020-10-18 | v14 | v0.17.1.1 | v0.17.3.2 | forbid old MLSAG transaction format
131 | 2688888 | 2022-08-13 | v15 | v0.18.0.0 | v0.18.5.0 | ringsize = 16, bulletproofs+, view tags, adjusted dynamic block weight algorithm
132 | 2689608 | 2022-08-14 | v16 | v0.18.0.0 | v0.18.5.0 | forbid old v14 transaction format
133 | XXXXXXX | XXX-XX-XX | XXX | vX.XX.X.X | vX.XX.X.X | XXX |
134
135 X's indicate that these details have not been determined as of commit date.
136
137 \* indicates estimate as of commit date
138
139 ## Release staging schedule and protocol
140
141 Approximately three months prior to a scheduled software upgrade, a branch from master will be created with the new release version tag. Pull requests that address bugs should then be made to both master and the new release branch. Pull requests that require extensive review and testing (generally, optimizations and new features) should *not* be made to the release branch.
142
143 ## Compiling Monero from source
144
145 ### Dependencies
146
147 The following table summarizes the tools and libraries required to build. A
148 few of the libraries are also included in this repository (marked as
149 "Vendored"). By default, the build uses the library installed on the system
150 and ignores the vendored sources. However, if no library is found installed on
151 the system, then the vendored source will be built and used. The vendored
152 sources are also used for statically-linked builds because distribution
153 packages often include only shared library binaries (`.so`) but not static
154 library archives (`.a`).
155
156 | Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Void pkg | Fedora pkg | Optional | Purpose |
157 | ------------ | ------------- | -------- | -------------------- | ------------ | ------------------ | ------------------- | -------- | --------------- |
158 | GCC | 5 | NO | `build-essential` | `base-devel` | `base-devel` | `gcc` | NO | |
159 | CMake | 3.5 | NO | `cmake` | `cmake` | `cmake` | `cmake` | NO | |
160 | pkg-config | any | NO | `pkg-config` | `base-devel` | `base-devel` | `pkgconf` | NO | |
161 | Boost | 1.66 | NO | `libboost-all-dev` | `boost` | `boost-devel` | `boost-devel` | NO | C++ libraries |
162 | OpenSSL | basically any | NO | `libssl-dev` | `openssl` | `openssl-devel` | `openssl-devel` | NO | sha256 sum |
163 | libzmq | 4.2.0 | NO | `libzmq3-dev` | `zeromq` | `zeromq-devel` | `zeromq-devel` | NO | ZeroMQ library |
164 | OpenPGM | ? | NO | `libpgm-dev` | `libpgm` | | `openpgm-devel` | NO | For ZeroMQ |
165 | libnorm[2] | ? | NO | `libnorm-dev` | | | | YES | For ZeroMQ |
166 | libunbound | 1.4.16 | YES | `libunbound-dev` | `unbound` | `unbound-devel` | `unbound-devel` | NO | DNS resolver |
167 | libsodium | ? | NO | `libsodium-dev` | `libsodium` | `libsodium-devel` | `libsodium-devel` | NO | cryptography |
168 | libunwind | any | NO | `libunwind8-dev` | `libunwind` | `libunwind-devel` | `libunwind-devel` | YES | Stack traces |
169 | liblzma | any | NO | `liblzma-dev` | `xz` | `liblzma-devel` | `xz-devel` | YES | For libunwind |
170 | libreadline | 6.3.0 | NO | `libreadline6-dev` | `readline` | `readline-devel` | `readline-devel` | YES | Input editing |
171 | expat | 1.1 | NO | `libexpat1-dev` | `expat` | `expat-devel` | `expat-devel` | YES | XML parsing |
172 | GTest | 1.5 | YES | `libgtest-dev`[1] | `gtest` | `gtest-devel` | `gtest-devel` | YES | Test suite |
173 | ccache | any | NO | `ccache` | `ccache` | `ccache` | `ccache` | YES | Compil. cache |
174 | Doxygen | any | NO | `doxygen` | `doxygen` | `doxygen` | `doxygen` | YES | Documentation |
175 | Graphviz | any | NO | `graphviz` | `graphviz` | `graphviz` | `graphviz` | YES | Documentation |
176 | lrelease | ? | NO | `qttools5-dev-tools` | `qt5-tools` | `qt5-tools` | `qt5-linguist` | YES | Translations |
177 | libhidapi | ? | NO | `libhidapi-dev` | `hidapi` | `hidapi-devel` | `hidapi-devel` | YES | Hardware wallet |
178 | libusb | ? | NO | `libusb-1.0-0-dev` | `libusb` | `libusb-devel` | `libusbx-devel` | YES | Hardware wallet |
179 | libprotobuf | ? | NO | `libprotobuf-dev` | `protobuf` | `protobuf-devel` | `protobuf-devel` | YES | Hardware wallet |
180 | protoc | ? | NO | `protobuf-compiler` | `protobuf` | `protobuf` | `protobuf-compiler` | YES | Hardware wallet |
181 | libudev | ? | NO | `libudev-dev` | `systemd` | `eudev-libudev-devel` | `systemd-devel` | YES | Hardware wallet |
182
183 [1] On Debian/Ubuntu `libgtest-dev` only includes sources and headers. You must
184 build the library binary manually. This can be done with the following command `sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make`
185 then:
186
187 * on Debian:
188 `sudo mv libg* /usr/lib/`
189 * on Ubuntu:
190 `sudo mv lib/libg* /usr/lib/`
191
192 [2] libnorm-dev is needed if your zmq library was built with libnorm, and not needed otherwise
193
194 Install all dependencies at once on Debian/Ubuntu:
195
196 ```
197 sudo apt update && sudo apt install build-essential cmake pkg-config libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev python3 ccache doxygen graphviz
198 ```
199
200 Install all dependencies at once on Arch:
201 ```
202 sudo pacman -Syu --needed base-devel cmake boost boost-libs openssl zeromq libpgm unbound libsodium libunwind xz readline expat gtest python3 ccache doxygen graphviz qt5-tools hidapi libusb protobuf systemd
203 ```
204
205 Install all dependencies at once on Fedora:
206 ```
207 sudo dnf install gcc gcc-c++ cmake pkgconf boost-devel openssl-devel zeromq-devel openpgm-devel unbound-devel libsodium-devel libunwind-devel xz-devel readline-devel expat-devel gtest-devel ccache doxygen graphviz qt5-linguist hidapi-devel libusbx-devel protobuf-devel protobuf-compiler systemd-devel
208 ```
209
210 Install all dependencies at once on openSUSE:
211
212 ```
213 sudo zypper ref && sudo zypper in cppzmq-devel libboost_chrono-devel libboost_date_time-devel libboost_filesystem-devel libboost_locale-devel libboost_program_options-devel libboost_regex-devel libboost_serialization-devel libboost_system-devel libboost_thread-devel libexpat-devel libsodium-devel libunwind-devel unbound-devel cmake doxygen ccache fdupes gcc-c++ libevent-devel libopenssl-devel pkgconf-pkg-config readline-devel xz-devel libqt5-qttools-devel patterns-devel-C-C++-devel_C_C++
214 ```
215
216 Install all dependencies at once on macOS with the provided Brewfile:
217
218 ```
219 brew update && brew bundle --file=contrib/brew/Brewfile
220 ```
221
222 FreeBSD 12.1 one-liner required to build dependencies:
223
224 ```
225 pkg install git gmake cmake pkgconf boost-libs libzmq4 libsodium unbound
226 ```
227
228 ### Cloning the repository
229
230 Clone recursively to pull-in needed submodule(s):
231
232 ```
233 git clone --recursive https://github.com/monero-project/monero
234 ```
235
236 If you already have a repo cloned, initialize and update:
237
238 ```
239 cd monero && git submodule init && git submodule update
240 ```
241
242 *Note*: If there are submodule differences between branches, you may need
243 to use `git submodule sync && git submodule update` after changing branches
244 to build successfully.
245
246 ### Build instructions
247
248 Monero uses the CMake build system and a top-level [Makefile](Makefile) that
249 invokes cmake commands as needed.
250
251 #### On Linux and macOS
252
253 * Install the dependencies
254 * Change to the root of the source code directory, change to the most recent release branch, and build:
255
256 ```bash
257 cd monero
258 git checkout release-v0.18
259 make
260 ```
261
262 *Optional*: If your machine has several cores and enough memory, enable
263 parallel build by running `make -j<number of threads>` instead of `make`. For
264 this to be worthwhile, the machine should have one core and about 2GB of RAM
265 available per thread.
266
267 *Note*: The instructions above will compile the most stable release of the
268 Monero software. If you would like to use and test the most recent software,
269 use `git checkout master`. The master branch may contain updates that are
270 both unstable and incompatible with release software, though testing is always
271 encouraged.
272
273 * The resulting executables can be found in `build/release/bin`
274
275 * Add `PATH="$PATH:$HOME/monero/build/release/bin"` to `.profile`
276
277 * Run Monero with `monerod --detach`
278
279 * **Optional**: build and run the test suite to verify the binaries:
280
281 ```bash
282 make release-test
283 ```
284
285 *NOTE*: `core_tests` test may take a few hours to complete.
286
287 * **Optional**: to build binaries suitable for debugging:
288
289 ```bash
290 make debug
291 ```
292
293 * **Optional**: to build statically-linked binaries:
294
295 ```bash
296 make release-static
297 ```
298
299 Dependencies need to be built with -fPIC. Static libraries usually aren't, so you may have to build them yourself with -fPIC. Refer to their documentation for how to build them.
300
301 * **Optional**: build documentation in `doc/html` (omit `HAVE_DOT=YES` if `graphviz` is not installed):
302
303 ```bash
304 HAVE_DOT=YES doxygen Doxyfile
305 ```
306
307 * **Optional**: use ccache not to rebuild translation units, that haven't really changed. Monero's CMakeLists.txt file automatically handles it
308
309 ```bash
310 sudo apt install ccache
311 ```
312
313 #### On the Raspberry Pi
314
315 Tested on a Raspberry Pi Zero with a clean install of minimal Raspbian Stretch (2017-09-07 or later) from https://www.raspberrypi.org/downloads/raspbian/. If you are using Raspian Jessie, [please see note in the following section](#note-for-raspbian-jessie-users).
316
317 * `apt-get update && apt-get upgrade` to install all of the latest software
318
319 * Install the dependencies for Monero from the 'Debian' column in the table above.
320
321 * Increase the system swap size:
322
323 ```bash
324 sudo /etc/init.d/dphys-swapfile stop
325 sudo nano /etc/dphys-swapfile
326 CONF_SWAPSIZE=2048
327 sudo /etc/init.d/dphys-swapfile start
328 ```
329
330 * If using an external hard disk without an external power supply, ensure it gets enough power to avoid hardware issues when syncing, by adding the line "max_usb_current=1" to /boot/config.txt
331
332 * Clone Monero and checkout the most recent release version:
333
334 ```bash
335 git clone https://github.com/monero-project/monero.git
336 cd monero
337 git checkout v0.18.5.0
338 ```
339
340 * Build:
341
342 ```bash
343 USE_SINGLE_BUILDDIR=1 make release
344 ```
345
346 * Wait 4-6 hours
347
348 * The resulting executables can be found in `build/release/bin`
349
350 * Add `export PATH="$PATH:$HOME/monero/build/release/bin"` to `$HOME/.profile`
351
352 * Run `source $HOME/.profile`
353
354 * Run Monero with `monerod --detach`
355
356 * You may wish to reduce the size of the swap file after the build has finished, and delete the boost directory from your home directory
357
358 #### *Note for Raspbian Jessie users:*
359
360 If you are using the older Raspbian Jessie image, compiling Monero is a bit more complicated. The version of Boost available in the Debian Jessie repositories is too old to use with Monero, and thus you must compile a newer version yourself. The following explains the extra steps and has been tested on a Raspberry Pi 2 with a clean install of minimal Raspbian Jessie.
361
362 * As before, `apt-get update && apt-get upgrade` to install all of the latest software, and increase the system swap size
363
364 ```bash
365 sudo /etc/init.d/dphys-swapfile stop
366 sudo nano /etc/dphys-swapfile
367 CONF_SWAPSIZE=2048
368 sudo /etc/init.d/dphys-swapfile start
369 ```
370
371
372 * Then, install the dependencies for Monero except for `libunwind` and `libboost-all-dev`
373
374 * Install the latest version of boost (this may first require invoking `apt-get remove --purge libboost*-dev` to remove a previous version if you're not using a clean install):
375
376 ```bash
377 cd
378 wget https://sourceforge.net/projects/boost/files/boost/1.72.0/boost_1_72_0.tar.bz2
379 tar xvfo boost_1_72_0.tar.bz2
380 cd boost_1_72_0
381 ./bootstrap.sh
382 sudo ./b2
383 ```
384
385 * Wait ~8 hours
386
387 ```bash
388 sudo ./bjam cxxflags=-fPIC cflags=-fPIC -a install
389 ```
390
391 * Wait ~4 hours
392
393 * From here, follow the [general Raspberry Pi instructions](#on-the-raspberry-pi) from the "Clone Monero and checkout most recent release version" step.
394
395 #### On Windows:
396
397 Binaries for Windows are built on Windows using the MinGW toolchain within
398 [MSYS2 environment](https://www.msys2.org). The MSYS2 environment emulates a
399 POSIX system. The toolchain runs within the environment and *cross-compiles*
400 binaries that can run outside of the environment as a regular Windows
401 application.
402
403 **Preparing the build environment**
404
405 * Download and install the [MSYS2 installer](https://www.msys2.org), either the 64-bit or the 32-bit package, depending on your system.
406 * Open the MSYS shell via the `MSYS2 Shell` shortcut
407 * Update packages using pacman:
408
409 ```bash
410 pacman -Syu
411 ```
412
413 * Exit the MSYS shell using Alt+F4
414 * Edit the properties for the `MSYS2 Shell` shortcut changing "msys2_shell.bat" to "msys2_shell.cmd -mingw64" for 64-bit builds or "msys2_shell.cmd -mingw32" for 32-bit builds
415 * Restart MSYS shell via modified shortcut and update packages again using pacman:
416
417 ```bash
418 pacman -Syu
419 ```
420
421
422 * Install dependencies:
423
424 To build for 64-bit Windows:
425
426 ```bash
427 pacman -S mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-unbound
428 ```
429
430 To build for 32-bit Windows:
431
432 ```bash
433 pacman -S mingw-w64-i686-toolchain make mingw-w64-i686-cmake mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-zeromq mingw-w64-i686-libsodium mingw-w64-i686-hidapi mingw-w64-i686-unbound
434 ```
435
436 * Open the MingW shell via `MinGW-w64-Win64 Shell` shortcut on 64-bit Windows
437 or `MinGW-w64-Win64 Shell` shortcut on 32-bit Windows. Note that if you are
438 running 64-bit Windows, you will have both 64-bit and 32-bit MinGW shells.
439
440 **Cloning**
441
442 * To git clone, run:
443
444 ```bash
445 git clone --recursive https://github.com/monero-project/monero.git
446 ```
447
448 **Building**
449
450 * Change to the cloned directory, run:
451
452 ```bash
453 cd monero
454 ```
455
456 * If you would like a specific [version/tag](https://github.com/monero-project/monero/tags), do a git checkout for that version. eg. 'v0.18.5.0'. If you don't care about the version and just want binaries from master, skip this step:
457
458 ```bash
459 git checkout v0.18.5.0
460 ```
461
462 * If you are on a 64-bit system, run:
463
464 ```bash
465 make release-static-win64
466 ```
467
468 * If you are on a 32-bit system, run:
469
470 ```bash
471 make release-static-win32
472 ```
473
474 * The resulting executables can be found in `build/release/bin`
475
476 * **Optional**: to build Windows binaries suitable for debugging on a 64-bit system, run:
477
478 ```bash
479 make debug-static-win64
480 ```
481
482 * **Optional**: to build Windows binaries suitable for debugging on a 32-bit system, run:
483
484 ```bash
485 make debug-static-win32
486 ```
487
488 * The resulting executables can be found in `build/debug/bin`
489
490 ### On FreeBSD:
491
492 The project can be built from scratch by following instructions for Linux above(but use `gmake` instead of `make`).
493 If you are running Monero in a jail, you need to add `sysvsem="new"` to your jail configuration, otherwise lmdb will throw the error message: `Failed to open lmdb environment: Function not implemented`.
494
495 Monero is also available as a port or package as `monero-cli`.
496
497 ### On OpenBSD:
498
499 You will need to add a few packages to your system. `pkg_add cmake gmake zeromq libiconv boost`.
500
501 The `doxygen` and `graphviz` packages are optional and require the xbase set.
502 Running the test suite also requires `py-requests` package.
503
504 Build monero: `env DEVELOPER_LOCAL_TOOLS=1 BOOST_ROOT=/usr/local gmake release-static`
505
506 Note: you may encounter the following error when compiling the latest version of Monero as a normal user:
507
508 ```
509 LLVM ERROR: out of memory
510 c++: error: unable to execute command: Abort trap (core dumped)
511 ```
512
513 Then you need to increase the data ulimit size to 2GB and try again: `ulimit -d 2000000`
514
515 ### On NetBSD:
516
517 Check that the dependencies are present: `pkg_info -c libexecinfo boost-headers boost-libs protobuf readline libusb1 zeromq git-base pkgconf gmake cmake | more`, and install any that are reported missing, using `pkg_add` or from your pkgsrc tree. Readline is optional but worth having.
518
519 Third-party dependencies are usually under `/usr/pkg/`, but if you have a custom setup, adjust the "/usr/pkg" (below) accordingly.
520
521 Clone the monero repository recursively and checkout the most recent release as described above. Then build monero: `gmake BOOST_ROOT=/usr/pkg LDFLAGS="-Wl,-R/usr/pkg/lib" release`. The resulting executables can be found in `build/NetBSD/[Release version]/Release/bin/`.
522
523 ### On Solaris:
524
525 The default Solaris linker can't be used, you have to install GNU ld, then run cmake manually with the path to your copy of GNU ld:
526
527 ```bash
528 mkdir -p build/release
529 cd build/release
530 cmake -DCMAKE_LINKER=/path/to/ld -D CMAKE_BUILD_TYPE=Release ../..
531 cd ../..
532 ```
533
534 Then you can run make as usual.
535
536 ### Building portable statically linked binaries
537
538 By default, in either dynamically or statically linked builds, binaries target the specific host processor on which the build happens and are not portable to other processors. Portable binaries can be built using the following targets:
539
540 * ```make release-static-linux-x86_64``` builds binaries on Linux on x86_64 portable across POSIX systems on x86_64 processors
541 * ```make release-static-linux-i686``` builds binaries on Linux on x86_64 or i686 portable across POSIX systems on i686 processors
542 * ```make release-static-linux-armv8``` builds binaries on Linux portable across POSIX systems on armv8 processors
543 * ```make release-static-linux-armv7``` builds binaries on Linux portable across POSIX systems on armv7 processors
544 * ```make release-static-linux-armv6``` builds binaries on Linux portable across POSIX systems on armv6 processors
545 * ```make release-static-win64``` builds binaries on 64-bit Windows portable across 64-bit Windows systems
546 * ```make release-static-win32``` builds binaries on 64-bit or 32-bit Windows portable across 32-bit Windows systems
547
548 ### Cross Compiling
549
550 You can also cross-compile static binaries on Linux for Windows and macOS with the `depends` system.
551
552 * ```make depends target=x86_64-linux-gnu``` for 64-bit linux binaries.
553 * ```make depends target=x86_64-w64-mingw32``` for 64-bit windows binaries.
554 * Requires: `python3 g++-mingw-w64-x86-64 wine1.6 bc`
555 * ```make depends target=x86_64-apple-darwin11``` for macOS binaries.
556 * Requires: `cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev`
557 * ```make depends target=aarch64-apple-darwin``` for Apple Silicon macOS binaries.
558 * Requires: `clang`
559 * ```make depends target=i686-linux-gnu``` for 32-bit linux binaries.
560 * Requires: `g++-multilib bc`
561 * ```make depends target=i686-w64-mingw32``` for 32-bit windows binaries.
562 * Requires: `python3 g++-mingw-w64-i686`
563 * ```make depends target=arm-linux-gnueabihf``` for armv7 binaries.
564 * Requires: `g++-arm-linux-gnueabihf`
565 * ```make depends target=aarch64-linux-gnu``` for armv8 binaries.
566 * Requires: `g++-aarch64-linux-gnu`
567 * ```make depends target=riscv64-linux-gnu``` for RISC V 64 bit binaries.
568 * Requires: `g++-riscv64-linux-gnu`
569 * ```make depends target=x86_64-unknown-freebsd``` for freebsd binaries.
570 * Requires: `clang-8`
571 * ```make depends target=arm-linux-android``` for 32bit android binaries
572 * ```make depends target=aarch64-linux-android``` for 64bit android binaries
573
574
575 The required packages are the names for each toolchain on apt. Depending on your distro, they may have different names. The `depends` system has been tested on Ubuntu 18.04 and 20.04.
576
577 Using `depends` might also be easier to compile Monero on Windows than using MSYS. Activate Windows Subsystem for Linux (WSL) with a distro (for example Ubuntu), install the apt build-essentials and follow the `depends` steps as depicted above.
578
579 The produced binaries still link libc dynamically. If the binary is compiled on a current distribution, it might not run on an older distribution with an older installation of libc. Passing `-DBACKCOMPAT=ON` to cmake will make sure that the binary will run on systems having at least libc version 2.17.
580
581 ## Installing Monero from a package
582
583 **DISCLAIMER: These packages are not part of this repository or maintained by this project's contributors, and as such, do not go through the same review process to ensure their trustworthiness and security.**
584
585 Packages are available for
586
587 * Debian Buster
588
589 See the [instructions in the whonix/monero-gui repository](https://gitlab.com/whonix/monero-gui#how-to-install-monero-using-apt-get)
590
591 * Debian Bullseye and Sid
592
593 ```bash
594 sudo apt install monero
595 ```
596 More info and versions in the [Debian package tracker](https://tracker.debian.org/pkg/monero).
597
598 * Arch Linux [(via Community packages)](https://www.archlinux.org/packages/community/x86_64/monero/):
599
600 ```bash
601 sudo pacman -S monero
602 ```
603
604 * Void Linux:
605
606 ```bash
607 xbps-install -S monero
608 ```
609
610 * GuixSD
611
612 ```bash
613 guix package -i monero
614 ```
615
616 * Gentoo [Monero overlay](https://github.com/gentoo-monero/gentoo-monero)
617
618 ```bash
619 emerge --noreplace eselect-repository
620 eselect repository enable monero
621 emaint sync -r monero
622 echo '*/*::monero ~amd64' >> /etc/portage/package.accept_keywords
623 emerge net-p2p/monero
624 ```
625
626 * macOS [(homebrew)](https://brew.sh/)
627 ```bash
628 brew install monero
629 ```
630
631 * Docker
632
633 ```bash
634 # Build using all available cores
635 docker build -t monero .
636
637 # or build using a specific number of cores (reduce RAM requirement)
638 docker build --build-arg NPROC=1 -t monero .
639
640 # either run in foreground
641 docker run -it -v /monero/chain:/home/monero/.bitmonero -v /monero/wallet:/wallet -p 18080:18080 monero
642
643 # or in background
644 docker run -it -d -v /monero/chain:/home/monero/.bitmonero -v /monero/wallet:/wallet -p 18080:18080 monero
645 ```
646
647 * The build needs 3 GB space.
648 * Wait one hour or more
649
650 Packaging for your favorite distribution would be a welcome contribution!
651
652 ## Running monerod
653
654 The build places the binary in `bin/` sub-directory within the build directory
655 from which cmake was invoked (repository root by default). To run in the
656 foreground:
657
658 ```bash
659 ./bin/monerod
660 ```
661
662 To list all available options, run `./bin/monerod --help`. Options can be
663 specified either on the command line or in a configuration file passed by the
664 `--config-file` argument. To specify an option in the configuration file, add
665 a line with the syntax `argumentname=value`, where `argumentname` is the name
666 of the argument without the leading dashes, for example, `log-level=1`.
667
668 To run in background:
669
670 ```bash
671 ./bin/monerod --log-file monerod.log --detach
672 ```
673
674 To run as a systemd service, copy
675 [monerod.service](utils/systemd/monerod.service) to `/etc/systemd/system/` and
676 [monerod.conf](utils/conf/monerod.conf) to `/etc/`. The [example
677 service](utils/systemd/monerod.service) assumes that the user `monero` exists
678 and its home is the data directory specified in the [example
679 config](utils/conf/monerod.conf).
680
681 If you're on Mac, you may need to add the `--max-concurrency 1` option to
682 monero-wallet-cli, and possibly monerod, if you get crashes refreshing.
683
684 ## Internationalization
685
686 See [README.i18n.md](docs/README.i18n.md).
687
688 ## Using Tor
689
690 > There is a new, still experimental, [integration with Tor](docs/ANONYMITY_NETWORKS.md). The
691 > feature allows connecting over IPv4 and Tor simultaneously - IPv4 is used for
692 > relaying blocks and relaying transactions received by peers whereas Tor is
693 > used solely for relaying transactions received over local RPC. This provides
694 > privacy and better protection against surrounding node (sybil) attacks.
695
696 While Monero isn't made to integrate with Tor, it can be used wrapped with torsocks, by
697 setting the following configuration parameters and environment variables:
698
699 * `--p2p-bind-ip 127.0.0.1` on the command line or `p2p-bind-ip=127.0.0.1` in
700 monerod.conf to disable listening for connections on external interfaces.
701 * `DNS_PUBLIC=tcp` or `DNS_PUBLIC=tcp://x.x.x.x` where x.x.x.x is the IP of the
702 desired DNS server, for DNS requests to go over TCP, so that they are routed
703 through Tor. When IP is not specified, monerod uses the default list of
704 servers defined in [src/common/dns_utils.cpp](src/common/dns_utils.cpp).
705 * `TORSOCKS_ALLOW_INBOUND=1` to tell torsocks to allow monerod to bind to interfaces
706 to accept connections from the wallet. On some Linux systems, torsocks
707 allows binding to localhost by default, so setting this variable is only
708 necessary to allow binding to local LAN/VPN interfaces to allow wallets to
709 connect from remote hosts. On other systems, it may be needed for local wallets
710 as well.
711 * Do NOT pass `--detach` when running through torsocks with systemd, (see
712 [utils/systemd/monerod.service](utils/systemd/monerod.service) for details).
713 * If you use the wallet with a Tor daemon via the loopback IP (eg, 127.0.0.1:9050),
714 then use `--untrusted-daemon` unless it is your own hidden service.
715
716 Example command line to start monerod through Tor:
717
718 ```bash
719 DNS_PUBLIC=tcp torsocks monerod --p2p-bind-ip 127.0.0.1
720 ```
721
722 A helper script is in contrib/tor/monero-over-tor.sh. It assumes Tor is installed
723 already, and runs Tor and Monero with the right configuration.
724
725 ### Using Tor on Tails
726
727 TAILS ships with a very restrictive set of firewall rules. Therefore, you need
728 to add a rule to allow this connection too, in addition to telling torsocks to
729 allow inbound connections. Full example:
730
731 ```bash
732 sudo iptables -I OUTPUT 2 -p tcp -d 127.0.0.1 -m tcp --dport 18081 -j ACCEPT
733 DNS_PUBLIC=tcp torsocks ./monerod --p2p-bind-ip 127.0.0.1 --rpc-bind-ip 127.0.0.1 \
734 --data-dir /home/amnesia/Persistent/your/directory/to/the/blockchain
735 ```
736
737 ## Pruning
738
739 As of April 2022, the full Monero blockchain file is about 130 GB. One can store a pruned blockchain, which is about 45 GB.
740 A pruned blockchain can only serve part of the historical chain data to other peers, but is otherwise identical in
741 functionality to the full blockchain.
742 To use a pruned blockchain, it is best to start the initial sync with `--prune-blockchain`. However, it is also possible
743 to prune an existing blockchain using the `monero-blockchain-prune` tool or using the `--prune-blockchain` `monerod` option
744 with an existing chain. If an existing chain exists, pruning will temporarily require disk space to store both the full
745 and pruned blockchains.
746
747 For more detailed information see the ['Pruning' entry in the Moneropedia](https://www.getmonero.org/resources/moneropedia/pruning.html)
748
749 ## Debugging
750
751 This section contains general instructions for debugging failed installs or problems encountered with Monero. First, ensure you are running the latest version built from the GitHub repo.
752
753 ### Obtaining stack traces and core dumps on Unix systems
754
755 We generally use the tool `gdb` (GNU debugger) to provide stack trace functionality, and `ulimit` to provide core dumps in builds which crash or segfault.
756
757 * To use `gdb` in order to obtain a stack trace for a build that has stalled:
758
759 Run the build.
760
761 Once it stalls, enter the following command:
762
763 ```bash
764 gdb /path/to/monerod `pidof monerod`
765 ```
766
767 Type `thread apply all bt` within gdb in order to obtain the stack trace
768
769 * If however the core dumps or segfaults:
770
771 Enter `ulimit -c unlimited` on the command line to enable unlimited filesizes for core dumps
772
773 Enter `echo core | sudo tee /proc/sys/kernel/core_pattern` to stop cores from being hijacked by other tools
774
775 Run the build.
776
777 When it terminates with an output along the lines of "Segmentation fault (core dumped)", there should be a core dump file in the same directory as monerod. It may be named just `core`, or `core.xxxx` with numbers appended.
778
779 You can now analyse this core dump with `gdb` as follows:
780
781 ```bash
782 gdb /path/to/monerod /path/to/dumpfile`
783 ```
784
785 Print the stack trace with `bt`
786
787 * If a program crashed and cores are managed by systemd, the following can also get a stack trace for that crash:
788
789 ```bash
790 coredumpctl -1 gdb
791 ```
792
793 #### To run Monero within gdb:
794
795 Type `gdb /path/to/monerod`
796
797 Pass command-line options with `--args` followed by the relevant arguments
798
799 Type `run` to run monerod
800
801 ### Analysing memory corruption
802
803 There are two tools available:
804
805 #### ASAN
806
807 Configure Monero with the -D SANITIZE=ON cmake flag, eg:
808
809 ```bash
810 cd build/debug && cmake -D SANITIZE=ON -D CMAKE_BUILD_TYPE=Debug ../..
811 ```
812
813 You can then run the monero tools normally. Performance will typically halve.
814
815 #### valgrind
816
817 Install valgrind and run as `valgrind /path/to/monerod`. It will be very slow.
818
819 ### LMDB
820
821 Instructions for debugging suspected blockchain corruption as per @HYC
822
823 There is an `mdb_stat` command in the LMDB source that can print statistics about the database but it's not routinely built. This can be built with the following command:
824
825 ```bash
826 cd ~/monero/external/db_drivers/liblmdb && make
827 ```
828
829 The output of `mdb_stat -ea <path to blockchain dir>` will indicate inconsistencies in the blocks, block_heights and block_info table.
830
831 The output of `mdb_dump -s blocks <path to blockchain dir>` and `mdb_dump -s block_info <path to blockchain dir>` is useful for indicating whether blocks and block_info contain the same keys.
832
833 These records are dumped as hex data, where the first line is the key and the second line is the data.
834
835 # Known Issues
836
837 ## Protocols
838
839 ### Socket-based
840
841 Because of the nature of the socket-based protocols that drive monero, certain protocol weaknesses are somewhat unavoidable at this time. While these weaknesses can theoretically be fully mitigated, the effort required (the means) may not justify the ends. As such, please consider taking the following precautions if you are a monero node operator:
842
843 - Run `monerod` on a "secured" machine. If operational security is not your forte, at a very minimum, have a dedicated a computer running `monerod` and **do not** browse the web, use email clients, or use any other potentially harmful apps on your `monerod` machine. **Do not click links or load URL/MUA content on the same machine**. Doing so may potentially exploit weaknesses in commands which accept "localhost" and "127.0.0.1".
844 - If you plan on hosting a public "remote" node, start `monerod` with `--restricted-rpc`. This is a must.
845
846 ### Blockchain-based
847
848 Certain blockchain "features" can be considered "bugs" if misused correctly. Consequently, please consider the following:
849
850 - When receiving monero, be aware that it may be locked for an arbitrary time if the sender elected to, preventing you from spending that monero until the lock time expires. You may want to hold off acting upon such a transaction until the unlock time lapses. To get a sense of that time, you can consider the remaining blocktime until unlock as seen in the `show_transfers` command.