stdnum.bitcoin

Bitcoin address.

A Bitcoin address is an identifier that is used as destination in a Bitcoin transaction. It is based on a hash of the public portion of a key pair.

There are currently three address formats in use:

  • P2PKH: pay to pubkey hash

  • P2SH: pay to script hash

  • Bech32

More information:

>>> validate('1NEDqZPvTWRaoho48qXuLLsrYomMXPABfD')
'1NEDqZPvTWRaoho48qXuLLsrYomMXPABfD'
>>> validate('BC1QARDV855YJNGSPVXUTTQ897AQCA3LXJU2Y69JCE')
'bc1qardv855yjngspvxuttq897aqca3lxju2y69jce'
>>> validate('1NEDqZPvTWRaoho48qXuLLsrYomMXPABfX')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
stdnum.bitcoin.b32decode(data)

Decode a list of Base32 values to a bytestring.

stdnum.bitcoin.b58decode(s)

Decode a Base58 encoded string to a bytestring.

stdnum.bitcoin.bech32_checksum(values)

Calculate the Bech32 checksum.

stdnum.bitcoin.compact(number)

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.bitcoin.is_valid(number)

Check if the number provided is valid. This checks the length and check digit.

stdnum.bitcoin.validate(number)

Check if the number provided is valid. This checks the length and check digit.