
    `                     n    d dl Z d dlmZ ddlmZ  e j        d          Zd Zd Zd Z	ed	             Z
dS )
    N)sha256   )	validatorz%^(bc|tc)[0-3][02-9ac-hj-np-z]{14,74}$c                 6    t                               |           S )N)segwit_patternmatch)addrs    6lib/python3.11/site-packages/validators/btc_address.pyvalidate_segwit_addressr   
   s    %%%    c           	      j    dt          fdt          | d d d                   D                       S )N:123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyzc                 L    g | ] \  }}d |z                       |          z  !S ):   )index).0eialphabets      r
   
<listcomp>z!decode_base58.<locals>.<listcomp>   sB       Aq 
qHNN1%%%  r   )sum	enumerate)r	   r   s    @r
   decode_base58r      sR    KH    d44R4j))     r   c                 J   t          |           t          dd          vrdS t          |                               dd          }|dd         }|dd         }|t	          t	          |                                                                                    dd         k    S )z$Validate P2PKH and P2SH type address   #   FbigN   )lenranger   to_bytesr   digest)r	   decoded_bytesheaderchecksums       r
   validate_old_btc_addressr(      s    t99b"%%u!$''00U;;M3B3FRSS!HvfVnn335566==??CCCr   c                     | rt          | t                    sdS | dd         dv rt          |           S t          |           S )a  
    Return whether or not given value is a valid bitcoin address.

    If the value is valid bitcoin address this function returns ``True``,
    otherwise :class:`~validators.utils.ValidationFailure`.

    Full validation is implemented for P2PKH and P2SH addresses.
    For segwit addresses a regexp is used to provide a reasonable estimate
    on whether the address is valid.

    Examples::

        >>> btc_address('3Cwgr2g7vsi1bXDUkpEnVoRLA9w4FZfC69')
        True

    :param value: Bitcoin address string to validate
    FN   )bctb)
isinstancestrr   r(   )values    r
   btc_addressr0       sQ    &  
5#.. uRaRyL  &u---#E***r   )rehashlibr   utilsr   compiler   r   r   r(   r0    r   r
   <module>r6      s    				            ,. .& & &  D D D + + + + +r   