I have read some documents from NXT
I think i can use these APIs to get asset Holders
1. use getTrades&asset=ASSETID to get all trade happened of one asset
2. check all BidOrder by getTransaction&transaction=BidID to get all buyer IDs
by these i can get all asset holders if they do not transfer their assets
3. check all the buyer's asset transaction by
getAccountTransactionIds&account=accountID&type=2subtype=1
And repeat step 2-3 untill followed all the final asset transfer
another way is use
getAccount&account=ACCOUNTID
if i can have a list of all account in the NFD net.
is there anyway to get all account? which might make things easy
I fear you will miss transferred assets.
The method Account.getAllAccounts() is only used by GetState.java to get status information. You would have to get all transactions to know all accounts.
Sometimes ago I wrote a RichList generator. It was only a fast hack but should be a good starting point to get all shareholders of an asset. It also uses Account.getAllAccounts() and loops through every single account.
http://woll-e.net/~matthias/RichList.javaI think the API should be completely rethought, without breaking old behavior. This should be coordinated with NXT developers.
I have looked at the problem in more detail. There is no function to get an asset balance of an account. At least I didn't found one.
One possibility exist. You could activate debug trace for all accounts.
nxt.debugTraceAccounts=*
You will get a big nfd-trace.csv with all transactions tab-separated.
Take row 1 2 3 4 6 from file.
Search for "asset balance" in second row.
You get a list with accounts, asset ids and the current asset balance.
height" "event" "account" "asset" "asset balance"
"86754" "asset balance" "4093015566329367683" "8537833860395844488" "9999494"
"86754" "asset balance" "13510103993148326478" "8537833860395844488" "54"
"86754" "asset balance" "4093015566329367683" "8537833860395844488" "9999493"
"86754" "asset balance" "7680600898101588699" "8537833860395844488" "1"
"86809" "asset balance" "970166099509975653" "8537833860395844488" "56"
"86809" "asset balance" "9286011010206951429" "8537833860395844488" "1"
Account 4093015566329367683 (network bounty account) has 2 entries. The entries have a chronological order. Only the last value of an account have the correct value.
There is also a row with timestamps. That makes it easy to get a list of shareholder for a current time.