dash/dash-docs/protocol-documentation.md
Alexander Block f95aae2b30 Remove all legacy/compatibility MN code (#2600)
* Remove CActiveLegacyMasternodeManager

* Remove sentinelping RPC

* Remove unused P2P messages and inv types

There are still places where these are used in the code. The next commits
will clean these up.

* Remove MNB/MNP/MNVERIFY related code from masternode(man).h/cpp

* Remove all legacy code regarding block MN payee voting

* Remove MASTERNODE_SYNC_LIST and MASTERNODE_SYNC_MNW states

Also replace all uses of IsMasternodeListSynced and IsWinnersListSynced
with IsBlockchainSynced.

* Remove unsupported masternode RPCs

* Remove UpdateLastPaid methods

* Remove duplicate deterministicmns.h include

* Remove masternode.conf support

* Remove legacy MN lists support from masternode list GUI

* Remove unnecessary AskForMN call

* Remove compatibility code in CPrivateSendQueue::GetSignatureHash

* Don't add locally calculated MN payee in case GetBlockTxOuts failed

This is not valid in DIP3 mode

* Remove check for IsDeterministicMNsSporkActive in "masternode status"

* Move CMasternode::IsValidNetAddr to CActiveDeterministicMasternodeManager

* Remove use of CMasternode::CheckCollateral in governance code

* Remove uses of MASTERNODE_SENTINEL_PING_MAX_SECONDS/MASTERNODE_SENTINEL_PING_MAX_SECONDS

* Remove support for "-masternodeprivkey"

* Remove pre-DIP3 vote cleanup

* Remove compatibility code for quorumModifierHash/masternodeProTxHash

* Remove check for invalid nBlockHeight in CMasternodePayments::GetBlockTxOuts

...and let it crash instead. We expect this method to be called with the
correct height now (after DIP3 was fully deployed).

* Remove ECDSA based Sign/CheckSignature from CGovernanceObject

Only masternodes sign governance objects, so there is no need for ECDSA
support here anymore.

* Always add superblock and MN reward payments into new block

* Always check block payees (except if fLiteMode==true)

* Always allow superblock and MN payees in same block

* Remove/Fix a few references to masternode.conf and related stuff

Also delete guide-startmany.md and masternode_conf.md

* Implement NotifyMasternodeListChanged signal and call governance maintenance

* Remove non-DIP3 code path from CMasternodeMan::Find

* Remove remaining unused code from CMasternode/CMasternodeMan

* Always load governance.dat on startup

* Mine an empty block instead of incrementing nHeight from chain tip in miner tests

This test is crashing otherwise in GetBlockTxOuts as it tries to access a
previous block that is not existing.

* Skip MN payments verification on historical blocks (pre-DIP3 blocks)

Even though DIP3 was active on BIP9 level, the spork was not active yet at
that point meaning that payments were not enforced at that time.

* Remove unused state and CollateralStatus enums

* Unconditionally return false from IsBlockPayeeValid when IsTransactionValid returns false

IsTransactionValid already handles the case where IsDIP3Active() returns
false, making it return true.

* Add override keyword to CDSNotificationInterface::NotifyMasternodeListChanged

* Fix help for masternodelist status (POSE_BANNED and no OUTPOINT_SPENT)
2019-01-03 12:17:43 +03:00

10 KiB

Protocol Documentation - 0.12.1

This document describes the protocol extensions for all additional functionality build into the Dash protocol. This doesn't include any of the Bitcoin protocol, which has been left intact in the Dash project. For more information about the core protocol, please see https://en.bitcoin.it/w/index.php?title#Protocol_documentation&action#edit

Common Structures

Simple types

uint256 => char[32]

CScript => uchar[]

COutPoint

Bitcoin Outpoint https://bitcoin.org/en/glossary/outpoint

Field Size Field Name Data type Description
32 hash uint256 Hash of transactional output which is being referenced
4 n uint32_t Index of transaction which is being referenced

CTxIn

Bitcoin Input https://bitcoin.org/en/glossary/input

Field Size Field Name Data type Description
36 prevout COutPoint The previous output from an existing transaction, in the form of an unspent output
1+ script length var_int The length of the signature script
? script CScript The script which is validated for this input to be spent
4 nSequence uint_32t Transaction version as defined by the sender. Intended for "replacement" of transactions when information is updated before inclusion into a block.

CTxOut

Bitcoin Output https://bitcoin.org/en/glossary/output

Field Size Field Name Data type Description
8 nValue int64_t Transfered value
? scriptPubKey CScript The script for indicating what conditions must be fulfilled for this output to be further spent

CTransaction

Field Size Field Name Data type Description
4 nVersion int32_t Transaction data format version
1+ tx_in count var_int Number of Transaction inputs
41+ vin CTxIn[] A list of 1 or more transaction inputs
1+ tx_out count var_int Number of Transaction outputs
9+ vout CTxOut[] A list of 1 or more transaction outputs
4 nLockTime uint32_t The block number or timestamp at which this transaction is unlocked

CPubKey

Bitcoin Public Key https://bitcoin.org/en/glossary/public-key

Field Size Field Name Data type Description
33-65 vch char[] The public portion of a keypair which can be used to verify signatures made with the private portion of the keypair.

CService

Field Size Field Name Data type Description
16 IP CNetAddr IP Address
2 Port uint16 IP Port

Message Types

DSTX - "dstx"

CDarksendBroadcastTx

Masternodes can broadcast subsidised transactions without fees for the sake of security in mixing. This is done via the DSTX message.

Field Size Field Name Data type Description
# tx CTransaction The transaction
36 masternodeOutpoint COutPoint The unspent output of the masternode which is signing the message
71-73 vchSig char[] Signature of this message by masternode (verifiable via pubKeyMasternode)
8 sigTime int64_t Time this message was signed

DSSTATUSUPDATE - "dssu"

Mixing pool status update

Field Size Field Name Data type Description
4 nMsgSessionID int Session ID
4 nMsgState int Current state of mixing process
4 nMsgEntriesCount int Number of entries in the mixing pool
4 nMsgStatusUpdate int Update state and/or signal if entry was accepted or not
4 nMsgMessageID int ID of the typical masternode reply message

DSQUEUE - "dsq"

CDarksendQueue

Asks users to sign final mixing tx message.

Field Size Field Name Data type Description
4 nDenom int Which denomination is allowed in this mixing session
36 masternodeOutpoint COutPoint The unspent output of the masternode which is hosting this session
8 nTime int64_t the time this DSQ was created
1 fReady bool if the mixing pool is ready to be executed
66 vchSig char[] Signature of this message by masternode (verifiable via pubKeyMasternode)

DSACCEPT - "dsa"

Response to DSQ message which allows the user to join a mixing pool

Field Size Field Name Data type Description
4 nDenom int denomination that will be exclusively used when submitting inputs into the pool
216+ txCollateral CTransaction collateral tx that will be charged if this client acts maliciously

DSVIN - "dsi"

CDarkSendEntry

When queue is ready user is expected to send his entry to start actual mixing

Field Size Field Name Data type Description
? vecTxDSIn CTxDSIn[] vector of users inputs (CTxDSIn serialization is equal to CTxIn serialization)
216+ txCollateral CTransaction Collateral transaction which is used to prevent misbehavior and also to charge fees randomly
? vecTxOut CTxOut[] vector of user outputs

DSSIGNFINALTX - "dss"

User's signed inputs for a group transaction in a mixing session

Field Size Field Name Data type Description
# inputs CTxIn[] signed inputs for mixing session

TXLOCKREQUEST - "ix"

CTxLockRequest

Transaction Lock Request, serialization is the same as for CTransaction.

TXLOCKVOTE - "txlvote"

CTxLockVote

Transaction Lock Vote

Field Size Field Name Data type Description
32 txHash uint256 txid of the transaction to lock
36 outpoint COutPoint The utxo to lock in this transaction
36 outpointMasternode COutPoint The utxo of the masternode which is signing the vote
71-73 vchMasternodeSignature char[] Signature of this message by masternode (verifiable via pubKeyMasternode)

MNGOVERNANCEOBJECT - "govobj"

Governance Object

A proposal, contract or setting.

Field Size Field Name Data type Description
32 nHashParent uint256 Parent object, 0 is root
4 nRevision int Object revision in the system
8 nTime int64_t Time which this object was created
32 nCollateralHash uint256 Hash of the collateral fee transaction
0-16384 strData string Data field - can be used for anything
4 nObjectType int ????
36 masternodeOutpoint COutPoint The unspent output of the masternode which is signing this object
66* vchSig char[] Signature of the masternode (unclear if 66 is the correct size, but this is what it appears to be in most cases)

MNGOVERNANCEOBJECTVOTE - "govobjvote"

Governance Vote

Masternodes use governance voting in response to new proposals, contracts, settings or finalized budgets.

Field Size Field Name Data type Description
36 masternodeOutpoint COutPoint The unspent output of the masternode which is voting
32 nParentHash uint256 Object which we're voting on (proposal, contract, setting or final budget)
4 nVoteOutcome int ???
4 nVoteSignal int ???
8 nTime int64_t Time which the vote was created
66* vchSig char[] Signature of the masternode (unclear if 66 is the correct size, but this is what it appears to be in most cases)

SPORK - "spork"

Spork

Spork

Field Size Field Name Data type Description
4 nSporkID int
8 nValue int64_t
8 nTimeSigned int64_t
66* vchSig char[] Unclear if 66 is the correct size, but this is what it appears to be in most cases

Defined Sporks (per src/sporks.h)

Spork ID Number Name Description
10001 2 INSTANTSEND_ENABLED Turns on and off InstantSend network wide
10002 3 INSTANTSEND_BLOCK_FILTERING Turns on and off InstantSend block filtering
10004 5 INSTANTSEND_MAX_VALUE Controls the max value for an InstantSend transaction (currently 2000 dash)
10005 6 NEW_SIGS Turns on and off new signature format for Dash-specific messages
10007 8 MASTERNODE_PAYMENT_ENFORCEMENT Requires masternodes to be paid by miners when blocks are processed
10008 9 SUPERBLOCKS_ENABLED Superblocks are enabled (the 10% comes to fund the dash treasury)
10009 10 MASTERNODE_PAY_UPDATED_NODES Only current protocol version masternode's will be paid (not older nodes)
10011 12 RECONSIDER_BLOCKS
10012 13 OLD_SUPERBLOCK_FLAG
10013 14 REQUIRE_SENTINEL_FLAG Only masternode's running sentinel will be paid

Undocumented messages

DSFINALTX - "dsf"

Darksend Final Transaction

Field Size Field Name Data type Description
4 nSessionID int
# txFinal CTransaction Final mixing transaction

DSCOMPLETE - "dsc"

Darksend Complete

Field Size Field Name Data type Description
4 nSessionID int
4 nMessageID int

MNGOVERNANCESYNC - "govsync"

Governance Sync

Field Size Field Name Data type Description
32 nHash uint256
# filter CBloomFilter

SYNCSTATUSCOUNT - "ssc"

Sync Status Count

Field Size Field Name Data type Description
4 nItemID int Masternode Sync Item ID
4 nCount int Masternode Sync Count

Defined Sync Item IDs (per src/masternode-sync.h)

Item ID Name Description
4 MASTERNODE_SYNC_GOVERNANCE
10 MASTERNODE_SYNC_GOVOBJ
11 MASTERNODE_SYNC_GOVOBJ_VOTE