Skip to content

Commit

Permalink
Include hash in toObject/toJSON results.
Browse files Browse the repository at this point in the history
  • Loading branch information
Braydon Fuller committed Aug 11, 2015
1 parent b7880ea commit 74dee1f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/block/blockheader.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ BlockHeader.fromBufferReader = function fromBufferReader(br) {
*/
BlockHeader.prototype.toObject = function toObject() {
return {
hash: this.hash,
version: this.version,
prevHash: BufferUtil.reverse(this.prevHash).toString('hex'),
merkleRoot: BufferUtil.reverse(this.merkleRoot).toString('hex'),
Expand Down
1 change: 1 addition & 0 deletions lib/transaction/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ Transaction.prototype.toObject = function toObject() {
outputs.push(output.toObject());
});
var obj = {
hash: this.hash,
version: this.version,
inputs: inputs,
outputs: outputs,
Expand Down
2 changes: 2 additions & 0 deletions test/block/block.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion test/data/merkleblocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ module.exports = {
JSON: [
{ // Mainnet Block 100014
header: {
hash: "000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6dea4",
version: 1,
prevHash: "0000000000016780c81d42b7eff86974c36f5ae026e8662a4393a7f39c86bb82",
merkleRoot: "8772d9d0fdf8c1303c7b1167e3c73b095fd970e33c799c6563d98b2e96c5167f",
time: 1293629558,
bits: 453281356,
nonce: 151839121
nonce: 696601429
},
numTransactions: 7,
hashes: [
Expand All @@ -45,6 +46,7 @@ module.exports = {
},
{ // Mainnet Block 12363
header: {
hash: "00000000ae81d8be56fcad40f7b2ca03612a9ab681ca5bc6628ab3c2d914ef9a",
version: 1,
prevHash: "00000000acc3e6a055e05edc7cd0cfac6187cd73adc3c06d408d05c95edaaef8",
merkleRoot: "67313e7a73b62faffe9380578a1a96727c1f0af62e61eb8aa050064007a008d0",
Expand Down Expand Up @@ -443,6 +445,7 @@ module.exports = {
"036bf6944a47791471e9a2cb86615de837f3aa234a7d1cd024026b3e1daee79e"
],
header : {
hash: "00000000000000018eaf634bf13b7e5e50860b99466b91140538223c75b75049",
prevHash : "000000000000000124f6ce137a43bb288d63cc84f9847033cb84595ead05f9de",
merkleRoot : "792f40129c95aec653d2838ef4b031bf541f11c764ca6c3ecc2e20b396ce83cb",
time : 1389715824,
Expand Down

0 comments on commit 74dee1f

Please sign in to comment.