Dash Core

Dash Core Developer Documentation

Welcome to the Dash Core developer documentation. You'll find guides and documentation to help you start working with Dash Core as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Guides

Transactions

Transactions let users spend duffsduffs - Denominations of Dash value, usually measured in fractions of a dash but sometimes measured in multiples of a duff. One dash equals 100,000,000 duffs.. Each transactiontransaction - A transaction spending satoshis. is constructed out of several parts which enable both simple direct payments and complex transactions. This section will describe each part and demonstrate how to use them together to build complete transactions.

To keep things simple, this section pretends coinbase transactions do not exist. Coinbase transactions can only be created by Dash miners and they're an exception to many of the rules listed below. Instead of pointing out the coinbase exception to each rule, we invite you to read about coinbase transactions in the block chainblock chain - A chain of blocks with each block referencing the block that preceded it. The most-difficult-to-recreate chain is the best block chain. section of this guide.

The Parts Of A TransactionThe Parts Of A Transaction

The figure above shows the main parts of a Dash transaction. Each transaction has at least one inputinput - An input in a transaction which contains three fields: an outpoint, a signature script, and a sequence number. The outpoint references a previous output and the signature script allows spending it. and one outputoutput - An output in a transaction which contains two fields: a value field for transferring zero or more duffs and a pubkey script for indicating what conditions must be fulfilled for those duffs to be further spent.. Each inputinput - An input in a transaction which contains three fields: an outpoint, a signature script, and a sequence number. The outpoint references a previous output and the signature script allows spending it. spends the duffs paid to a previous output. Each outputoutput - An output in a transaction which contains two fields: a value field for transferring zero or more duffs and a pubkey script for indicating what conditions must be fulfilled for those duffs to be further spent. then waits as an Unspent Transaction Output (UTXO) until a later input spends it. When your Dash wallet tells you that you have a 10,000 duff balance, it really means that you have 10,000 duffs waiting in one or more UTXOs.

Each transaction is prefixed by a four-byte transaction version numbertransaction version number - A version number prefixed to transactions to allow upgrading. which tells Dash peerspeers - A computer that connects to the Dash network. and miners which set of rules to use to validate it. This lets developers create new rules for future transactions without invalidating previous transactions.

Spending An OutputSpending An Output

An output has an implied indexindex - An index number used in the HD wallet formula to generate child keys from a parent key number based on its location in the transaction---the index of the first output is zero. The output also has an amount in duffs which it pays to a conditional pubkey scriptpubkey script - A script included in outputs which sets the conditions that must be fulfilled for those duffs to be spent. Data for fulfilling the conditions can be provided in a signature script. Pubkey Scripts are called a scriptPubKey in code.. Anyone who can satisfy the conditions of that pubkey script can spend up to the amount of duffs paid to it.

An input uses a transaction identifier (TXIDTXID - An identifier used to uniquely identify a particular transaction; specifically, the sha256d hash of the transaction.) and an output index number (often called "vout" for output vector) to identify a particular output to be spent. It also has a signature script which allows it to provide data parameters that satisfy the conditionals in the pubkey script. (The sequence number and locktime are related and will be covered together in a later subsection.)

The figures below help illustrate how these features are used by showing the workflow Alice uses to send Bob a transaction and which Bob later uses to spend that transaction. Both Alice and Bob will use the most common form of the standard Pay-To-Public-Key-Hash (P2PKH) transaction type. P2PKHP2PKH - A Dash payment address comprising a hashed public key, allowing the spender to create a standard pubkey script that Pays To PubKey Hash (P2PKH). lets Alice spend duffs to a typical Dash addressaddress - A 20-byte hash formatted using base58check to produce either a P2PKH or P2SH Dash address. Currently the most common way users exchange payment information., and then lets Bob further spend those duffs using a simple cryptographic key pair.

Creating A P2PKH Public Key Hash To Receive PaymentCreating A P2PKH Public Key Hash To Receive Payment

Bob must first generate a private/public key pairkey pair - A private key and its derived public key. before Alice can create the first transaction. Dash uses the Elliptic Curve Digital Signature Algorithm (ECDSA) with the secp256k1 curve; secp256k1 private keysprivate keys - The private portion of a keypair which can create signatures that other people can verify using the public key. are 256 bits of random data. A copy of that data is deterministically transformed into an secp256k1 public keypublic key - The public portion of a keypair which can be used to verify signatures made with the private portion of the keypair.. Because the transformation can be reliably repeated later, the public key does not need to be stored.

The public keypublic key - The public portion of a keypair which can be used to verify signatures made with the private portion of the keypair. (pubkey) is then cryptographically hashed. This pubkey hash can also be reliably repeated later, so it also does not need to be stored. The hash shortens and obfuscates the public key, making manual transcription easier and providing security against unanticipated problems which might allow reconstruction of private keysprivate keys - The private portion of a keypair which can create signatures that other people can verify using the public key. from public key data at some later point.

Bob provides the pubkey hash to Alice. Pubkey hashes are almost always sent encoded as a Dash addressaddress - A 20-byte hash formatted using base58check to produce either a P2PKH or P2SH Dash address. Currently the most common way users exchange payment information., which is a base58base58 - The method used in Dash for converting 160-bit hashes into P2PKH and P2SH addresses. Also used in other parts of Dash, such as encoding private keys for backup in WIP format. Not the same as other base58 implementations.-encoded string containing an address version number, the hash, and an error-detection checksum to catch typos. The address can be transmitted through any medium, including one-way mediums which prevent the spender from communicating with the receiver, and it can be further encoded into another format, such as a QR code containing a dash: URI.

Once Alice has the address and decodes it back into a standard hash, she can create the first transaction. She creates a standard P2PKHP2PKH - A Dash payment address comprising a hashed public key, allowing the spender to create a standard pubkey script that Pays To PubKey Hash (P2PKH). transaction output containing instructions which allow anyone to spend that output if they can prove they control the private key corresponding to Bob's hashed public key. These instructions are called the pubkey scriptpubkey script - A script included in outputs which sets the conditions that must be fulfilled for those duffs to be spent. Data for fulfilling the conditions can be provided in a signature script. Pubkey Scripts are called a scriptPubKey in code.
or scriptPubKey.

Alice broadcasts the transaction and it is added to the block chain. The networknetwork - The Dash P2P network which broadcasts transactions and blocks. categorizes it as an Unspent Transaction Output (UTXO), and Bob's wallet software displays it as a spendable balance.

When, some time later, Bob decides to spend the UTXO, he must create an input which references the transaction Alice created by its hash, called a Transaction Identifier (txid), and the specific output she used by its index number (output indexoutput index - The sequentially-numbered index of outputs in a single transaction starting from 0.). He must then create a signature scriptsignature script - Data generated by a spender which is almost always used as variables to satisfy a pubkey script. Signature Scripts are called scriptSig in code.---a collection of data parameters which satisfy the conditions Alice placed in the previous output's pubkey script. Signature scriptsSignature scripts - Data generated by a spender which is almost always used as variables to satisfy a pubkey script. Signature Scripts are called scriptSig in code. are also called scriptSigs.

Pubkey scripts and signature scripts combine secp256k1 pubkeys and signaturessignatures - A value related to a public key which could only have reasonably been created by someone who has the private key that created that public key. Used in Dash to authorize spending duffs previously sent to a public key. with conditional logic, creating a programmable authorization mechanism.

Unlocking A P2PKH Output For SpendingUnlocking A P2PKH Output For Spending

For a P2PKH-style output, Bob's signature script will contain the following two pieces of data:

  1. His full (unhashed) public key, so the pubkey script can check that it hashes to the same value as the pubkey hash provided by Alice.

  2. An secp256k1 signaturesignature - A value related to a public key which could only have reasonably been created by someone who has the private key that created that public key. Used in Dash to authorize spending duffs previously sent to a public key. made by using the ECDSA cryptographic formula to combine certain transaction data (described below) with Bob's private key. This lets the pubkey script verify that Bob owns the private key which created the public key.

Bob's secp256k1 signature doesn't just prove Bob controls his private key; it also makes the non-signature-script parts of his transaction tamper-proof so Bob can safely broadcast them over the peer-to-peer network.

Some Things Signed When Spending An OutputSome Things Signed When Spending An Output

As illustrated in the figure above, the data Bob signs includes the txid and output index of the previous transaction, the previous output's pubkey script, the pubkey script Bob creates which will let the next recipient spend this transaction's output, and the amount of duffs to spend to the next recipient. In essence, the entire transaction is signed except for any signature scripts, which hold the full public keys and secp256k1 signatures.

After putting his signature and public key in the signature script, Bob broadcasts the transaction to Dash miners through the peer-to-peer network. Each peer and miner independently validates the transaction before broadcasting it further or attempting to include it in a new block of transactions.

Updated about a year ago



Transactions


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.