Bitcoin transactions consist of multiple TxIn (payers) and TxOut (payees).
All TxIn must be signed with a private key. The difference between the total value of the TxIn and TxOut is given to the miners who generated the block as a commission.
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.