Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clients/python/docs/GeneralApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ with graphsense.ApiClient(configuration) as api_client:
q = "foo" # str | It can be (the beginning of) an address, a transaction or a label
currency = "btc" # str | The cryptocurrency (e.g., btc) (optional)
limit = 10 # int | Maximum number of search results (optional) if omitted the server will use the default value of 10
include_sub_tx_identifiers = True # bool | Whether to include sub-transaction identifiers (optional) if omitted the server will use the default value of False

# example passing only required values which don't have defaults set
try:
Expand All @@ -128,7 +129,7 @@ with graphsense.ApiClient(configuration) as api_client:
# and optional values
try:
# Returns matching addresses, transactions and labels
api_response = api_instance.search(q, currency=currency, limit=limit)
api_response = api_instance.search(q, currency=currency, limit=limit, include_sub_tx_identifiers=include_sub_tx_identifiers)
pprint(api_response)
except graphsense.ApiException as e:
print("Exception when calling GeneralApi->search: %s\n" % e)
Expand All @@ -142,6 +143,7 @@ Name | Type | Description | Notes
**q** | **str**| It can be (the beginning of) an address, a transaction or a label |
**currency** | **str**| The cryptocurrency (e.g., btc) | [optional]
**limit** | **int**| Maximum number of search results | [optional] if omitted the server will use the default value of 10
**include_sub_tx_identifiers** | **bool**| Whether to include sub-transaction identifiers | [optional] if omitted the server will use the default value of False
**_preload_content** | **bool** | If False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. | [optional] default is True.
**async_req** | **bool** | Execute request asynchronously | [optional] default is False.

Expand Down
6 changes: 6 additions & 0 deletions clients/python/graphsense/api/general_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def __search(
Keyword Args:
currency (str): The cryptocurrency (e.g., btc). [optional]
limit (int): Maximum number of search results. [optional] if omitted the server will use the default value of 10
include_sub_tx_identifiers (bool): Whether to include sub-transaction identifiers. [optional] if omitted the server will use the default value of False
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
Expand Down Expand Up @@ -224,6 +225,7 @@ def __search(
'q',
'currency',
'limit',
'include_sub_tx_identifiers',
],
'required': [
'q',
Expand Down Expand Up @@ -257,16 +259,20 @@ def __search(
(str,),
'limit':
(int,),
'include_sub_tx_identifiers':
(bool,),
},
'attribute_map': {
'q': 'q',
'currency': 'currency',
'limit': 'limit',
'include_sub_tx_identifiers': 'include_sub_tx_identifiers',
},
'location_map': {
'q': 'query',
'currency': 'query',
'limit': 'query',
'include_sub_tx_identifiers': 'query',
},
'collection_format_map': {
}
Expand Down
8 changes: 6 additions & 2 deletions gsrest/service/general_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ async def search_by_currency(request, currency, q, limit=10):
return pydantic_search_result_by_currency_to_openapi(pydantic_result)


async def search(request, q, currency=None, limit=10):
async def search(request, q, currency=None, limit=10, include_sub_tx_identifiers=False):
services = get_service_container(request)
tagstore_groups = get_tagstore_access_groups(request)

pydantic_result = await services.general_service.search(
q, tagstore_groups, currency, limit, include_sub_tx_identifiers=False
q,
tagstore_groups,
currency,
limit,
include_sub_tx_identifiers=include_sub_tx_identifiers,
)

return pydantic_search_result_to_openapi(pydantic_result)
8 changes: 5 additions & 3 deletions openapi_server/controllers/general_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def get_statistics(request: web.Request, ) -> web.Response:
raise web.HTTPInternalServerError()


async def search(request: web.Request, q, currency=None, limit=None) -> web.Response:
async def search(request: web.Request, q, currency=None, limit=None, include_sub_tx_identifiers=None) -> web.Response:
"""Returns matching addresses, transactions and labels


Expand All @@ -103,6 +103,8 @@ async def search(request: web.Request, q, currency=None, limit=None) -> web.Resp
:type currency: str
:param limit: Maximum number of search results
:type limit: int
:param include_sub_tx_identifiers: Whether to include sub-transaction identifiers
:type include_sub_tx_identifiers: bool

"""

Expand All @@ -127,11 +129,11 @@ async def search(request: web.Request, q, currency=None, limit=None) -> web.Resp
request.app['request_config']['show_private_tags'] = show_private_tags

try:
if 'currency' in ['','q','currency','limit']:
if 'currency' in ['','q','currency','limit','include_sub_tx_identifiers']:
if currency is not None:
currency = currency.lower()
result = service.search(request
,q=q,currency=currency,limit=limit)
,q=q,currency=currency,limit=limit,include_sub_tx_identifiers=include_sub_tx_identifiers)
result = await result

for plugin in request.app['plugins']:
Expand Down
21 changes: 21 additions & 0 deletions openapi_server/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ paths:
maximum: 100
type: integer
style: form
- description: Whether to include sub-transaction identifiers
example: true
explode: true
in: query
name: include_sub_tx_identifiers
required: false
schema:
default: false
type: boolean
style: form
responses:
"200":
content:
Expand Down Expand Up @@ -3167,6 +3177,17 @@ components:
maximum: 100
type: integer
style: form
include_sub_tx_identifiers:
description: Whether to include sub-transaction identifiers
example: true
explode: true
in: query
name: include_sub_tx_identifiers
required: false
schema:
default: false
type: boolean
style: form
operation:
description: The operation to execute in bulk
example: get_block
Expand Down
10 changes: 10 additions & 0 deletions openapi_spec/graphsense.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ paths:
- $ref: '#/components/parameters/currency_query'
- $ref: '#/components/parameters/search_query'
- $ref: '#/components/parameters/limit'
- $ref: '#/components/parameters/include_sub_tx_identifiers'
responses:
"200":
description: OK
Expand Down Expand Up @@ -1205,6 +1206,15 @@ components:
maximum: 100
description: Maximum number of search results
example: 10
include_sub_tx_identifiers:
in: query
name: include_sub_tx_identifiers
required: false
schema:
type: boolean
default: false
description: Whether to include sub-transaction identifiers
example: true
operation:
in: path
name: operation
Expand Down