Bitcoin Forum
June 24, 2024, 01:28:38 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Doubts about scriptPubKey  (Read 165 times)
fabbit (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 6


View Profile
January 24, 2020, 07:42:22 PM
 #1

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 ?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3430
Merit: 4680



View Profile
January 24, 2020, 08:09:32 PM
Merited by ABCbits (1), nc50lc (1), Heisenberg_Hunter (1)
 #2

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
nc50lc
Legendary
*
Offline Offline

Activity: 2450
Merit: 5733


Self-proclaimed Genius


View Profile
January 25, 2020, 04:04:03 AM
 #3

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.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
pooya87
Legendary
*
Offline Offline

Activity: 3486
Merit: 10666



View Profile
January 25, 2020, 04:22:26 AM
 #4

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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!