Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Mention Bitcoin's RPC Hash Byte Order #583

Merged
merged 1 commit into from Oct 25, 2014

Conversation

Projects
None yet
4 participants
Contributor

harding commented Sep 30, 2014

Preview: http://dg1.dtrt.org/en/developer-reference#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

@SergioDemianLerner do you think this describes the situation sufficiently well for other people to figure out what's going on?

@harding harding referenced this pull request Sep 30, 2014

Closed

Wrong Endianess? #580

@saivann saivann and 1 other commented on an outdated diff Oct 1, 2014

_includes/ref_core_rpc_intro.md
+0000000000000</b>ab0aaa377ca3f49b1545e2ae6b0667a08f42e72d8c24ae\
+237140e28f14f3bb7c6bcc6d536c890019edd83ccf</pre>
+
+However Bitcoin RPCs use the reverse byte order for hashes, so if you
+want to get information about block 300,000 using the `getblock` RPC,
+you need to reverse the byte order:
+
+ > bitcoin-cli getblock \
+ 000000000000000082ccf8f1557c5d40b21edabb18d2d691cfbf87118bac7254
+
+(Note: hex representation uses two characters to display each byte of
+data, which is why the reversed string looks somewhat mangled.)
+
+The rational for the reversal is unknown, but it likely stems from
+Bitcoin's use of hash digests (which are byte arrays in C++) as integers
+for the purpose of determing whether the hash is below the network
@saivann

saivann Oct 1, 2014

Contributor

s/determing/determining

@harding

harding Oct 1, 2014

Contributor

Fixed. Thanks!

Contributor

saivann commented Oct 1, 2014

Mmh, I can't help review this one. Is a more knowledgeable developer available to take a quick look?

Contributor

saivann commented Oct 23, 2014

@SergioDemianLerner Do you have some time to review the changes and tell if the pull req fixes your issue #580 (to the best of your understanding)?

jgarzik commented Oct 23, 2014

Huzzah! Thank you for documenting this.

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!)
Contributor

harding commented Oct 23, 2014

Rebased to fix merge conflict; also lowercased Merkle as per discussion in pull #589.

This seems ready to merge to me, and we do have a highly-visible disclaimer on the page, so if nobody spots any errors by 19:00 UTC Saturday (48 hours from now), I'll merge it.

Contributor

saivann commented Oct 23, 2014

@harding Thanks!

Documentation looks consistent. Good!

Contributor

saivann commented Oct 23, 2014

@SergioDemianLerner Thanks for taking the time to come back and comment, this is very useful and appreciated.

@harding harding merged commit e65d86d into bitcoin-dot-org:master Oct 25, 2014

harding added a commit that referenced this pull request Oct 25, 2014

@harding harding deleted the harding:byte-order branch Feb 25, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment