Title: how to figure out transaction in values from addresses Post by: earney on January 27, 2011, 02:09:54 AM 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.. Title: Re: how to figure out transaction in values from addresses Post by: theymos on January 27, 2011, 02:26:16 AM You need to follow the prev_out. It's not specified in the transaction. Looking at this transaction (http://blockexplorer.com/rawtx/3fe3888d8e1d2a379baa57a18ac8600e7568d97cb61d48504e70b41a01175bf3), locate output #1 in transaction b8983967c707 to get the value. It's the second "out" here (http://blockexplorer.com/rawtx/b8983967c70713ef766f64211f93d32f957b4b86ef33fbf5c341c96d8b30339c). 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. Title: Re: how to figure out transaction in values from addresses Post by: earney on January 27, 2011, 02:33:14 AM 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..
Title: Re: how to figure out transaction in values from addresses Post by: Hal on January 27, 2011, 06:49:02 AM 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.
Title: Re: how to figure out transaction in values from addresses Post by: theymos on January 27, 2011, 07:21:07 AM 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 |