Dev ref conversion (#2)

Developer reference/guide updates to this point

* Update some reference documents
 - Adjust ref_intro to reference Dash
 - Start updating p2p network ref
 - Adjust some items in references.md to point to Dash URLs

* Update P2P networking protocol versions and message headers sections
Update subheading-links
Update more items in references.md

* Update inventories to include Dash specific items
 - Update references.md with them also
Update disclaimer (Bitcoin -> Dash)

* Remove reference to bitcoin mailing list from ref_intro

* Add Spork/GetSporks message details
Add placeholders for Dash specific messages
 - Added subsections for InstantSend, PrivateSend, Masternodes, and
Governance

* Some Bitcoin->Dash conversions
 - Update title / section name for Dev Doc/Dev Reference
 - Updated favicon

* Updates for the Data Network section of P2P reference

* Added Alert message details from Bitcoin back and removed feefilter

* More updates for Control Messages section of P2P network
 - Bitcoin->Dash reference changes
 - Reject and Version message updates

* InstantSend subsection of P2P reference detail
 - Added ix, txlvote message details and associated references

* Governance subsection (P2P)
 - Start adding govobj, govobjvote details
 - Add spork references

* Missed spork xref in previous

* Governance (P2P) updates
 - Add details to govobjvote and govsync

* Governance object P2P messages
 - Add additional description/details

* PrivateSend P2P messages
 - Added details for dsa, dsc, dsf, dsi, dsq, dss, dssu, and dstx
messages
  - Added references also
  - Hexdump examples for all but dsi and dss

* PrivateSend P2P minor updates

* Masternode P2P messages
 - Add descriptions
 - Add hexdump details

* Masternode P2P messages (dseg, mnb, mnget, mnp, mnv, mnw, mnwb, ssc)
 - Add reference/crossref entries
 - Add message structure

* P2P messages - minor formatting and corrections

* Block chain reference
 - Version info updates

* Update Block Chain reference (Headers)
 - Update version details
 - Update block reward info

* Update Transactions reference
 - Add some Dash specific updates

* Minor Transactions reference change

* RPC reference updates

* RPC reference updates
 - Added/removed commands to match available Dash commands

* Core API updates

* Renamed devdocs/bitcoin-core to dash-core
 - Updated developer-reference.md to point at new location

* Update filename to use dash-core instead of bitcoin-core

* Add Dash-specific GetAddressBalance RPC command and associated updates
Update RPC quick reference list

* Added cross reference/reference placeholders for remaining GetAddress... RPC commands
Added RPC template placeholder files for remaining GetAddress...
commands

* Scripts for environment setup and frequently used builds

* Add details for GetAddressDeltas/Mempool RPCs
Update path in Makefile bitcoin-core -> dash-core

* Add GetAddressTxids/Utxos details
Update minor formatting, etc. for GetAddressBalance/Deltas/Mempool
Changed reference to Dash Core and updated denominations for Dash

* Misc minor cleanup

* Work on updating existing Block Chain RPCs
 - GetBestBlockHash, GetBlock, GetBlockChainInfo, GetBlockCount,
GetBlockHash

* Continue updating existing Block Chain RPCs
 - GetBlockHeader, GetChainTips, GetDifficulty, GetMemPoolInfo,
GetRawMemPool

* Update RPCs quick-ref
 - Added descriptions for Dash
 - Updated description for Bitcoin related items for clarity

* Comment out content of non-implemented Block chain RPCs (GetMemPoolAncestors, GetMemPoolDescendants, GetMemPoolEntry, PreciousBlock, PruneBlockChain)

* Continue updating existing Block Chain RPCs
 - GetTxOut, GetTxOutProof, GetTxOutSetInfo, VerifyChain,
VerifyTxOutProof
Update previous block hash type to indicate X11 instead of double SHA256

* Add script to create basic RPC md file
Set up empty GetBlockHashes/Headers and GetSpentInfo RPCs

* Add GetBlockhashes details
Minor correction in Empty RPC generation script

* Add GetBlockHeaders details
Minor formatting updates

* Update Address Index related RPCs to indicate the necessity of enabling addressindex to use them

* Actual details of GetBlockHeaders

* Add details for GetSpentInfo

* Update existing Control RPCs (GetInfo, Help, Stop)

* Add Debug RPC

* Expand empty RPC generation script to add example section and fix format

* Added empty RPC files and cross-ref details for all Dash RPCs

* Add details for some Dash RPCs
- GetGovernanceInfo, GetPoolInfo, GetSuperblockBudget

* Add details for MasternodeList RPC (Dash section)

* Add details for MnSync RPC (Dash section)

* Dash RPC updates
 - Add Result section to MasternodeList
 - Formatting updates to MnSync

* Expand script to add placeholders for parameters/resuls/example

* Add details for PrivateSend RPC (Dash section)

* Update Generating RPCs
 - Added details back for GetGenerate/SetGenerate which were deprecated
in Bitcoin

* Formatting and example updates

* Add result detail and example to GetBlockTemplate

* Update existing Mining RPCs
 - GetMiningInfo, GetNetworkHashPs, PrioritiseTransaction, SubmitBlock

* Minor formatting updates

* Update most existing Network RPCs
 - AddNode, ClearBanned, DisconnectNode, GetAddedNodeInfo,
GetConnectionCount, GetNetTotals,GetNetworkInfo, GetPeerInfo,
ListBanned, Ping, SetBan
 - Added some norefs as needed (Network RPCs only)

* Misc cleanup

* SetNetworkActive (Network RPC)

* Misc updates
 - Change logo
 - Disable some headers (alert, donation)
 - Disable footer

* Governance updates
 - Add description of govsync to P2P guide
 - Updates to P2P reference

* Governance
 - Add governance message SVG image
 - Typo fixes

* Dseg updates
 - Added clarifying details regarding how to request single/all nodes
 - Ban warning

* Minor governance updates

* Governance updates / MN sync
 - Correct some reference links
 - Add MN sync info to guide
 - Update dseg, mnget, ssc, and govsync messages to include more detail

* Governance updates
 - Guide updated to show both stages of govsync
 - Reference
  - Correcte ssc typo and add sync item detail
  - Update govobjvote to include detail about propagation
  - Update govsync details

* Governance updates
 - More clarification on govsync (guide and reference)

* Raw Transaction RPC
 - Previously uncommitted CreateRawTransaction update

* Dash RPC (Gobject)
 - Add details for count and get sub-commands

Also added description for govobj types

* P2P messages
 - Spork updated to include verification details and a hexdump

Minor typo / note updates

* P2P Message - mnv
 - Draft details regarding use and operation

* P2P message (mnv)
 - Additional detail updates based on info from Udjin

Minor update to mnp

* Guide - Masternode payment
 - Add section and start putting in details

* P2P Messages - deprecated
 - Move deprecated messages to their own group

* Misc minor non-content updates
This commit is contained in:
thephez 2017-10-25 09:17:55 -04:00 committed by GitHub
parent 17c265f5fd
commit 703c54ffbc
183 changed files with 9570 additions and 1373 deletions

View file

@ -0,0 +1,94 @@
{% comment %}
This file is licensed under the MIT License (MIT) available on
http://opensource.org/licenses/MIT.
{% endcomment %}
{% assign filename="_includes/devdoc/dash-core/api-intro.md" %}
## Dash Core APIs
{% include helpers/subhead-links.md %}
### Hash Byte Order
{% include helpers/subhead-links.md %}
{% autocrossref %}
Dash Core RPCs accept and return the byte-wise reverse of computed
SHA-256 hash values. For example, the Unix `sha256sum` command displays the
SHA256(SHA256()) hash of mainnet block 300,000's header as:
> /bin/echo -n '020000007ef055e1674d2e6551dba41cd214debbee34aeb544c7ec670000000000000000d3998963f80c5bab43fe8c26228e98d030edf4dcbe48a666f5c39e2d7a885c9102c86d536c890019593a470d' | xxd -r -p | sha256sum -b | xxd -r -p | sha256sum -b
5472ac8b1187bfcf91d6d218bbda1eb2405d7c55f1f8cc820000000000000000
The result above is also how the hash appears in the
previous-header-hash part of block 300,001's header:
<pre>02000000<b>5472ac8b1187bfcf91d6d218bbda1eb2405d7c55f1f8cc82000\
0000000000000</b>ab0aaa377ca3f49b1545e2ae6b0667a08f42e72d8c24ae\
237140e28f14f3bb7c6bcc6d536c890019edd83ccf</pre>
However, Dash Core's RPCs use the byte-wise reverse for hashes, so if you
want to get information about block 675,776 using the `getblock` RPC,
you need to reverse the requested hash:
<!--> bitcoin-cli getblock \
000000000000000082ccf8f1557c5d40b21edabb18d2d691cfbf87118bac7254
-->
> dash-cli getblock \
000000000000327a66cd1011b2d1defd1417b7d9e39b439e8e67ba996ee92602
(Note: hex representation uses two characters to display each byte of
data, which is why the reversed string looks somewhat mangled.)
The rationale for the reversal is unknown, but it likely stems from
Dash Core's use of hashes (which are byte arrays in C++) as integers
for the purpose of determining whether the hash is below the network
target. Whatever the reason for reversing header hashes, the reversal
also extends to other hashes used in RPCs, such as TXIDs and merkle
roots.
As header hashes and TXIDs are widely used as global identifiers in
other Dash software, this reversal of hashes has become the standard
way to refer to certain objects. The table below should make clear where
each byte order is used.
|---------------+---------------------|-----------------|
| Data | Internal Byte Order | RPC Byte Order |
|---------------|---------------------|-----------------|
| Example: SHA256(SHA256(0x00)) | Hash: 1406...539a | Hash: 9a53...0614 |
|---------------|---------------------|-----------------|
| Header Hashes: SHA256(SHA256(block header)) | Used when constructing block headers | Used by RPCs such as `getblock`; widely used in block explorers |
|---------------|---------------------|-----------------|
| Merkle Roots: SHA256(SHA256(TXIDs and merkle rows)) | Used when constructing block headers | Returned by RPCs such as `getblock` |
|---------------|---------------------|-----------------|
| TXIDs: SHA256(SHA256(transaction)) | Used in transaction inputs | Used by RPCs such as `gettransaction` and transaction data parts of `getblock`; widely used in wallet programs |
|---------------|---------------------|-----------------|
| P2PKH Hashes: RIPEMD160(SHA256(pubkey)) | Used in both addresses and pubkey scripts | **N/A:** RPCs use addresses which use internal byte order |
|---------------|---------------------|-----------------|
| P2SH Hashes: RIPEMD160(SHA256(redeem script)) | Used in both addresses and pubkey scripts | **N/A:** RPCs use addresses which use internal byte order |
|---------------|---------------------|-----------------|
Note: RPCs which return raw results, such as `getrawtransaction` or the
raw mode of `getblock`, always display hashes as they appear in blocks
(internal byte order).
The code below may help you check byte order by generating hashes
from raw hex.
{% endautocrossref %}
{% highlight python %}
#!/usr/bin/env python
from sys import byteorder
from hashlib import sha256
## You can put in $data an 80-byte block header to get its header hash,
## or a raw transaction to get its txid
data = "00".decode("hex")
hash = sha256(sha256(data).digest()).digest()
print "Warning: this code only tested on a little-endian x86_64 arch"
print
print "System byte order:", byteorder
print "Internal-Byte-Order Hash: ", hash.encode('hex_codec')
print "RPC-Byte-Order Hash: ", hash[::-1].encode('hex_codec')
{% endhighlight %}