When getting information about transactions with blockchain.info's API, every transaction contains exactly one "prev_out" object, and within that object "n" is always equal to either 0 or 1.
What do these things stand for/mean?
Bitcoin Stack Exchange is a question and answer site for Bitcoin users, developers, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
A transaction consists of a number of inputs and a number of outputs. Outputs define a script that need to be executed to be able to spend the coins in the output. Inputs provide data to enter into an output script to make it execute successfully and to spend the coins in it.
So, a transaction input must be able to reference the output it is willing to spend. Outputs in a transaction are ordered, so an output can be referred to by specifying the transaction ID of the transaction it has been defined in, and the index it has in the list of specified outputs in that transaction.
prev_out field is the transaction hash (txid) and the
n is the index of the output.
It's not true that every transaction contains exactly one
prev_out value. However, many transactions do. This is because many transactions have only one input. You must know, though, that it is possible to have multiple inputs.
A typical bitcoin transaction is made up of inputs and outputs. Unspent coins from previous outputs are reference by the inputs. These coins are pooled, then redistributed to the outputs, which now represent the same number of unspent coins (minus fees).
The inputs reference the unspent coins by the transaction hash and the index of the output that's being redeemed.
Although you can have as many inputs and outputs as you want -- in theory, you could write a transaction that references every coin in existence, and redistributes it to ten million new addresses -- in practice, most transactions only have one output (the recipient) or two outputs (the recipient and the "change" address), so "n" is usually -- but not always -- 0 or 1.
For example, if you look at https://blockchain.info/tx/017ee876b7078170066da40894b291e496dc09b7fb3edff4e2e7e8262545c7b1?format=json you can see the "n" value in the sole "prev_out" dictionary is 170. That's because this transaction is spending coins that came from a prior transaction with 170 or more outputs.
Previous tx is a hash of a previous transaction. Index is the specific output in the referenced transaction. see: https://en.bitcoin.it/wiki/Transactions