How to use the duniterpy.grammars.output.SIG.token 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 / tests / grammars / test_output.py View on Github external
def test_instanciate_condition(self):
        Condition.token(
            SIG.token("HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd"),
            Operator.token("||"),
            Condition.token(
                SIG.token("DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV"),
                Operator.token("&&"),
                XHX.token("309BC5E644F797F53E5A2065EAF38A173437F2E6"),
            ),
        )
        condition = (
            "(SIG(HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd) || (SIG("
            "DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV) && XHX(309BC5E644F797F53E5A2065EAF38A173437F2E6)))"
        )
        inst = pypeg2.parse(condition, Condition)
        self.assertEqual(
            inst.left.left.pubkey, "HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd"
        )
        self.assertEqual(inst.left.op.name, "||")
        self.assertEqual(
            inst.left.right.left.pubkey, "DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV"
        )
github duniter / sakia / src / sakia / core / wallet.py View on Github external
:param str pubkey: The target pubkey of the transaction
        :param list outputs: The amount to send
        :param list inputs: The inputs used to send the given amount of money
        :param list overheads: The overheads used to send the given amount of money

        :return: The list of outputs to use in the transaction document
        """
        total = []
        outputs_bases = set(o[1] for o in outputs)
        for base in outputs_bases:
            output_sum = 0
            for o in outputs:
                if o[1] == base:
                    output_sum += o[0]
            total.append(OutputSource(output_sum, base, output.Condition.token(output.SIG.token(pubkey))))

        overheads_bases = set(o[1] for o in overheads)
        for base in overheads_bases:
            overheads_sum = 0
            for o in overheads:
                if o[1] == base:
                    overheads_sum += o[0]
            total.append(OutputSource(overheads_sum, base, output.Condition.token(output.SIG.token(self.pubkey))))

        return total
github duniter / sakia / src / sakia / services / documents.py View on Github external
total = []
        outputs_bases = set(o[1] for o in outputs)
        for base in outputs_bases:
            output_sum = 0
            for o in outputs:
                if o[1] == base:
                    output_sum += o[0]
            total.append(OutputSource(output_sum, base, output.Condition.token(output.SIG.token(receiver))))

        overheads_bases = set(o[1] for o in overheads)
        for base in overheads_bases:
            overheads_sum = 0
            for o in overheads:
                if o[1] == base:
                    overheads_sum += o[0]
            total.append(OutputSource(overheads_sum, base, output.Condition.token(output.SIG.token(issuer))))

        return total
github duniter / sakia / src / sakia / services / documents.py View on Github external
Get outputs to generate a transaction with a given amount of money
        :param str issuer: The issuer of the transaction
        :param str receiver: The target of the transaction
        :param list outputs: The amount to send
        :param list inputs: The inputs used to send the given amount of money
        :param list overheads: The overheads used to send the given amount of money
        :return: The list of outputs to use in the transaction document
        """
        total = []
        outputs_bases = set(o[1] for o in outputs)
        for base in outputs_bases:
            output_sum = 0
            for o in outputs:
                if o[1] == base:
                    output_sum += o[0]
            total.append(OutputSource(output_sum, base, output.Condition.token(output.SIG.token(receiver))))

        overheads_bases = set(o[1] for o in overheads)
        for base in overheads_bases:
            overheads_sum = 0
            for o in overheads:
                if o[1] == base:
                    overheads_sum += o[0]
            total.append(OutputSource(overheads_sum, base, output.Condition.token(output.SIG.token(issuer))))

        return total
github duniter / sakia / src / sakia / core / wallet.py View on Github external
total = []
        outputs_bases = set(o[1] for o in outputs)
        for base in outputs_bases:
            output_sum = 0
            for o in outputs:
                if o[1] == base:
                    output_sum += o[0]
            total.append(OutputSource(output_sum, base, output.Condition.token(output.SIG.token(pubkey))))

        overheads_bases = set(o[1] for o in overheads)
        for base in overheads_bases:
            overheads_sum = 0
            for o in overheads:
                if o[1] == base:
                    overheads_sum += o[0]
            total.append(OutputSource(overheads_sum, base, output.Condition.token(output.SIG.token(self.pubkey))))

        return total