Компилирование клиента Dash Core

While Dash offers stable binary builds on the website and on GitHub, and development builds using Jenkins, many users will also be interested in building Dash binaries for themselves. The following guides are available:

These guides describe how to build the current stable version. To build the latest version from the develop branch, replace the normal git clone command with the following command when pulling from GitHub:

git clone https://github.com/dashpay/dash.git -b develop

Linux

This guide describes how to build Dash Core wallet without the GUI from source under Ubuntu Linux. For a more detailed guide, see the Unix Build Notes. The content on this page is intended to serve as a simple guide for general compilation of non-deterministic binary files from the stable source code. A standard installation of Ubuntu Linux 18.04 LTS will be used as an environment for the build. We assume you are running as a user with sudo permissions. First add the necessary extra repository and update all packages:

sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt update
sudo apt upgrade

Теперь установите зависимости в соответствии с установочной документацией:

sudo apt install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils git libdb4.8-dev libdb4.8++-dev curl
sudo apt install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libzmq3-dev

На ваше усмотрение установите Qt-зависимости, если хотите получить графический интерфейс Dash.

sudo apt install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler

Скачайте стабильный репозиторий Dash:

git clone https://github.com/dashpay/dash.git

И версия:

cd dash
./autogen.sh
./configure
make
make install

/usr/local/bin содержит скомпилированные версии Dash.

macOS

Dash can be built for macOS either using a cross-compiler under Linux or natively under macOS.

Linux cross-compile

This guide describes how to build Dash Core wallet from source under Ubuntu Linux. It is intended to serve as a simple guide for general compilation of non-deterministic binary files from the stable source code. For a more detailed guide, see the macOS Build Notes. A standard installation of Ubuntu Linux 18.04 LTS will be used as an environment for the build. We assume you are running as a user with sudo permissions. First add the necessary extra repository and update all packages:

sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt update
sudo apt upgrade

Теперь установите зависимости в соответствии с установочной документацией:

sudo apt install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils git libdb4.8-dev libdb4.8++-dev curl
sudo apt install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libzmq3-dev
sudo apt install ca-certificates curl g++ git-core pkg-config autoconf librsvg2-bin libtiff-tools libtool automake faketime bsdmainutils cmake imagemagick libcap-dev libz-dev libbz2-dev python python-dev python-setuptools fonts-tuffy p7zip-full sleuthkit

На ваше усмотрение установите Qt-зависимости, если хотите получить графический интерфейс Dash.

sudo apt install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler

Скачайте стабильный репозиторий Dash:

git clone https://github.com/dashpay/dash.git
cd dash

A copy of the macOS SDK is required during the build process. To download this, use a Google Chrome in a desktop environment to go to https://appleid.apple.com and create or sign in to your Apple account. Then go to https://developer.apple.com and open the Chrome Developer Tools from the Menu -> More tools -> Developer tools. Click on the Network tab, then go back to your main browser window and copy in the following URL:

https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_7.3.1/Xcode_7.3.1.dmg

Cancel the download as soon as it begins and go back to your the Network tab in the developer tools. Right click on the network request at the bottom of the list labeled Xcode_7.3.1.dmg and select Copy -> Copy as cURL (bash). Paste this long string of text into your Linux terminal, append -o Xcode_7.3.1.dmg at the end and then press enter to begin the download. Once it is complete, extract the required files from the disc image as follows:

contrib/macdeploy/extract-osx-sdk.sh
rm -rf 5.hfs MacOSX10.11.sdk
mkdir depends/SDKs
mv MacOSX10.11.sdk/ depends/SDKs/

И версия:

make -C depends HOST=x86_64-apple-darwin11
./autogen.sh
./configure --prefix=`pwd`/depends/x86_64-apple-darwin11
make

~/dash/src now contains the compiled Dash binaries, and ~/dash/src/qt contains the Dash GUI wallet.

macOS Native

This guide describes how to build Dash Core wallet from source under macOS. It is intended to serve as a simple guide for general compilation of non-deterministic binary files from the stable source code. For a more detailed guide, see the macOS Build Notes. A standard installation of macOS 10.13 High Sierra will be used as an environment for the build. We assume you are running as a user with sudo permissions. First, open a the Terminal app and enter the following command to install the OS X command line tools:

xcode-select --install

When the popup appears, click Install. Then install Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install dependencies:

brew install automake berkeley-db4 libtool boost --c++11 miniupnpc openssl pkg-config protobuf qt libevent librsvg

Clone the Dash Core source code and change to the dash directory:

git clone https://github.com/dashpay/dash
cd dash

Build Dash Core. Configure and build the headless dash binaries as well as the GUI (if Qt is found). You can disable the GUI build by passing --without-gui to configure:

./autogen.sh
./configure
make

It is recommended to build and run the unit tests:

make check

You can also create a .dmg that contains the .app bundle (optional):

make deploy

Dash Core is now available at ./src/dashd.

Windows

This guide describes how to build Dash Core wallet from source for 64-bit Windows. Most developers use cross-compilation from Linux to build executables for Windows. The content on this page is intended to serve as a simple guide for general compilation of non-deterministic binary files from the stable source code. For a more detailed guide, see the Windows Build Notes. A standard installation of Ubuntu Linux 18.04 LTS will be used as an environment for the build. We assume you are running as a user with sudo permissions. First add the necessary extra repository and update all packages:

sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt update
sudo apt upgrade

Теперь установите зависимости в соответствии с установочной документацией:

sudo apt install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils git libdb4.8-dev libdb4.8++-dev curl
sudo apt install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libzmq3-dev
sudo apt-get install g++-mingw-w64-x86-64 mingw-w64-x86-64-dev

На ваше усмотрение установите Qt-зависимости, если хотите получить графический интерфейс Dash.

sudo apt install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler

Скачайте стабильный репозиторий Dash:

git clone https://github.com/dashpay/dash.git

Build and link the depends system:

cd dash/depends
make HOST=x86_64-w64-mingw32
cd ..
sudo update-alternatives --set x86_64-w64-mingw32-gcc  /usr/bin/x86_64-w64-mingw32-gcc-posix
sudo update-alternatives --set x86_64-w64-mingw32-g++  /usr/bin/x86_64-w64-mingw32-g++-posix

И версия:

./autogen.sh
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/
make

~/dash/src now contains the compiled Dash binaries, and ~/dash/src/qt contains the Dash GUI wallet.

Gitian

Gitian - это процесс детерминизированной компиляции, который используется для получения исполнительных файлов Dash Core. Он обеспечивает уверенность, что исполнительные файлы были получены из источника на GitHub, а также что при компиляции в конечный исполнительный файл были статично встроены стабильные проверенные зависимости. Многие разработчики пишут исходный код с использованием особых дескрипторов («рецептов»), криптографически подписывают результат и выгружают соответствующую подпись. Эти результаты сравниваются и только при полном совпадении версия принимается и выкладывается на dash.org.

Эта инструкция была написана, потому что существует потребность в большем количестве независимых версий на Gitian. Желательно, чтобы вы сами выполнили указанные действия, а не использовали чью-то чужую VM-копию. Это нужно чтобы не „загрязнять“ версию.

Установка принимающей системы

Gitian-версии работают на Debian 8.x. Если у вас уже установлена эта система, то вы можете запускать Gitian-версии прямо на собственном оборудовании. Если нет, то вы можете установить её на виртуальную машину. Выполните установку VPS для Мастернод, выбрав раздел Debian 8.x во время процесса установки и назвав вашего пользователя без администраторских полномочий gitianuser. Выбрав для VPS машину с двумя процессорами, вы значительно ускорите процесс построения. Если вы не можете войти на свой VPS через SSH как администратор, то воспользуйтесь терминалом и выполните следующие команды:

sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
/etc/init.d/ssh restart

Войдите в вашу новую систему под SSH как администратор. Сначала установите зависимости, скопировав в терминал следующие команды:

apt-get install git ruby sudo apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils make ubuntu-archive-keyring curl
adduser gitianuser sudo

Потом установите LXC и всё нижеследующее:

# the version of lxc-start in Debian needs to run as root, so make sure
# that the build script can execute it without providing a password
echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-start" > /etc/sudoers.d/gitian-lxc
echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-execute" >> /etc/sudoers.d/gitian-lxc
# make /etc/rc.local script that sets up bridge between guest and host
echo '#!/bin/sh -e' > /etc/rc.local
echo 'brctl addbr br0' >> /etc/rc.local
echo 'ifconfig br0 10.0.3.2/24 up' >> /etc/rc.local
echo 'iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE' >> /etc/rc.local
echo 'echo 1 > /proc/sys/net/ipv4/ip_forward' >> /etc/rc.local
echo 'exit 0' >> /etc/rc.local
# make sure that USE_LXC is always set when logging in as gitianuser,
# and configure LXC IP addresses
echo 'export USE_LXC=1' >> /home/gitianuser/.profile
echo 'export GITIAN_HOST_IP=10.0.3.2' >> /home/gitianuser/.profile
echo 'export LXC_GUEST_IP=10.0.3.5' >> /home/gitianuser/.profile
reboot

В конце необходимо перезагрузить Debian, чтобы убедиться, что установки вступили в силу. Перезайдите как пользователь gitianuser, которого вы создали в ходе установки. Оставшиеся шаги в этом руководстве выполняются от имени этого пользователя.

В Debian нет пакета python-vm-builder, так что его придётся установить из источника самостоятельно:

wget http://archive.ubuntu.com/ubuntu/pool/universe/v/vm-builder/vm-builder_0.12.4+bzr494.orig.tar.gz
echo "76cbf8c52c391160b2641e7120dbade5afded713afaa6032f733a261f13e6a8e  vm-builder_0.12.4+bzr494.orig.tar.gz" | sha256sum -c
# (verification -- must return OK)
tar -zxvf vm-builder_0.12.4+bzr494.orig.tar.gz
cd vm-builder-0.12.4+bzr494
sudo python setup.py install
cd ..

Установите среду и скомпилируйте

Клонируйте репозиторий Dash Core в свой каталог home:

git clone https://github.com/dashpay/dash.git

Создайте скриптовый файл:

nano dash/contrib/gitian-build.sh

Вставьте следующий скрипт (это будет произведено автоматически когда и если скрипт присутствует в Dash Core):

https://github.com/strophy/dash/blob/master/contrib/gitian-build.sh

Сохраните файл и сделайте его исполнительным:

sudo chmod +x dash/contrib/gitian-build.sh

Установите среду, заменив имя и версию своим именем и целевой версией:

dash/contrib/gitian-build.sh --setup strophy 0.12.1.5

Запустите компилирующий скрипт:

dash/contrib/gitian-build.sh --build strophy 0.12.1.5

Ваша система построит версию клиента Dash Core со всеми зависимостями для Windows и Linux (и для macOS, если зависимости были установлены в соответствии с этими инструкциями). Это может занять какое-то время. По завершении вы увидите контрольные суммы SHA256, которые можно сравнить с теми, что доступны на сайте Dash. Теперь вы можете быть уверены, что используете оригинальную неизменённую версию кода, который приведён на GitHub.