Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: NielDLR on May 22, 2013, 02:20:24 AM



Title: How do I find the fee of a received transaction?
Post by: NielDLR on May 22, 2013, 02:20:24 AM
I'm currently developing a bitcoin service and to mitigate risk in zero-confirm transactions, I want to determine if a transaction has a miners fee attached to it or not.

How can I do this?

I know send transactions include the 'fee' in the details field in the gettransaction api call. But if I receive bitcoins how can I determine if it has a fee attached? Any help here would be appreciated.

I see Blockchain.info has this information, so I know it's possible.



Title: Re: How do I find the fee of a received transaction?
Post by: Revalin on May 22, 2013, 04:17:11 AM
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


Title: Re: How do I find the fee of a received transaction?
Post by: NielDLR on May 22, 2013, 06:07:47 AM
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!