Jump to content

Bitcoin Core Tx and UTXO questions

ScratchCat

I am attempting to understand how Bitcoin processes Txs and stores UTXOs.

 

Firstly: How do Bitcoin wallets/nodes derive the solution to a locking script?

From what I understand Bitcoin defines standard transactions including P2PKH, P2PK, P2SH and Multisig. These transactions can be identified by the locking script patterns e.g. using regular expressions and can be solved using predefined solutions, replacing components with the required signatures/hashes.

However there are more complex scripts which use more commands and may contain branches using IF/ELSE statements, how would a script solve this?

I would assume one could create a tree for each branch in the program, get the user to select the target branch and traverse the tree backwards to obtain a single script, then use the previous methods to solve the individual components of the transaction.

 

Secondly: How does Bitcoin store the UTXOs which belong to a given address?

Bitcoin stores the UTXOs for fast access to unspend outputs however at +400MB this database would take a long time to comb through to find the UTXOs which a given wallet can spend. The UTXOs for a wallet could either be stored in the wallet or be linked in a seperate table Address_UTXO(Address,Tx_Hash,Tx_Index).

How does Bitcoin quickly find UTXOs which belong to a wallet?

 

Thanks

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×