技术指南

Dash Wallet Integration

This documentation is also available as a PDF.

Dash Core is a fork of Bitcoin and the majority of functionality included in the Dash Core Daemon can be integrated in a similar manner. Key differences relate to customizations to existing JSON-RPC commands to support unique functionalities such as InstantSend. These differences, as well as more general information, are summarized below.

  1. General Information: Dash is a “Proof of Work” blockchain with attributes similar to that of Bitcoin.

    1. Block Time: ~2.6 Minutes per Block
    2. Blockchain Confirmations: 6 Confirmations (or 1 in the case of InstantSend)
    3. Github Source: https://github.com/dashpay/dash
    4. Release Link: https://github.com/dashpay/dash/releases
  2. JSON-RPC Interface: The majority of Bitcoin JSON-RPC commands are unchanged making integration into existing systems relatively straightforward. For a complete listing of RPC commands see the Developer Guide.

    It’s worth noting that several key Transaction-related JSON-RPC commands have been modified to support InstantSend through the addition of an “InstantLock” field and are listed below:

    1. GetTransaction
    2. ListTransactions
    3. ListSinceBlock
  3. Block Hashing Algorithm: Dash uses the “X11” algorithm in place of SHA256 used in Bitcoin. It’s important to note, however, that this only affects the hashing of the Block itself. All other internals utilize SHA256 hashes (transactions, merkle root, etc) which allows for most existing libraries to work in the Dash ecosystem.

  4. Supporting Libraries: Due to the aforementioned differences in Hashing Algorithm only minor adjustments are required before using Bitcoin libraries on the Dash network. The most popular libraries have already been ported to Dash which has enabled support for most major programming languages. These resources are outlined in the SDK Resources section of this document.

v0.13.0 Integration Notes

This documentation is also available as a PDF.

Dash 0.13.0 implements DIP002 Special Transactions, which form a basis for new transaction types that will provide on-chain metadata to assist various consensus mechanisms. The following special transaction types exist:

Release Version Type Payload Size Payload Payload JSON Transaction Purpose
v0.13.0 3 0 n/a n/a n/a Standard Transaction
v0.13.0 3 1 <variable int> <hex> proRegTx Masternode Registration
v0.13.0 3 2 <variable int> <hex> proUpServTx Update Masternode Service
v0.13.0 3 3 <variable int> <hex> proUpRegTx Update Masternode Operator
v0.13.0 3 4 <variable int> <hex> proUpRevTx Masternode Revocation
v0.13.0 3 5 <variable int> <hex> cbTx Masternode List Merkle Proof
v0.13.0 3 6 <variable int> <hex> qcTx Quorum Commitment

Integration notes:

  1. DIP002 Special Transactions are a foundational component of Dash Core v0.13.0 and introduce a new Transaction Version and related “Payload” to the network.
  2. Integrated Systems must be able to serialize and deserialize these new Transaction Types in order to accurately encode and decode Raw Transaction data.
  3. From a backwards compatibility perspective, the 4 byte (32-bit) version field included in Legacy Transactions has been split into two fields: version and type (each consisting of 2 bytes).
  4. InstantSend status and Payload JSON (e.g. proRegTx) is included in the JSON-RPC response, please note that this data is not part of the calculated hash and is provided for convenience.

Legacy transaction structure:

{
  "txid": <string>,
  "size": <int>,
  "version": 2,
  "locktime": 0,
  "vin": [],
  "vout": [ … ]
}

Updated transaction structure:

{
  "txid": <string>,
  "size": <int>,
  "version": 3,
  "type": <int>,
  "locktime": 0,
  "vin": [ … ],
  "vout": [ … ],
  "extraPayloadSize": <variable int>,
  "extraPayload": …
}

See the Special Transactions developer documentation for additional detail on these data types, e.g. <variable int>. See the v0.13.0 transaction types integration documentation (PDF) for worked examples of each transaction type.

API 服务

用户也可以以PDF的形式阅读本文档。

现有的多种应用程序接口服务可以帮助用户轻松、快捷地享受达世币网络的各项服务,其中包括:

  • 交易广播
  • 汇率
  • 货币兑换
  • 发票生成

应用程序接口的意义在于它可以免除用户为实现区块链交互而运行基础设施的麻烦。其中涉及的机制和流程包括:

  • 向达世币网络公告交易信息。
  • 通过HD钱包生成地址。
  • 通过WebHooks处理支付。

以定价模式和支持的功能为区分标准,市面上可供使用的设备有很多。下表罗列了常见的应用程序接口供应商、主打产品的性能和相关说明文档的链接。

Insight

../_images/insight.png

https://github.com/dashevo/insight-api

The open-source Insight REST API provides you with a convenient, powerful and simple way to read data from the Dash network and build your own services with it. A practical guide to getting started with the Insight API and Insight UI block explorer is available here.

BlockCypher

../_images/blockcypher.png

https://www.blockcypher.com

BlockCypher是简单实用的JSON应用程序接口,可实现与区块链的交互,还可以借助HTTP或HTTPS在api.blockcypher.com域名上进行访问。

ChainRider

../_images/chainrider.png

https://www.chainrider.io

ChainRider是云服务平台,为数字货币的管理和探究提供一套REST应用程序接口。

  • 功能:区块链询问,事件通知,交易广播,支付处理,等。
  • 定价:免费试用,每次API调用时付费
  • 说明文档的链接: https://www.chainrider.io/docs/dash

GoCoin

../_images/gocoin.png

https://gocoin.com

在GoCoin平台的帮助下,达世币的集成就和插件安装一样简单。它为各大交易平台提供便捷的支付处理,侧重为隐私保护等特定的小众行业提供服务,并帮助他们规避来自所有客户的交易风险。

  • 功能:发票生成、汇率及WebHook回调。GoCoin在其服务器上保存私钥,帮助商家以加密数字货币的形式提款或实现加密数字货币与法定货币间的兑换。
  • 合作商:WooCommerce、Magento, Prestashop、VirtueMart、ZenCart、OpenCart、OSCommerce、 UberCart、nopCommerce、WHMCS、NATS4和Shopify。
  • 定价:收取1%的交易费用(https://gocoin.com/fees)
  • 说明文档的链接: https://gocoin.com/docs

CoinPayments

../_images/coinpayments.png

https://www.coinpayments.net

CoinPayments是适用于达世币等加密数字货币的集成支付网关。它为当前流行的所有webcarts提供购物车插件,还可以帮助用户设置新的结帐页面或合并之前的结帐页面。

  • 功能:发票生成、汇率及WebHook回调。CoinPayments在其服务器上保存私钥,帮助商家以加密数字货币的形式提款或实现加密数字货币与法定货币间的兑换。
  • 合作商:aMember Pro、Arastta、Blesta、BoxBilling、Drupal、Ecwid、Hikashop、Magento、OpenCart、OSCommerce、PrestaShop、Tomato Cart、WooCommerce、Ubercart、XCart及ZenCart
  • 定价:收取0.5%的交易费用(https://www.coinpayments.net/help-fees)
  • 说明文档的链接: https://www.coinpayments.net/apidoc

软件开发工具包资源

用户也可以以PDF的形式阅读本文档。

SDKs (Software Development Kits) are used to accelerate the design and development of a product for the Dash Network. These resources can either be used to interface with an API provider or for the creation of standalone applications by forming transactions and/or performing various wallet services.

达世币研发者指南

../_images/dash-logo.png

https://dash-docs.github.io/en/developer-guide

达世币研发者指南致力于为读者提供达世币的相关信息,并帮助他们创建以达世币为基础的应用程序。为了充分发挥这份指南的作用,用户需要通过源代码或预编译的可执行文件安装Dash Core钱包的最新版本。

NodeJS/JavaScript: Bitcore (Dashcore)

../_images/bitcore.png

https://bitcore.io

Dashcore is a fork of Bitcore and operates as a full Dash node — your apps run directly on the peer-to-peer network. For wallet application development, additional indexes have been added into Dash for querying address balances, transaction history, and unspent outputs.

PHP: Bitcoin-PHP

https://github.com/Bit-Wasp/bitcoin-php

Bitcoin-PHP is an implementation of Bitcoin with support for Dash using mostly pure PHP.

Python: PyCoin

https://github.com/richardkiss/pycoin

PyCoin is an implementation of a bunch of utility routines that may be useful when dealing with Bitcoin and Dash. It has been tested with Python 2.7, 3.6 and 3.7.

Java: DashJ

../_images/bitcoinj.png

https://github.com/HashEngineering/dashj

DashJ是一个适用于达世币协议的库。它可以维护钱包的运行,支持达世币的接收与发送(包括即时发送功能),同时还具备许多其它高级功能,而且还无需建立Dash Core钱包的副本。虽然它要借助Java才能实现各项功能,但它也可以借助Java虚拟机的兼容语言,其中包括Python和JavaScript中的示例。

.NET: NBitcoin

../_images/dash-logo.png

https://github.com/MetacoSA/NBitcoin

NBitcoin是.NET平台上最完整的比特币程序库,并且在修补后可支持达世币。它不仅支持最新的比特币优化提案 (BIPs) 和达世币优化提案 (DIPs) ,并且还提供对达世币原语的访问,从而帮助研发者以此为基础轻松地构建应用程序。

BlockCypher

../_images/blockcypher.png

https://www.blockcypher.com

BlockCypher也提供软件开发工具箱。

GoCoin

../_images/gocoin.png

https://gocoin.com

即时支付

用户也可以以PDF的形式阅读本文档。

即时发送是达世币网络提供的一项功能。借助这项服务,商家和其它服务供应商可以安全地参与0-确认交易。主节点网络的保驾护航意味着即时支付可以在协议层面锁定既定的交易输入并规避 “双花支付” 的风险。

即时发送交易与标准交易

从整合的角度来看,即时发送交易与标准交易之间的区别微乎其微。这两种类型的交易都具有相同的基础,交易的签名流程也完全相同,关键的区别在于交易费率和输入要求。

  1. 交易费率标准:每次即时发送功能需收取0.0001个达世币作为交易费用。
  2. 输入要求:即时发送功能必须至少经过6次确认。

未能达到交易费率和输入要求的相关要求的交易应被视作标准交易。

接收即时发送交易

即时发送交易与标准交易的处理模式是一样的,通常都需要借助JSON-RPC远程过程调用、Insight应用程序接口 / 服务器上的内部通知脚本及服务。

  1. JSON-RPC远程过程调用:以下的远程过程调用将包含与即时发送功能相关的信息。在响应过程用,用户将会看到一个 “InstantLock” 字段,它将显示既定交易的状态。具体来说,(布尔值)使用常量True 和False将说明即时发送功能是否已经过确认。

    1. GetTransaction的相关链接:https://dash-docs.github.io/en/developer-reference#gettransaction
    2. ListTransactions的相关链接:https://dash-docs.github.io/en/developer-reference#listtransactions
    3. ListSinceBlock的相关链接:https://dash-docs.github.io/en/developer-reference#listsinceblock
  2. Insight API:Insight应用程序接口可用于探查即时发送交易,并通过WebSockets将信息推送至客户端。该应用程序接口还可以帮助用户人工查询包括即时发送交易状态在内的交易信息。

    1. Web Socket: https://github.com/dashevo/insight-api#web-socket-api
    2. Transaction API: https://github.com/dashevo/insight-api#instantsend-transactions
  3. 脚本通知:Dash Core钱包的守护进程可以被设置为在探查到与钱包相关的即时发送交易时执行外部脚本。用户可通过在dash.conf文件中添加以下内容来完成这项设置:

    instantsendnotify=/path/to/concurrent/safe/handler %s

    注意:这项设置只会监控即时发送交易过程当中导入钱包的地址。

广播即时发送功能的交易信息

就交易的创建和交易信息的广播而言,即时发送交易与标准交易并无区别。只要达到交易费率和输入要求的标准,即时发送的交易资讯就可以作为原始交易通过JSON-RPC远程过程调用或Insight应用程序接口来公告。

  1. JSON-RPC远程过程调用:“SendRawTransaction”远程过程调用命令可用于广播即时发送的相关交易信息。在使用这项命令之前,用户需要将两个可选参数设为““true”

    sendrawtransaction "hexstring" ( allowhighfees instantsend ) sendrawtransaction "hexstring" true true

    更多信息:https://dash-docs.github.io/en/developer-reference#sendrawtransaction

  2. Insight API:即时发送的交易信息也可以作为原始交易通过Insight应用程序接口来广播。在这种情况下,用户只需使用 /tx/sendix 路径就完成广播。

    更多信息:https://github.com/dashevo/insight-api#instantsend-transaction

其它资源

下列资源提供即时发送功能的更多信息,以便帮助用户全面地了解它的基础技术。

自动贩卖机

达世币社区成员moocowmoo已经发布了代码,致力于帮助商家建立属于自己的自动售货机并使用即时发送功能接收顾客支付的款项。 Dashvend软件可用于创建任何类型的支付系统,其中包括支持即时发送功能的POS系统。

价格提示器

用户可以在使用CoinGeckocode网站上的工具添加价格提示器。

除了上述应用和服务之外,CoinLib,WorldCoinIndexCryptonator上还提供了具备不同设计和类似功能的组件。此外,DashCentral也提供类似信息的应用程序接口。

二维码

很多钱包都能生成二维码,以便用户扫描和简化达世币地址的使用。打印二维码或将二维码公布在网站上可以简化二维码的线上和线下交易流程。

  • Dash Core钱包的用户可以打开 接收 选项卡,在必要的情况下生成地址,然后双击生成二维码。然后,右键单击二维码,并以PNG文件格式 保存图片
  • Android版达世币钱包的用户可以点击 申请付款 ,然后点击放大二维码,并截图保存。
  • iOS版达世币钱包的用户可以向左滑动,找到 接收达世币 页面。此时,页面上将显示二维码和达世币地址,用户就可以截图保存图像了。
  • 如需生成任何达世币地址的二维码,用户可以访问 CWA 二维码生成器 页面并复制粘贴地址,以便生成二维码的图像。