Bitcoin script is a pretty cool programming tool used in the Bitcoin network, mainly for handling transactions. Each output from a transaction has a locking script (ScriptPubKey) and an unlocking script that helps access the output.
Basically, a script consists of two main components: Opcodes and Data. Opcodes perform various operations on the data, while the data includes public keys and signatures.
There are a bunch of scripts that Bitcoin uses for transactions, and I've pointed some out in a previous post. I felt it was necessary to dig into how these scripts really work and share what I've found for those who might be interested later.
Here are some Bitcoin Scripts I've gathered, along with what they do. Remember, these are all standard scripts and fit into two big groups: Legacy and SegWit.
Legacy includes:
P2PK P2PKH P2SH P2MS OP_RETURN
SegWit consists of:
P2TR P2WPKH P2WSH
Let's start with Legacy.
P2PK
P2PK means Pay-To-Public-Key. It's a script that secures a Bitcoin output to a specific public key. This setup only lets someone get Bitcoin sent to their public key. This was the OG way to receive Bitcoin. To access a P2PK, you need a valid signature in the ScriptSig.
A good example is a transaction from block 170, where you see two different transactions of 1B sats and 4B sats, totaling 5B sats. If you check the address on the left, you’ll spot a P2PK.
Overview of Bitcoin Standard Scripts
6 replies 481 views
gr3g.0rbitHero Member
Posts: 1025 · Reputation: 2646
#2Aug 24, 2024, 05:00 AM
While the description fits, the general example shouldn't mention or display an address because:
Like P2PK, P2MS can't be encoded into an address since the script isn't "wrapped" in P2SH or P2WSH script.
The common term they use for P2MS is "Bare MultiSig" while the wrapped script we use today is commonly called as "MultiSig".
But to be specific, call them: "P2SH-MultiSig" and "P2WSH-MultiSig".
So your example belongs to P2SH.
You can use this example instead: 949591ad468cef5c41656c0a502d9500671ee421fadb590fbc6373000039b693
(notice that it doesn't show an address)
In addition to P2WSH...
The low transaction fee is as a result of providing an increase in blocksize plus the transactions(outputs) signature gets separated from the transaction hash, the separated signature is referred to as witness data or witness thus qualifying your statement below
Witness =>Segwit
Legacy => ScriptSig
Thanks for pointing this out. The transaction is even identified as a Bare multisig from the link you sent.
Perfect. I have made the necessary adjustment.
QuantumYieldSenior Member
Posts: 117 · Reputation: 813
#5Aug 25, 2024, 08:28 PM
You can add following resources to your reference document list too.
List of address prefixesBitcoin Script: a Reading ListWallets Supporting Output Descriptors. Scripts and descriptors, some people might need both.
You missed P2WPKH-P2SH, also known as the nested segwit script. That one is basically a P2WPKH script wrapped inside a P2SH as its name suggests, so it technically looks like any other P2SH when software that only supports the old, pre-segwit transaction format looks at it.
I actually aim to address the ones I pointed out in a previous thread, but since this is a compilation, it makes more sense to add both nested segwits to the thread. Let me start working on it
Related topics
- Bitcoin Core displaying coins (UTXOs) in a new tab 13
- Are you in favor of BIP-110? Let's get a Bitcoin poll going. 0
- Erlay seems to have some issues here’s a better proposal for a bitcoin protocol without invites 3
- Ways to earn some sats by contributing to bitcoin core development 5
- Exploring the Potential and Challenges of a Kardashev-Scale Bitcoin Network 3
- What can I do to fix this Bitcoin Core error? 8