0% found this document useful (0 votes)
6 views25 pages

Module2_Lect5_202425

This presentation from St. Francis Institute of Technology covers Bitcoin transactions, focusing on their structure, lifecycle, and the concept of Unspent Transaction Outputs (UTXO). It explains how transactions are created, propagated, and validated within the Bitcoin network, as well as the role of miners and transaction fees. Additionally, it discusses how UTXOs function within the Bitcoin system, emphasizing that there are no traditional accounts, only scattered UTXOs that represent ownership of Bitcoin.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views25 pages

Module2_Lect5_202425

This presentation from St. Francis Institute of Technology covers Bitcoin transactions, focusing on their structure, lifecycle, and the concept of Unspent Transaction Outputs (UTXO). It explains how transactions are created, propagated, and validated within the Bitcoin network, as well as the role of miners and transaction fees. Additionally, it discusses how UTXOs function within the Bitcoin system, emphasizing that there are no traditional accounts, only scattered UTXOs that represent ownership of Bitcoin.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

The material in this presentation belongs to St. Francis Institute of Technology and is solely for educational purposes.

Distribution and modifications of the content is prohibited.

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).

• Transactions are the most important part of the bitcoin system.


• Transactions are data structures that encode the transfer of value between
participants in the bitcoin system.

• Each transaction is a public entry in bitcoin’s 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

• Transaction message + signed


hash of message
Bitcoin Transaction Lifecycle
• A transaction’s lifecycle starts with the transaction’s creation, also known as
origination.

• 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.

• Finally, the transaction is verified by a mining node and included in a block of


transactions that is recorded on the blockchain.
Sender
Bitcoin Transaction Lifecycle
Origination Amount Authentication

Propagation of New Verification by Miner & Transaction sent


Block by Miner New Block Creation to Memory Pool Propagation & Validation
5

Verification, Propagation Recipient receives Receiver


and Addition of New Block First Confirmation
by other nodes
1. Originating 2. Amount 3. Signing
• Creating Transactions: A transaction is an instrument that expresses the intent to
transfer money and is not visible to the financial system until it is submitted for
execution.
• Transactions can be created online or offline by anyone, even if the person creating
the transaction is not an authorized signer on the account.
• Bitcoin transaction references a specific previous transaction as its source of Funds,
rather than an account.
• Once a transaction has been created, it is signed by the owner of the source funds.
• The signed transaction is valid and contains all the information needed to execute
the transfer of funds.
• Finally, the valid transaction has to reach the bitcoin network so that it can be
propagated until it reaches a miner for inclusion in the pubic ledger (the blockchain).
4. Propagation and Validation
• Broadcasting Transactions to the Bitcoin Network:
• 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 senders do not need to trust the nodes they use to broadcast the transaction
• The nodes don’t need to trust the sender or establish the sender’s “identity” because the
transaction is signed and contains no confidential information.
• It is broadcasted over insecure networks such as WiFi, Bluetooth, NFC, Chirp, barcodes, or
by copying and pasting into a web form
• A bitcoin transaction could be transmitted over packet radio, satellite relay, or shortwave
using burst transmission, spread spectrum, or frequency hopping to evade detection and
jamming.
• A bitcoin transaction could even be encoded as smileys (emoticons) and posted in a public
forum or sent as a text message or Skype chat message.
• Bitcoin has turned money into a data structure, making it virtually impossible to stop anyone
from creating and executing a bitcoin transaction.
4. Propagation and Validation
• Propagation and Validation:
• Once a bitcoin transaction is sent to any node connected to the bitcoin network, the
transaction will be validated by that node.
• If valid, that node will propagate it to the other nodes to which it is connected, and a
success message will be returned synchronously to the originator.
• If the transaction is invalid, the node will reject it and synchronously return a
rejection message to the originator.
• Messages, including transactions and blocks, are propagated from each node to all
the peers to which it is connected, a process called “flooding.”
• The bitcoin network is designed to propagate transactions and blocks to all nodes in
an efficient and resilient manner that is resistant to attacks.
• To prevent spamming, denial-of-service attacks, or other nuisance attacks against
the bitcoin system, every node independently validates every transaction before
propagating it further.
• A malformed transaction will not get beyond one node.
5. Memory Pool
• Mempool (Memory Pool) is where the transactions stay until the miner is ready to get them.
• In bitcoin's blockchain, the miner prioritize the biggest transactions over the smallest ones.
• This happens because here is where the miner makes money.
• Every transaction in the blockchain has a fee, and the miner get that fee to him plus the
reward for mining the block.
6. Mining and 7. Propagation of New Block
• Consensus Algorithm:
• The Bitcoin uses one consensus algorithm
called Proof Of Work (PoW).
• In POW miners try to get the right nonce
number by checking the hash created for
the block until the result hash have the
same number of zero's in it's prefix as the
current difficulty set in the Blockchain.
• This difficulty exists to control how fast the
block will be mined in the network.
• Bitcoin protocol sets the time of mining
near of 10 minutes.
• If the mining is faster than it, the network
increases the difficulty and if this is getting
slow, the network decreases the difficulty.
• The mined block is then propagated.
https://www.businesstechweekly.com/finance-and-accounting/cryptocurrency/understanding-cryptocurrency-101-basics/
8. Verification, Propagation & Addition of New Block
• The chain of nodes validates the new block and every peer in the network will get
the blockchain with the new block added.

• Once recorded on the blockchain and confirmed by sufficient subsequent blocks


(confirmations), the transaction is a permanent part of the bitcoin ledger and is
accepted as valid by all participants.

• 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.

Without transaction fees With transaction fees


Transaction Fees
• Transaction fees serve as an incentive to include (mine) a transaction into the next block and
also as a disincentive against “spam” transactions or any kind of abuse of the system, by
imposing a small cost on every transaction.
• Transaction fees are collected by the miner who mines the block that records the transaction.
• Transaction fees are calculated based on the size of the transaction in kilobytes, not the
value of the transaction in bitcoin.
• Overall, transaction fees are set based on market forces within the bitcoin network.
• Transaction fees affect the processing priority, meaning that a transaction with sufficient fees
is likely to be included in the next-most–mined block, whereas a transaction with insufficient
or no fees might be delayed, processed on a best-effort basis after a few blocks, or not
processed (unconfirmed) at all.
• Transaction fees are not mandatory, and transactions without fees might be processed;
however, including transaction fees encourages priority processing.
• The data structure of transactions does not have a field for fees. Instead, fees are implied as
the difference between the sum of inputs and the sum of outputs.
Transaction Outputs and Inputs (UTXO)
• Fundamental building block of a bitcoin transaction is an Unspent Transaction Output (UTXO)
• The UTXO consumed by a transaction are called transaction inputs, and the UTXO created by a
transaction are called transaction outputs.
• Every transaction input references an existing UTXO by the previous txid and the index of the
transaction output within that previous transaction.
• Example: If Alice wants to pay Bob 1 BTC and she has 2 UTXOs worth 0.5 BTC and 0.7 BTC,
she can use both UTXOs as inputs and send an output worth 1 BTC to Bob.
• In order to claim the leftover change, Alice creates another output worth 0.199 BTC, which she
sends to herself (and not 0.2 BTC because she must pay a transaction fee of 0.001).
UTXO Example
• UTXO can be any arbitrary value, once created it is indivisible just like a coin cannot be cut
in half.
• If a UTXO is larger than the desired value of a transaction, it must still be consumed in its
entirety and change must be generated in the transaction.
• Example: if you have a 10 bitcoin UTXO and want to pay 1.5 bitcoin, your transaction must
consume the entire 10 bitcoin UTXO and produce two outputs: one paying 1.5 bitcoin to your
desired recipient and another paying 8.5 bitcoin in change back to your wallet.
UTXO Model
• Bitcoin account Balance:
– There is no such thing as a stored balance of a bitcoin address or account; there are only
scattered UTXO, locked to specific owners.
– In the traditional financial system, a transaction takes money from one account and
moves it into another.
– Since Bitcoin’s UTXO model does not have accounts, there is no “from” account or
address. While addresses are used to receive UTXOs, addresses are never directly
inscribed on the blockchain.
– Bitcoin addresses are encodings of scriptPubKeys, which are included in each
transaction output.
– When bitcoin is spent, an input only includes the signatures and public keys required to
satisfy the scriptPubKey.
• There is no mention of which address the bitcoin came from on the blockchain.
However, the previous address of a UTXO can be easily calculated.
Transaction Outputs and Inputs
• Unspent transaction output ( UTXO):
– UTXO helps Bitcoin to be fully transparent, fair, and auditable.
– UTXO are indivisible chunks of bitcoin currency locked to a specific owner, recorded on the
blockchain, and recognized as currency units by the entire network.
– The bitcoin network tracks all available (unspent) UTXO currently numbering in the millions.
– Whenever a user receives bitcoin, that amount is recorded within the blockchain as a UTXO.
– User’s bitcoin might be scattered as UTXO amongst hundreds of transactions and hundreds
of blocks.

• 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.

1. Increase the commission fee (Replace-by-fee).


2. Double Waste.
1. When you resubmit the transaction with a higher commission, the old one is cancelled. You
should not abuse this method.
3. Child Pays For Parent (CPFP).
1. It means selecting transactions for mining not just based on their fees but also based on the
fees of their ancestors (parents) and descendants (children).
Thank You

You might also like