Skip to content

Commit

Permalink
Add getblockhash RPC method
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-belcher committed Jul 16, 2021
1 parent e6c0847 commit 9a372fd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions jmclient/jmclient/blockchaininterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def is_address_imported(self, addr):
def get_block(self, blockheight):
"""Returns full serialized block at a given height.
"""
block_hash = self._rpc('getblockhash', [blockheight])
block_hash = self.get_block_hash(blockheight)
block = self._rpc('getblock', [block_hash, False])
if not block:
return False
Expand Down Expand Up @@ -503,6 +503,9 @@ def get_block_height(self, blockhash):
def get_block_time(self, blockhash):
return self._get_block_header_data(blockhash, 'time')

def get_block_hash(self, height):
return self._rpc("getblockhash", [height])

def get_tx_merkle_branch(self, txid, blockhash=None):
if not blockhash:
tx = self._rpc("gettransaction", [txid])
Expand All @@ -522,7 +525,7 @@ def core_proof_to_merkle_branch(self, core_proof):
return core_proof[80:]

def verify_tx_merkle_branch(self, txid, block_height, merkle_branch):
block_hash = self._rpc("getblockhash", [block_height])
block_hash = self.get_block_hash(block_height)
core_proof = self._rpc("getblockheader", [block_hash, False]) + \
binascii.hexlify(merkle_branch).decode()
ret = self._rpc("verifytxoutproof", [core_proof])
Expand Down

0 comments on commit 9a372fd

Please sign in to comment.