Hot answers tagged

15 votes
Accepted

Why is Bitcoin address encoded in base58?

Why base-58 instead of standard base-64 encoding? Don't want 0OIl characters that look the same in some fonts and could be used to create visually identical looking account numbers. A string with ...
Tailer's user avatar
  • 3,659
7 votes
Accepted

Why are P2WSH addresses larger than P2SH addresses?

Because P2SH addresses are too short to provide the typically desirable level of security we expect from Bitcoin, against certain attacks. On top of that, they use bech32 encoding rather than base58, ...
Pieter Wuille's user avatar
6 votes

Why are hashes base16 (hex) encoded rather than base58 encoded?

Mark H's answer is correct, but I think there is a more fundamental point: addresses are directly intended for human consumption. Transaction hashes (as well as public keys, block hashes, raw scripts, ...
Pieter Wuille's user avatar
5 votes
Accepted

Encoding my Bitcoin Address with Base58 encoding

Yes. ECKey key = ...; String addr = key.toAddress(MainNetParams.get()).toString(); https://bitcoinj.github.io/javadoc/0.12/org/bitcoinj/core/ECKey.html#toAddress-org.bitcoinj.core.NetworkParameters-
Nick ODell's user avatar
  • 29.4k
5 votes
Accepted

Why P2SH seems to be never smaller than 34 characters, unlike P2PKH?

Because Base58 initial 1s carry 8 bits of data, but P2SH addresses cannot be represented with a string with initial 1s so it starts with 3 which, like all other cases & characters, encodes 5.86 ...
MCCCS's user avatar
  • 10.2k
4 votes

base58 cannot get 34 chars results (as Bitcoin address does) but 68 chars

When you use that site, you are encoding the hex as a hex string, not of the actual bytes that they should be. The base58 encoding for addresses operates on the bytes themselves which are represented ...
Ava Chow's user avatar
  • 69.9k
4 votes

ELI5: What is Base58Check encoding?

A Bitcoin address is a series of bits (on its simpler form is just a public key). In order to make it human "readable" it is converted to a series of letters. Base64 is a well known previous ...
circulosmeos's user avatar
4 votes
Accepted

Java: Base58-encode String

Your output is correct given the input that you used. However, If you are expecting to get an output address of 39YteymR86cG7V3Kijg8Gm2ST1r4nTeM1b, it looks like your input is incorrect. It's missing ...
Ryan McGeary's user avatar
4 votes
Accepted

ELI5: What is Base58Check encoding?

Can someone explain what it is and why it's called Base58Check encoding? There are two parts to the name "Base58Check". The first part is "Base58". This is fairly self explanatory, the encoding uses ...
Ava Chow's user avatar
  • 69.9k
4 votes

What is the prefix number, in bytes, of a native segwit address?

Native segwit addresses are not encoded using base58, but using a different encoding system called bech32. The details can be found in BIP 173. For the segwit v1+ addresses that will be used for ...
Pieter Wuille's user avatar
3 votes
Accepted

Why are hashes base16 (hex) encoded rather than base58 encoded?

SHA256 hashes are encoded in plain binary in bitcoin protocol and in block storage (32-bytes in little-endian byte order when treated as integers, which makes them effectively "base256"). The textual ...
Mark H's user avatar
  • 3,334
3 votes

ELI5: What is Base58Check encoding?

Can someone explain what it is and why it's called Base58Check encoding? Because of the name the function in the original Bitcoin codebase had. The "Base58" refers to the fact that it is a base 58 ...
Pieter Wuille's user avatar
3 votes

encode/decode Base-58 C++

I used BIGNUM from openssl to encode hex with base58 #include <string> #include <vector> #include <openssl/bn.h> string b58(const char *priv_hex) { char table[] = {'1','2','...
Markus's user avatar
  • 31
3 votes
Accepted

Cashaddr (bech32) to legacy address format convertor for Bitcoin Cash

They should use those: cashaddr.org cashaddr.bitcoincash.org cashaddress.github.io Or, you can use the CashAddrJS library to convert between them (Here are the browser JS). Unfortunately there's no ...
MCCCS's user avatar
  • 10.2k
3 votes

Cashaddr (bech32) to legacy address format convertor for Bitcoin Cash

I've found this project: https://github.com/oskyk/cashaddress , checked the accounts generated by it using validateaddress of my wallet, seems working fine!
0x49D1's user avatar
  • 207
3 votes
Accepted

What is the significance of the last 5 digits of Base 58 WIF?

The last 4 bytes of the WIF format is a checksum. The details can be seen here: https://en.bitcoin.it/wiki/Wallet_import_format That's approximately 5 characters of Base58 that are essentially ...
Jimmy Song's user avatar
  • 7,759
3 votes
Accepted

Correct way to convert a 256-bit private key to WIF?

You're performing a SHA256 on an ASCII string, not on the actual number. That ASCII string is actually the hexadecimal representation of the actual number. This is a little code snippet that uses a ...
Riaan Swart's user avatar
3 votes
Accepted

Can I know if a bitcoin private/public key or address was derived from another key in an HD wallet by its structure?

Individual address private keys begin with 5,L or K. What you're calling root private keys are actually called extended private keys and they begin with ?prv where ? is either x,z,y,Y,Z. You can see ...
Abdussamad's user avatar
  • 2,689
3 votes

ELI5: is it true that Base58 doesn't prevent typo, but Base58check does, really because there is a checksum?

Yes. Every byte sequence corresponds to one Base58 string. Every byte sequence also corresponds to one Base58Check string, which contains a 4-byte redundancy, a checksum. And this 4-byte-code's only ...
MCCCS's user avatar
  • 10.2k
3 votes

Why are P2WSH addresses larger than P2SH addresses?

The encoding is bech32 not base58, which is slightly longer but vastly easier to type due to a lack of capital letters, and the inclusion of error correction rather than error detection. SegWit ...
Claris's user avatar
  • 15.4k
3 votes

How do i properly encode and decode base58 in python?

You need to convert string hex to bytes hex format before feeding it to b58encode to produce C6t2iJ7AXA2X1KQVnqw3r7NKtKaERdLnaGmbDZNqxXjk. import base58 privatekey_base58 = base58.b58encode(bytes....
martinkersner's user avatar
2 votes

Correct way to convert a 256-bit private key to WIF?

Here is how to use the bitcoin-explorer command line to generate an uncompressed WIF private key on a UNIX box: % echo 0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D | bx ...
skaht's user avatar
  • 3,047
2 votes

Is this how to generate a bitcoin address with python?

If the public key were correct (see Mark's answer), the code is not complete (lacks signature) and contains a hash of an ASCII hexdigest which is not correct. I'd like to contribute with this ...
circulosmeos's user avatar
2 votes

encode/decode Base-58 C++

Have added my own implementation, complete with a fuzz tester to ensure that it works properly. (The CodecMapping parameter is provided so that you can change the alphabet string as I've had to do ...
The Welder's user avatar
2 votes

What is the significance of the last 5 digits of Base 58 WIF?

A picture is worth a 1000 words. See Figure 6 from Chapter 4 of the Bitcoin Book. The last 4 bytes are used as a checksum for error checking. The version prefix is different for Bitcoin altcoin forks. ...
skaht's user avatar
  • 3,047
2 votes
Accepted

encode/decode Base-58 C++

I've used Base58 encoding/decoding many times. On the contrary, I hated using a BIGNUM library. So, I used Base-x's base conversion algorithm. (Make sure to respect the MIT license) It should be easy ...
MCCCS's user avatar
  • 10.2k
2 votes

How to convert xpub ypub and zpub in Ruby

I'm not sure about ruby, but here's what's happening in practice. Take any xpub: xpub6DBfkACRRWo6B9Fo31Ko6P7M92Yb3rdbuXb81Ls7aDCaZsMr1tyvZWHAHz1exRZuTBspafkPTynwoWL5o3i4WiJX4P3SyGQxNpxQLaUnB2c ...
m1xolyd1an's user avatar
  • 5,626
2 votes

Why is this burn address starting to get confirmations?

Base58 addresses are case sensitive. With the correct capitalization, the address resolves fine: https://blockchain.com/btc/address/1111111111111111111114oLvT2. Addresses do not get any confirmations. ...
Murch's user avatar
  • 74.4k
2 votes

How much can be stripped of a base58 address in a recoverable way?

The checksum of Base58Check encoding is simply a truncated hash of the rest of the bytes. This means there is no recovery algorithm other than just brute-forcing until the hash matches. That is one of ...
meshcollider's user avatar
  • 11.8k
2 votes

Is there a Base58 encoder function that runs in pure javascript without node?

Here's a pure javascript base58 encoder fuction I helped put together. Included are some comments that helped me understand what is going on beyond the barebones functions you can find elsewhere. ...
kawthuldrok's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible