graphsense / graphsense-python

A Python client for the GraphSense REST interface.
MIT License
19 stars 5 forks source link

Feature Request: All Tx from a specific date #22

Open ayinkosh opened 1 year ago

ayinkosh commented 1 year ago

Hi!

I would like to have a feature, where I can display all transaction from a specific day. Is there any chance to get it?

myrho commented 1 year ago

If you know the heights of blocks that were created on that specific day, you can easily get all transactions of these blocks using BlocksApi.list_block_txs.

However, resolving the time range of the start and end of the day to block heights cannot be achieved directly through GraphSense's API. You could find them using BlocksApi.get_block in an approximative way.

behas commented 1 year ago

Or do you mean all transactions for a given input address on a specific day?

ayinkosh commented 1 year ago

Thank you. I am just using list_blocks_txs. But to find the corresponding blocks, I have to search on another place. So I thought, It might be easier, if iknaio could possibly do that.'

Another issue: If I send the txs to a CSV, the CSV is multilined and ugly. Why does it not write each datarow in one single row. If i use fields like total_input_eur or total_input_usd it gets multilined and is no useable anymore.

for example: this should be one line, but it gives me this 4 rows:

,,490524,True,btc,490524,,0,0,2,"{'address': ['1CK6KHY6MHgYvmRQ4PAafKYDrg1ejbH1cE'], 'value': {'fiat_values': [{'code': 'eur', 'value': 65500.55}, {'code': 'usd', 'value': 76956.6}], 'value': 1376513431}}",1,1508363840,0.0,0.0,0,65500.55,76956.6,1376513431,28d0d1bcf2c819bfe5cc83c4f48da56b021fe5d9e78d3b082dc90fa6a88fede0,utxo

myrho commented 1 year ago

Thank you for your feedback. Surely the bulk api needs to be improved regarding how nested data is returned. As a workaroud you might consider using get_tx_io, which gives you only the inputs/outputs, eg.:

txs = bulk_api.BulkApi(api_client).bulk_csv(
    currency,
    'get_tx_io',
    body={
        'tx_hash': ['c7acfbc501820baf9786a7727ea9b61da01bff7043c8dae58adfb037c259e6f0'],
        'io': 'inputs'
    },
    num_pages=1)

print(txs)

Result:

_error,_info,_request_tx_hash,address,address_count,value_eur,value_usd,value_value
,,c7acfbc501820baf9786a7727ea9b61da01bff7043c8dae58adfb037c259e6f0,17geVBGbVPGVxg7nxj1XqVyNdRH4V24pT2,1,4.25,5.0,89367
,,c7acfbc501820baf9786a7727ea9b61da01bff7043c8dae58adfb037c259e6f0,17geVBGbVPGVxg7nxj1XqVyNdRH4V24pT2,1,4.08,4.8,85775
,,c7acfbc501820baf9786a7727ea9b61da01bff7043c8dae58adfb037c259e6f0,17geVBGbVPGVxg7nxj1XqVyNdRH4V24pT2,1,2.92,3.43,61380
,,c7acfbc501820baf9786a7727ea9b61da01bff7043c8dae58adfb037c259e6f0,17geVBGbVPGVxg7nxj1XqVyNdRH4V24pT2,1,4.67,5.49,98181
,,c7acfbc501820baf9786a7727ea9b61da01bff7043c8dae58adfb037c259e6f0,17geVBGbVPGVxg7nxj1XqVyNdRH4V24pT2,1,1.71,2.01,36000