Пример #1
0
    def Encode(cls, hrp: str, data: bytes) -> str:
        """
        Encode to Bech32.

        Args:
            hrp (str)   : HRP
            data (bytes): Data

        Returns:
            str: Encoded address

        Raises:
            ValueError: If the data is not valid
        """
        return cls._EncodeBech32(hrp, Bech32BaseUtils.ConvertToBase32(data),
                                 Bech32Const.SEPARATOR)
Пример #2
0
    def Encode(hrp, wit_ver, wit_prog):
        """ Encode to Segwit Bech32.

        Args:
            hrp (str)       : HRP
            wit_ver (int)   : Witness version
            wit_prog (bytes): Witness program

        Returns:
            str: Encoded address

        Raises:
            Bech32FormatError: If the data is not valid
        """

        return SegwitBech32Encoder._EncodeBech32(hrp, [wit_ver] + Bech32BaseUtils.ConvertToBase32(wit_prog), SegwitBech32Const.SEPARATOR)
Пример #3
0
    def Encode(hrp: str, data: bytes) -> str:
        """ Encode to Atom Bech32.

        Args:
            hrp (str)   : HRP
            data (bytes): Data

        Returns:
            str: Encoded address

        Raises:
            Bech32FormatError: If the data is not valid
        """

        return AtomBech32Encoder._EncodeBech32(
            hrp, Bech32BaseUtils.ConvertToBase32(data),
            AtomBech32Const.SEPARATOR)
Пример #4
0
    def Encode(hrp, net_ver, data):
        """ Encode to Bitcoin Cash Bech32.

        Args:
            hrp (str)      : HRP
            net_ver (bytes): Net version
            data (bytes)   : Data

        Returns:
            str: Encoded address

        Raises:
            Bech32FormatError: If the data is not valid
        """

        return BchBech32Encoder._EncodeBech32(
            hrp, Bech32BaseUtils.ConvertToBase32(net_ver + data),
            BchBech32Const.SEPARATOR)
Пример #5
0
    def Encode(cls, hrp: str, wit_ver: int, wit_prog: bytes) -> str:
        """
        Encode to Segwit Bech32.

        Args:
            hrp (str)       : HRP
            wit_ver (int)   : Witness version
            wit_prog (bytes): Witness program

        Returns:
            str: Encoded address

        Raises:
            ValueError: If the data is not valid
        """
        return cls._EncodeBech32(hrp, [wit_ver] +
                                 Bech32BaseUtils.ConvertToBase32(wit_prog),
                                 SegwitBech32Const.SEPARATOR)