Overview of Bitcoin Standard Scripts

6 replies 481 views
3r1c777Full Member
Posts: 177 · Reputation: 674
#1Aug 24, 2024, 03:28 AM
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.
5 Reply Quote Share
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)
5 Reply Quote Share
bull_2019Senior Member
Posts: 296 · Reputation: 1992
#3Aug 24, 2024, 06:09 AM
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
0 Reply Quote Share
3r1c777Full Member
Posts: 177 · Reputation: 674
#4Aug 24, 2024, 07:28 AM
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.
0 Reply Quote Share
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.
5 Reply Quote Share
LuckyCoinLegendary
Posts: 832 · Reputation: 4795
#6Aug 27, 2024, 09:55 AM
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.
3 Reply Quote Share
3r1c777Full Member
Posts: 177 · Reputation: 674
#7Aug 28, 2024, 02:12 AM
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
1 Reply Quote Share

Related topics