Bitcoin Forum
September 27, 2018, 11:07:17 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [C parser] How to check if this transaction data is ok?  (Read 732 times)
Delek
Full Member
***
Offline Offline

Activity: 157
Merit: 100


Salí para ver


View Profile WWW
January 20, 2015, 01:14:15 PM
 #1

Hi there guys!, I'm writing another Blockchain parser in C.
Atm I have completely read all blocks (~130mb each one) and the program is outputting information that seems to be ok, however, how could I check out if this information is ACTUALLY ok?; take a look at this output for example:

Quote from: Soft
Prev Block Hash: 000000000000000065709a9a4aaeea6108f0c288af277b0cc1826c7e8ea908cc

 - Transaction 0
 - - - Prev tx: 0000000000000000000000000000000000000000000000000000000000000000 from output 4294967295  Script: 03cf3104e4b883e5bda9e7a59ee4bb99e9b1bc52b76272ffb1ede86953c87d93a8b664fa598eaab 1888d4db0128ec70ccafb020400000000000000b851516500000000000003cf4d696e6564206279 20757365722077616e673636383836393037
 - - - Output 0 Satoshis 1161932642346598400 Script: 76a914c825a1ecf2a6830c4401620c3a16f1995057c2ab88ac

 - Transaction 1
 - - - Prev tx: 18106b50b5be65e644cb8044d712cb98e76a836da26350e4debc72aca770d05c from output 1  Script: 483045022024d6501f26e5200f930ac120104e2452810277f588a1700e15763565b76d7a7e02210 0b383c56575a1d5ac5703ec1be7e308713c16dd33885be78766ff566c86d6212801210275811580 2e2a9b7ed08a47bb966824cf299e54a31035c8ac8e0dec3a12ec3cd1
 - - - Output 0 Satoshis 14178876884254720 Script: 76a914eaa191f519cb90557f99bed963cd8943a7e99a4b88ac
 - - - Output 1 Satoshis 57027523489300480 Script: 76a914b20252ea508b5c8790ea0e42c0002503dfb0b62488ac

 - Transaction 2
 - - - Prev tx: fad405bccd41fea34cf39077c51a3f9e89f42f1d4398965c6d90c0750756f03d from output 0  Script: 493046022100e0b1b6b9126aed4956654e59daf97deb2af39a9482d63016d4820b47d47e3cda022 100f816e85d022d9ff5e9c510100e1bc6ff18f1605d81e20077007e5c5ded1bf0830121030c0485 70c5d26bc93a40640710eba7908c6e8b28cbf11ee94941c812e4bb41aa
 - - - Output 0 Satoshis 2089140485833621504 Script: 76a914d20f9801da48203aa5c00d11250fcbe9c038713588ac
 - - - Output 1 Satoshis 4858284486304989184 Script: 76a914205591d19cb7894f43fb5330ea49b1d5da3e651188ac

 - Transaction 3
 - - - Prev tx: 49709ac2faeee2c85831d3c95f2baeefc1a622bafd177ff1f7a6d17a73aabf49 from output 0  Script: 493046022100cfdc199ee8337fbe3d14bc4bb399711d1f1914ab7f52a63ff8e1f432c99fbd4e022 100a2d57560ade3cdb639efd973003d58e978360434a88464ed5e4a01f65d856433012103a16825 ea6db2112140c3473d7dc82c6733bb46f1b6af04871aa5b00c8b4b3944
 - - - Output 0 Satoshis 3766029635272310784 Script: 76a914601a270adc1e663ed4caa50fdcac319e5a886d1488ac
 - - - Output 1 Satoshis 8011388100515201024 Script: 76a9143045e0ad4f3d8496fb7d8651909cd5ec40f3479c88ac

End of block...


As this being a chain, everything references to the previous thing, so, how could I check that THIS block is ok?, where is the hash of the current block?, I need to mine it?, if I mine it I will not find the same hash that is in the main blockchain; so WTF?, I'm missing something isn'it?

Thanks a lot.

\/\/\/\/\/\/\/
-> delek.net <-
/\/\/\/\/\/\/\
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1000


View Profile
January 20, 2015, 04:09:03 PM
 #2

https://en.bitcoin.it/wiki/Protocol_rules

but if you are parsing existing blocks you can skip almost all checks
bitcoin core client did them already
you should only skip non-mainchain blocks from blk***.dat files
Delek
Full Member
***
Offline Offline

Activity: 157
Merit: 100


Salí para ver


View Profile WWW
January 20, 2015, 04:31:57 PM
 #3

https://en.bitcoin.it/wiki/Protocol_rules

but if you are parsing existing blocks you can skip almost all checks
bitcoin core client did them already
you should only skip non-mainchain blocks from blk***.dat files
Sorry if I didn't express myself properly; what I'm trying to figure out is if the data posted corresponds 100% to a certain block. I thought that it would be as easy as writing the block hash @ blockchain.info:
Prev Block Hash: 000000000000000065709a9a4aaeea6108f0c288af277b0cc1826c7e8ea908cc
https://blockchain.info/block-index/337052/000000000000000065709a9a4aaeea6108f0c288af277b0cc1826c7e8ea908cc

But obviously, this will not give to me the current block information, only the PREVIOUS block information. How can I know the Hash of the block that I'm analyzing?

\/\/\/\/\/\/\/
-> delek.net <-
/\/\/\/\/\/\/\
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1000


View Profile
January 20, 2015, 04:47:57 PM
 #4

Quote
But obviously, this will not give to me the current block information, only the PREVIOUS block information. How can I know the Hash of the block that I'm analyzing?
blockhash is not stored in block
because it can be calculated
SHA256 ( SHA256 ( blockheader ) )
Delek
Full Member
***
Offline Offline

Activity: 157
Merit: 100


Salí para ver


View Profile WWW
January 20, 2015, 04:55:30 PM
 #5

OH shit, you're right. Thanks a lot!

\/\/\/\/\/\/\/
-> delek.net <-
/\/\/\/\/\/\/\
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!