Clarification on what’s the distinction between these items: public key hash, scriptPubKey, addresses.
Public key hash
represents, because it identify says, the hash of the general public key. So you’re taking the general public key and first do SHA256 hash operate on it, after which RIPEMD160.
scriptPubKey
represents a locking script that you just use to lock satoshis. To unlock them, you have to present a legitimate unlocking script, also referred to as scriptSig
.
Addresses
doesn’t truly exist in Bitcoin protocol. They’re simply referred to as like that in Blockchain explorer to simplify Bitcoin protocol for finish customers. Addresses truly characterize only a hash of the general public key, nothing else (in case of P2PKH). It’s price mentioning that they’re extra typically represented in some encoded kind like Bech32 or Base58check.
Implementable steps to get the scriptPubKey
There are not any implementable steps to get the scriptPubKey
. You’ll be able to lock your satoshis the best way you need. You simply have to take care that you’re utilizing legitimate opcodes and that your locking logic is legitimate since if it’s not, you will not be capable to unlock funds. There are some customary methods to create this locking script like P2PKH, P2SH and so forth.
I realise that utilizing this hash of the general public key, I can ship transactions on to it and deal with it as an handle and a few explorer calls it handle, how is that attainable?
It’s the one of many customary scriptPubKey, the place you lock your funds to hash of the general public key. It’s referred to as P2PKH.
Useful resource suggestion to go additional within the understanding.
Grasp Bitcoin e book (Andreas Antonopolus), Grokking Bitcoin, Programming Bitcoin (Jimmy Track).
All of the talked about books take you intimately by methods to create scripts and the way bitcoin works usually. They’re price studying and provides you with solutions to many questions, together with the one you requested.
I imagine by reverting this course of, I might get the general public key and generate an handle and get the scriptPubKey from the handle, however I imagine there could be higher strategy to do it.
You’ll be able to’t revert hashing. Hash capabilities are a method capabilities. Nevertheless, you don’t even have to revert it. Because the hash of the general public key represents handle, you’re creating scriptPubKey utilizing it, in a roundabout way public key.