Skip to content

Commit 27a971b

Browse files
authored
Merge pull request #1764 from evoskuil/master
Add first "hash" property to header and tx json serialization.
2 parents 71fefdd + 95f3478 commit 27a971b

5 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/chain/header.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ DEFINE_JSON_FROM_TAG(header)
386386
{
387387
value =
388388
{
389+
// hash is meta property
390+
{ "hash", encode_hash(instance.hash()) },
389391
{ "version", instance.version() },
390392
{ "previous", encode_hash(instance.previous_block_hash()) },
391393
{ "merkle_root", encode_hash(instance.merkle_root()) },

src/chain/transaction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,8 @@ DEFINE_JSON_FROM_TAG(transaction)
969969
{
970970
value =
971971
{
972+
// hash is meta property
973+
{ "hash", encode_hash(instance.hash(false)) },
972974
{ "version", instance.version() },
973975
{ "inputs", value_from(*instance.inputs_ptr()) },
974976
{ "outputs", value_from(*instance.outputs_ptr()) },

test/chain/block.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ BOOST_AUTO_TEST_CASE(block__json__conversions__expected)
724724
"{"
725725
"\"header\":"
726726
"{"
727+
"\"hash\":\"d5b1048b2dcb443dd79a15e54de994fa18620d1d99250f2a4123660c68dea664\","
727728
"\"version\":42,"
728729
"\"previous\":\"0000000000000000000000000000000000000000000000000000000000000000\","
729730
"\"merkle_root\":\"0000000000000000000000000000000000000000000000000000000000000001\","
@@ -734,6 +735,7 @@ BOOST_AUTO_TEST_CASE(block__json__conversions__expected)
734735
"\"transactions\":"
735736
"["
736737
"{"
738+
"\"hash\":\"6d74f0162f9c7a3be99cb60cca0c658f3e19fb3462f4c9731d5a0b7495183335\","
737739
"\"version\":42,"
738740
"\"inputs\":"
739741
"["

test/chain/header.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ BOOST_AUTO_TEST_CASE(header__json__conversions__expected)
353353
const std::string text
354354
{
355355
"{"
356+
"\"hash\":\"d5b1048b2dcb443dd79a15e54de994fa18620d1d99250f2a4123660c68dea664\","
356357
"\"version\":42,"
357358
"\"previous\":\"0000000000000000000000000000000000000000000000000000000000000000\","
358359
"\"merkle_root\":\"0000000000000000000000000000000000000000000000000000000000000001\","

test/chain/transaction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,7 @@ BOOST_AUTO_TEST_CASE(transaction__json__conversions__expected)
15041504
const std::string text
15051505
{
15061506
"{"
1507+
"\"hash\":\"6d74f0162f9c7a3be99cb60cca0c658f3e19fb3462f4c9731d5a0b7495183335\","
15071508
"\"version\":42,"
15081509
"\"inputs\":"
15091510
"["

0 commit comments

Comments
 (0)