mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-09-01 17:55:13 +00:00
added --include_protobuf to add hexlified protobuf to RPC responses
This commit is contained in:
parent
f660691e78
commit
9fae8f5153
2 changed files with 6 additions and 2 deletions
|
@ -441,13 +441,14 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
|
|
||||||
async def handle_old_jsonrpc(self, request):
|
async def handle_old_jsonrpc(self, request):
|
||||||
data = await request.json()
|
data = await request.json()
|
||||||
|
include_protobuf = data.get('params', {}).pop('include_protobuf', False)
|
||||||
result = await self._process_rpc_call(data)
|
result = await self._process_rpc_call(data)
|
||||||
ledger = None
|
ledger = None
|
||||||
if 'wallet' in self.component_manager.get_components_status():
|
if 'wallet' in self.component_manager.get_components_status():
|
||||||
# self.ledger only available if wallet component is not skipped
|
# self.ledger only available if wallet component is not skipped
|
||||||
ledger = self.ledger
|
ledger = self.ledger
|
||||||
return web.Response(
|
return web.Response(
|
||||||
text=jsonrpc_dumps_pretty(result, ledger=ledger),
|
text=jsonrpc_dumps_pretty(result, ledger=ledger, include_protobuf=include_protobuf),
|
||||||
content_type='application/json'
|
content_type='application/json'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -98,9 +98,10 @@ def encode_file_doc():
|
||||||
|
|
||||||
class JSONResponseEncoder(JSONEncoder):
|
class JSONResponseEncoder(JSONEncoder):
|
||||||
|
|
||||||
def __init__(self, *args, ledger: MainNetLedger, **kwargs):
|
def __init__(self, *args, ledger: MainNetLedger, include_protobuf=False, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.ledger = ledger
|
self.ledger = ledger
|
||||||
|
self.include_protobuf = include_protobuf
|
||||||
|
|
||||||
def default(self, obj): # pylint: disable=method-hidden
|
def default(self, obj): # pylint: disable=method-hidden
|
||||||
if isinstance(obj, Account):
|
if isinstance(obj, Account):
|
||||||
|
@ -168,6 +169,8 @@ class JSONResponseEncoder(JSONEncoder):
|
||||||
})
|
})
|
||||||
if txo.script.is_claim_name or txo.script.is_update_claim:
|
if txo.script.is_claim_name or txo.script.is_update_claim:
|
||||||
output['value'] = txo.claim
|
output['value'] = txo.claim
|
||||||
|
if self.include_protobuf:
|
||||||
|
output['protobuf'] = hexlify(txo.claim.to_bytes())
|
||||||
output['sub_type'] = txo.claim.claim_type
|
output['sub_type'] = txo.claim.claim_type
|
||||||
if txo.channel is not None:
|
if txo.channel is not None:
|
||||||
output['signing_channel'] = {
|
output['signing_channel'] = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue