add other missing scripthash apis

- `blockchain.scripthash.unsubscribe`
- `blockchain.scripthash.listunspent`
This commit is contained in:
Jack Robison 2022-04-11 17:45:07 -04:00
parent aa75eebc22
commit cb5f396b33
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -827,8 +827,12 @@ class LBRYElectrumX(asyncio.Protocol):
coro = self.scripthash_get_mempool coro = self.scripthash_get_mempool
elif method == 'blockchain.scripthash.subscribe': elif method == 'blockchain.scripthash.subscribe':
coro = self.scripthash_subscribe coro = self.scripthash_subscribe
elif method == 'blockchain.scripthash.unsubscribe':
coro = self.scripthash_unsubscribe
elif method == 'blockchain.scripthash.get_balance': elif method == 'blockchain.scripthash.get_balance':
coro = self.scripthash_get_balance coro = self.scripthash_get_balance
elif method == 'blockchain.scripthash.listunspent':
coro = self.scripthash_listunspent
elif method == 'blockchain.transaction.broadcast': elif method == 'blockchain.transaction.broadcast':
coro = self.transaction_broadcast coro = self.transaction_broadcast
elif method == 'blockchain.transaction.get': elif method == 'blockchain.transaction.get':
@ -1158,7 +1162,7 @@ class LBRYElectrumX(asyncio.Protocol):
# self.session_manager.pending_query_metric.dec() # self.session_manager.pending_query_metric.dec()
# self.session_manager.executor_time_metric.observe(time.perf_counter() - start) # self.session_manager.executor_time_metric.observe(time.perf_counter() - start)
async def mempool_compact_histogram(self): async def mempool_compact_histogram(self): # TODO: fix this
return [] #self.mempool.compact_fee_histogram() return [] #self.mempool.compact_fee_histogram()
async def claimtrie_search(self, **kwargs): async def claimtrie_search(self, **kwargs):
@ -1441,10 +1445,10 @@ class LBRYElectrumX(asyncio.Protocol):
hashX = scripthash_to_hashX(scripthash) hashX = scripthash_to_hashX(scripthash)
return self.unconfirmed_history(hashX) return self.unconfirmed_history(hashX)
# async def scripthash_listunspent(self, scripthash): async def scripthash_listunspent(self, scripthash):
# """Return the list of UTXOs of a scripthash.""" """Return the list of UTXOs of a scripthash."""
# hashX = scripthash_to_hashX(scripthash) hashX = scripthash_to_hashX(scripthash)
# return await self.hashX_listunspent(hashX) return await self.hashX_listunspent(hashX)
async def scripthash_subscribe(self, scripthash): async def scripthash_subscribe(self, scripthash):
"""Subscribe to a script hash. """Subscribe to a script hash.
@ -1453,6 +1457,10 @@ class LBRYElectrumX(asyncio.Protocol):
hashX = scripthash_to_hashX(scripthash) hashX = scripthash_to_hashX(scripthash)
return await self.hashX_subscribe(hashX, scripthash) return await self.hashX_subscribe(hashX, scripthash)
async def scripthash_unsubscribe(self, scripthash: str):
hashX = scripthash_to_hashX(scripthash)
return await self.hashX_unsubscribe(hashX, scripthash)
async def _merkle_proof(self, cp_height, height): async def _merkle_proof(self, cp_height, height):
max_height = self.db.db_height max_height = self.db.db_height
if not height <= cp_height <= max_height: if not height <= cp_height <= max_height: