Bitcoin Forum
November 20, 2017, 07:48:08 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: How to efficiently extract values of vin in blockchain transactions  (Read 297 times)
PVminer
Newbie
*
Online Online

Activity: 27


View Profile
November 09, 2017, 08:07:11 PM
 #1

I'm trying to analyze fees in the blockchain and I wrote a script in Python using bitcoinrpc library and getrawtransaction RPC call. However, getrawtransaction does not print vin values, only corresponding txids so I had to read all those transactions and extract the values from vout of the parent transactions. The script works but is very slow, each block takes a few minutes to process.

Is there a faster way to do it? I want a local solution (I can patch Bitcoin Core if necessary) but downloading e.g. from blockchain.info will not work because they have limits on the number of queries.
1511207288
Hero Member
*
Offline Offline

Posts: 1511207288

View Profile Personal Message (Offline)

Ignore
1511207288
Reply with quote  #2

1511207288
Report to moderator
Join ICO Now Coinlancer is Disrupting the Freelance marketplace!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1511207288
Hero Member
*
Offline Offline

Posts: 1511207288

View Profile Personal Message (Offline)

Ignore
1511207288
Reply with quote  #2

1511207288
Report to moderator
DannyHamilton
Legendary
*
Online Online

Activity: 1974



View Profile
November 09, 2017, 08:51:53 PM
 #2

Is there a faster way to do it? I want a local solution (I can patch Bitcoin Core if necessary) but downloading e.g. from blockchain.info will not work because they have limits on the number of queries.

You could write a program to maintain your own indexed UTXO list, and then just grab the values from your list.

PVminer
Newbie
*
Online Online

Activity: 27


View Profile
November 09, 2017, 10:50:28 PM
 #3


You could write a program to maintain your own indexed UTXO list, and then just grab the values from your list.

The problem is that the input transaction does not have to be unspent and the list of all outputs is going to be a large database. And initializing it via RPC will be slow.
DannyHamilton
Legendary
*
Online Online

Activity: 1974



View Profile
November 10, 2017, 12:34:56 AM
 #4

the list of all outputs is going to be a large database.

And this is why it is so slow for you to look it up right now.  The blockchain is effectively a database of all outputs.  The value of the input is NOT stored in the transaction.  It is ONLY stored in the output that is being spent, so you have to go find it (either in the blockchain or your own database).

byteball
Member
**
Offline Offline

Activity: 84


View Profile
November 14, 2017, 04:48:28 PM
 #5

Have a look at https://github.com/metrodexcoin/litecoin/blob/getblocksummary/src/rpc/misc.cpp#L651

getblocksummary RPC method.

The code that might help you to calculate each tx fee is commented out, in lines 691-700.

The reason I commented it out (after writing it myself) was that I only needed the fee for entire block,
which I can find in the coinbase transaction. Line 706 has the calculation.

In your case, you would need a similar method that returns fee for every transaction in the block.
Having -txindex is vital for this (see line 660), as transactions with all outputs already spent are not linked from UTXO
and therefore not easily findable, unless you know their block hash or height.

I can do this for a small donation or bounty, when I have free time, if C++ is alien to you Smiley
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!