Bitcoin transaction

This is the approved revision of this page, as well as being the most recent.
How bitcoin transaction works

Bitcoin transaction is a section of data confirmed by a signature of Bitcoin. It is sent to the Bitcoin network and forms blocks. It typically contains references to preceding transactions and associates a certain number of bitcoins with one or several public keys (Bitcoin addresses). It is not encrypted because there is nothing to encrypt in the Bitcoin system. A Blockchain browser is where all transactions are combined in the form of a blockchain. They can be found and verified. This is necessary to determine technical transaction parameters as well as verify the details of payments.

Contents

The general format of all Bitcoin transactionsEdit

Field Description Size
Version number Currently 1 4 bytes
In-Counter Positive integer VI = Varlnt 1-9 bytes
List of inputs The first input of the first transaction is also called a coinbase <In-counter> many inputs
Out-counter Positive integer VI = Varlnt 1-9 bytes
List of outputs The first output of the first transaction use Bitcoins found for the block <out-counter> many outputs
Lock time If not equal to 0 and sequence numbers are inferior to OxFFFFFFFF: block height or timestamp (for final transactions) 4 bytes

View bitcoin transactions with input and outputEdit

DataEdit

Input:
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index: 0
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501
Output:
Value: 5000000000
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d
OP_EQUALVERIFY OP_CHECKSIG

InterpretationEdit

Input in this transaction imports 50BTC from output # 0 in transactions f5d8…, then the output sends 50 BTC to a Bitcoin address (expressed here in the form of a hexadecimal system – 4043…). When the recipient wants to spend their money, he will reference this transaction’s output # 0 for his own transaction’s input.

InputEdit

The mining ecosystem

Input is a reference to the output of another transaction. A transaction often possesses several inputs. The values of these references are resumed and the total value of bitcoins can be used for the current transaction output. Previous tx is the hash of a preceding transaction. Index is a certain output from this transaction. ScriptSig is the first half of the script (see below for more details about this).

The script is composed of two elements: the signature and the public key. The public key belongs to the user who applies the transaction outputs and confirms that the creator of the transaction has the right to have at his disposal the sum of money obtained from the outputs. Another element is EDCSA (hash signature of a simplified version of the transaction). In combination with the public key, this signature confirms that the transaction has been created by the real owner of this Bitcoin address.

OutputEdit

The output contains instructions about sending the bitcoins. The value is an amount in satoshi (1 BTC = 100000000 satoshi), which can be used by the transaction for which the current transaction is the input. ScriptPubKey is the second half of the script (this will be elaborated upon afterwards). There can be more than one output and these will share the amount sent from the inputs. Each transaction output may only be used as the input for the subsequent transaction once, with the effect that the sum of all current transaction inputs must be used in the output. Otherwise the remaining sum from the transaction inputs will be lost. For example, if the input is equal to 50BTC and the user must only send 25BTC, Bitcoin creates two outputs of 25BTC each: one will go to the destination, the other will go to the owner of the funds again (the so-called ‘change’ – a transaction in which the user in fact sends money to himself). Any amount remaining from the input of bitcoins not used in the transaction will become the fee for the transaction. The person generating the block will receive this fee.

Transaction verificationEdit

In order to verify if the inputs are permitted to collect the requisite sums from the outputs of the preceding transactions, Bitcoin uses the standard system of the script (see below) of scriptSig input and scriptPubKey output which this transaction references. They are evaluated with the help of scriptPubKey using the remaining values in the scriptSig stack.

The input is confirmed if the scriptPubKey script returns a “true” value. Using the script system, the sender can create very complex conditions to fulfill by those who wish to obtain the output value. For example, it is possible to create an input which any user will obtain without authorization. It is equally possible to request that the input be signed by 10 different keys or verified by password.

General format of each transaction input – TxinEdit

Field Description Size
Hash of preceding transaction Hashed double SHA256 of preceding transaction 32 bytes
Previous Txout-index Arithmetical integer. It indexes outputs of the preceding transaction 4 bytes
List of inputs The first input of the first transaction is also called a coinbase <In-counter> many inputs
Length of Txin script Arithmetical integer VI = Varlnt 1-9 bytes
Txin-script / scriptSig Script <length within the script> many bytes
Sequence number Normally 0[FFFFFFFF; functions in the case that the lock time of the transaction > 0 4 bytes

The input adequately describes where and how the number of bitcoins can be obtained which can be redeemed by their new owner. If it is the only input of the first transaction in the block, it is called the generated transaction input. Its contents are completely ignored.

General format of each transaction output – TxoutEdit

Field Description Size
Value Arithmetical integer giving a satoshi amount (BTE/10^8) necessary for transactions 8 bytes
Length of Txout-script Arithmetical stack 1-9 bytes
Txout-script / scriptPubKey Script <length of output script> many bytes

The output determines the conditions of use of the Bitcoin data in the following transactions, the sum of the output values of the first transaction in the block is a value of bitcoins taken for the block. Here a fee amount is added from the other transactions added to this block.

Transaction confirmationEdit

Main page: Transaction confirmation

A transaction is a transfer of value between Bitcoin wallets that gets included in the block chain. How does Bitcoin work?Bitcoin transactions are not immediate. When a user wishes to send bitcoins, information is broadcast from her wallet to the (users in the) network, who verify that she has enough coins, and that they have never been spent before. Once validated, miners will include this transaction – along with others – in a new block in the blockchain. This is called a transaction confirmation. The transaction is now said to be "0/unconfirmed"

Each time a new block is added to the chain (every ten minutes), the transaction is said to be confirmed again. As a consensus, many users wait for a transaction to be confirmed six times (after roughly sixty minutes) before accepting it as payment, to avoid double-spending. Users will usually show a transaction as "n/unconfirmed" until it is six blocks deep.


TransactionConfirmationTimesExample.PNG
==

Current bitcoin transaction feeEdit

Main page: Bitcoin transaction fee

Currently a large amount of transactions is processed in a way that commission isn't necessary. At the same time in case if transaction has a lot of entry points (e.g. it carries large amounts of data) a small commission is not uncommon.

Any miner can be the one who processes the transaction and earns the commission fee. When the network finds a new block it includes all information about transactions including their commission. Thus any user of group of users who find that block will gain both the reward for the block and the commission fees for every transaction included in it.

Including commission in a transaction is a voluntary decision but a user who finds a block can attach any transactions he wants to the said block. That way transactions with 0 commission have the lowest priority when transactions with even the minimal possible commission (~0.0001 BTC at the current moment) have standard priority and will more probably be included in the block.

See AlsoEdit


Licence.png

Read in another language