Bitcoin Forum
March 24, 2023, 03:05:56 AM *
News: Latest Bitcoin Core release: 24.0.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How do I find the fee of a received transaction?  (Read 673 times)
NielDLR (OP)
Member
**
Offline Offline

Activity: 95
Merit: 10



View Profile WWW
May 22, 2013, 02:20:24 AM
 #1

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.


The Cypherfunks - A decentralized band and cryptocurrency. The first cryptocollective.
1679627156
Hero Member
*
Offline Offline

Posts: 1679627156

View Profile Personal Message (Offline)

Ignore
1679627156
Reply with quote  #2

1679627156
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1679627156
Hero Member
*
Offline Offline

Posts: 1679627156

View Profile Personal Message (Offline)

Ignore
1679627156
Reply with quote  #2

1679627156
Report to moderator
Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
May 22, 2013, 04:17:11 AM
 #2

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

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
NielDLR (OP)
Member
**
Offline Offline

Activity: 95
Merit: 10



View Profile WWW
May 22, 2013, 06:07:47 AM
 #3

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!

The Cypherfunks - A decentralized band and cryptocurrency. The first cryptocollective.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!