Généralités sur l’intégration#
This documentation is also available as a PDF.
Dash Core is a fork of Bitcoin Core and shares many common functionalities. Key differences are found in existing JSON-RPC commands which have been customized to support unique functionalities such as InstantSend.
The Basics#
Dash is a Proof of Work network, and similar to Bitcoin, Dash has a mining network but uses a different block hashing algorithm. Dash serves as an improvement of Bitcoin’s shortcomings by offering a robust solution for instant transactions, enhancing user privacy, and offering a self-sustainable decentralized governance model.
Notably, Dash InstantSend provides a mechanism for zero-confirmation transactions to be safely accepted and re-spent. InstantSend also provides enhanced security compared to the conventional practice of waiting for multiple block confirmations. Therefore, implementing InstantSend is the recommended best practice for all Dash integrations.
Block time: ~2.6 minutes per block
Github source: dashpay/dash
Latest release: dashpay/dash
JSON-RPC Interface#
The majority of commands are unchanged from Bitcoin making integration into existing systems relatively straightforward. For a complete listing of RPC commands please refer to the Dash Developer Guide.
Note that the following commands have been modified to support InstantSend:
Transactions spéciales#
Dash Core v0.13.0 introduced the concept of “Special Transactions” as specified in DIP002. Special Transactions provide a more native way to implement additional features which do not fit into the original concept of transactions. Please see the Special Transactions section below for more information.
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.
Transactions spéciales#
This documentation is also available as a PDF.
Dash, dans sa version 0.13.0 et ultérieure, implémente les transactions spéciales DIP002, qui forment la base de nouveaux types de transactions fournissant des métadonnées sur chaîne, pour rendre possibles différents mécanismes de consensus. Les types de transactions spéciales sont les suivants :
Version |
Type |
Volume de charge |
Transaction Purpose / Example |
---|---|---|---|
3 |
0 |
n/d |
Transaction standard |
3 |
1 |
variable |
|
3 |
2 |
variable |
|
3 |
3 |
variable |
|
3 |
4 |
variable |
|
3 |
5 |
variable |
|
3 |
6 |
variable |
Notes sur l’intégration :
DIP002 Special Transactions introduced a new Transaction Version and related “Payload” to the network.
Integrated Systems must be able to serialize and deserialize these new Transaction Types to accurately encode and decode Raw Transaction data.
From a backwards compatibility perspective, the 4 byte (32-bit)
version
field included in Classical Transactions was split into two fields:version
andtype
(each consisting of 2 bytes).Refer to the Special Transactions section of the Dash developer reference for additional detail on these data types, e.g. <variable int>.
L Ȏtat InstantSend et la charge JSON (par exemple
proRegTx
) sont inclus dans la réponse JSON-RPC. Veuillez noter que ces données ne sont pas incluses dans la signature de hachage calculée, et sont fournies par commodité.
See the transaction types integration documentation (PDF) for worked examples of each transaction type.
InstantSend#
Cette documentation est aussi disponible au format PDF.
InstantSend is a feature provided by the Dash network that allows for zero-confirmation transactions to be safely accepted and re-spent. The network attempts to lock the inputs of every valid transaction when it is broadcast to the network. Every secured transaction is included in a following block in accordance with standard blockchain principles. Transactions are typically locked by InstantSend within 3 seconds of being propagated to the network.
InstantSend is enabled by the Masternode Network which comprises several thousand masternode servers. These nodes are differentiated from standard nodes by having proven ownership of 1,000 Dash, making the network highly resistant to Sybil attacks. Masternodes form Long-Living Masternode Quorums (LLMQs), which are responsible for providing near-instant certainty to the transaction participants that the transaction inputs cannot be re-spent, and that the transaction will be included in a following block instead of a conflicting transaction.
This concept works as an extension to Nakamoto Consensus to provide additional security. InstantSend enables transacted funds to be immediately and securely re-spent by the recipient, even before the transaction is included in a block.
Réception de transactions InstantSend#
Note
An « InstantSend Transaction » is simply a standard transaction that has been provided additional assurances by the masternode network. As a result, and from an integration perspective, the only technical difference is the InstantSend status.
Recevoir une transaction InstantSend suppose deux obligations :
La capacité à déterminer l’état InstantSend d’une transaction donnée.
La capacité à ajuster l’état de confirmation indépendamment de la confirmation de bloc.
InstantSend Status is provided by the dash daemon, typically through a direct connection (e.g. RPC), ZMQ notification, or through the usage of an external wallet notification script.
Direct Connection#
InstantSend Status can be identified through direct connection with the Dash
daemon using JSON-RPC protocol. The instantlock
attribute of the JSON
response reflects the status of the transaction and is included in the following
commands:
ZMQ Notification#
Whenever a transaction enters the mempool and whenever a transaction is locked in the mempool, ZMQ notifications can be broadcast by the node. Refer to the list of possible ZMQ notifications for more details.
Les notifications suivantes sont utiles pour reconnaître les transactions et leurs verrouillages instantanés correspondants :
zmqpubhashtx
zmqpubhashtxlock
zmqpubrawtx
zmqpubrawtxlock
Wallet Notification#
The Dash Core Daemon can be configured to execute an external script whenever an InstantSend transaction relating to that wallet is observed. This is configured by adding the following line to the dash.conf file:
instantsendnotify=/path/to/concurrent/safe/handler %s
This is typically used with a wallet that has been populated with watch-only addresses.
Diffusion des transactions InstantSend#
Astuce
Because all transactions on the Dash network are automatically InstantSend, no procedural changes are required to broadcast transactions as InstantSend.
Depuis que la version 0.14.0 de Dash a lancé les LLMQ sur le réseau Dash, les quorums tentent par défaut de verrouiller chaque transaction valide, sans frais supplémentaires ni action à effectuer par le portefeuille d’envoi ou l’utilisateur. Une transaction est éligible pour InstantSend quand chacune de ses entrées est considérée comme confirmée. Cela est le cas dès qu’une des conditions suivantes est vraie :
la transaction précédente à laquelle l’entrée fait référence est confirmée par 6 blocs
la transaction précédente est confirmée par un verrouillage InstantSend antérieur
le bloc contenant la transaction précédente est verrouillé sur chaîne
When checking the previous transaction for an InstantSend lock, it is important to do this on mempool (non-mined) transactions. This allows chained InstantSend locking.
Ressources supplémentaires#
Les ressources suivantes fournissent des informations supplémentaires sur InstantSend et sont destinées à fournir une compréhension plus complète des technologies sous-jacentes.
ChainLocks#
ChainLocks est une fonctionnalité fournie par le réseau Dash, qui garantit totalement l’acceptation des paiements. Cette technologie, notamment lorsqu’elle est utilisée conjointement avec InstantSend, crée un environnement dans lequel les paiements peuvent être acceptés immédiatement et sans aucun risque de “réorganisation de blockchain”.
The risk of blockchain reorganization is typically addressed by requiring multiple confirmations before a transaction can be safely accepted as payment. This type of indirect security is effective, but at a cost of time and user experience. ChainLocks are a solution for this problem.
Receiving ChainLocks#
Note
Once a ChainLock is observed for a block, each transaction in that block and all previous blocks can be considered irreversibly and fully confirmed.
Receiving a ChainLock introduces two requirements:
The ability to determine the “ChainLock Status” of a given block or transaction.
La capacité à ajuster l’état de confirmation indépendamment de la confirmation de bloc.
ChainLock status is provided by the dash daemon, typically through a direct connection (e.g. RPC) or by a ZMQ notification.
Direct Connection#
ChainLock status can be identified through direct connection with the Dash
daemon using JSON-RPC protocol. The boolean chainlock
attribute of the JSON
response reflects the ChainLock status of the block or transaction and is
included in the following commands:
ZMQ Notification#
ChainLock signatures are created shortly after the related block has been mined. As a result it is recommended that integrated clients use ZMQ (ZeroMQ) notifications in order to ensure that this information is received as promptly as possible. Refer to the list of possible ZMQ notifications for more details.
The following notifications are relevant for recognizing blocks and their corresponding ChainLocks:
zmqpubhashblock
zmqpubhashchainlock
zmqpubrawblock
zmqpubrawchainlock
zmqpubrawchainlocksig
This sample code uses the js-dashd-zmq library to listen for ChainLock ZMQ notifications and return the hash of blocks that receive a ChainLock.
const { ChainLock } = require('@dashevo/dashcore-lib');
const ZMQClient = require('@dashevo/dashd-zmq');
const client = new ZMQClient({
protocol: 'tcp',
host: '0.0.0.0',
port: '20009',
});
(async () => {
await client.connect();
client.subscribe(ZMQClient.TOPICS.hashchainlock);
client.on(ZMQClient.TOPICS.hashchainlock, async (hashChainLockMessage) => {
console.log(`ChainLock received for block ${hashChainLockMessage}`)
});
})();
Wallet Notification#
The Dash Core daemon can be configured to execute an external script whenever a ChainLock is received. This is configured by adding the following line to the dash.conf file:
chainlocknotify=/path/to/concurrent/safe/handler %s
Ressources supplémentaires#
Les ressources suivantes fournissent des informations supplémentaires sur InstantSend et sont destinées à fournir une compréhension plus complète des technologies sous-jacentes.