Cài đặt

Cài đặt một masternode cần một mức độ hiểu biết cơ bản về Linux và công nghệ blockchain, cũng như khả năng làm theo các hướng dẫn một cách chính xác. Nó cũng cần phải thường xuyên bảo trì và bảo mật một cách cẩn thận, đặc biệt là nếu bạn không giữ Dash trong một ví phần cứng. Cần phải ra một số quyết định trong quá trình thực hiện, và một số bước bổ sung để tăng cường tính bảo mật.

Có các dịch vụ lưu trữ masternode nếu bạn thích việc uỷ nhiệm việc vận hành hàng ngày masternode của bạn cho những nhà vận hành chuyên nghiệp. Khi sử dụng dịch vụ lưu trữ, bạn vẫn giữ toàn quyền kiểm soát 1000 Dash đặt cọc và trả mức thoả thuận tương ứng với phần trăm của phần thưởng cho người vận hành. Bạn cũng có thể uỷ quyền bỏ phiếu cho một người đại diện, xem trong tài liệu về quản trị để biết thêm thông tin.

Trước khi bạn bắt đầu

Hướng dẫn này giả định rằng bạn thiết lập một masternode riêng trên mạng chính lần đầu tiên. Nếu bạn đang cập nhật một masternode, hãy xem ở đây. Bạn cũng cần:

  • 1000 Dash
  • Một ví để chứa Dash của bạn, tốt nhất là dùng một ví phần cứng, mặc dù ví Dash Core cũng có thể giúp bạn
  • Một máy chủ Linux, một máy chủ ảo (VPS) thì hay hơn

Dash 0.13.0 và sau đó triển khai DIP003, cái này mang đến một số thay đổi cách cài đặt và vận hành masternode của Dash. Trong khi nâng cấp mạng này đã được hoàn thành vào đầu năm 2019, chúng ta vẫn có một danh sách các tài liệu bên dưới:

Tài liệu này mo tả các câu lệnh khi chúng được nhập vào trong giao diện đồ hoạ của Dash bằng việc mở bảng điều khiển từ menu Công cụ > Giao diện gỡ rối, nhưng cũng có cùng kết quả trên một masternode bằng việc đánh cùng những câu lệnh đó và thêm tiền tố ~/.dashcore/dash-cli cho mỗi câu lệnh.

Cài đặt VPS của bạn

A VPS, more commonly known as a cloud server, is fully functional installation of an operating system (usually Linux) operating within a virtual machine. The virtual machine allows the VPS provider to run multiple systems on one physical server, making it more efficient and much cheaper than having a single operating system running on the "bare metal" of each server. A VPS is ideal for hosting a Dash masternode because they typically offer guaranteed uptime, redundancy in the case of hardware failure and a static IP address that is required to ensure you remain in the masternode payment queue. While running a masternode from home on a desktop computer is technically possible, it will most likely not work reliably because most ISPs allocate dynamic IP addresses to home users.

We will use Vultr hosting as an example of a VPS, although DigitalOcean, Amazon EC2, Google Cloud, Choopa and OVH are also popular choices. First create an account and add credit. Then go to the Servers menu item on the left and click + to add a new server. Select a location for your new server on the following screen:

../_images/setup-server-location.png

Màn hình chọn địa điểm cho máy chủ trên Vultr

Chọn kiểu máy chủ là Ubuntu 18.04 x64. Chúng ta sử dụng phiên bản LTS của Ubuntu thay cho phiên bản mới nhất bởi vì phiên bản LTS được hỗ trợ với các cập nhật bảo mật cho 5 năm, thay vì 9 tháng như thông thường.

../_images/setup-server-type.png

Màn hình chọn kiểu máy chủ trên Vultr

Chọn một máy chủ với kích thước bộ nhớ yêu cầu tối thiểu là 2GB

../_images/setup-server-size.png

Màn hình lựa chọn kích thước máy chủ trên Vultr

Nhập tên máy chủ và nhãn cho máy chủ của bạn. Trong ví dụ này thì chúng tôi sử dụng dashmn1 làm tên cho máy chủ.

../_images/setup-server-hostname.png

Tên máy chủ và màn hình lựa chọn nhãn trên Vultr

Vultr sẽ cài đặt máy chủ cho bạn. Quá trình này sẽ mất vài phút.

../_images/setup-server-installing.png

Màn hình cài đặt máy chủ ở Vultr

Bấm vào Manage khi việc cài đặt được hoàn tất và bạn nên ghi lại địa chỉ IP, tên người dùng và mật khẩu.

../_images/setup-server-manage.png

Màn hình quản lý máy chủ của Vultr

Cài đặt hệ điều hành của bạn

We will begin by connecting to your newly provisioned server. On Windows, we will first download an app called PuTTY to connect to the server. Go to the PuTTY download page and select the appropriate MSI installer for your system. On Mac or Linux you can ssh directly from the terminal - simply type ssh root@<server_ip> and enter your password when prompted.

../_images/setup-putty-download.png

Trang tải PuTTY

Double-click the downloaded file to install PuTTY, then run the app from your Start menu. Enter the IP address of the server in the Host Name field and click Open. You may see a certificate warning, since this is the first time you are connecting to this server. You can safely click Yes to trust this server in the future.

../_images/setup-putty-alert.png

Cảnh báo an ninh của PuTTY khi kết nối với một máy chủ mới

Bây giờ bạn đã kết nối với máy chủ của mình và sẽ nhìn thấy một cửa sổ làm việc. Bắt đầu bằng việc đăng nhập vào máy chủ của bạn với tên người dùng là root và mật khẩu được cung cấp bởi nhà cung cấp dịch vụ lưu trữ của bạn.

../_images/setup-putty-connect.png

Yêu cầu mật khẩu khi bạn kết nối với máy chủ ảo - còn gọi là "VPS" trong lần đầu tiên

You should immediately change the root password and store it in a safe place for security. You can copy and paste any of the following commands by selecting them in your browser, pressing Ctrl + C, then switching to the PuTTY window and right-clicking in the window. The text will paste at the current cursor location:

passwd root

Nhập và nhập lại một khẩu mới (tốt nhất đủ dài và được sinh một cách ngẫu hiên). Tiếp đó chúng ta sẽ tạo một người dùng mới bằng câu lệnh sau, thay <username> với một tên người dùng mà bạn chọn:

adduser <username>

Bạn sẽ được nhắc nhập mật khẩu. Nhập và xác nhận lại một mật khẩu mới (khác với mật khẩu root) và lưu nó ở một nơi an toàn. Bạn cũng sẽ được nhắc về thông tin cho người dùng, nhưng cứ để nó trống. Một khi người dùng được tạo, chúng ta sẽ đưa nó vào trong nhóm sudo và họ có thể thực hiện các câu lệnh như là root:

usermod -aG sudo <username>

Bây giờ, trong khi vẫn là root, chúng ta sẽ cập nhật hệ thống từ hệ thống quản lý ứng dụng của Ubuntu:

apt update
apt upgrade

The system will show a list of upgradable packages. Press Y and Enter to install the packages. We will now install a firewall (and some other packages we will use later), add swap memory and reboot the server to apply any necessary kernel updates, and then login to our newly secured environment as the new user:

apt install ufw python virtualenv git unzip pv

(bấm YEnter để xác nhận)

ufw allow ssh/tcp
ufw limit ssh/tcp
ufw allow 9999/tcp
ufw logging on
ufw enable

(bấm YEnter để xác nhận)

fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
nano /etc/fstab

Thêm dòng sau đây và ở cuối của file (bấm phím tab để phân cách mỗi từ/số), sau đó bấm tổ hợp phím Ctrl + X để đóng trình soạn thảo. sau đó YEnter để lưu file.

/swapfile none swap sw 0 0

Cuối cùng, để ngăn chặn việc dò mật khẩu, chúng ta sẽ cài fail2ban và tắt quyền truy cập ssh với root. Những bước sau là tuy chọn, nhưng rất khuyến khích. Bắt đầu với fail2ban nhé:

apt install fail2ban

Tạo một file cấu hình mới:

nano /etc/fail2ban/jail.local

Và dán cấu hinhf sau đây:

[sshd]
enabled = true
port = 22
filter = sshd
logpath = /var/log/auth.log
maxretry = 3

Bấm tổ hợp phím Ctrl + X để đóng trình soạn thảo, sau đó YEnter để lưu file. Khởi động lại và bật dịch vụ fail2ban:

systemctl restart fail2ban
systemctl enable fail2ban

Tiếp theo, mở file cấu hình SSH để tắt quyền đăng nhập của root qua SSH:

nano /etc/ssh/sshd_config

Locate the line that reads PermitRootLogin yes and set it to PermitRootLogin no. Directly below this, add a line which reads AllowUsers <username>, replacing <username> with the username you selected above. Then press Ctrl + X to close the editor, then Y and Enter save the file.

Sau đó khởi động lại máy chủ:

reboot now

PuTTY sẽ ngắt kết nối khi máy chủ khởi động lại.

While this setup includes basic steps to protect your server against attacks, much more can be done. In particular, authenticating with a public key instead of a username/password combination and enabling automatic security updates is advisable. More tips are available here. However, since the masternode does not actually store the keys to any Dash, these steps are considered beyond the scope of this guide.

Gửi khoản đặt cọc

A Dash address with a single unspent transaction output (UTXO) of exactly 1000 DASH is required to operate a masternode. Once it has been sent, various keys regarding the transaction must be extracted for later entry in a configuration file and registration transaction as proof to write the configuration to the blockchain so the masternode can be included in the deterministic list. A masternode can be registered from a hardware wallet or the official Dash Core wallet, although a hardware wallet is highly recommended to enhance security and protect yourself against hacking. This guide will describe the steps for both hardware wallets and Dash Core.

Tuỳ chọn 1: Gửi từ một ví phần cứng

Set up your Trezor using the Trezor wallet at https://wallet.trezor.io/ and send a test transaction to verify that it is working properly. For help on this, see this guide - you may also choose to (carefully!) add a passphrase to your Trezor to further protect your collateral. Create a new account in your Trezor wallet by clicking Add account. Then click the Receive tab and send exactly 1000 DASH to the address displayed. If you are setting up multiple masternodes, send 1000 DASH to consecutive addresses within the same new account. You should see the transaction as soon as the first confirmation arrives, usually within a few minutes.

../_images/setup-collateral-trezor.png

Trang Wallet Receive của Trezor hiển thị đã nhận được giao dịch đặt cọc 1000 DASH

Once the transaction appears, click the QR code on the right to view the transaction on the blockchain. Keep this window open as we complete the following steps, since we will soon need to confirm that 15 confirmations exist, as shown in the following screenshot.

../_images/setup-collateral-blocks.png

Trình khám phá blockchain hiển thị 15 xác thực cho giao dịch đặt cọc

While we are waiting for 15 confirmations, download the latest version of the Dash Masternode Tool (DMT) from the GitHub releases page here. Unzip and run the file. The following window appears.

../_images/setup-collateral-dmt-start.png

Màn hình khởi động của Dash Masternode Tool

Click the third button from the left Check Dash Network Connection in the top left corner of the main window to verify that the connection is working. Then connect your Trezor device and click the next button Test Hardware Wallet Connection to verify the Trezor connection is working.

../_images/setup-collateral-connection.png
../_images/setup-collateral-hardware.png

Dash Masternode Tool xác nhận kết nối thành công

Bây giờ chúng ta sẽ sử dụng DMT để nhập vào một số thông tin căn bản về masternode và trích mã giao dịch. Thực hiện chuỗi các bước sau đây như trong ảnh chụp màn hình này:

../_images/setup-collateral-dmt-steps.png

Các bước cấu hình Dash Masternode Tool

  1. Bấm nút New.
  2. Nhập tên cho masternode của bạn. Bạn có thể dùng luôn tên máy chủ mà bạn xác định cho VPS ở trên.
  3. Nhập vào địa chỉ IP masternode của bạn. Địa chỉ này được cung cấp cho bạn bởi nhà cung cấp VPS khi bạn cài đặt máy chủ. Sau đó nhập vào số cổng TCP. Nó sẽ là 9999.
  4. Click Locate collateral to view unused collateral funding transactions available on the connected hardware wallet. Select the address to which you sent 1000 Dash and click Apply. The Collateral address, path, Collateral TX hash and index fields should be filled automatically.
../_images/setup-collateral-dmt-ready.png

Dash Masternode Tool với cấu hình masternode

Cứ để DMT mở và tiếp tục bước tiếp theo: Cài đặt Dash Core trên máy chủ ảo.

Tuỳ chọn 2: Gửi từ ví Dash Core

Mở ví Dash Core và đợi cho nó đồng bộ với mạng lưới. Nó sẽ nhìn như thế này khi đã sẵn sàng:

../_images/setup-collateral-dashcore.png

Ví Dash Core đã được đồng bộ xong

Click vào Công cụ > Giao diện gỡ rối để mở cửa sổ này. Nhập vào câu lệnh sau trong cửa sổ để sinh ra một địa chỉ Dash mới dùng cho việc gửi khoản đặt cọc:

getnewaddress
yiFfzbwiN9oneftd7cEfr3kQLRwQ4kp7ue

Take note of the collateral address, since we will need it later. The next step is to secure your wallet (if you have not already done so). First, encrypt the wallet by selecting Settings > Encrypt wallet. You should use a strong, new password that you have never used somewhere else. Take note of your password and store it somewhere safe or you will be permanently locked out of your wallet and lose access to your funds. Next, back up your wallet file by selecting File > Backup Wallet. Save the file to a secure location physically separate to your computer, since this will be the only way you can access our funds if anything happens to your computer. For more details on these steps, see here.

Now send exactly 1000 DASH in a single transaction to the new address you generated in the previous step. This may be sent from another wallet, or from funds already held in your current wallet. Once the transaction is complete, view the transaction in a blockchain explorer by searching for the address. You will need 15 confirmations before you can register the masternode, but you can continue with the next step at this point already: generating your masternode operator key.

../_images/setup-collateral-blocks.png

Trình khám phá blockchain hiển thị 15 xác thực cho giao dịch đặt cọc

Cài đặt phần mềm Dash Core

Dash Core là phần mềm đằng sau cả ví đồ hoạ Dash Core và Dash masternode. Nếu không hiển thị một giao diện đồ họ, nó chạy ngầm như một dịch vụ trên máy chủ (dashd), được điều khiển bởi giao diện câu lệnh đơn giản (dash-cli).

Open PuTTY or a console again and connect using the username and password you just created for your new, non-root user. There are two options to install Dash Core, an automated option using a script utility called dashman, and a more complicated option which will allow you to understand all of the key steps involved in preparing your masternode.

Tuỳ chọn 1: Tự động cài đặt sử dụng dashman

Để cài đặt Dash với dashman, nhập vào câu lệnh sau đây sau khi bạn đăng nhập:

cd ~
git clone https://github.com/moocowmoo/dashman
~/dashman/dashman install

(bấm YEnter để xác nhận)

dashman sẽ tải phiên bản mới nhất của Dash Core vào hệ thống của bạn và một phần của blockchain để tăng tốc cho quá trình bootstrapping. Tiếp theo là tải và cài Sentinel, nó cần cho masternode từ phiên bản 0.12.1 hoặc cao hơn.

~/dashman/dashman install sentinel

Your system is now running as a standard Dash node, and is busy completing synchronisation with the blockchain. Since dashman does not automatically restart your masternode in the event of a system error, add a check function to crontab to make sure it checks every minute to ensure your masternode is still running:

crontab -e

Sử dụng nano làm trình soạn thảo cho bạn và nhập vào dòng sau đây vào phần cuối của file, sau dòng dành cho sentinel:

* * * * * { pidof dashd || ~/.dashcore/dashd;} >/dev/null 2>&1

Press enter to make sure there is a blank line at the end of the file, then press Ctrl + X to close the editor and Y and Enter save the file. Check the sync status and wait until all blockchain synchronisation and the 15 confirmations for the collateral transaction are complete:

~/dashman/dashman status
../_images/setup-dashman-done.png

dashman status output hiển thị masternode đã sẵn sàng để đăng ký

Tiếp tục với bước tiếp theo để đăng ký masternode của bạn.

Tuỳ chọn 2: Cài đặt bằng tay

To manually download and install the components of your Dash masternode, visit the GitHub releases page and copy the link to the latest x86_64-linux-gnu version. Go back to your terminal window and enter the following command, pasting in the address to the latest version of Dash Core by right clicking or pressing Ctrl + V:

cd /tmp
wget https://github.com/dashpay/dash/releases/download/v0.15.0.0/dashcore-0.15.0.0-x86_64-linux-gnu.tar.gz

Kiểm tra tính toàn vẹn của file được tải bằng việc chạy câu lệnh sau và so sánh giá trị đầu ra với giá trị trong file SHA256SUMS.asc:

wget https://github.com/dashpay/dash/releases/download/v0.15.0.0/SHA256SUMS.asc
sha256sum dashcore-0.15.0.0-x86_64-linux-gnu.tar.gz
cat SHA256SUMS.asc

You can also optionally verify the authenticity of your download as an official release by Dash Core Team. All releases of Dash are signed using GPG by Alexander Block (codablock) with the key 63A9 6B40 6102 E091, verifiable here on Keybase. Import the key, download the ASC file for the current release of Dash and verify the signature as follows:

curl https://keybase.io/codablock/pgp_keys.asc | gpg --import
gpg --verify SHA256SUMS.asc
../_images/setup-manual-gpg.png

Tải xuống khoá PGP và kiểm tra chương trình so với chữ ký

Tạo một thư mục làm việc cho Dash, gỡ nén file và copy các file cần thiết vào thu mục này:

mkdir ~/.dashcore
tar xfv dashcore-0.15.0.0-x86_64-linux-gnu.tar.gz
cp -f dashcore-0.15.0/bin/dashd ~/.dashcore/
cp -f dashcore-0.15.0/bin/dash-cli ~/.dashcore/

Tạo một file cấu hình sử dụng câu lệnh sau đây:

nano ~/.dashcore/dash.conf

An editor window will appear. We now need to create a configuration file specifying several variables. Copy and paste the following text to get started, then replace the variables specific to your configuration as follows:

#----
rpcuser=XXXXXXXXXXXXX
rpcpassword=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
rpcallowip=127.0.0.1
#----
listen=1
server=1
daemon=1
#----
#masternode=1
#masternodeblsprivkey=
externalip=XXX.XXX.XXX.XXX
#----

Thay những trường được đánh dâu với XXXXXXX như sau:

  • rpcuser: nhập vào bất kỳ xâu các chữ số hoặc chữ cái nào, không dùng các ký tự đặc biệt
  • rpcpassword: nhập vào bất kỳ xâu các chữ số hoặc chữ cái nào, không dùng các ký tự đặc biệt
  • externalip: đây là địa chỉ IP của máy chủ của bạn

Tạm thời cứ để mặc các trường masternodemasternodeblsprivkey dưới dấu comment. Kết quả sẽ có dạng như sau:

../_images/setup-manual-conf.png

Nhập vào những dữ liệu quan trọng vào file dash.conf trên masternode

Bấm tổ hợp phím Ctrl + X để đóng trình soạn thảo và YEnter để lưu file. Bây giờ bạn có thể bắt đầu chạy Dash trên masternode để bắt đầu đồng bộ blockchain:

~/.dashcore/dashd

You will see a message reading Dash Core server starting. We will now install Sentinel, a piece of software which operates as a watchdog to communicate to the network that your node is working properly:

cd ~/.dashcore
git clone https://github.com/dashpay/sentinel.git
cd sentinel
virtualenv venv
venv/bin/pip install -r requirements.txt
venv/bin/python bin/sentinel.py

Bạn sẽ nhìn thấy một thông báo dashd not synced with network! Awaiting full sync before running Sentinel. Thêm dashd và sentinel vào crontab để đảm bảo rằng nó sẽ chạy mỗi phút để kiểm tra masternode của bạn:

crontab -e

Chọn nano làm trình soạn thảo của bạn và nhập vào các dòng sau đây vào phần cuối của file:

* * * * * cd ~/.dashcore/sentinel && ./venv/bin/python bin/sentinel.py 2>&1 >> sentinel-cron.log
* * * * * pidof dashd || ~/.dashcore/dashd

Press enter to make sure there is a blank line at the end of the file, then press Ctrl + X to close the editor and Y and Enter save the file. We now need to wait for 15 confirmations of the collateral transaction to complete, and wait for the blockchain to finish synchronizing on the masternode. You can use the following commands to monitor progress:

~/.dashcore/dash-cli mnsync status

Khi quá trình đồng bộ hoàn tất, bạn sẽ thấy những phản hồi như sau:

{
  "AssetID": 999,
  "AssetName": "MASTERNODE_SYNC_FINISHED",
  "AssetStartTime": 1558596597,
  "Attempt": 0,
  "IsBlockchainSynced": true,
  "IsSynced": true,
  "IsFailed": false
}

Tiếp tục với bước tiếp theo để thiết lâu giao dịch ProTx cần cho việc kích hoạt masternode của bạn.

Đăng ký masternode của bạn

DIP003 introduced several changes to how a masternode is set up and operated. These changes and the three keys required for the different masternode roles are described briefly under DIP003 Những thay đổi Masternode in this documentation.

Tuỳ chọn 1: Đăng ký từ một ví phần cứng

Go back to DMT and ensure that all fields from the previous step are still filled out correctly. Click Generate new for the three private keys required for a DIP003 deterministic masternode:

  • Khoá riêng của chủ sở hữu
  • Khoá riêng của người vận hành
  • Khoá riêng bỏ phiếu
../_images/setup-dmt-full.png

Dash Masternode Tool sẵn sàng cho việc đăng ký một masternode mới

Then click Register masternode. Optionally specify a different Payout address and/or Operator reward, then click Continue. Select Remote Dash RPC Node (automatic method). (See here for documentation on using your own local RPC node.) and confirm the following two messages:

../_images/setup-dmt-send.png
../_images/setup-dmt-sent.png

Các bảng hội thoại của Dash Masternode Tool xác nhận việc đăng ký một masternode

The BLS private key must be entered in the dash.conf file on the masternode. This allows the masternode to watch the blockchain for relevant Pro*Tx transactions, and will cause it to start serving as a masternode when the signed ProRegTx is broadcast by the owner, as we just did above. Log in to your masternode using ssh or PuTTY and edit the configuration file as follows:

nano ~/.dashcore/dash.conf

The editor appears with the existing masternode configuration. Add or uncomment these lines in the file, replacing the key with your BLS private key generated above:

masternode=1
masternodeblsprivkey=24c1fa3c22c6ea6b1cc68a37be18acb51042b19465fe0a26301c8717bf939805

Press enter to make sure there is a blank line at the end of the file, then press Ctrl + X to close the editor and Y and Enter save the file. We now need to restart the masternode for this change to take effect. Enter the following commands, waiting a few seconds in between to give Dash Core time to shut down:

~/.dashcore/dash-cli stop
sleep 15
~/.dashcore/dashd

At this point you can monitor your masternode using ~/dashman/dashman status, by entering ~/.dashcore/dash-cli masternode status or using the Get status function in DMT. The final result should appear as follows:

../_images/setup-dash-cli-start.png

dash-cli masternode status output hiển thị masternode được đăng ký thành công

Ở thời điểm này bạn có thể thoát khỏi máy chủ của bạn bằng việc gõ exit. Chúc mừng bạn! Masternode của bạn bây giờ đang được chạy.

Tuỳ chọn 2: Đăng ký từ ví Dash Core

Xác định giao dịch cấp vốn

If you used an address in Dash Core wallet for your collateral transaction, you now need to find the txid of the transaction. Click Tools > Debug console and enter the following command:

masternode outputs

Điều này sẽ trả về một chuỗi các ký tự tương tự như sau

{
"16347a28f4e5edf39f4dceac60e2327931a25fdee1fb4b94b63eeacf0d5879e3" : "1",
}

Dòng dài đầu tiên là collateralHash của bạn, còn số cuối cùng là collateralIndex.

Sinh một cặp khoá BLS

A public/private BLS key pair is required to operate a masternode. The private key is specified on the masternode itself, and allows it to be included in the deterministic masternode list once a provider registration transaction with the corresponding public key has been created.

If you are using a hosting service, they may provide you with their public key, and you can skip this step. If you are hosting your own masternode or have agreed to provide your host with the BLS private key, generate a BLS public/private keypair in Dash Core by clicking Tools > Debug console and entering the following command:

bls generate

{
  "secret": "395555d67d884364f9e37e7e1b29536519b74af2e5ff7b62122e62c2fffab35e",
  "public": "99f20ed1538e28259ff80044982372519a2e6e4cdedb01c96f8f22e755b2b3124fbeebdf6de3587189cf44b3c6e7670e"
}

Những khoá này KHÔNG được lưu trữ bởi ví mà phải giữ một cách bảo mật, tương tự như giá trị được cung cấp bởi câu lệnh masternode genkey trước đây

Thêm khoá riêng vào cấu hình masternode của bạn

The public key will be used in following steps. The private key must be entered in the dash.conf file on the masternode. This allows the masternode to watch the blockchain for relevant Pro*Tx transactions, and will cause it to start serving as a masternode when the signed ProRegTx is broadcast by the owner (final step below). Log in to your masternode using ssh or PuTTY and edit the configuration file as follows:

nano ~/.dashcore/dash.conf

The editor appears with the existing masternode configuration. Add or uncomment these lines in the file, replacing the key with your BLS private key generated above:

masternode=1
masternodeblsprivkey=395555d67d884364f9e37e7e1b29536519b74af2e5ff7b62122e62c2fffab35e

Press enter to make sure there is a blank line at the end of the file, then press Ctrl + X to close the editor and Y and Enter save the file. We now need to restart the masternode for this change to take effect. Enter the following commands, waiting a few seconds in between to give Dash Core time to shut down:

~/.dashcore/dash-cli stop
sleep 15
~/.dashcore/dashd

Chúng ta sẽ chuẩn bị giao dịch được dùng để đăng ký masternode lên mạng.

Chuẩn bị cho một giao dịch ProRegTx

A pair of BLS keys for the operator were already generated above, and the private key was entered on the masternode. The public key is used in this transaction as the operatorPubKey.

First, we need to get a new, unused address from the wallet to serve as the owner key address (ownerKeyAddr). This is not the same as the collateral address holding 1000 Dash. Generate a new address as follows:

getnewaddress

yfgxFhqrdDG15ZWKJAN6dQvn6dZdgBPAip

This address can also be used as the voting key address (votingKeyAddr). Alternatively, you can specify an address provided to you by your chosen voting delegate, or simply generate a new voting key address as follows:

getnewaddress

yfRaZN8c3Erpqj9iKnmQ9QDBeUuRhWV3Mg

Then either generate or choose an existing address to receive the owner's masternode payouts (payoutAddress). It is also possible to use an address external to the wallet:

getnewaddress

yjZVt49WsQd6XSrPVAUGXtJccxviH9ZQpN

You can also optionally generate and fund another address as the transaction fee source (feeSourceAddress). If you selected an external payout address, you must specify a fee source address. Either the payout address or fee source address must have enough balance to pay the transaction fee, or the final register_submit transaction will fail.

The private keys to the owner and fee source addresses must exist in the wallet submitting the transaction to the network. If your wallet is protected by a password, it must now be unlocked to perform the following commands. Unlock your wallet for 5 minutes:

walletpassphrase yourSecretPassword 300

We will now prepare an unsigned ProRegTx special transaction using the protx register_prepare command. This command has the following syntax:

protx register_prepare collateralHash collateralIndex ipAndPort ownerKeyAddr
  operatorPubKey votingKeyAddr operatorReward payoutAddress (feeSourceAddress)

Open a text editor such as notepad to prepare this command. Replace each argument to the command as follows:

  • collateralHash: Mã txid của giao dịch đặt cọc 1000 Dash
  • collateralIndex: Chỉ số đầu ra của giao dịch cấp vốn 1000 Dash
  • ipAndPort: Địa chỉ IP và cổng của masternode, theo định dạng x.x.x.x:yyyy
  • ownerKeyAddr: Địa chỉ Dash mới được sinh ở trên cho địa chỉ sở hữu/bỏ phiếu
  • operatorPubKey: Khoá công khai BLS được sinh ở trên (hoặc được cung cấp bởi nhà cung cấp dịch vụ lưu trữ)
  • votingKeyAddr: Địa chỉ Dash mới được sinh ở trên, hoặc địa chỉ uỷ nhiệm cho việc bỏ phiếu các đề xuất
  • operatorReward: Phần trăm phần thưởng khối sẽ được trả cho người vận hành
  • payoutAddress: Một địa chỉ mới hoặc cũ để nhận phần thưởng khối cho người chủ sở hữu
  • feeSourceAddress: Một địa chỉ (tuỳ chọn) dùng để cấp vốn cho khoản phí ProTx. Nếu feeSourceAddress không được cung cấp nó sẽ lấy tiền phí từ địa chỉ payoutAddress.

Note that the operator is responsible for specifying their own reward address in a separate update_service transaction if you specify a non-zero operatorReward. The owner of the masternode collateral does not specify the operator's payout address.

Ví dụ (hãy xoá các xuống dòng nếu copy):

protx register_prepare
  16347a28f4e5edf39f4dceac60e2327931a25fdee1fb4b94b63eeacf0d5879e3
  1
  45.76.230.239:19999
  yfgxFhqrdDG15ZWKJAN6dQvn6dZdgBPAip
  99f20ed1538e28259ff80044982372519a2e6e4cdedb01c96f8f22e755b2b3124fbeebdf6de3587189cf44b3c6e7670e
  yfRaZN8c3Erpqj9iKnmQ9QDBeUuRhWV3Mg
  0
  yjZVt49WsQd6XSrPVAUGXtJccxviH9ZQpN
  yR83WsikBaBaNusTnHZf28kAcL8oVmp1TE

Đầu ra:

{
  "tx": "030001000175c9d23c2710798ef0788e6a4d609460586a20e91a15f2097f56fc6e007c4f8e0000000000feffffff01a1949800000000001976a91434b09363474b14d02739a327fe76e6ea12deecad88ac00000000d1010000000000e379580dcfea3eb6944bfbe1de5fa2317932e260acce4d9ff3ede5f4287a34160100000000000000000000000000ffff2d4ce6ef4e1fd47babdb9092489c82426623299dde76b9c72d9799f20ed1538e28259ff80044982372519a2e6e4cdedb01c96f8f22e755b2b3124fbeebdf6de3587189cf44b3c6e7670ed1935246865dce1accce6c8691c8466bd67ebf1200001976a914fef33f56f709ba6b08d073932f925afedaa3700488acfdb281e134504145b5f8c7bd7b47fd241f3b7ea1f97ebf382249f601a0187f5300",
  "collateralAddress": "yjSPYvgUiAQ9AFj5tKFA8thFLoLBUxQERb",
  "signMessage": "yjZVt49WsQd6XSrPVAUGXtJccxviH9ZQpN|0|yfgxFhqrdDG15ZWKJAN6dQvn6dZdgBPAip|yfRaZN8c3Erpqj9iKnmQ9QDBeUuRhWV3Mg|ad5f82257bd00a5a1cb5da1a44a6eb8899cf096d3748d68b8ea6d6b10046a28e"
}

Next we will use the collateralAddress and signMessage fields to sign the transaction, and the output of the tx field to submit the transaction.

Ký cho giao dịch ProRegTx

We will now sign the content of the signMessage field using the private key for the collateral address as specified in collateralAddress. Note that no internet connection is required for this step, meaning that the wallet can remain disconnected from the internet in cold storage to sign the message. In this example we will again use Dash Core, but it is equally possible to use the signing function of a hardware wallet. The command takes the following syntax:

signmessage collateralAddress signMessage

Ví dụ:

signmessage yjSPYvgUiAQ9AFj5tKFA8thFLoLBUxQERb yjZVt49WsQd6XSrPVAUGXtJccxviH9ZQpN|0|yfgxFhqrdDG15ZWKJAN6dQvn6dZdgBPAip|yfRaZN8c3Erpqj9iKnmQ9QDBeUuRhWV3Mg|ad5f82257bd00a5a1cb5da1a44a6eb8899cf096d3748d68b8ea6d6b10046a28e

Đầu ra:

II8JvEBMj6I3Ws8wqxh0bXVds6Ny+7h5HAQhqmd5r/0lWBCpsxMJHJT3KBcZ23oUZtsa6gjgISf+a8GzJg1BfEg=

Gửi thông điệp đã được ký

We will now submit the ProRegTx special transaction to the blockchain to register the masternode. This command must be sent from a Dash Core wallet holding a balance on either the feeSourceAddress or payoutAddress, since a standard transaction fee is involved. The command takes the following syntax:

protx register_submit tx sig

Ở đó:

  • tx: Kết quả trường đầu ra tx được trả về từ câu lệnh protx register_prepare
  • sig: Là thông điệp được ký với khoá đặt cọc từ câu lệnh signmessage

Ví dụ:

protx register_submit 030001000175c9d23c2710798ef0788e6a4d609460586a20e91a15f2097f56fc6e007c4f8e0000000000feffffff01a1949800000000001976a91434b09363474b14d02739a327fe76e6ea12deecad88ac00000000d1010000000000e379580dcfea3eb6944bfbe1de5fa2317932e260acce4d9ff3ede5f4287a34160100000000000000000000000000ffff2d4ce6ef4e1fd47babdb9092489c82426623299dde76b9c72d9799f20ed1538e28259ff80044982372519a2e6e4cdedb01c96f8f22e755b2b3124fbeebdf6de3587189cf44b3c6e7670ed1935246865dce1accce6c8691c8466bd67ebf1200001976a914fef33f56f709ba6b08d073932f925afedaa3700488acfdb281e134504145b5f8c7bd7b47fd241f3b7ea1f97ebf382249f601a0187f5300 II8JvEBMj6I3Ws8wqxh0bXVds6Ny+7h5HAQhqmd5r/0lWBCpsxMJHJT3KBcZ23oUZtsa6gjgISf+a8GzJg1BfEg=

Đầu ra:

aba8c22f8992d78fd4ff0c94cb19a5c30e62e7587ee43d5285296a4e6e5af062

Your masternode is now registered and will appear on the Deterministic Masternode List after the transaction is mined to a block. You can view this list on the Masternodes -> DIP3 Masternodes tab of the Dash Core wallet, or in the console using the command protx list valid, where the txid of the final protx register_submit transaction identifies your masternode.

At this point you can go back to your terminal window and monitor your masternode using ~/dashman/dashman status, by entering ~/.dashcore/dash-cli masternode status or using the Get status function in DMT. The final result should appear as follows:

../_images/setup-dashman-started.png

dashman status output hiển thị masternode được đăng ký thành công

Ở thời điểm này bạn có thể thoát khỏi máy chủ của bạn bằng việc gõ exit. Chúc mừng bạn! Masternode của bạn bây giờ đang được chạy.