Author

Topic: What is the minimum and maximum length of a Bitcoin Address? (Read 254 times)

sr. member
Activity: 310
Merit: 727
---------> 1231006505
As asnswered in this thread: 62 characters.
I found this source from Trezor's wiki that says that a Bech32 "string" can be up to 90 characters long. This is what it says:
Quote
A Bech32 string is at most 90 characters long and consists of:

The human-readable part.
"bc" for mainnet
"tb" for testnet
The separator, which is always "1".
The data part, which is at least 6 characters long and only consists of alphanumeric characters excluding "1", "b", "i" and "o".
https://wiki.trezor.io/Bech32
 
The question was, or at least in my opinion, what the maximum current length is for addresses currently in use. The answer still remains 62 based on the current version 0 witness program. In the future newer versions may arise and in that case there is room left to go to a maximum of 90.
legendary
Activity: 2730
Merit: 7065
As asnswered in this thread: 62 characters.
I found this source from Trezor's wiki that says that a Bech32 "string" can be up to 90 characters long. This is what it says:
Quote
A Bech32 string is at most 90 characters long and consists of:

The human-readable part.
"bc" for mainnet
"tb" for testnet
The separator, which is always "1".
The data part, which is at least 6 characters long and only consists of alphanumeric characters excluding "1", "b", "i" and "o".
https://wiki.trezor.io/Bech32
 
sr. member
Activity: 310
Merit: 727
---------> 1231006505
it should be noted that the length depends on the script each address represents and these numbers here are for version 0 witness program and may be different for version 1+ witness programs.
Agreed, the version 0 witness program requirement was in my original response. My post was more a summing up of the previous replies since imho everything was in there already.
legendary
Activity: 3472
Merit: 10611
Somebody can tell me with sure, what is the max number of characters in a bech32 address?

Id like to validate the max number of characters inside a database, so, that is important, after some google i still didnt found one exact answer!
As asnswered in this thread: 62 characters.

The reason you might not have found one answer is because there is a difference in length between a P2WPKH-address and a P2WSH-address:
  • P2WPKH: 42 characters
  • P2WSH: 62 characters
Also mentioned in this thread: P2WSH contains the SHA256 of a script, which is longer than the hash160 of a pubkey in the shorter P2WPKH address. That's the reason the length differ.
it should be noted that the length depends on the script each address represents and these numbers here are for version 0 witness program and may be different for version 1+ witness programs.

Id like to validate the max number of characters inside a database,
what kind of "database" contains addresses?
sr. member
Activity: 310
Merit: 727
---------> 1231006505
Somebody can tell me with sure, what is the max number of characters in a bech32 address?

Id like to validate the max number of characters inside a database, so, that is important, after some google i still didnt found one exact answer!
As asnswered in this thread: 62 characters.

The reason you might not have found one answer is because there is a difference in length between a P2WPKH-address and a P2WSH-address:
  • P2WPKH: 42 characters
  • P2WSH: 62 characters
Also mentioned in this thread: P2WSH contains the SHA256 of a script, which is longer than the hash160 of a pubkey in the shorter P2WPKH address. That's the reason the length differ.
member
Activity: 264
Merit: 16
Somebody can tell me with sure, what is the max number of characters in a bech32 address?

Id like to validate the max number of characters inside a database, so, that is important, after some google i still didnt found one exact answer!

What about bech32 php or javascript good address validator?
staff
Activity: 4284
Merit: 8808
have better error detection at a cost of being
It would be more accurate to say: These addresses don't use mixed case, enabling MUCH faster and more accurate transcription via writing or speaking and support 256-bit payloads which are important for providing adequate security especially when addresses are created with input from multiple parties, both at the expense of being longer.

BC1 addresses actually spend slightly fewer bits on error detection (30 instead of 32), but the error detection is designed to be much more effective for common errors (which corrupt only a few characters).
staff
Activity: 3458
Merit: 6793
Just writing some code
But, this Bech32 address is longer - bc1qgdjqv0av3q56jvd82tkdjpy7gdp9ut8tlqmgrpmv24sq90ecnvqqjwvw97.

I'd also like to know why this address is longer than the usual, e.g. bc1q5shngj24323nsrmxv99st02na6srekfctt30ch?
The longer address is for a Pay 2 Witness Script Hash output. These contain the SHA256 of a script, which is longer than the hash160 of a pubkey in the shorter P2WPKH address.
sr. member
Activity: 310
Merit: 727
---------> 1231006505
The mentioned 26-35 length is valid for addresses encoded using base58. These are the addresses starting with either a "1" or a "3".

Native Segwit addresses use a base32 encoding, start with "bc" and they are case insensitive. These addresses have better error detection at a cost of being around 27% larger than the base58 equivalent. Version 0 witness addresses are always 42 or 62 characters afaik,

If you would like more info on bech32 check out: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
full member
Activity: 214
Merit: 278
https://en.bitcoin.it/wiki/Address says 26-35 alphanumeric characters.

But, this Bech32 address is longer - bc1qgdjqv0av3q56jvd82tkdjpy7gdp9ut8tlqmgrpmv24sq90ecnvqqjwvw97.

I'd also like to know why this address is longer than the usual, e.g. bc1q5shngj24323nsrmxv99st02na6srekfctt30ch?
Jump to: