How to use the duniterpy.documents.block_uid.BlockUID.from_str function in duniterpy

To help you get started, we’ve selected a few duniterpy 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 duniter / duniter-python-api / duniterpy / documents / membership.py View on Github external
) -> MembershipType:
        """
        Return Membership instance from inline format

        :param version: Version of the document
        :param currency: Name of the currency
        :param membership_type: "IN" or "OUT" to enter or exit membership
        :param inline: Inline string format
        :return:
        """
        data = Membership.re_inline.match(inline)
        if data is None:
            raise MalformedDocumentError("Inline membership ({0})".format(inline))
        issuer = data.group(1)
        signature = data.group(2)
        membership_ts = BlockUID.from_str(data.group(3))
        identity_ts = BlockUID.from_str(data.group(4))
        uid = data.group(5)
        return cls(
            version,
            currency,
            issuer,
            membership_ts,
            membership_type,
            uid,
            identity_ts,
            signature,
        )
github duniter / duniter-python-api / duniterpy / documents / transaction.py View on Github external
lines = compact.splitlines(True)
        n = 0

        header_data = Transaction.re_header.match(lines[n])
        if header_data is None:
            raise MalformedDocumentError("Compact TX header")
        version = int(header_data.group(1))
        issuers_num = int(header_data.group(2))
        inputs_num = int(header_data.group(3))
        unlocks_num = int(header_data.group(4))
        outputs_num = int(header_data.group(5))
        has_comment = int(header_data.group(6))
        locktime = int(header_data.group(7))
        n += 1

        blockstamp = BlockUID.from_str(
            Transaction.parse_field("CompactBlockstamp", lines[n])
        )
        n += 1

        issuers = []
        inputs = []
        unlocks = []
        outputs = []
        signatures = []
        for index in range(0, issuers_num):
            issuer = Transaction.parse_field("Pubkey", lines[n + index])
            issuers.append(issuer)
        n += issuers_num

        for index in range(0, inputs_num):
            input_source = InputSource.from_inline(lines[n + index])
github duniter / duniter-python-api / duniterpy / documents / peer.py View on Github external
lines = raw.splitlines(True)
        n = 0

        version = int(Peer.parse_field("Version", lines[n]))
        n += 1

        Peer.parse_field("Type", lines[n])
        n += 1

        currency = Peer.parse_field("Currency", lines[n])
        n += 1

        pubkey = Peer.parse_field("Pubkey", lines[n])
        n += 1

        block_uid = BlockUID.from_str(Peer.parse_field("Block", lines[n]))
        n += 1

        Peer.parse_field("Endpoints", lines[n])
        n += 1

        endpoints = []
        while not Peer.re_signature.match(lines[n]):
            endpoints.append(endpoint(lines[n]))
            n += 1

        data = Peer.re_signature.match(lines[n])
        if data is None:
            raise MalformedDocumentError("Peer")
        signature = data.group(1)

        return cls(version, currency, pubkey, block_uid, endpoints, signature)
github duniter / duniter-python-api / duniterpy / documents / certification.py View on Github external
Certification.parse_field("Type", lines[n])
        n += 1

        currency = Certification.parse_field("Currency", lines[n])
        n += 1

        pubkey_from = Certification.parse_field("Issuer", lines[n])
        n += 1

        identity_pubkey = Certification.parse_field("IdtyIssuer", lines[n])
        n += 1

        identity_uid = Certification.parse_field("IdtyUniqueID", lines[n])
        n += 1

        identity_timestamp = BlockUID.from_str(
            Certification.parse_field("IdtyTimestamp", lines[n])
        )
        n += 1

        identity_signature = Certification.parse_field("IdtySignature", lines[n])
        n += 1

        timestamp = BlockUID.from_str(
            Certification.parse_field("CertTimestamp", lines[n])
        )
        n += 1

        signature = Certification.parse_field("Signature", lines[n])

        identity = Identity(
            version,
github duniter / duniter-python-api / duniterpy / documents / identity.py View on Github external
version = int(Identity.parse_field("Version", lines[n]))
        n += 1

        Identity.parse_field("Type", lines[n])
        n += 1

        currency = Identity.parse_field("Currency", lines[n])
        n += 1

        pubkey = Identity.parse_field("Issuer", lines[n])
        n += 1

        uid = Identity.parse_field("UniqueID", lines[n])
        n += 1

        ts = BlockUID.from_str(Identity.parse_field("Timestamp", lines[n]))
        n += 1

        signature = Identity.parse_field("Signature", lines[n])

        return cls(version, currency, pubkey, uid, ts, signature)
github duniter / duniter-python-api / duniterpy / documents / ws2p / heads.py View on Github external
def from_inline(cls, inline: str, signature: str):
        try:
            data = HeadV0.re_inline.match(inline)
            if data is None:
                raise MalformedDocumentError("HeadV0")
            api = API.from_inline(data.group(1))
            head = Head.from_inline(data.group(2), "")
            pubkey = data.group(3)
            blockstamp = BlockUID.from_str(data.group(4))
            offload = data.group(5)
            return cls(head.version, signature, api, head, pubkey, blockstamp), offload
        except AttributeError:
            raise MalformedDocumentError("HeadV0")
github duniter / duniter-python-api / duniterpy / documents / certification.py View on Github external
identity_pubkey = Certification.parse_field("IdtyIssuer", lines[n])
        n += 1

        identity_uid = Certification.parse_field("IdtyUniqueID", lines[n])
        n += 1

        identity_timestamp = BlockUID.from_str(
            Certification.parse_field("IdtyTimestamp", lines[n])
        )
        n += 1

        identity_signature = Certification.parse_field("IdtySignature", lines[n])
        n += 1

        timestamp = BlockUID.from_str(
            Certification.parse_field("CertTimestamp", lines[n])
        )
        n += 1

        signature = Certification.parse_field("Signature", lines[n])

        identity = Identity(
            version,
            currency,
            identity_pubkey,
            identity_uid,
            identity_timestamp,
            identity_signature,
        )

        return cls(version, currency, pubkey_from, identity, timestamp, signature)
github duniter / duniter-python-api / duniterpy / documents / membership.py View on Github external
"""
        Return Membership instance from inline format

        :param version: Version of the document
        :param currency: Name of the currency
        :param membership_type: "IN" or "OUT" to enter or exit membership
        :param inline: Inline string format
        :return:
        """
        data = Membership.re_inline.match(inline)
        if data is None:
            raise MalformedDocumentError("Inline membership ({0})".format(inline))
        issuer = data.group(1)
        signature = data.group(2)
        membership_ts = BlockUID.from_str(data.group(3))
        identity_ts = BlockUID.from_str(data.group(4))
        uid = data.group(5)
        return cls(
            version,
            currency,
            issuer,
            membership_ts,
            membership_type,
            uid,
            identity_ts,
            signature,
        )