1

When transferring BTC between two users, the new transaction will consist of references to previous transactions.

For example, if I user A wishes to transfer 1 BTC to user B, he will need 'n' transactions totaling 1 BTC in order for the transaction to be valid. If these 'n' transactions occur with large periods of time between them (say 1 year) and for some reason I felt the absolute necessity to verify that these 'n' transactions actually took place.

How would I find the relevant block?

Would I decrypt the block to read it? Is this ever done in actual practice and is it expensive and time consuming to do it?

1

I felt the absolute necessity to verify that these 'n' transactions actually took place. How would I find the relevant block?

A transaction consumes inputs, and creates outputs (new 'unspent transaction outputs' or UTXOs). For the transaction to be valid, each input must be a valid UTXO that exists on the network. Full nodes keep a continually updated index of all valid UTXOs, that they can check against incoming transactions.

A transaction input will reference the transaction which created it, via the transaction ID and the output index. So a full node will just look up that entry in the UTXO index, ensuring it exists and is being used validly.

Would I decrypt the block to read it?

Blocks are not encrypted, but you will have to parse through the relevant blocks to obtain the relevant transaction data.

Is this ever done in actual practice and is it expensive and time consuming to do it?

Yes, this is done by each and every node, for each and every transaction / block. Checking a single transaction is not a computationally expensive procedure, but there is consideration for the sum of verifications a full node must compute in order to synchronize with the network. In order to maintain a robust and decentralized network (which is integral to the network's properties), it is important that the total resource requirements to run a node remain relatively low, to ensure that a sufficient number of nodes are able to stay online.

3
  • You don't need to parse the relevant blocks if you keep all information about UTXOs in a UTXO database (like Bitcoin Core does). In that case, the UTXO set is not an index into the blocks; it is a fully self contained database of all unspent outputs. – Pieter Wuille May 5 '20 at 0:07
  • @PieterWuille so a node contains the blockchain as well as a database called a UTXO database that contains all unspent transaction points of all nodes (people) on the network? Also what happens when a transaction is spent? Is it removed from the UTXO table or a special column in the DB is updated to specify a spent transaction? – Bittu May 5 '20 at 1:30
  • 1
    Yes. When a transaction is confirmed in a block its inputs are removed from the UTXO set, and its outputs are added to it. – Pieter Wuille May 5 '20 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.