0
I'd like to better understand how a light client works. As far as I know, a light client stores locally only the block headers (80 bytes each) and it receives a new block header on average each 10 minutes.
I've essentially two questions:
1) How can a light client retrieve a transaction given its hash? I'd like to get back the complete transaction so to read out the data after the OP_RETURN code.
2) How can the light client be sure that the retrieved transaction is really the one in the longest blockchain? Does it simply check if there are 5 blocks already confirmed after the transaction's block?
Thank you very much
thank you for the explanation! Can I also ask you what are the minimum requirements for a thin client in term of RAM and CPU ? – gatb27 – 2017-01-30T19:58:12.983
Pretty much nothing. Strictly speaking, you don't even need to keep all of the block headers once you've checked that they connect to the genesis block. You could keep only the chain tip, and the ones you're interested in. The primary issue with thin clients is not the resources they use, but their inability to check whether a blockchain is valid. – Nick ODell – 2017-01-30T20:43:21.127
Ok, now I've got it. To be sure the blockchain is a valid one, we need the complete blocks with all the transaction, so a full node right? – gatb27 – 2017-01-30T21:15:10.967
Right. You need all of the blocks to enforce rules like not letting the same output be spent twice. – Nick ODell – 2017-01-30T21:25:57.580
Hi @nick , if I am a thin client (bitcoinj) and I know both the
tx_hashand theblock_number, what kind of message do I need to send to my peers to get back the complete transaction? – gatb27 – 2017-02-01T14:17:51.037@gatb27 Once you know
– Nick ODell – 2017-02-01T17:28:09.080block_hash, andtx_hash, you send the bloom filter withfilterload. Then you sendgetdata, with an inv type ofMSG_FILTERED_BLOCK, and the block hash. This documents the low-level details. https://en.bitcoin.it/wiki/Protocol_documentation#Inventory_Vectors Let me see if I can work up some example code for you.I've just studied the different kind of messages on the developer guide :) I'd like to ask for the last favour: I'm interested in a snippet of code in python (jython for bitcoinj) that given a
tx_hashandblock_number, it returns the hex after OP_RETURN in the tx_hash output. Where can I find a guide for learning how to do it? :) – gatb27 – 2017-02-03T07:01:22.887