Bitcoin Forum
June 25, 2024, 07:41:05 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Re: Base 58 address and public key hash on: July 06, 2015, 04:46:36 AM
Oh man, I can't tell you how many documents I've pored over trying to figure this out. I never quite got it . . . until now. In particular, I didn't get that the OPs are added as actual bytes to the pubKeyHash to form the scriptPubKey. This clears it all up.

I hope this starts showing up in Google searches under BITCOIN RAW TRANSACTION EXPLAINED.

Many thanks.
2  Bitcoin / Development & Technical Discussion / Base 58 address and public key hash on: July 06, 2015, 12:43:49 AM
I'm trying to figure out the relationship between the base 58 address, the public key hash, and the scriptPubKey on a standard transaction output.

I know the base 58 address is basically a 25-byte wrapper for the 20-byte double hash of the public key (with version prefix and check sum suffix), encoded to a 17-byte address. I know the public key hash is also part of the scriptPubKey, but that's where my questions arise.

As an example, on testnet (block 487805), I had bitcoins sent to base 58 address mjj4MR1aeTjWSRqHuixfoCGRDRwabbK3zv

The raw transaction is

010000000105287a343ffb315b10c03574975535badbe801cf6ffdf73c79ac22da215d095b01000 0006a4730440220670ef406032cc1c20c284da8ccc2a40d5b135776dac672ce04e8cbb9036fec15 022011e6f589e5ca946f974b3ff69523497d06262a7e75be38ae99a85e493940ea8401210278072 1cc016aaf0434878f95bce130147ccdc4bd88478222bcba2018294e99d4ffffffff02c09e0a0000 0000001976a9142e2a8d353ea825de6bc2b081324f412764e53e5788ac85351931100000001976a914c73c92961d27fb399e1d408c94f1dade2860394588ac00000000

If the bold font comes through, you can see these bytes, which I believe are the scriptPubKey:

76a9142e2a8d353ea825de6bc2b081324f412764e53e5788ac

When I decode the transaction I see this output:

        {
            "value" : 0.00696000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 2e2a8d353ea825de6bc2b081324f412764e53e57 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9142e2a8d353ea825de6bc2b081324f412764e53e5788ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "mjj4MR1aeTjWSRqHuixfoCGRDRwabbK3zv"
                ]
            }
        },

There's the base 58 address again, along with the script in hex. Since the base 58 address isn't part of the raw transaction, and since the hex script is 25 bytes, I assumed that if I encoded the script, I'd get the base 58 address, and if I decoded the base 58 address, I'd get the script. But that doesn't work (at least using the Base58 class from bitcoinj).

So what is the relationship between the script and the base 58 address? How does the network even know about the base 58 address, when it's not part of the raw transaction? And what is the asm value, which looks like an actual script but with yet another set of bytes?

Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!