Exemple #1
0
    def from_dict(cls, config, mongo, txn):
        try:
            relationship = Relationship(**txn.get('relationship', ''))
        except:
            relationship = txn.get('relationship', '')

        return cls(config=config,
                   mongo=mongo,
                   transaction_signature=txn.get('id'),
                   rid=txn.get('rid', ''),
                   relationship=relationship,
                   public_key=txn.get('public_key'),
                   dh_public_key=txn.get('dh_public_key', ''),
                   fee=float(txn.get('fee')),
                   requester_rid=txn.get('requester_rid', ''),
                   requested_rid=txn.get('requested_rid', ''),
                   txn_hash=txn.get('hash', ''),
                   inputs=[
                       Input.from_dict(input_txn)
                       for input_txn in txn.get('inputs', '')
                   ],
                   outputs=[
                       Output.from_dict(output_txn)
                       for output_txn in txn.get('outputs', '')
                   ],
                   coinbase=txn.get('coinbase', ''),
                   signatures=txn.get('signatures', ''))
Exemple #2
0
        def input_listener(request):
            nonlocal bc
            request_data = json.loads(request.data)
            candidate_input = Output.from_dict(request_data)
            status = bc.get_output_status(candidate_input)

            payload = {'Status': status}
            return Response(json.dumps(payload), mimetype='application/json')
Exemple #3
0
    def __init__(
        self,
        config,
        mongo,
        block_height,
        time='',
        rid='',
        transaction_signature='',
        relationship='',
        public_key='',
        dh_public_key='',
        fee=0.0,
        requester_rid='',
        requested_rid='',
        txn_hash='',
        inputs='',
        outputs='',
        coinbase=False,
        signatures=None,
        extra_blocks=None
    ):
        self.config = config
        self.mongo = mongo
        self.block_height = block_height
        self.time = time
        self.rid = rid
        self.transaction_signature = transaction_signature
        self.relationship = relationship
        self.public_key = public_key
        self.dh_public_key = dh_public_key
        self.fee = fee
        self.requester_rid = requester_rid
        self.requested_rid = requested_rid
        self.hash = txn_hash
        self.outputs = []
        self.extra_blocks = extra_blocks
        for x in outputs:
            self.outputs.append(Output.from_dict(x))
        self.inputs = []
        for x in inputs:
            if 'signature' in x and 'public_key' in x:
                self.inputs.append(ExternalInput.from_dict(self.config, self.mongo, x))
            else:
                self.inputs.append(Input.from_dict(x))
        self.coinbase = coinbase

        if not signatures:
            signatures = []

        self.signatures = []
        for signature in signatures:
            if isinstance(signature, FastGraphSignature):
                self.signatures.append(signature)
            else:
                self.signatures.append(FastGraphSignature(signature))