Post
Topic
Board Development & Technical Discussion
Re: How do I find the fee of a received transaction?
by
NielDLR
on 22/05/2013, 06:07:47 UTC
Total inputs - total outputs = fees

For example:
http://blockchain.info/tx/1c7179f134e553df60e5f5bc2f6484e7c10ae04d04373d63e2fc86cb0f978295

1.69788468 in
1.44 + 0.25688468 = 1.69688468 out


1.69788468 - 1.69688468 = 0.001 fee


Hi Revalin,

ah yes. I figured that out. But I was wondering how to programmatically determine that. But I've since figured it out.

I wasn't sure how to get the exact "input" amount from the getrawtransaction api call, because each 'vin' only had the txid. There were multiple outputs (addresses) for each input. Then after some deeper research I found that the 'vout' reference in each input was a reference to the output of that corresponding input.

Once I found that out, it was each to calculate the input total and then minus the outputs to get the fee!