Bitcoin Transactions, Pay-To-Public-Key-Hash Discussion

Hy, I was wondering if my thoughts on this are correct?

“asm” = stack script with hash of the public key. To unlock the transaction and the encrypted hash, we need the private key to unlock it.

Yeah, basically correct.

Any script (locking and unlocking), can be written in many different ways using different formats. It can be in human-readable form, with all the OP_CODES in plain text. It can be in assembly (asm), which is an un-serialized version of the script, but with the OP_codes written with numbers instead of text. Then there is hexadecimal (hex) which is the serialized version of the script.

There is a lecture on serialization in the course, if you want to know more.

2 Likes

Hello Fillip,

I have a quick question about UTXO’s–Am I correct in assuming that the largest a UTXO can be is 50 Bitcoin, as that was the original coinbase award, and since then it has gotten smaller. UTXOs are never recombined, correct?

Hi everyone, does anyone know how to currently view all of the data in a block explorer or in the code? I’ve tried all of the suggestions but cannot get a format similar to the video with all the data that’s shown in the video.
Any info would be Great!! Thank everyone for the previous posts as they did provide some light.

No, you can actually re-combine outputs. One transaction could in theory have 10 inputs of 10 bitcoin and one single output (utxo) of 100. So there is no limit on the size of one utxo.

What data are you looking for? Was there any specific video where I showed something interesting? I remember I used blockchain.info a lot, there you can view the scripts by clicking a link at the bottom of the transaction page. But maybe there was another page as well.

It all makes sense although I will watch the lecture a second time in order to solidify the knowledge.

Just writing here because I wanted to rave about how amazing this design is…pure genius! Loving the content and the explanation.

2 Likes

Haha I agree, it’s amazing!

Has anyone tried to run the unlocking script?
I believe understand how it works and read from other sources, but tried to run the code in the Bitcoin IDE for the UTXO in the video and also numerous of other UTXOs I pick from block explorers, but I keep getting different result when hashing the public key from unlocking script compared to the public key hash from the locking script .
Lets take the transaction from the video. To verify the signature, I run this script:

304402203939a0a60876c330fd5165f4648cd431d8b379a6ac1a9022e31afa10ef30d827022035e07560ca6068669ce17d7acaac19354a148ac453d2feb518b236aa8fc1cc2a01
02dc109689e8655dc90d09544397d8b04989cd42b8037d15ba629b12d5ab77c068
op_dup
op_hash160
9b7906c8b4f9370e390863d26709fd16e34de2ea
op_equalverify
op_checksig

However, OP_HASH160 operation returns this public key hash:
0x02424E212EF22653854D5C4B5122376A9375A9C1
Then obviously OP_EQUALVERIFY returns FALSE because hashes of the public keys are different.
I tried to run this script directly in assembly format too, still didn’t work.
Can someone please clarify why this is the case, and/or what am I doing wrong?

4 Likes

The Bitcoin IDE actually has a bug in one of it’s functions (I can’t remember which one), so it doesn’t actually work to run bitcoin transactions. It’s really stupid I know.

I ran into the exact same issue when I recorded to course, and I got very frustrated trying to figure out what was wrong. In the end I had to use this one: https://github.com/kallewoof/btcdeb

It was also quite tedious in the beginning, but once you get the hang of it it actually is quite helpful.

3 Likes

Yea, I thought there must be something wrong with that IDE. I’ll try working with btcdeb repo. Thanks, man!

1 Like

Not just any legitimate private key though… Because private key and public keys are pairs(they are linked mathematically).
If you sign a data with the private key, it can only be verified with a public key that is derived from that particular private key. This is why we do not need the private key to check the signature & anyone can check the signature if they have the public key.

2 Likes

great work filip! Thanks!
would it be possible to privide us your document? Maybe in the lecture description?

Great idea. I’ve added the PDFs into the lectures now :slight_smile:

1 Like

Hi first post as got this far before becoming stuck.

Question is in regards to locking and unlocking scripts.

  1. The locking script contains a hash of the public key.

Q1a) Is the public key the public bitcoin address?

Q1b) Is the hash used instead of the address/public key purely because its smaller in size?

  1. The unlocking script contains a signature from private key

Q2a) Is the private key the same as the private key corresponding to the bitcoin public address as in Q1a ?

Q2b) To generate a signature you need a private key and some data. What data is used in generating this signature? Is it the bitcoin address/public key or the complete transaction data or something else?

Any help greatly appreciated.

1 Like

@filip pleaded help with post as above. Thx

If nobody is helping you soon, I will try to help you out. I’m very busy on different jobs, and your question requires some good explanation. maybe we could soon arrange a voice call on a discord server.

1 Like

@filip,
You keep referring to the Blockchain Fundamentals class. Is that class still in the library? I thought I may review/re-review that course but I can’t find it. Thanks.

@Samm, I believe the basic fundamentals class referred to in the videos, is the [Blockchain & Bitcoin 101] course. It’s one of the recommended starting foundational classes. Hope this helps.

2 Likes

Ok. Thanks. I guess I already took that one!