Unspent/Spent Flag in Blockchain
I just started getting interested in the blockchain a week ago, however there is something I can not just figure out.
Regarding the flag "Spent/Unspent" in transactions. I get that we flag "spent" the output of a transaction if this same output is used as an input in a future transaction.
-Suppose that we make a transaction (transaction 1), and this transaction get included in the blockchain (let's say block 1). We do not spent the output (consider a simple transaction single input & a single output) until 100 blocks later (transaction 2) in the blockchain.
I understand that in transaction 2, in the inputs, there is the info of the previous transactions (since we are implementing hash pointers)like shown below in "prev_out" (JSON format of transaction extracted from Blockexplorer api) :
'inputs': [{'prev_out': {'addr': '1PFtrRjbq4aLfM7k4tyLZ3ZAuTsgLr6Q8Q', 'n': 0, 'script': '76a914f423dfee34e4833104508103d89e316b4a49314088ac', 'spent': True, 'tx_index': 356882858, Up to now, there is no problem, I can totally understand that we can add a flag spent/unspent for the previous outputs (inputs) in transaction 2.
Suppose now this is the output of transaction 1 (which we are going to spent 100 blocks later).
By the way, this is a real transaction, its hash: a117a7aab7e2db8ef5fd40e74f72d689e13b733136454d2340a244236fbed9eb
'out': {'addr': '1PFtrRjbq4aLfM7k4tyLZ3ZAuTsgLr6Q8Q', 'n': 0, 'script': '76a914f423dfee34e4833104508103d89e316b4a49314088ac', 'spent': True, 'tx_index': 356893407, 'type': 0, 'value': 16351264}
My question is: You can see that the flag "spent" is True, How is this even possible ? Because during 99 blocks the transaction was unspent (flag=False). There is only one case possible for the flag "spent" to be True:
-The transaction 2 has to be in the same block as transaction 1. Otherwise if transaction 2 is in block 100 and the flag "Spent" of transaction 1 is True, it means that:
For 99 Blocks the flag was False and in the block 100, we change the flag of transaction 1, which is in block 1.
That means that we changed block 1, hence changed its hash --> impossible given the structure of the Blockchain.
Thank you for enlightening me !
https://ift.tt/2yN2A7m
Comments
Post a Comment