diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -921,9 +921,11 @@ {RPCResult::Type::NUM, "nTx", "The number of transactions in the block"}, {RPCResult::Type::STR_HEX, "previousblockhash", - "The hash of the previous block"}, + /* optional */ true, + "The hash of the previous block (if available)"}, {RPCResult::Type::STR_HEX, "nextblockhash", - "The hash of the next block"}, + /* optional */ true, + "The hash of the next block (if available)"}, }}, RPCResult{"for verbose=false", RPCResult::Type::STR_HEX, "", "A string that is serialized, hex-encoded data for block " @@ -1056,9 +1058,11 @@ {RPCResult::Type::NUM, "nTx", "The number of transactions in the block"}, {RPCResult::Type::STR_HEX, "previousblockhash", - "The hash of the previous block"}, + /* optional */ true, + "The hash of the previous block (if available)"}, {RPCResult::Type::STR_HEX, "nextblockhash", - "The hash of the next block"}, + /* optional */ true, + "The hash of the next block (if available)"}, }}, RPCResult{"for verbosity = 2", RPCResult::Type::OBJ, diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -337,6 +337,11 @@ header.calc_sha256() assert_equal(header.hash, besthash) + assert 'previousblockhash' not in node.getblockheader( + node.getblockhash(0)) + assert 'nextblockhash' not in node.getblockheader( + node.getbestblockhash()) + def _test_getdifficulty(self): difficulty = self.nodes[0].getdifficulty() # 1 hash in 2 should be valid, so difficulty should be 1/2**31 @@ -441,6 +446,9 @@ blockinfo['nextblockhash'], blockheaderinfo['nextblockhash']) + assert 'previousblockhash' not in node.getblock(node.getblockhash(0)) + assert 'nextblockhash' not in node.getblock(node.getbestblockhash()) + if __name__ == '__main__': BlockchainTest().main()