I'm using blockchain dumps from http://dumps.webbtc.com/ in database schema in mentioned that result of script in pk_script should specify recipient of transaction. But how do I get amount of bitcoin sent and sender?
Asked
Active
Viewed 1,183 times
1 Answers
1
The database schema is located here: https://webbtc.com/api/schema
You might be disappointed to find out that it's not as simple as an amount and a sender for each transaction. What there are is a list of inputs (references to previous outputs), and a list of new outputs. Each output with an amount and a pseudonymous address. Each input has a TXID and output index to reference which previous output it is spending. Unless you know who owns specific addresses, though, you can't determine the identity of the sender(s).
You can use the prev_out and prev_out_index from a row in the inputs table to find the associated previous output, which will tell you the amount and address.
morsecoder
- 14,008
- 2
- 42
- 92
-
I need sender in sense of getting his pubkey or even hash of pubkey which your comment if I understand correctly refers to as 'address'. So, I need to look up previous transactions. And what if previous transaction has many recipients and only one of them participating in the current? – Moonwalker Dec 10 '15 at 19:07
-
1The `pk_script` of the outputs table gives you that, but you'll need to convert that scriptPubKey to an address. It's not super easy to do that, and the table doesn't give you the actual address. So, you can either look up the standard output types and learn how to convert them to an address, or use a different data set that has the addresses in them. – morsecoder Dec 10 '15 at 19:14
-
Could you suggest different data set which already has addresses in it? I would much appreciate it. – Moonwalker Dec 10 '15 at 20:08
-
If you're specifically looking for downloadable databases, I don't know of any, unfortunately. There are API web services that provide that information, but it takes a long time to parse the whole block chain (and a lot of bandwidth) with an API. – morsecoder Dec 10 '15 at 20:30
-
See http://bitcoin.stackexchange.com/questions/11687/reliable-efficient-way-to-parse-the-blockchain-into-a-sql-database – morsecoder Dec 10 '15 at 20:31