Mention Bitcoin's RPC Hash Byte Order

* Add a short subsection about the different byte orders used with
  hashes in Bitcoin Core and other software.

* Re-word some text in other sections to mention the byte order
  differences

This commit created based on comments from @SergioDemianLerner (thanks!)
This commit is contained in:
David A. Harding 2014-09-28 14:07:13 -04:00
parent 84b0bcf1ce
commit e65d86de21
No known key found for this signature in database
GPG key ID: 4B29C30FF29EC4B7
6 changed files with 106 additions and 4 deletions

View file

@ -86,7 +86,7 @@ bytes commonly used by Bitcoin are:
2. Create a copy of the version and hash; then hash that twice with SHA256: `SHA256(SHA256(version . hash))`
3. Extract the four most significant bytes from the double-hashed copy.
3. Extract the first four bytes from the double-hashed copy.
These are used as a checksum to ensure the base hash gets transmitted
correctly.
@ -135,6 +135,10 @@ Bitcoin transactions are broadcast between peers and stored in the
block chain in a serialized byte format, called [raw format][]{:#term-raw-format}{:.term}. Bitcoin Core
and many other tools print and accept raw transactions encoded as hex.
The binary form of a raw transaction is SHA256(SHA256()) hashed to create
its TXID. Bitcoin Core RPCs use a reversed byte order for hashes; see the [subsection about hash byte
order][section hash byte order] for details.
A sample raw transaction is the first non-coinbase transaction, made in
[block 170][block170]. To get the transaction, use the `getrawtransaction` RPC with
that transaction's txid (provided below):
@ -142,7 +146,7 @@ that transaction's txid (provided below):
{% endautocrossref %}
~~~
> getrawtransaction \
> bitcoin-cli getrawtransaction \
f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16
0100000001c997a5e56e104102fa209c6a852dd90660a20b2d9c352423e\