0

I'm trying to understand Bitcoin address encodings. I understand there's three (four?) different address encodings P2PKH, P2SH, Bech32, and Bech32m (Bech32m just uses a different constant when XORing). They all encode the public key using Ripe160 (RIPEMD160?). I was able to use some libraries to extract the ripe160 encoded address, which should be 20 bytes, but there are some longer strings in this list of addresses with currency:

Bitcoin addresses with currency from loyce.com

34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo
**bc1qgdjqv0av3q56jvd82tkdjpy7gdp9ut8tlqmgrpmv24sq90ecnvqqjwvw97**
1P5ZEDWTKTFGxQjZphgWPQUpe554WKDfHQ
37XuVSEpWW4trkfmvWzegTHQt7BdktSKUs
38UmuUqPCrFmQo4khkomQwZ4VbY2nZMJ67
3Kzh9qAqVWQhEsfQz7zEQL1EuSx5tyNLNS
1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF
3LYJfcfHPXYJreMsASk2jkn69LWEYKzexb
bc1qa5wkgaew2dkv56kfvj49j0av5nml45x9ek9hz6
1LdRcdxfbSnmCYYNdeYpUnztiYzVfBEQeC
1AC4fMwgY8j9onSbXEWeH6Zan8QGMSdmtA
1LruNZjwamWJXThX2Y8C2d47QqhAkkc5os
1NDyJtNTjmwk5xPNhjgAMu4HDHigtobu1s
3Gpex6g5FPmYWm26myFq7dW12ntd8zMcCY
bc1q5shngj24323nsrmxv99st02na6srekfctt30ch
385cR5DM96n1HvBDMzLHPYcw89fZAXULJP
3LQUu4v9z6KNch71j7kbj8GPeAGUo1FW6a
**bc1q5pucatprjrqltdp58f92mhqkfuvwpa43vhsjwpxlryude0plzyhqjkqazp**
...

They start with bc1 so that indicates Bech32, correct? When decoding using something like bech32-buffer I get 32 bytes.

In doing some more digging, there's also this scriptPubKey encoding. Is that what these long encodings are? How do you differentiate them? I assume since the site is listing address with currency, I should be able to pull the ripe160 address from the script, are there any recommended parsers?

I found another post which suggests doing pattern matching, and pulling the parsing code from Bitcoin Core. Am I heading down the correct path here?

3
  • What are you trying to do with these addresses? The answer very much depends on that. Nov 15 at 15:33
  • 1
    MULTISIG 3 OF 5 P2WSH
    – Prayank
    Nov 15 at 17:00
  • @PieterWuille Learning, just want to understand all the different forms.
    – Jerinaw
    Nov 18 at 18:18
3

They are bech32 addresses that encode a P2WSH scriptPubKey. The script that maps to those addresses contain the SHA256 of a script that will be revealed when the output is spent.

They all encode the public key using Ripe160 (RIPEMD160?)

No. Addresses do not just encode public keys, nor do they necessarily encode a particular hash. It depends on the address type as it is dependent on the script that will be created.

Addresses beginning with a 1 encode the RIPEMD160 of the SHA256 of a public key and create P2PKH output scripts.

Addresses beginning with a 3 encode the RIPEMD160 of the SHA256 of a script and create P2SH output scripts.

bc1q addresses that are 42 characters long encode the RIPEMD160 of the SHA256 of a public key and create P2WPKH output scripts.

bc1q addresses that are 62 characters long encode the SHA256 of a script and create P2WSH output scripts.

bc1p addresses that are 62 characters long encode an X-only public key and create P2TR (Taproot) output scripts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.