ensure public api served blocks are not decrypted

This commit is contained in:
Kevin Froman 2020-03-19 01:40:52 -05:00
parent 62a01b6dba
commit 24284e058f
2 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import onionrexceptions
class GetBlockData: class GetBlockData:
def __init__(self, client_api_inst=None): def __init__(self, client_api_inst=None):
return return
def get_block_data(self, bHash, decrypt=False, raw=False, headerOnly=False): def get_block_data(self, bHash, decrypt=False, raw=False, headerOnly=False):
if not stringvalidators.validate_hash(bHash): raise onionrexceptions.InvalidHexHash("block hash not valid hash format") if not stringvalidators.validate_hash(bHash): raise onionrexceptions.InvalidHexHash("block hash not valid hash format")
bl = onionrblockapi.Block(bHash) bl = onionrblockapi.Block(bHash)
@ -26,7 +26,7 @@ class GetBlockData:
validSig = False validSig = False
signer = bytesconverter.bytes_to_str(bl.signer) signer = bytesconverter.bytes_to_str(bl.signer)
if bl.isSigned() and stringvalidators.validate_pub_key(signer) and bl.isSigner(signer): if bl.isSigned() and stringvalidators.validate_pub_key(signer) and bl.isSigner(signer):
validSig = True validSig = True
bl.bheader['validSig'] = validSig bl.bheader['validSig'] = validSig
bl.bheader['meta'] = '' bl.bheader['meta'] = ''
retData = {'meta': bl.bheader, 'metadata': bl.bmetadata} retData = {'meta': bl.bheader, 'metadata': bl.bmetadata}

View File

@ -43,7 +43,7 @@ def get_block_data(publicAPI, data):
if stringvalidators.validate_hash(data): if stringvalidators.validate_hash(data):
if not config.get('general.hide_created_blocks', True) or data not in publicAPI.hideBlocks: if not config.get('general.hide_created_blocks', True) or data not in publicAPI.hideBlocks:
if data in blockmetadb.get_block_list(): if data in blockmetadb.get_block_list():
block = apiutils.GetBlockData().get_block_data(data, raw=True) block = apiutils.GetBlockData().get_block_data(data, raw=True, decrypt=False)
try: try:
block = block.encode() # Encode in case data is binary block = block.encode() # Encode in case data is binary
except AttributeError: except AttributeError: