Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: NotATether on October 23, 2021, 12:53:29 PM



Title: combining multiple prev_hash and prev_index in tx creation
Post by: NotATether on October 23, 2021, 12:53:29 PM
Me and a friend are writing some code to programmatically create Trezor transactions (it's proprietary code). But we are not sure how to fill in the prev_hash field inside the Trezor API.

As you might know, when you create a transaction on Trezor, two of the parameters are prev_index and prev_hash.

But we are not sure if we should use the values from the previous transaction or combine them somehow.

Actually we are not even sure what these values are to be honest.

If someone could shed some light on these details I would really appreciate it.



We basically need to get all the UTXOs of an address. What is the most efficient way to do that?


Title: Re: combining multiple prev_hash and prev_index in tx creation
Post by: achow101 on October 23, 2021, 09:16:02 PM
A UTXO is identified by the txid of the transaction it was created in, and the 0-based index of its position in the transaction's outputs array. That txid is prev_hash, and the position is prev_index. This applies to all Bitcoin transactions, it is not specific to trezor.