Author

Topic: Compilation of Bitcoin Standard Scripts (Read 214 times)

brand new
Activity: 0
Merit: 0
June 24, 2024, 06:06:07 AM
#8
Ok that's new for me .
full member
Activity: 238
Merit: 174
cout << "Bitcoin";
June 21, 2024, 02:18:23 AM
#7
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
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
June 20, 2024, 05:41:54 AM
#6
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.
legendary
Activity: 2310
Merit: 4085
Farewell o_e_l_e_o
June 18, 2024, 06:11:21 AM
#5
You can add following resources to your reference document list too.
full member
Activity: 238
Merit: 174
cout << "Bitcoin";
June 18, 2024, 06:01:34 AM
#4
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".

Thanks for pointing this out. The transaction is even identified as a Bare multisig from the link you sent.

Quote
So your example belongs to P2SH.
You can use this example instead: 949591ad468cef5c41656c0a502d9500671ee421fadb590fbc6373000039b693
(notice that it doesn't show an address)

Perfect. I have made the necessary adjustment.
sr. member
Activity: 476
Merit: 299
Learning never stops!
June 18, 2024, 03:53:59 AM
#3
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
Quote
This output can also be unlocked via the witness
Witness =>Segwit
Legacy => ScriptSig
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
June 18, 2024, 12:53:59 AM
#2
P2MS
-snip-
A general example is when a multi-signature wallet address is created for three parties, but only two parties can unlock the Bitcoin with their signatures.
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)
full member
Activity: 238
Merit: 174
cout << "Bitcoin";
June 18, 2024, 12:25:27 AM
#1
The Bitcoin script happens to be a very powerful programming tool/language used within the Bitcoin protocol primarily for transaction purposes. Every transaction output has a locking script (ScriptPubKey) and an unlocking script that helps to unlock the output.

Script basically comprises of two things, which are: Opcodes and Data. The Opcode enables several operations on the data, while the data contains public keys and signatures.

There are several scripts used in Bitcoin for transaction purposes, which I pointed out in my previous Thread . I saw the need to conduct my own research on how these scripts work and share my findings with others who might want to make reference to them in the future.

The following are examples of Bitcoin Scripts I listed, along with their explanations. Note that these are all standard scripts that fall under two main categories: Legacy and SegWit.

Legacy contains:
  • P2PK
  • P2PKH
  • P2SH
  • P2MS
  • OP_RETURN

SegWit contains:
 
  • P2TR
  • P2WPKH
  • P2WSH

Starting with Legacy
P2PK
  P2PK stands for Pay-To-Public-Key. It is a script that locks a Bitcoin output to a public key. This pattern only allows someone to receive Bitcoin on their public key. This was the first method used for receiving Bitcoin. To unlock a P2PK, a valid signature is required in the ScriptSig.

A typical example is the transaction made in block 170, as shown below. There are two separate transactions of 1B sats and 4B sats, making a total of 5B sats. When you take a close look at the address on the left, you see a P2PK.


P2PKH
  P2PKH stands for Pay-To-Public-Key-Hash. Unlike P2PK which contains a public key, P2PKH contains a public key hash also known as an address. As I stated in another of my old Thread , addresses are generated from a public key by a process called hashing. Note that P2PKH is literally the most common method used for receiving Bitcoin today. To unlock P2PKH, it requires the public key and corresponding signature. Addresses that usually begin with the prefix '1' and contain 33 to 34 characters are P2PKH addresses.


P2SH
 P2SH stands for Pay-To-Script-Hash. Unlike P2PKH, which produces an address by hashing a single public key, P2SH's address are created by hashing a redeem script. They usually have a prefix of '3' and contain about 34 characters.

Code:
3M2GhZW2FsMdfezHDBvjMEAZz6wkB32LMG

P2MS
  P2MS stands for Pay-to-Multisig. Most of us might have heard about multi-signature or maybe multi-signature wallets, where it involves more than one person signing the signature of a particular transaction. In this case, this script helps to lock Bitcoin in multiple public keys and requires at least two corresponding signatures to unlock them, or the assigned number of signature permitted to unlock them.
A general example is when a multi-signature wallet address is created for three parties, but only two parties can unlock the Bitcoin with their signatures.

Edited: https://www.talkimg.com/images/2024/06/18/hUY5d.jpeg

SegWit
P2TR
 P2TR stands for Pay-To-Taproot. P2TR uses a form of digital signature called Schnorr, which is different from the initial ECDSA. P2TR uses the Bech32m encoding scheme and is usually around 62 characters in length. P2TR is still a very new address format that is still growing in terms of adoption.

P2WPKH
  P2WPKH stands for Pay-To-Witness-Public-Key-Hash. This is a script that locks an output to a public key hash. This output can only be unlocked via the witness, unlike the P2PKH that unlocks via ScriptSig.
P2WPKH was literally an upgrade to serve as a replacement for P2PKH.

P2WSH stands for Pay-To-Witness-Script-Hash. This is also part of the SegWit upgrade but serves as a replacement for P2SH. It has a greater benefit when used because it requires lower transaction fees when unlocking a P2WSH. This is clearly unlike the P2SH. Just like P2WPKH, the output of P2WSH can also be unlocked via the witness. They usually begin with 'bc1'.

Code:
bc1q34aq5drpuwy3wgl9lhup9892qp6svr8ldzyy7c



If you want to read further in details, use the reference link

Reference is located at the bottom of the thread, though the images are screenshots made by me for illustrations which are not visually present in any of the reference material.

I am 100% open to correction as I still see myself as a learner. Pardon any of my error and share your personal opinion. You might want to also DOYR after reading this.




Public keys and Addresses - Are there striking similarities or difference:
https://bitcointalksearch.org/topic/m.64193874

Total confusion about Scriptpubkey,  Standard and non standard Transactions: https://bitcointalksearch.org/topic/--5499658

Bitcoin Scripts: https://learnmeabitcoin.com/technical/script/#legacy

P2PK: https://learnmeabitcoin.com/technical/script/p2pk/

P2PKH: https://learnmeabitcoin.com/technical/script/p2pkh/

P2MS: https://learnmeabitcoin.com/technical/script/p2ms/

P2SH:
https://learnmeabitcoin.com/technical/script/p2sh/

P2WPKH:
https://learnmeabitcoin.com/technical/script/p2wpkh/

P2WSH:
https://learnmeabitcoin.com/technical/script/p2wsh/

P2TR:
https://thebitcoinmanual.com/articles/pay-to-taproot-p2tr/

Bitcoinmagazine:
https://bitcoinmagazine.com/technical/bitcoin-address-types-compared-p2pkh-p2sh-p2wpkh-and-more

List of address prefixes: https://en.bitcoin.it/wiki/List_of_address_prefixes
Jump to: