How do bitcoin transactions work?

14
How do transactions work? Pavel Kravchenko Lecture 3

Transcript of How do bitcoin transactions work?

How do transactions work?

Pavel Kravchenko

Lecture 3

Plan

Terms

What is transaction

What is included there

Change and fee

Creation of the transaction

How can you spend the result

Terms

tx – transaction

txid – id of a transaction. Is used to search a transaction in blockchain

Script – the name of the script language that describes how a client should validate transactions

UTXO - Unspent Transaction Output – transactions output

Wallet – key pair

Address – public key

Transaction format

Transaction – a signed piece of data that authorizes the sending of funds from one account to another

Service information – identifies the transaction and allows implementing it correctly

Input – information about where the sender got money from and proof that sender owns this money

Output – information about where money is flowing to

Transaction always spends money from previous transaction

identifier of transaction amount of inputs and

outputs hash of transaction

that is spent here

signature of the sender and their public key

amount of money that is transferred

address where money goes

Most important fields

Input

Account has no “balance” There is a list of not spent transactions (cheques) Input indicates which previous transaction

should be spent Input contains also a signature of the sender

Transaction that contains 2 inputs and 2 outputs

Change and fee

All the money from previous transaction (you can find this amount if you look up previous transaction) is spent in the current one

Difference between money that input has and output spends is considered a fee and is taken by miners

If you don’t want to pay high fee :) you have to create output that returns change for you (thats why transactions with many outputs are needed)

Change money is sent to address that you control

How transaction with change is formed

Combining your unspent transactions

If none of the unspent transactions that you have (UTXO) contains enough money to pay - you have to combine a few

Here transactions with a few inputs are needed Money are summed up (and fee paid to miners is

calculated in the same way - difference between total input and total output)

Your wallet (a piece of software) contains key pairs - that is money that you control

How transactions spend money

notice that each transaction pays 10k satoshi as a fee

Summary

Every balance which is received or sent should be tied to the address

Every address may be associated with the wallet. All the rest – non-spendable, the coins that are sent to them – are lost

The balance that can be spent was always received from the wallet

The coins received to the address are not mixed – they are used separately (or in a combination) in the moment when they are spent

If the sum of all inputs is more, than the sum of outputs, the change is considered to be a commission

Questions?

[email protected]

ideateam_macuser

ua.linkedin.com/in/pkravchenko/