How to use the base58.b58encode_check function in base58

To help you get started, we’ve selected a few base58 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cdecker / lightning-integration / lnaddr.py View on Github external
def parse_fallback(fallback, currency):
    if currency == 'bc' or currency == 'tb':
        wver = fallback[0:5].uint
        if wver == 17:
            addr=base58.b58encode_check(bytes([base58_prefix_map[currency][0]])
                                        + fallback[5:].tobytes())
        elif wver == 18:
            addr=base58.b58encode_check(bytes([base58_prefix_map[currency][1]])
                                        + fallback[5:].tobytes())
        elif wver <= 16:
            addr=bech32_encode(currency, bitarray_to_u5(fallback))
        else:
            return None
    else:
        addr=fallback.tobytes()
    return addr
github ontio / ontology-python-sdk / ontology / crypto / hd_public_key.py View on Github external
def b58encode(self) -> str:
        """ Generates a Base58Check encoding of this key.
        """
        return base58.b58encode_check(bytes(self)).decode('ascii')
github 21dotco / two1-python / two1 / bitcoin / crypto.py View on Github external
def address(self, compressed=True, testnet=False):
        """ Address property that returns the Base58Check
        encoded version of the HASH160.

        Args:
            compressed (bool): Whether or not the compressed key should
               be used.
            testnet (bool): Whether or not the key is intended for testnet
               usage. False indicates mainnet usage.

        Returns:
            bytes: Base58Check encoded string
        """
        # Put the version byte in front, 0x00 for Mainnet, 0x6F for testnet
        version = bytes([self.TESTNET_VERSION]) if testnet else bytes([self.MAINNET_VERSION])
        return base58.b58encode_check(version + self.hash160(compressed))
github jujugoboom / Bitduino / generate.py View on Github external
def publicKeyGenerator():
    sk = ecdsa.SigningKey.from_string(start[0:64].decode('hex'), curve=ecdsa.SECP256k1)
    vk = sk.verifying_key
    publicKey = ('\04' + sk.verifying_key.to_string()).encode('hex')
    ripemd160 = hashlib.new('ripemd160')
    ripemd160.update(hashlib.sha256(publicKey.decode('hex')).digest())
    address = base58.b58encode_check(chr(0) + ripemd160.digest())
    print("Public Address: " + address)
    addrFile = address[-8:]
    img2 = qrcode.make(address)
    img2.save("Address_" + addrFile + ".png")
github iexbase / tron-api-python / tronapi / abstract.py View on Github external
def from_hex(address):
        """Helper function that will convert a generic value from hex

        Args:
            address (str): address

        """
        return base58.b58encode_check(bytes.fromhex(address))
github iexbase / tron-api-python / tronapi / common / account.py View on Github external
def from_hex(address):
        """Helper function that will convert a generic value from hex"""
        if not is_hex(address):
            return address

        return base58.b58encode_check(bytes.fromhex(address))
github aeternity / aepp-sdk-python / aeternity / hashing.py View on Github external
def _base58_encode(data):
    """create a base58 encoded string with checksum"""
    return base58.b58encode_check(data).decode("ascii")
github ranaroussi / pywallet / pywallet / utils / bip32.py View on Github external
def export_to_wif(self):
        """Export a key to WIF.

        See https://en.bitcoin.it/wiki/Wallet_import_format for a full
        description.
        """
        # Add the network byte, creating the "extended key"
        extended_key_hex = self.private_key.get_extended_key()
        # BIP32 wallets have a trailing \01 byte
        extended_key_bytes = unhexlify(extended_key_hex) + b'\01'
        # And return the base58-encoded result with a checksum
        return base58.b58encode_check(extended_key_bytes)
github jamesob / tinychain / tinychain.py View on Github external
def pubkey_to_address(pubkey: bytes) -> str:
    if 'ripemd160' not in hashlib.algorithms_available:
        raise RuntimeError('missing ripemd160 hash algorithm')

    sha = hashlib.sha256(pubkey).digest()
    ripe = hashlib.new('ripemd160', sha).digest()
    return b58encode_check(b'\x00' + ripe)