Extend `getAccountTransactions` by token/asset Id filter
Motivation
While trying to support Tokens in the XT Wallet I came up with an "accuracy" problem of fetching transactions for a specific token. Atm, I'm doing 5 (five) HTTP requests to the node to get
- Token Trades
- Token Transfers
- Open Bid Orders
- Open Ask Orders
- further transactions like minting, issuance, distribution using
getAccountTransactionswith type/subtype filter
Problem
The problem is that I need to filter the result getAccountTransactions by the Token Id, trying to find the tx for the related token. This is limited as it may happen, that an active account can have hundreds of transactions per day and then some token related transactions from a very few days ago won't appear. I could do multiple calls using the pagination, but the main problem still persists.
Solution
If we would be able to return only transactions for a given account and given token we can be much more precise on the transaction history for a token. So, additionally to the type/subtype filter an additional asset filter could be a nice extension.
I'm aware that this might introduce a bigger effort, as one cannot simply filter the attachment_bytes using SQL. And doing the filter only server side brings up the similar "accuracy" problem as doing it on application level (although, it can be done much faster due to direct database access) - Ideally, another nullable column asset_id for token/asset related can be added to the transaction table and set on each transaction with type=2.
From my point of view is this change working without a HF.
We should create a new table which only store asset_id and tx_id and block height.
In this case we could have several entries for the same tx (e.g. Multi-token transfer)
For sure we need a DB update script.