bitcoin transaction and script.pptx
bitcoin transaction and script.pptx
Bitcoin wallet
● Each Bitcoin wallet comes with a private key and a corresponding public address by
default (as well as a public key).
● Bitcoin wallet is designed to be able to store multiple key pairs.
● BTC is never actually stored in a Bitcoin wallet.
● a bitcoin wallet manages your keys and addresses so that you can send and
receive bitcoins.
● Bitcoin is an open-source program, so anyone can create their own wallet.
○ Desktop: Electrum
○ Android: Samourai
○ iOS: Green or Mycelium
● Seed:
○ is a randomly generated list of 12-24 words
○ seed is unique, and it is used to create every address in your wallet
● Bitcoin wallet address (also known as a public address) to
• A Bitcoin address is a
160-bit hash of the public
portion of a
public/private ECDSA keypai
r. Using public-key
cryptography, you can
"sign" data with
your private key and anyone
who knows your public key
can verify that the signature
is valid.
6 *
Encoding Schemes
● Base58 is a group of encoding/decoding schemes used to switch data
between binary format (hexdecimal) and alphanumeric text format (ASCII).
Base58 enables data compressing, is easy to identify, and is suitable for
constructing encoding mechanism of transmission system that is
anti-auto-monitoring.
● An encoding method that converts cryptocurrency addresses into ASCII
text that can be manually copied without making mistakes.
● Base 58 is an arithmetic base using 62 alphanumeric characters (26 lowercase
letters + 26 uppercase letters + 10 digits) but removing 0 (zero), O (uppercase
letter o), I (letter i uppercase) and l (lowercase letter L) in order to limit potential
reading errors (by a human or a machine).
● it avoids similar looking letters
https://bitcoinpaperwallet.io/bitcoinpaperwallet/generate-wallet.html
BIP 58 DEMO:https://learnmeabitcoin.com/technical/base58
BIP 38 DEMO: https://themoneymongers.com/bip-38-encryption/
(https://www.bitaddress.org/bitaddress.org-v3.3.0-SHA256-dec17c07685e18
70960903d8f58090475b25af946fe95a734f88408cef4aa194.html)
UTXO
● A transaction is a fundamental entity in the blockchain ledger.
● The UTXO model is an account model used in Bitcoin and many other cryptocurrencies.
● UTXOs define where each blockchain transaction starts and finishes.
● It is defined as transferring the ownership of a coin from one party to the other through
digital signatures (ECDSA).
● Destinations of ownership transfer are called outputs, and the sources of ownership are
called inputs.
● A subset of previous outputs is spent as inputs of the NEW transaction.
● The transactions contain multiple inputs and outputs.
● The set of the Unspent Transaction Outputs (UTXO) is called the state of a blockchain.
● A UTXO is the amount of digital currency remaining after cryptocurrency transaction is
executed.
● UTXO model makes bitcoin more secure, immutable, auditable and transparent than
traditional financial systems, which rely on a/c’s, balances and 3rd parties.
UTXO
● An unspent transaction output (UTXO) refers to a transaction output that can be used
as input in a new transaction.
● The state changes dynamically as a subset of previous outputs (or inputs) are being
spent, and create new outputs.
● The set of all UTXO’s at any given point is called UTXO set.
● Bitcoin node keep track of UTXO in order to determines where coins are at any given
point and who can spend them.
● Utxo MODEL is used in many cryptocurrency becoz it allows users to track ownership
of all portions of cryptocurrencies.
ALICE BOB
P Z
Transactions
● Unlocking and Locking of wallets model is called UTXO model.
UNLOCK
ALICE, 2BTC
o/p
5 BTC=2+1
+1.5+3
LOCK
i/p
BOB, 3BTC
o/p
Transactions
● Unlocking and Locking of wallets model is called UTXO model.
UNLOCK
ALICE, 2BTC
o/p
TOM, 6
BTC=2+1
+1.5+.5+1
LOCK
i/p
BOB, 3BTC
o/p
O/P 0.5 BTC I/P 0.5 BTC O/P 0.7 BTC BOB UTXO
Alice
O/P 1.7BTC I/P 1.7 BTC O/P 1.199 BTC Alice UTXO
main difference is its single “blank” input, which we call the coinbase.
● A satoshi is the smallest denomination of bitcoin, equivalent to 100 millionth
● Satoshi per byte is a unit for measuring transaction priority, defined by the
● The cheapest and fastest transaction fee amounts to 6–12 satoshis per byte
A TXID (Transaction ID) is basically an identification number for a bitcoin
transaction.
TXID by hashing transaction data through SHA256 twice.
A TXID is always 32 bytes (64 characters), represented in hexadecimal.
Examples:
● f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16 - First ever
Bitcoin transaction to Hal Finney in 2010.
● a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d - Pizza
transaction for 10,000 BTC in 2010.
● RBF ( Replace-by-Fee) AND SEGWIT TRANSACTIONS
https://learnmeabitcoin.com/technical/txid
https://developer.bitcoin.org/reference/transactions.html
https://learn.saylor.org/mod/book/view.php?id=36375&chapterid=19427
ALICE BOB
P Z
Each transaction is prefixed by a four-byte transaction version number which tells Bitcoin peers and
miners which set of rules to use to validate it.
ScriptSig: It encodes the public key and the signature of the current owner of the Bitcoin
(payer)
https://learnmeabitcoin.com/technic
al/input
Bitcoin transactions use locking and unlocking scripts, which are
executed together to verify a transaction. A locking script is a spending
condition specified in the transaction output, and an unlocking script
satisfies this condition when the two scripts are executed together.
Scripting language
• Bitcoin software (also known as Bitcoin Core) The original implementation
of the Bitcoin software was written in C++. additional implementations have
been written in Python, Java, and Go .
• Bitcoin Script is a simple programming language used to interact with the
Bitcoin software. In particular, Script gives the Bitcoin software instructions
on how coins in a UTXO (Unspent Transaction Output) can be spent.
• for the version of the Bitcoin software written in Go, the Bitcoin Script inside
it is also implemented using Go. The same applies for the other
implementations, as well.
• Wallets and other Bitcoin applications complete all the processing behind
the scenes automatically.
*
• Script was implemented by Satoshi Nakamoto
32
in the release of Bitcoin Core
Bitcoin Script
Forth-Like, stack-based, Reverse-polish, Turing incomplete
programming language
● Forth-Like Script: It resembles Forth, a programming language that
first appeared in 1970. Forth is used in the Open Firmware
Bootloader, space applications (including the Philae spacecraft), and
a variety of other embedded systems involving interactions with
hardware.Forth is a procedural, stack-oriented programming
language.
● stack-based:
Bitcoin Script uses a data structure (linear structure represented
by a physical stack or pile), “Last In, First Out (LIFO)” queue.
33 *
• Reverse-polish:
RPN is a method of placing the operation function at the end of a
sentence.
• Turing incomplete programming language
Script for Bitcoin and other cryptocurrencies does not allow infinite
loops.
advantages: inability to run malformed scripts, regardless if they are
intentional malicious attacks or unintentional programming errors.
Essentially, Script is able to prevent the halting problem.
Other blockchains developed since Bitcoin have mainly chosen to be
Turing Complete, or at least have a high degree of Turing
completeness. Although this potentially brings the halting problem
into play, and also provides better support for the complex logic
required for developing smart contracts.
SIMPLE SCRIPT
BITCOIN IDE:
https://siminchen.github.io/bitcoinIDE/build/editor.html
https://learn.saylor.org/mod/book/view.php?id=36364&chapterid=18950
2 7 OP_ADD 3 OP_SUB 1 OP_ADD 7 OP_EQUAL
● Bitcoin Script uses a system of operation codes (better known as Opcodes)
● opcodes are commands which tell nodes in the Bitcoin network how to
process any transaction request.
● standard transaction or create a custom transaction script
● Bitcoin Script and opcodes are required components of this process.
● One main advantage of Legacy addresses is their compatibility with almost
all wallets and exchanges available in the market.
Bitcoin PAYMENTS/type of Bitcoin address format
● All Bitcoin transactions use Script to define how outputs can be spent
● The Bitcoin protocol allows users to send different types of payments using Bitcoin
Script. Three popular examples include
When the Bitcoin protocol launched in 2009, Pay To Pubkey (P2PK) was an important payment type.
Pay-to-Public-Key (P2PK) is a type of ScriptPubKey which locks bitcoin to a public key. This means that the
bitcoin can only be spent by the owner of the private key corresponding to the public key provided in the
script.https://learnmeabitcoin.com/technical/block-hash
X SENDS btc TO Y PUBLIC KEY, Recipient Y Wants to spend those funds (spend the corresponding
UTXO) at any point in the future, they only need to prove they own the public key to which the funds
were sent.
ScriptSig (unlockingscript): It encodes the public key and the signature of
the current owner of the Bitcoin (payer)
It involves verifying the sender's wallet balance and the recipient's address
and ensuring the transaction is secure and tamper-proof.
https://drive.google.com/drive/u/0/my-drive
● OP_DUP: Duplicate the top item on the stack (place a copy of it on
the stack)
● OP_HASH160: Pop the top item off the stack, calculate it’s
stack
● OP_EQUALVERIFY: Pop the top 2 items off the stack, and if they are
● OP_CHECKSIG: Pop the top 2 items off the stack, and use the top as
the public key, the second as the signature, and verify the transaction
signature
● Users holding BTC in P2PK format wallets have the ability to easily send
these funds to wallets that use newer, more secure address formats.
● Public Key Length: public key is inconvenient for sending and receiving BTC
payments.public keys are longer at 64 characters in comparison to public
addresses which are long alphanumeric strings of 26-34 characters,. They
also don’t have built-in error checks. This may slightly increase the
possibility of errors when typing or copy/pasting public keys on computers or
mobile devices.
● According to research from Deloitte, more than 4 Million BTC (around 19%
of the total supply) is currently sitting in P2PK format wallets.According to
txstats.com, over 10.2 million BTC (more than 56 percent of the existing
BTC supply) is currently held in P2PKH wallets. The total number of P2PKH
unspent transaction outputs (UXTOs) has surpassed 52.2 million.
keys is created securely using the elliptic curve digital signature algorithm (ECDSA) with the curve
secp256k1. Then the generated public key is transformed using the functions SHA-256 and
RIPEMD-160.
P2PKH or Legacy address (old address format) is the first version of a Bitcoin address that starts with the number
“1” and has 26 to 36 characters.
The most important difference is that P2PKH transactions are sent to the hash of the recipient's public
key. P2PKH,Pay-to-Public-Key-Hash (P2PKH)
First, compared to a public key, a public key hash is a shorter and more manageable alphanumeric
string. Second, P2PKH enables error detection through a checksum feature, helping users to
drastically reduce the odds of sending BTC to an invalid address.
Multisignature
Multisignature scripts set a condition where N public keys are recorded in the script and at least
M of those must provide signatures to unlock the funds. This is also known as an M-of-N
scheme, where N is the total number of keys and M is the threshold of signatures required for
validation. For example, a 2-of-3 multisignature is one where three public keys are listed as
potential signers and at least two of those must be used to create signatures for a valid
https://learnmeabitcoin.com/technical/block-hash
https://komodoplatform.com/en/academy/bitcoin-script/#:~:text=BTC%2
0Script%20%2D%20Basic%20P2PKH%20Transaction%20Example&text=In%
20a%20P2PKH%20transaction%2C%20Alice,to%20his%20%E2%80%9Cpub
key%20hash.%E2%80%9D
https://siminchen.github.io/bitcoinIDE/build/editor.html
https://scrypt.studio/
https://learnmeabitcoin.com/technical/address
A custodial wallet service (like Coinbase or Kraken) holds on to the private key, so it is responsible for safeguarding a
user's funds. A non-custodial wallet, on the other hand, gives users full control over their private key, and with it sole
responsibility for protecting their holdings
Examples of software non-custodial wallets include Metamask and Trust Wallet. Hardware Wallets: Hardware wallets
are crypto wallets that store your private keys offline in a secure physical (hardware) device isolated from internet
connection.MetaMask Institutional is the only multi-custodial institutional Web3 wallet.Binance Chain Wallet are
examples of non-custodial wallets.Coinbase Wallet is a self-custody wallet that gives you complete control of your
digital assets. This means that the private keys (that represent ownership of the cryptocurrency) for your Wallet are
stored directly on your web browser or mobile device and not with a centralized exchange like Coinbase.com.
Result Validation
• https://www.blockchain.com/
• https://bitinfocharts.com/top-100-richest-bitcoin-addresses.h
tml
Signed by Alice
51 *
How addresses are created?
52 *
How a transaction is verified cryptographically?
*
53
2.2 Block format in Bitcoin
◆
Digital signature = signed message digest
equal
?
*
56
https://learnmeabitcoin.com/technical/address