Bitcoin Forum
September 24, 2017, 08:48:37 AM *
News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: how to figure out transaction in values from addresses  (Read 1131 times)
earney
Newbie
*
Offline Offline

Activity: 11


View Profile
January 27, 2011, 02:09:54 AM
 #1

how to figure out transaction IN values from addresses?  I've been looking at the output of a transaction, and I can't figure out how blockexplorer figures out the transaction in values for each bc address.

For example,  see http://blockexplorer.com/b/104777  , the second transaction has 9 inputs with different values.   How are these derived from the raw block?

Thanks..
1506242917
Hero Member
*
Offline Offline

Posts: 1506242917

View Profile Personal Message (Offline)

Ignore
1506242917
Reply with quote  #2

1506242917
Report to moderator
1506242917
Hero Member
*
Offline Offline

Posts: 1506242917

View Profile Personal Message (Offline)

Ignore
1506242917
Reply with quote  #2

1506242917
Report to moderator
1506242917
Hero Member
*
Offline Offline

Posts: 1506242917

View Profile Personal Message (Offline)

Ignore
1506242917
Reply with quote  #2

1506242917
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
theymos
Administrator
Legendary
*
Offline Offline

Activity: 2786


View Profile
January 27, 2011, 02:26:16 AM
 #2

You need to follow the prev_out. It's not specified in the transaction. Looking at this transaction, locate output #1 in transaction b8983967c707 to get the value. It's the second "out" here. The index ("n") starts at 0.

The difficulty of processing this by hand is one of the main reasons I wrote BBE. Previously I output all of the blocks to a file and then searched it for hashes, but I had to go back and forth dozens of times just to figure out the total value of a transaction.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
earney
Newbie
*
Offline Offline

Activity: 11


View Profile
January 27, 2011, 02:33:14 AM
 #3

thanks..  that makes sense..  I was thinking that the values in the transaction IN added up to the values in the transaction out, but in the example I gave you, this is not the case..  Most of the time the aggregate values in tx_in was equal to the values of the tx_out..
Hal
VIP
Sr. Member
*
Offline Offline

Activity: 314



View Profile
January 27, 2011, 06:49:02 AM
 #4

The sum of the IN values has to be greater than or equal to the sum of the OUT values. If it is greater, the difference is a transaction fee, collectable by whoever generates the block that includes this transaction.

Hal Finney
theymos
Administrator
Legendary
*
Offline Offline

Activity: 2786


View Profile
January 27, 2011, 07:21:07 AM
 #5

thanks..  that makes sense..  I was thinking that the values in the transaction IN added up to the values in the transaction out, but in the example I gave you, this is not the case..  Most of the time the aggregate values in tx_in was equal to the values of the tx_out..

All of the input values do add up to the output values in that block. Are you counting all of the outputs of the input transactions, perhaps?

I forgot to answer part of your original question: you can get the actual addresses by parsing the scriptSig/scriptPubKey. My tools are useful for doing the necessary conversions:
http://blockexplorer.com/q/hashpubkey
http://blockexplorer.com/q/hashtoaddress
http://blockexplorer.com/q/addresstohash

Transactions to addresses use:
scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <sig> <pubKey>

Various other less usual transactions use:
scriptPubKey: <pubKey> OP_CHECKSIG
scriptSig: <sig>

You can put pubKeyHash through hashtoaddress to get the address, or you can put pubKey through hashpubkey+hashtoaddress.

Addresses can't be easily determined for non-standard transactions such as this:
http://blockexplorer.com/testnet/tx/802b9e557161b9bffdc2e12cc755eb4379f88014f288c2484bb39b831bb9938e#o1

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!