Bitcoin Forum
April 25, 2024, 06:01:34 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What is the minimum and maximum length of a Bitcoin Address?  (Read 251 times)
CounterEntropy (OP)
Full Member
***
Offline Offline

Activity: 214
Merit: 277


View Profile
July 10, 2020, 03:25:09 PM
Merited by ABCbits (2), TryNinja (1), Husna QA (1)
 #1

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?
1714024894
Hero Member
*
Offline Offline

Posts: 1714024894

View Profile Personal Message (Offline)

Ignore
1714024894
Reply with quote  #2

1714024894
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
TheArchaeologist
Sr. Member
****
Offline Offline

Activity: 310
Merit: 727


---------> 1231006505


View Profile WWW
July 10, 2020, 03:42:40 PM
Merited by bitmover (2), vapourminer (1), ABCbits (1), TryNinja (1), nc50lc (1), hosseinimr93 (1)
 #2

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

Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
July 10, 2020, 04:08:00 PM
Merited by ABCbits (2), bitmover (2), CounterEntropy (2), nc50lc (1)
 #3

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.

gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
July 10, 2020, 05:18:53 PM
Merited by ABCbits (2), bitmover (2)
 #4

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).
cfbtcman
Member
**
Offline Offline

Activity: 264
Merit: 16


View Profile
July 12, 2020, 06:52:07 AM
 #5

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?
TheArchaeologist
Sr. Member
****
Offline Offline

Activity: 310
Merit: 727


---------> 1231006505


View Profile WWW
July 12, 2020, 07:36:42 AM
 #6

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.

Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10498



View Profile
July 12, 2020, 07:39:19 AM
 #7

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?

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
TheArchaeologist
Sr. Member
****
Offline Offline

Activity: 310
Merit: 727


---------> 1231006505


View Profile WWW
July 12, 2020, 07:49:17 AM
 #8

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.

Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
Pmalek
Legendary
*
Offline Offline

Activity: 2744
Merit: 7095



View Profile
July 12, 2020, 11:05:05 AM
 #9

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
 

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
TheArchaeologist
Sr. Member
****
Offline Offline

Activity: 310
Merit: 727


---------> 1231006505


View Profile WWW
July 12, 2020, 11:13:58 AM
 #10

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.

Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
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!