Module2_Lect5_202425
Module2_Lect5_202425
Blockchain
and DLT
(BLCH)
ITC801
Subject In-charge
Dr. Joanne Gomes
Professor Dept. of Information Technology SFIT
Room No. 317
email: [email protected]
Module 2
Lecture 5
Bitcoin
Topics:
• Bitcoin Transaction and UTXO
Bitcoin Transaction
• The main purpose of the Bitcoin blockchain is to enable participants to be able to
exchange value between themselves.
• Everything else in bitcoin is designed to ensure that secure and immutable
transactions can be created, propagated on the network, validated, and finally
added to the global ledger of transactions (the blockchain).
• A bitcoin transaction consists of three main components, these are inputs, outputs,
and the amount that is intended to be transferred between parties.
• A bitcoin transaction consists of
inputs, outputs, and the amount
• The transaction is then signed with one or more signatures indicating the
authorization to spend the funds referenced by the transaction.
• The transaction is then broadcast on the bitcoin network, where each network node
(participant) validates and propagates the transaction until it reaches (almost) every
node in the network.
• The funds allocated to a new owner by the transaction can then be spent in a new
transaction, extending the chain of ownership and beginning the lifecycle of a
transaction again.
9. Block Explorer for Receiver
• So, the money was sent and left the wallet, but it will take some time until it reaches the recipient. What
if something happens to the coins – how to check the Bitcoin transaction?
• For this, Block Explorer was created. (https://www.blockchain.com/explorer)
9. Block Explorer for Receiver
• A blockchain explorer lets you:
– View the transaction history of any wallet address
– View receiving addresses and change addresses
– View unconfirmed transactions
– View double-spend incidents
– View orphaned blocks
– View who mined/validated a particular block
– View fees, hash rate, difficulty, and other information associated with a given block or
transaction
• In addition, investors may use a blockchain explorer to check that wallet addresses
are valid before sending, to confirm whether crypto was sent or not sent, and to
check current gas or network fees.
Transaction Structure
• A transaction is a data structure that encodes a transfer of value from a source of funds,
called an input, to a destination, called an output.
• Transaction inputs and outputs are not related to accounts or identities.
• Instead, you should think of them as bitcoin amounts locked with a specific secret that only
the owner, or person who knows the secret, can unlock.
• Bitcoin transaction is 300 to 400 bytes of data and contains a No. of fields, as shown in Table
Size Field Description
Specifies which rules this
4 bytes Version
transaction follows
1–9 bytes Input
How many inputs are included
(VarInt) Counter
Variable Inputs One or more transaction inputs
1–9 bytes Output
How many outputs are included
(VarInt) Counter
Variable Outputs One or more transaction outputs
4 bytes Locktime A Unix timestamp or block number
Wallet deduction
• Sender sent 0.5 BTC and Receiver got 0.5 BTC, but there is transaction fees that should be
deducted here.
• Let's suppose a Sender is sending 0.5 BTC to Receiver and there is 0.70 BTC in the wallet,
lets assume that the transaction fee is 0.10 BTC. Here is what happens:
• Sender says that he wants to send 0.5 BTC to Receiver.
• The transaction will have as a input 0.70 BTC, and one output of the transaction is going to
be 0.5 BTC that Receiver should receive.
• The other output is going to be the change that Sender will get from this transaction:
0.70 BTC – 0.5 BTC - 0.10 BTC = 0.10 BTC.
• These outputs are called UTXO ( Unspent Transaction Output)
• Then sender balance is 0.10 and the Receiver gets your 0.5 BTC.
• The wallet calculates the user’s balance by scanning the blockchain and
aggregating all UTXO belonging to that user.
• All of this complex assembly of spendable UTXO is done by the user’s wallet
automatically
Transaction Output
• Every bitcoin transaction creates outputs, which are recorded on the bitcoin ledger,
recognized by the whole network and available for the owner to spend in a future transaction.
• Sending someone bitcoin is creating an unspent transaction output (UTXO) registered to
their address and available for them to spend.
• UTXO are tracked by every full-node bitcoin client as a data set called the UTXO set or
UTXO pool, held in a database. New transactions consume (spend) from the UTXO set.
• Transaction outputs consist of two parts:
– An amount of bitcoin, denominated in satoshis, the smallest bitcoin unit
– A locking script, also known as an “encumbrance” that “locks” this amount by specifying the
conditions that must be met to spend the output.
• The structure of a transaction output is as follows
Size Field Description
8 bytes Amount Bitcoin value in satoshis (10-8 bitcoin)
1-9 bytes (VarInt) Locking-Script Size Locking-Script length in bytes, to follow
Variable Locking-Script A script defining the conditions needed to spend the output
Transaction Inputs
• Transaction inputs are pointers to UTXO. They point to a specific UTXO by reference to the
transaction hash and sequence number where the UTXO is recorded in the blockchain.
• To spend UTXO, a transaction input also includes unlocking scripts that satisfy the spending
conditions set by the UTXO which is usually a signature proving ownership of the bitcoin
address that is in the locking script.
• When users make a payment, their wallet constructs a transaction by selecting from the
available UTXOs. For example, to make a 0.015 bitcoin payment, the wallet app may select
a 0.01 UTXO and a 0.005 UTXO, using them both to add up to the desired payment amount.
• The structure of a transaction input is as follows
Size Field Description
32 bytes Transaction Hash Pointer to the transaction containing the UTXO to be spent
4 bytes Output Index The index number of the UTXO to be spent; first one is 0
1-9 bytes (VarInt) Unlocking-Script Size Unlocking-Script length in bytes, to follow
Variable Unlocking-Script A script that fulfills the conditions of the UTXO locking script.
4 bytes Sequence Number Currently disabled Tx-replacement feature, set to 0xFFFFFFFF
How to Speed Up Bitcoin Transaction?
• There are three ways to independently solve the bitcoin unconfirmed transaction
problem, but note that none of them guarantee a 100% result.