Bitcoin transactions consist of multiple TxIn (payers) and TxOut (payees).
Neither addresses nor amounts are written in TxIn transactions; the only things that are recorded are the "hash" transactions indicating that coin was acquired from the payer and which index number TxOut is in that transaction.
This means that it is not possible to calculate the total TxIn without extracting the relevant transaction from among over 100 million transactions. This is probably the most difficult aspect of creating a new Bitcoin Daemon.
You must take care to determine whether the payer's coin has been double-spent.