高级功能#

达世币轻钱包 Electrum 以比特币轻钱包为基础,因此两者之间的功能大致相同,这意味着没有必要在这里重复有关轻钱包的文档内容。在下文中,我们将重点描述常用的高级功能。如需详细了解比特币及达世币轻钱包的高级功能,请点击以下链接。

匿名支付#

PrivateSend offers users enhanced privacy when creating transactions by splitting the user’s balance into a number of predefined denominations in advance of spending. This process is known as CoinJoin. PrivateSend is available in Dash Electrum versions 3.3.8.3 and higher, with support for hardware wallets added in 3.3.8.7.

Processing and sending#

To start PrivateSend processing in Dash Electrum, select Wallet > PrivateSend or click the PS icon in the lower right corner of the main window. The following window appears:

../../../../_images/ps-view.png

PrivateSend dialog in Dash Electrum#

Enter the Amount of Dash to keep anonymized and the number of PrivateSend rounds to use. Then click Enable PrivateSend, followed by Start Mixing. The process will begin, and the Mixing Progress bar shows the completion progress. Additional information on the process is available on the Info and Log tabs.

When processing is complete, simply check the PrivateSend checkbox on the Send tab before sending your transaction. Dash Electrum will only use Dash processed according to your specifications for the transaction.

硬件钱包#

You can use hardware wallets with Dash Electrum. Under Linux, it may be necessary to first install dependencies and udev rules as follows:

sudo apt-get install python3-dev python3-pip cython3 libusb-1.0-0-dev libudev-dev
sudo pip3 install trezor

PrivateSend processing is also supported. Starting PrivateSend processing in Dash Electrum with a hardware wallet will generate a new HD wallet and mnemonic for the PrivateSend keystore. A transaction from the hardware wallet to an address in this keystore will be created, and processing will begin. You can then spend the processed Dash, or send it back to your hardware wallet.

主节点#

Dash Electrum supports masternode creation through the DIP3 tab.

DIP3#

The DIP3 tab can be enabled via the View > Show DIP3 menu. This tab displays the status of your masternode(s) and also allows viewing a list of all registered masternodes on the network.

The tab displays the following data about each masternode you have set up:

  • 主节点的别名(名称)。

  • The state of the masternode (e.g. whether it has been activated).

  • The keys

  • The Provider Registration transaction hash of the masternode.

  • 接通主节点的IP地址和端口。

../../../../_images/mn-dip3-registered-owner-operator.png

DIP3 tab with masternode information#

主节点架设#

To setup a masternode, navigate to the DIP3 tab and click the Add/Import button.

备注

If combined with Electrum’s multisig features the masternode collateral can be stored in a multisig wallet for increased security flexibility. See this page for the Dash Electrum documentation demonstrating how to configure a masternode using a multisig collateral.

Always exercise caution when using multisig accounts and verify that each mnemonic is backed up appropriately.

../../../../_images/mn-dip3-add-or-import.png

Add or import masternode#

Electrum supports creating/registering new masternodes as well as importing and registering legacy masternodes via a masternode.conf file. At this point very few legacy masternodes are present, so only the Create and register DIP3 Masternode option will be covered in detail.

There are two supported ownership types: owner-only and owner/operator. The primary difference during setup is whether or not the operator BLS private key is stored in Electrum. The following steps show the creation of a self-hosted masternode so both ownership type checkboxes are selected. Click Next to continue.

../../../../_images/mn-create-and-register-owner-operator.png

Select operation type and ownership properties#

To start a masternode, you must have a 1000 DASH plus a small amount for fees available in your wallet. Leave Create collateral as ProRegTx output checked and click Next.

../../../../_images/mn-create-select-collateral.png

Select collateral output for masternode#

Certain information about your masternode is required. The IP address and port that your masternode uses must be supplied. Click Next after entering them (the port will be set to the default mainnet port of 9999 automatically).

../../../../_images/mn-create-service-params.png

Enter masternode IP address and port#

Each masternode requires three addresses: owner, voting, and payout. Electrum will automatically select addresses from your wallet. Click Next to continue.

../../../../_images/mn-create-select-addresses.png

Select masternode owner, voting, and payout addresses#

A masternode requires a BLS “operator” key as described in DIP3. If you manage your own masternode, both Dash Electrum and your masternode must know the operator private key. Your masternode will use the private key to sign messages, and the Dash network will know that you authorized it to do so.

Electrum will generate the required BLS private/public key pair and provide you with the line that must be copied to the masternode for proper masternode configuration. Click Next after copying this line to your masternode’s dash.conf file.

../../../../_images/mn-create-bls-key-setup.png

BLS key setup#

All parameters are now configured. This screen shows the configuration details and allows you to save the information. Make sure the Make ProRegTx after saving Masternode data box is checked, then click Save. The Send tab will open and be populated with the info necessary to register the masternode.

../../../../_images/mn-create-review-and-save.png

Examine parameters and save masternode#

Registering your masternode#

Since the ProRegTx information required to register the masternode was filled out by the previous step, just Click Pay… to complete the registration.

备注

To complete registration of any previously setup masternode, go to the DIP3 tab, select the unregistered masternode from the list of Wallet MNs, and click Register.

../../../../_images/mn-proregtx.png

Send tab with ProRegTx prepared#

Enter your password and click Send to broadcast the registration transaction.

../../../../_images/mn-proregtx-confirm-tx.png

Confirm ProRegTx Transaction#

The transaction hash will be displayed once the transaction has been sent successfully. This ProRegTx hash is used by the network to uniquely identify the masternode. Click OK to close the screen.

../../../../_images/mn-proregtx-sent-confirmation.png

Transaction sent screen showing transaction hash#

Prior to the ProRegTx being confirmed the new masternode will appear as unregistered on the DIP3 tab.

../../../../_images/mn-dip3-unregistered.png

DIP3 tab showing unregistered masternode#

Once the ProRegTx has been confirmed, the new masternode will appear as registered on the DIP3 tab.

../../../../_images/mn-dip3-registered.png

DIP3 tab showing registered masternode#

Updating masternode registration#

To update masternode registration information, navigate to the DIP3 tab and click the Update Registrar button.

../../../../_images/mn-update-registrar.png

Update Registrar#

The masternode owner may update the voting and payout addresses at any time. Addresses from the current wallet can be selected from the drop down menu or addresses from a different wallet (e.g. a hardware wallet) can be pasted into either field. Click Next to continue.

../../../../_images/mn-update-registrar-addresses.png

Update masternode voting and/or payout address#

The masternode owner may also update the operator BLS key at any time. Click Next to continue.

警告

Any time the the operator private key is changed it must be copied into the dash.conf file on the masternode. Electrum will provide a notification with instructions when this is required.

../../../../_images/mn-update-registrar-operator-key-owner-operator.png

Update operator BLS key#

All parameters are now configured. This screen shows the updated configuration details. Click Prepare ProUpRegTx to continue. The Send tab will open and be populated with the info necessary to update the masternode.

../../../../_images/mn-update-registrar-review.png

Examine parameters and update masternode#

The ProUpRegTx information required to update the masternode registration was filled out by the previous step so just Click Pay… to complete the update.

../../../../_images/mn-proupregtx.png

Send tab with ProUpRegTx prepared#

Enter your password and click Send to broadcast the update transaction.

../../../../_images/mn-proupregtx-confirm-tx.png

Confirm ProUpRegTx Transaction#

The transaction hash will be displayed once the transaction has been sent successfully. Click OK to close the screen.

../../../../_images/mn-proupregtx-sent-confirmation.png

Transaction sent screen showing transaction hash#

Updating masternode service parameters#

The masternode service may need to be updated to:

  1. Change the IP address, port, or operator payout address of a masternode

  2. Revive a masternode that was Proof of Service (PoSe) banned

To update masternode service information, navigate to the DIP3 tab and click the Update Service button.

../../../../_images/mn-dip3-update-service.png

Update Service#

The masternode operator may update the IP address and port at any time. Update the IP address and click Next to continue.

../../../../_images/mn-update-service.png

Update masternode IP address#

All parameters are now configured. This screen shows the updated configuration details. Click Prepare ProUpServTx to continue. The Send tab will open and be populated with the info necessary to update the masternode.

../../../../_images/mn-update-service-review.png

Examine parameters and update masternode service#

The ProUpServTx information required to update the masternode was filled out by the previous step so just Click Pay… to complete the update.

../../../../_images/mn-proupservtx.png

Send tab with ProUpServTx prepared#

Enter your password and click Send to broadcast the update transaction.

../../../../_images/mn-proupservtx-confirm-tx.png

Confirm ProUpServTx Transaction#

The transaction hash will be displayed once the transaction has been sent successfully. Click OK to close the screen.

../../../../_images/mn-proupservtx-sent-confirmation.png

Transaction sent screen showing transaction hash#

多重签名钱包#

本文档向用户介绍了创建2/2多重签名钱包的方法。2/2多重签名钱包包含两个独立的钱包。两个钱包拥有一样的地址,(但它们通常位于两个独立的设备上)并且由不同的个人管控。因此,用户只有协同使用这两个钱包才能获取资金。

  • 多重签名钱包多用于协同管控资金的情况。举个例子,如果朋友共同管理企业资金,那么只有在双方同意的情况下,多重签名钱包里的资金才能支付出去。

  • 多重签名钱包带来的另一个好处是强化安全性——一个钱包在主机上,而另一个钱包处于脱机状态的设备上。这样一来,黑客或者垃圾软件就很难窃取用户的达世币了。

创建2-2多重签名钱包#

多重签名钱包的两位持有人都需要完成以下步骤:在菜单栏中选择 文件 > 新建 ,然后选择 多重签名钱包 ,并在下一个页面上选择2/2。

../../../../_images/faq-multisig-create.png

选择多重签名钱包中的x/y次签名#

在生成并确认恢复种子之后,用户会看到钱包的xpub地址。

../../../../_images/faq-multisig-xpub.png

第一个钱包中的xpub地址#

在生成种子(并妥善保存)后,用户需要提供另一个钱包的主节点公钥。当然,在创建另一个钱包的时候,用户也需要提供第一个钱包的主公钥。

../../../../_images/faq-multisig-share-xpub.png

在第一个钱包中输入第二个钱包的xpub地址#

用户需要为两个钱包进行这项操作。请注意,用户可以暂时取消这个步骤,随后再重新打开该文件。

接收#

点击两个钱包并生成相同的地址。用户此时就可以通过可发送到P2SH地址的钱包向该地址(以“7”开头)发送款项了。

发送#

要想从2-2钱包中完成支付,用户必须同时取得双方的联合签名。这就意味着,用户需要在其中一个钱包当中(借助 发送 选项卡创建交易),在签名授权后,钱包将会弹出一个显示交易细节的窗口。

../../../../_images/faq-multisig-partially-signed.png

在达世币轻钱包中取得2-2多重签名中的部分签名#

用户可以通过以下步骤将交易信息发送到第二个钱包:

  • 通过U盘转移文件

    用户可以(点击 保存 按键)将取得部分签名的交易存储到文件,再借助U盘(等)将文件转移到第二个钱包运行的设备上,最后(再通过 工具 > 加载交易 > 来自文件 )来加载文件。

  • 借助二维码转移文件

    此外,用户也可以点击按键获取二维码。在点击按键之后,窗口会显示一个包含交易信息的二维码,用户可以扫描并将交易信息传输到第二个钱包。( 工具 > 加载交易 > 来自二维码

上述的两种方法都能帮助用户取得第二个钱包的交易签名。(用户只需点击 签名 按键即可)取得签名后,交易信息将会在达世币网络上公告。

../../../../_images/faq-multisig-fully-signed.png

在达世币轻钱包中取得2-2多重签名中的全部签名#

扫描纸钱包#

You may have received a paper wallet as a gift from another Dash user, or previously stored one in a safe deposit box. Funds are swept from a paper wallet into a live wallet by importing its private key, which is a long sequence of characters starting with the number “7” or the capital letter “X”. The example below displays a private key (WIF format).

../../../../_images/sweep-secret.png

由达世币纸钱包生成器生成的公共地址和关联的私钥#

用户可以使用私钥创建交易并将其发送到新的地址,从而将纸钱包中的资金转移到达世币轻钱包。这项操作很有必要,因为用户无法将新的公钥或私钥添加到由种子短语派生出的确定性地址上。

用户首先选择 钱包 > 私钥 > 清除。此时, 清除私钥 的对话框就会出现,用户可以粘贴(多个)私钥。由达世币轻钱包控制的未经使用的地址将会显示在下方的字段中,用户可以点击 地址 按键来进更改。一旦完成私钥的粘贴,用户可以点击 清除 按键。

../../../../_images/sweep-privkey.png

输入私钥#

达世币轻钱包将会使用用户导入的私钥来生成交易收款所需的公共地址,使用钱包的地址作为交易支付的地址,并为信息签名。用户需要点击 广播 ,以便在区块链上公告交易信息。然后,钱包的具体地址下将会显示个人余额。经过清除的地址余额为零。

../../../../_images/sweep-broadcast.png

广播清除的交易#

冷存储#

这一章节主要介绍如何创建存储个人资金的离线钱包和仅用于浏览历史记录的在线钱包。此外,用户必须先用离线钱包签名并创建交易,然后才能通过在线钱包广播交易信息。

创建离线钱包#

用户可以按照常规流程( 文件 > 新建 )在脱机状态的计算机上创建钱包。创建钱包后,用户可以访问 钱包 -> 主节点公钥

../../../../_images/faq-cold-xpub.png

新的离线钱包的主节点公钥#

钱包的主节点公钥会显示在弹窗上。用户需要以某种方式将该公钥传输到在线钱包的设备上。

创建仅供浏览的钱包#

用户需要在联网的设备上打开达世币轻钱包,选择 文件 > 新建/存储 ,输入钱包名称并选择 使用公钥或私钥 。接下来,用户需要将主节点公钥输入框中,并点击 下一步 来完成钱包的创建。完成这些步骤之后,用户将会看一个弹窗,告知正在打开仅供浏览的钱包。

../../../../_images/faq-cold-watching.png

新的离线钱包的主节点公钥#

用户随后就可以在钱包上查看交易记录了。

创建未经签名的交易#

用户需打开仅供浏览的在线钱包上的 发送 标签,输入交易数据,然后点击 发送 。此时钱包将会弹出一个窗口,告知用户交易费用已添加。接下来,用户需要在弹窗钟点击 保存 ,将交易文件保存到计算机的某个位置。随后,用户需要关闭窗口,并通过U盘(或其它途径)将交易文件转存到脱机的设备上。

对交易签名#

用户需要在离线钱包上选择 工具 > 加载交易 -> 从文件加载 ,并选择上一步操作中创建的交易文件。随后,用户应点击 签名 。在对交易进行签名授权后,交易ID将会出现在既定的字段上。此时,用户应点击 保存 ,将交易文件保存到计算机的某个位置,并将它转存到联网的设备上。

广播你的交易#

用户需要在联网设备上选择 工具 > 加载交易 -> 从文件加载 ,然后选择已经签名授权的交易文件。在随后打开的窗口中,用户需点击 广播 。此时,交易将在达世币网络上进行广播。

命令行#

当达世币轻钱包在Linux或mac操作系统下运行时,它将具备功能强大的命令行。本章节将为用户介绍一些基本原则。

使用内联帮助#

如需浏览达世币轻钱包的命令行列表,请输入:

electrum help

如需浏览某一命令的文件说明,请输入:

electrum help <command>

关键词#

传递给命令的一系列参数可能包括以下关键的符号:! ? : -

感叹号 ! 是一个快捷方式,代表‘可用资金的最大数额’。请注意,钱包将计算并扣除交易费用。例子如下所示:

electrum payto Xtdw4fezqbSpC341vcr8u9HboiJMFa9gBq !

问号 ? 表示的是用户希望提示参数。例子如下所示:

electrum signmessage Xtdw4fezqbSpC341vcr8u9HboiJMFa9gBq ?

如果希望隐藏参数(不在终端上显示),那么用户可以使用冒号 : 。注意:这个示例可能在钱包中出现两次,一次是针对私钥,另一次是关于钱包密码:

electrum importprivkey :

如需读取标准输入值,用户可使用(破折号) - 替代参数:

cat LICENCE | electrum signmessage Xtdw4fezqbSpC341vcr8u9HboiJMFa9gBq -

别名#

对于大多数命令,用户可以用DNS别名来取代比特币地址:

electrum payto ecdsa.net !

使用jq进行格式输出#

命令输出通常是简单的字符串或JSON结构化数据。其中的一个实用案例就是使用 ‘jq’ 程序。用户可以通过以下操作完成安装:

sudo apt-get install jq

用户可参考以下示例。

签名并验证信息#

用户可以使用变量来存储并验证签名:

sig=$(cat LICENCE| electrum signmessage Xtdw4fezqbSpC341vcr8u9HboiJMFa9gBq -)

以及:

cat LICENCE | electrum verifymessage Xtdw4fezqbSpC341vcr8u9HboiJMFa9gBq $sig -

显示未支付的金额#

listunspent命令返回带有各种字段的dict对象列表。如果用户想要提取各项记录的value字段,这一目标可以借助JQ命令实现:

electrum listunspent | jq 'map(.value)'

仅选择历史记录中的交易输入#

输入的交易具有正值的‘value’字段:

electrum history | jq '.[] | select(.value>0)'

根据日期筛分交易#

以下命令用于选择在既定日期后盖上时间戳的交易:

after=$(date -d '07/01/2015' +"%s")
electrum history | jq --arg after $after '.[] | select(.timestamp>($after|tonumber))'

同样,用户也可以选择导出既定时间段的交易:

before=$(date -d '08/01/2015' +"%s")
after=$(date -d '07/01/2015' +"%s")
electrum history | jq --arg before $before --arg after $after '.[] | select(.timestamp&gt;($after|tonumber) and .timestamp&lt;($before|tonumber))'

加密和解密信息#

首先,用户需要用到钱包地址的公钥:

pk=$(electrum getpubkeys Xtdw4fezqbSpC341vcr8u9HboiJMFa9gBq| jq -r '.[0]')

加密:

cat | electrum encrypt $pk -

解密:

electrum decrypt $pk ?

注意:此项命令将先后提示加密信息和钱包密码。

导出私钥并清除达世币#

以下命令将导出存有达世币的所有钱包地址的私钥:

electrum listaddresses --funded | electrum getprivatekeys -

这项操作将会返回私钥的列表。在大多数情况下,用户需要一份简洁的列表。用户只需按照以下步骤即可添加JQ文件夹并获得私钥列表:

electrum listaddresses --funded | electrum getprivatekeys - | jq 'map(.[0])'

最后,用户需要在执行清除命令的时候使用私钥列表:

electrum listaddresses --funded | electrum getprivatekeys - | jq 'map(.[0])' | electrum sweep - [destination address]

使用带有命令行的冷存储#

本章节将为用户介绍如何通过命令行为离线达世币轻钱包交易签名。

创建未经签名的交易#

在(仅供浏览的)钱包上创建未经签名的交易:

electrum payto Xtdw4fezqbSpC341vcr8u9HboiJMFa9gBq 0.1 --unsigned > unsigned.txn

未经签名的交易存储在名为 ‘unsigned.txn’ 的文件中。请注意,如果用户使用的是仅供浏览的钱包,那么用户就没必要用到 -unsigned选项。

用户可以通过下列途径浏览:

cat unsigned.txn | electrum deserialize -

对交易签名#

达世币轻钱包的序列化格式包含主节点公钥和离线钱包衍生的密码,从而为交易签名授权。因此,用户只需将交易的序列化转移到离线钱包上:

cat unsigned.txn | electrum signtransaction - > signed.txn

该命令将咨询用户的密码并将已签名的交易保存在 ‘signed.txn’文件中。

广播交易#

以广播的方式将你的交易向达世币网络传播:

cat signed.txn | electrum broadcast -

如果广播成功,该命令将返回交易ID。

如何使用达世币轻钱包在网站上接收达世币#

本教程将向用户展示如何在具有SSL签名付款请求的网站上接收达世币。它针对的是达世币轻钱包 2.6版本。

要求#

  • 提供静态HTML的Web服务器

  • (由CA签发的)SSL证书

  • 达世币轻钱包版本 >= 2.6

创建钱包#

在Web服务器上创建钱包:

electrum create

如果想要将私钥保存在服务器之外,用户可以使用仅供浏览的钱包(从xpub上恢复而来)。在成功创建钱包之后,用户可以启动达世币轻钱包作为守护进程:

electrum daemon start

将SSL证书添加到配置当中#

用户应当拥有与域名对应的一个私钥和一个公共证书。用户可创建一个仅包含私钥的文件:

-----BEGIN PRIVATE KEY-----
your private key
-----BEGIN END KEY-----

使用setconfig设置获取私钥的路径:

electrum setconfig ssl_privkey /path/to/ssl.key

用户需创建一个包含证书和证书列表的文件。其中,用户的证书应当位于列表的顶端,CA签发的证书应位于列表的结尾:

-----BEGIN CERTIFICATE-----
your cert
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
intermediate cert
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
root cert
-----END CERTIFICATE-----

通过setconfig设置 ssl_chain 路径:

electrum setconfig ssl_chain /path/to/ssl.chain

配置请求目录#

此目录须由用户的web服务器(例如Apache)提供:

electrum setconfig requests_dir /var/www/r/

在默认情况下,达世币轻钱包会显示本地网址,这个本地网址以 ‘file://‘ 开头。为了显示公共网址,用户需要设置另一个变量,即`url_rewrite`。示例如下:

electrum setconfig url_rewrite "['file:///var/www/','https://electrum.org/']"

创建一个已签名的支付请求#

electrum addrequest 3.14 -m "this is a test"
{
   "URI": "dash:Xtdw4fezqbSpC341vcr8u9HboiJMFa9gBq?amount=3.14&r=https://electrum.org/r/7c2888541a",
   "address": "Xtdw4fezqbSpC341vcr8u9HboiJMFa9gBq",
   "amount": 314000000,
   "amount (DASH)": "3.14",
   "exp": 3600,
   "id": "7c2888541a",
   "index_url": "https://electrum.org/r/index.html?id=7c2888541a",
   "memo": "this is a test",
   "request_url": "https://electrum.org/r/7c2888541a",
   "status": "Pending",
   "time": 1450175741
}

此项命令将会返回一个JSON对象及两个网址:

  • request_url 是已签名的BIP70请求的网址。

  • index_url 是显示请求的网页的网址。

值得注意的是,request_url和index_url使用的是前文中定义的 url_rewrite 的域名。用户可以通过 listrequests 命令来浏览当前的申请列表。

打开浏览器中的支付请求页面#

在网络浏览器上打开`index_url`。

../../../../_images/payrequest.png

网络浏览器上的支付请求页面#

该页面显示支付请求。此时,用户可以打开达世币钱包或扫描二维码。页面下方将显示距离支付到期的剩余时间。

../../../../_images/payreq_window.png

等待支付的钱包#

该页面可以直接用于款项的接收。不过,它无法告诉用户付款申请是否已经支付,因此,用户需要设置websockets。

添加支持websockets功能#

用户可通过以下途径获得SimpleWebSocketServer:

git clone https://github.com/ecdsa/simple-websocket-server.git

在个人配置中设置 websocket_server 和`websocket_port`

electrum setconfig websocket_server <FQDN of your server>
electrum setconfig websocket_port 9999

重启守护进程:

electrum daemon stop
electrum daemon start

现在,页面已经可以在收到支付的时候自动更新了。请注意,某些客户端的防火墙可能会阻止更高的端口,因此通过标注的443端口在其它子域名上逆转websockets的传送。

JSON-RPC界面#

用户可以使用JSON-RPC发送达世币轻钱包守护程序的命令。这对想要在PHP脚本中使用达世币轻钱包的用户来说非常实用。

请注意,守护程序默认使用随机端口。如需使用比较固定的端口,用户需要设置 rpcport 的配置变量(并重启守护进程):

electrum setconfig rpcport 7777

通过这项设置,用户可以使用curl或PHP进行查询。实例:

curl --data-binary '{"id":"curltext","method":"getbalance","params":[]}' http://127.0.0.1:7777

通过命名参数进行查询:

curl --data-binary '{"id":"curltext","method":"listaddresses","params":{"funded":true}}' http://127.0.0.1:7777

创建付款请求:

curl --data-binary '{"id":"curltext","method":"addrequest","params":{"amount":"3.14","memo":"test"}}' http://127.0.0.1:7777