---
description: Bitcoin Script is the stack-based, Turing-incomplete programming language used to define the conditions under which Bitcoin transactions can be spent.
title: Bitcoin Script - UPay Blog
---

[Skip to content](#content)

# Bitcoin Script

Definition

Bitcoin Script is the stack-based, Turing-incomplete programming language used to define the conditions under which [Bitcoin transactions](https://blog.upay.com/lightning-network-speedy-affordable-bitcoin-transactions/) can be spent. It is a simple yet powerful scripting system embedded in every Bitcoin transaction output (locking script or scriptPubKey) and input (unlocking script or scriptSig), enabling programmable spending conditions without exposing the Bitcoin network to the risks of a Turing-complete smart contract platform. Bitcoin Script enables [multi-signature wallets](https://blog.upay.com/multi-signature-wallets-purpose-functions-benefits/), time-locked transactions, [hash-locked contracts,](https://blog.upay.com/how-hashing-safeguard-blockchain-technology/) payment channels, and atomic swaps — all without requiring a general-purpose blockchain.

 Origin & History

| **Date** | **Event** |
| --- | --- |
| **2008** | Satoshi Nakamoto designs Bitcoin Script as part of the Bitcoin whitepaper design |
| **2009** | Bitcoin Script deployed in Bitcoin genesis block; Pay-to-Public-Key (P2PK) is first script type |
| **2012** | BIP 16: Pay-to-Script-Hash (P2SH) introduced, enabling complex redeem scripts |
| **2015** | CHECKLOCKTIMEVERIFY (CLTV) added enabling absolute time locks on transactions |
| **2016** | CHECKSEQUENCEVERIFY (CSV) added enabling relative time locks for payment channels |
| **2017** | SegWit introduces Pay-to-Witness-Public-Key-Hash (P2WPKH) and P2WSH |
| **2021** | Taproot upgrade (BIP 340/341/342) introduces Schnorr signatures and MAST via Tapscript |
| **2023** | Bitcoin Ordinals leverage Script to inscribe data in witness data |
| **2023** | BIP 347 (OP\_CAT) revival debate intensifies for potential Script extensions |

 “Bitcoin Script is deliberately limited — and that’s a feature, not a bug. Simplicity is security.” — Greg Maxwell, Bitcoin Core Developer

 How It Works

 BITCOIN TRANSACTION SCRIPT EXECUTION ═══════════════════════════════════════════════════════ LOCKING SCRIPT (scriptPubKey) — on the UTXO output: OP\_DUP OP\_HASH160 \<pubKeyHash> OP\_EQUALVERIFY OP\_CHECKSIG (Standard P2PKH — Pay to Public Key Hash)

UNLOCKING SCRIPT (scriptSig) — provided by spender: \<signature> \<publicKey>

EXECUTION (stack-based): Stack starts empty

1. Push \<signature>          → Stack: \[sig]
2. Push \<publicKey>          → Stack: \[sig, pubKey]
3. OP\_DUP: duplicate top     → Stack: \[sig, pubKey, pubKey]
4. OP\_HASH160: hash top      → Stack: \[sig, pubKey, pubKeyHash]
5. Push \<pubKeyHash>         → Stack: \[sig, pubKey, pubKeyHash, expected]
6. OP\_EQUALVERIFY: compare   → Stack: \[sig, pubKey] (if equal)
7. OP\_CHECKSIG: verify sig   → Stack: \[TRUE]

Result: TRUE = transaction is valid and [UTXO](https://blog.upay.com/crypto-terminology/utxo-model/) is spent

SCRIPT TYPES: P2PK   → Pay to Public Key (legacy) P2PKH  → Pay to Public Key Hash (most common) P2SH   → Pay to Script Hash (multi-sig, complex) P2WPKH → Native SegWit (bech32) P2TR   → Pay to Taproot (most efficient/private) ═══════════════════════════════════════════════════════ 

| **Script Type** | **Address Format** | **Use Case** | **Privacy** |
| --- | --- | --- | --- |
| **P2PK** | (no standard address) | Original Bitcoin, [Satoshi coins](https://blog.upay.com/crypto-terminology/satoshi/) | Low |
| **P2PKH** | 1… (Base58) | Standard single-sig payments | Low |
| **P2SH** | 3… (Base58) | Multi-sig, complex scripts | Medium |
| **P2WPKH** | bc1q… (bech32) | Native SegWit, lower fees | Medium |
| **P2WSH** | bc1q… (bech32) | Native SegWit scripts | Medium |
| **P2TR** | bc1p… (bech32m) | Taproot, Tapscript, Ordinals | High |

 In Simple Terms

8. **Lock and key**: Every Bitcoin output has a lock (locking script) — to spend it, you must provide the correct key (unlocking script) that satisfies the conditions.
9. **Stack machine**: Script executes by pushing values onto a stack and running operations — it’s simple, predictable, and deliberately not Turing-complete to prevent infinite loops.
10. **Multi-sig example**: A 2-of-3 multisig script requires 2 of 3 designated private key signatures to unlock funds — used for team treasuries and secure wallets.
11. **Taproot privacy**: Taproot makes complex multi-sig and [smart contract scripts](https://blog.upay.com/crypto-terminology/smart-contract/) look identical to simple single-sig transactions on the blockchain — improving privacy.
12. **Deliberate limits**: Unlike Ethereum’s Solidity, Bitcoin Script cannot access external data, loop, or call other contracts — making it predictable and secure.

 Real-World Examples

| **Scenario** | **Script Type** | **Benefit** |
| --- | --- | --- |
| **Exchange hot wallet** | P2SH 2-of-3 multisig | Requires 2 of 3 keys to spend — protects against single key theft |
| **Lightning Network channel** | HTLC (Hash Time-Locked Contract) | Enables instant off-chain BTC payments |
| **Atomic swap BTC↔LTC** | HTLC on both chains | Trustless cross-chain exchange without intermediary |
| **Time-locked inheritance** | CHECKLOCKTIMEVERIFY | Funds only spendable after specific date |
| **Ordinals inscription** | P2TR witness data | NFT/data inscription in Taproot witness |

 Advantages

| **Advantage** | **Detail** |
| --- | --- |
| **Security** | Turing-incomplete design prevents complex attack vectors possible in smart contracts |
| **Predictability** | Every script executes deterministically with bounded computation |
| **Expressiveness** | Enables multi-sig, time locks, HTLCs sufficient for Lightning Network |
| **Efficiency** | Scripts are compact, minimizing transaction data and fees |
| **Privacy (Taproot)** | Complex spending conditions indistinguishable from simple payments |

 Disadvantages & Risks

| **Risk** | **Detail** |
| --- | --- |
| **Limited functionality** | Cannot implement complex [DeFi,](https://blog.upay.com/best-defi-lending-platforms/) oracles, or arbitrary smart contracts |
| **Script complexity** | Advanced multi-sig scripts are complex to implement correctly |
| **Legacy format issues** | Older script types (P2PK, P2PKH) have lower privacy than modern alternatives |
| **Disabled opcodes** | Several powerful opcodes (OP\_CAT, OP\_CHECKSIGFROMSTACK) were disabled for security |
| **Script bug risks** | Errors in custom scripts can permanently lock funds |

**Risk Management Tips:**

- Always test custom Script implementations on testnet before mainnet
- Use P2TR (Taproot) addresses for best privacy and future compatibility
- For multi-sig wallets, use established implementations (Bitcoin Core, Sparrow Wallet) rather than custom scripts
- Store redeem scripts (P2SH) securely — you need them to spend funds

 FAQ

**Q: Why is Bitcoin Script not Turing-complete?**

A: Turing completeness allows infinite loops — dangerous in a blockchain where all nodes must execute every script. Bitcoin Script’s deliberate incompleteness ensures scripts terminate predictably, preventing denial-of-service attacks and making formal verification of scripts possible.

**Q: What is an HTLC in Bitcoin Script?**

A: A Hash Time-Locked Contract (HTLC) is a script that allows a payment to be claimed by revealing a secret (preimage) that hashes to a predetermined value, or refunded to the sender after a timeout. HTLCs are the fundamental building block of the Lightning Network.

**Q: How does Taproot improve Bitcoin Script?**

A: Taproot (BIP 340/341/342) introduces Schnorr signatures enabling key aggregation, MAST (Merklized Abstract Syntax Trees) via Tapscript enabling complex scripts while revealing only executed branches, and making all Taproot outputs look identical externally — significantly improving privacy and efficiency.

**UPay Tip:** When setting up a Bitcoin wallet, use Taproot (bc1p…) addresses for the best combination of privacy, efficiency, and future compatibility. Most modern wallets like Sparrow and Phoenix support Taproot natively.

*Disclaimer: This content is for educational purposes only and does not constitute financial or technical advice.*

**UPay — Making Crypto Encyclopedic**

## Related Terms

[What is a Business Development Company (BDC) in Crypto](https://blog.upay.com/crypto-terminology/business-development-company-bdc/)

[What is a Brute Force Attack in Crypto?](https://blog.upay.com/crypto-terminology/brute-force-attack/)

[1inch DEX Aggregator: How It Works, Features, Benefits, and Risks](https://blog.upay.com/crypto-terminology/1inch-defi-aggregator/)

[What Is a Governance Attack in Blockchain?](https://blog.upay.com/crypto-terminology/governance-attack/)

[What Is an Epoch in Blockchain?](https://blog.upay.com/crypto-terminology/epoch/)

[BlockCypher: Enterprise-Grade Blockchain APIs for Developers](https://blog.upay.com/crypto-terminology/blockcypher/)

[BIP-84: Bitcoin’s Native SegWit Address Derivation Standard](https://blog.upay.com/crypto-terminology/bip84/)

[Ethereum Improvement Proposal (EIP)](https://blog.upay.com/crypto-terminology/ethereum-improvement-proposal-eip/)

[Bretton Woods System](https://blog.upay.com/crypto-terminology/bretton-woods-system/)

[Cryptocurrency Faucet: Meaning, How It Works, Examples, and Risks](https://blog.upay.com/crypto-terminology/faucet/)

## News & Events

[![UPay Scratch and Earn](https://blog.upay.com/wp-content/uploads/2026/08/scratch_1080_1080px.png)](https://blog.upay.com/upay-scratch-earn-spend/)

## [UPay Scratch & Earn: Spend](https://blog.upay.com/upay-scratch-earn-spend/)

Spend with your UPay Card and unlock even more rewards. UPay is officially launching the Scratch & Earn campaign! Starting

[Read More](https://blog.upay.com/upay-scratch-earn-spend/)

[![UPay Giveaway](https://blog.upay.com/wp-content/uploads/2026/08/2026-08-17-17.43.29.jpg)](https://blog.upay.com/upay-virtual-card-giveaway/)

## [Want a UPay Virtual Card?](https://blog.upay.com/upay-virtual-card-giveaway/)

UPay is giving 5 lucky winners 10 USDT each to apply for and receive a UPay Virtual Card. That’s 50

[Read More](https://blog.upay.com/upay-virtual-card-giveaway/)

[![UPay Platinum Metal Card: Fees, Access and Coverage (2026)](https://blog.upay.com/wp-content/plugins/ht-mega-for-elementor//assets/images/image-placeholder.png)](https://blog.upay.com/upay-platinum-metal-card-fees-access-and-coverage-2026/)

## [UPay Platinum Metal Card: Fees,](https://blog.upay.com/upay-platinum-metal-card-fees-access-and-coverage-2026/)

Crypto cardholders spent $759 million in July 2026, roughly two and a half times the $306 million recorded a year

[Read More](https://blog.upay.com/upay-platinum-metal-card-fees-access-and-coverage-2026/)

[![UPay looking for content creator](https://blog.upay.com/wp-content/uploads/2026/08/UPay-KOL-program.jpg)](https://blog.upay.com/upay-kol-program/)

## [Introducing the UPay KOL Program:](https://blog.upay.com/upay-kol-program/)

The UPay KOL Program is designed for creators who want to build a long-term partnership with UPay rather than participate

[Read More](https://blog.upay.com/upay-kol-program/)

[![Official UPay and Safeheron Sign a Wallet-to-Card Agreement as Stablecoin Payments in the UAE Gather Pace](https://blog.upay.com/wp-content/plugins/ht-mega-for-elementor//assets/images/image-placeholder.png)](https://blog.upay.com/upay-and-safeheron-sign-wallet-to-card-agreement/)

## [Official UPay and Safeheron Sign](https://blog.upay.com/upay-and-safeheron-sign-wallet-to-card-agreement/)

The two firms signed a memorandum in Abu Dhabi that pairs institutional-grade self-custody with everyday card spending, in the market

[Read More](https://blog.upay.com/upay-and-safeheron-sign-wallet-to-card-agreement/)

[![](https://blog.upay.com/wp-content/uploads/2026/06/apple-pay-binding-is-live.jpeg)](https://blog.upay.com/apple-pay-binding-is-officially-live/)

## [Apple Pay Binding is Officially](https://blog.upay.com/apple-pay-binding-is-officially-live/)

Apple Pay binding is officially live and now fully supported for UPay cards. UPay is pleased to announce that eligible

[Read More](https://blog.upay.com/apple-pay-binding-is-officially-live/)

[![Upay affiliate program](https://blog.upay.com/wp-content/uploads/2025/02/IMG-20250203-WA0010.jpg)](https://blog.upay.com/upays-affiliate-program/)

## [Everything You Need to Know](https://blog.upay.com/upays-affiliate-program/)

The UPay affiliate program is one of the most accessible ways to earn income from the growing cryptocurrency payments market

[Read More](https://blog.upay.com/upays-affiliate-program/)

[![](https://blog.upay.com/wp-content/uploads/2025/05/who-is-marc-andreessen.png)](https://blog.upay.com/who-is-marc-andreessen/)

## [Who is Marc Andreessen? Legacy](https://blog.upay.com/who-is-marc-andreessen/)

Marc Andreessen is one of the most consequential figures in the history of the internet. He co-created Mosaic, the browser

[Read More](https://blog.upay.com/who-is-marc-andreessen/)

[![BEST BITCION CONFERENCES](https://blog.upay.com/wp-content/uploads/2025/06/39_20250617_081348_0002-1.png)](https://blog.upay.com/best-bitcoin-conferences/)

## [12 Best Bitcoin Conferences You](https://blog.upay.com/best-bitcoin-conferences/)

Are you trying to decide which Bitcoin conference is worth your time and money in 2025? With so many choices

[Read More](https://blog.upay.com/best-bitcoin-conferences/)

[![Best Places to Spend Crypto in Saudi Arabia](https://blog.upay.com/wp-content/uploads/2025/07/3.jpg)](https://blog.upay.com/best-places-to-spend-crypto-in-saudi-arabia/)

## [Best Places to Spend Crypto](https://blog.upay.com/best-places-to-spend-crypto-in-saudi-arabia/)

The most direct best places to spend crypto in Saudi Arabia are: hotels and accommodations booked through Travala.com using Bitcoin

[Read More](https://blog.upay.com/best-places-to-spend-crypto-in-saudi-arabia/)

```json
{"@context":"https://schema.org","@graph":[{"@type":["Person","Organization"],"@id":"https://blog.upay.com/#person","name":"UPay Blog","logo":{"@type":"ImageObject","@id":"https://blog.upay.com/#logo","url":"https://blog.upay.com/wp-content/uploads/2024/02/imgi_1_upay-logo-1024x292-1.webp","contentUrl":"https://blog.upay.com/wp-content/uploads/2024/02/imgi_1_upay-logo-1024x292-1.webp","caption":"UPay Blog","inLanguage":"en-US","width":"1024","height":"292"},"image":{"@type":"ImageObject","@id":"https://blog.upay.com/#logo","url":"https://blog.upay.com/wp-content/uploads/2024/02/imgi_1_upay-logo-1024x292-1.webp","contentUrl":"https://blog.upay.com/wp-content/uploads/2024/02/imgi_1_upay-logo-1024x292-1.webp","caption":"UPay Blog","inLanguage":"en-US","width":"1024","height":"292"}},{"@type":"WebSite","@id":"https://blog.upay.com/#website","url":"https://blog.upay.com","name":"UPay Blog","publisher":{"@id":"https://blog.upay.com/#person"},"inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://blog.upay.com/crypto-terminology/bitcoin-script/#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://blog.upay.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://blog.upay.com/crypto-terminology/","name":"Crypto Terminology"}},{"@type":"ListItem","position":"3","item":{"@id":"https://blog.upay.com/crypto-terminology/bitcoin-script/","name":"Bitcoin Script"}}]},{"@type":"WebPage","@id":"https://blog.upay.com/crypto-terminology/bitcoin-script/#webpage","url":"https://blog.upay.com/crypto-terminology/bitcoin-script/","name":"Bitcoin Script - UPay Blog","datePublished":"2026-02-27T12:05:15+00:00","dateModified":"2026-02-27T12:05:17+00:00","isPartOf":{"@id":"https://blog.upay.com/#website"},"inLanguage":"en-US","breadcrumb":{"@id":"https://blog.upay.com/crypto-terminology/bitcoin-script/#breadcrumb"}},{"@type":"Person","@id":"https://blog.upay.com/author/ayanlowo/","name":"ayanlowo","url":"https://blog.upay.com/author/ayanlowo/","image":{"@type":"ImageObject","@id":"https://secure.gravatar.com/avatar/e60641123775ad9468c664f5642effc28f7d32302f8ad2ae2b01e5c7393c4939?s=96&amp;d=mm&amp;r=g","url":"https://secure.gravatar.com/avatar/e60641123775ad9468c664f5642effc28f7d32302f8ad2ae2b01e5c7393c4939?s=96&amp;d=mm&amp;r=g","caption":"ayanlowo","inLanguage":"en-US"}},{"headline":"Bitcoin Script","description":"Bitcoin Script is the stack-based, Turing-incomplete programming language used to define the conditions under which Bitcoin transactions can be spent.","keywords":"Bitcoin Script","@type":"Article","author":{"@id":"https://blog.upay.com/author/ayanlowo/","name":"ayanlowo"},"datePublished":"2026-02-27T12:05:15+00:00","dateModified":"2026-02-27T12:05:17+00:00","name":"Bitcoin Script","@id":"https://blog.upay.com/crypto-terminology/bitcoin-script/#schema-4078097","isPartOf":{"@id":"https://blog.upay.com/crypto-terminology/bitcoin-script/#webpage"},"publisher":{"@id":"https://blog.upay.com/#person"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://blog.upay.com/crypto-terminology/bitcoin-script/#webpage"}}]}
```
