Date based filtering of transactions

+2 votes
hi Multichain Team,

How can we do date based filtering of transactions for a particular wallet? I know transaction doesn't have a date but we are fine with the blocktime of that transaction. Lets say I want transactions for a particular address from 1st April - 30th April, so how do we do that?

Also how do we get transactions from a particular stream for a date range, lets say from 1st April - 30th April? I mean all keys who value got affected bewteen 1st - 30th April. How should we design our keys if we have such a requirement?

asked Apr 28, 2017 by amanc
I know we can parse the whole chain in a local db and get these results? Any other way to do it directly from the blockchain?

2 Answers

0 votes

There isn't currently a way to do this with MultiChain's APIs, but we're considering adding time-based indexing in future. In the meantime your best bet is to retrieve items using their global ordering (e.g. via liststreamitems) and use a binary search to identify the appropriate range for the start/count parameters. Bear in mind also that it's possible for the timestamps in blocks to not always increase in the way you expect, since the mining nodes can have their times out of sync, so you need to leave a bit of leeway when applying the binary search to find the appropriate range, then you can post-filter based on the actual timestamp you're looking for.

answered Apr 28, 2017 by MultiChain
ok Thanks.

And what about non-stream based transactions (just asset transfer transactions), how do I do date filtering there?
If a node is subscribed to an asset, you can use listassettransactions to query the transactions relating to that asset in exactly the same way as stream items.
No my requirement is to find transactions for all assets between a start date and end date? It can be any asset and either type - send or receive.
Unfortunately we don't support this type of query, yet, but it's on the roadmap.
Ok no issues, will wait for this feature to be incorporated. You product is already awesome, this feature will make it even better.
0 votes

Beta 2, just released, includes a new API liststreamblockitems which allows the stream items in a particular block, or set of blocks, to be retrieved. The blocks can be specified in various ways including a timestamp range, so this should now do exactly what you need.

answered Jun 15, 2017 by MultiChain
Thanks, will try out and let you know if further help is required.