Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: fabbit on January 24, 2020, 07:42:22 PM



Title: Doubts about scriptPubKey
Post by: fabbit on January 24, 2020, 07:42:22 PM
A scriptPubKey is (invented):
Code:
"scriptPubKey" : {
 "asm" : "OP_DUP OP_HASH160 7d7\
 OP_EQUALVERIFY OP_CHECKSIG",
 "hex" : "fg8ad8a",
 "reqSigs" : 1,
 "type" : "pubkeyhash",
 "addresses" : [
 "d8d"
 ]
hash(7d7)==d8d ?


Title: Re: Doubts about scriptPubKey
Post by: DannyHamilton on January 24, 2020, 08:09:32 PM
Code:
"asm" : "OP_DUP OP_HASH160 7d7 OP_EQUALVERIFY OP_CHECKSIG",
 "addresses" : [ "d8d" ]
hash(7d7)==d8d ?

That depends on what you mean by hash()

7d7 should already be the result of RIPEMD-160(SHA-256(public key))

To get from that hash value to the associated P2PKH address, you need to:

1. Add a version byte to the front of 7d7, resulting in 007d7

2. Calculate a checksum (the first 4 bytes of: SHA-256(SHA-256(007d7))

3. Add the 4 byte checksum to the end of the 007d7, resulting in 007d7GGGGGGGG (where GGGGGGGG is the 4 byte checksum from step 2)

4. Convert the result from a byte string into a base58 string using Base58Check encoding.

The result of that would be d8d

More information here:
https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses#How_to_create_Bitcoin_Address


Title: Re: Doubts about scriptPubKey
Post by: nc50lc on January 25, 2020, 04:04:03 AM
2. Calculate a checksum (the first 4 bytes of: SHA-256(SHA-256(007d7))
3. Add the 4 byte checksum to the end of the 007d7, resulting in 007d7GGGGGGGG
This is new to me, I though it will add '0' in front of 007d7 to be valid because it's odd-digit; instead, it resulted to 'G....'
7d7
If you want to put a random value, it should be 20 byte HEX or 40 (1-0, a-f) characters.


Title: Re: Doubts about scriptPubKey
Post by: pooya87 on January 25, 2020, 04:22:26 AM
This is new to me, I though it will add '0' in front of 007d7 to be valid because it's odd-digit; instead, it resulted to 'G....'

all the values here are fake, so something like foo and bar should have been used instead!
by the way 0 is the "address version byte" that is added to the hash to get version 1 (P2PKH) addresses.