Пример #1
0
    def _gen_req_data(self):
        if len(self._sources_amounts) == 0:
            raise NoReqDataAvailableException()

        source, amount = self._sources_amounts.popleft()
        address = random.choice(self._payment_addresses)

        inputs = [source]
        outputs = [{"recipient": address, "amount": amount}]

        return inputs, outputs
Пример #2
0
    def _gen_input_output(self, val, fees):
        address, inputs, outputs = gen_input_output(self._addr_txos,
                                                    val + fees)

        if inputs is None or outputs is None:
            raise NoReqDataAvailableException()

        addrs = list(self._addr_txos)
        addrs.remove(list(address)[0])
        to_address = random.choice(addrs)
        outputs.append({"recipient": to_address, "amount": val})

        return inputs, outputs
Пример #3
0
    def _gen_input_output(self, val, fees):
        address, inputs, outputs = gen_input_output(self._addr_txos,
                                                    val + fees)
        if inputs is None or outputs is None:
            self._logger.warning("Failed to create XFER, insufficient txos")
            raise NoReqDataAvailableException()
        log_addr_txos_update('XFER', self._addr_txos, -len(inputs))

        addrs = list(self._addr_txos)
        addrs.remove(list(address)[0])
        to_address = random.choice(addrs)
        outputs.append({"recipient": to_address, "amount": val})

        return inputs, outputs
Пример #4
0
    async def _gen_req(self, submit_did, req_data):
        req = await ledger.build_nym_request(submit_did, req_data, None, None,
                                             None)

        for ap in self._sources_amounts:
            if self._sources_amounts[ap]:
                (source, amount) = self._sources_amounts[ap].pop()
                address = ap
                inputs = [source]
                outputs = [{"recipient": address, "amount": amount - 1}]
                req_fees = await payment.add_request_fees(
                    self._wallet_handle, submit_did, req, json.dumps(inputs),
                    json.dumps(outputs), None)
                return req_fees[0]
        raise NoReqDataAvailableException()
Пример #5
0
 async def _gen_req(self, submit_did, req_data):
     cred_req_json, _ = await anoncreds.prover_create_credential_req(
         self._wallet_handle, submit_did, self._cred_offer_json,
         json.dumps(self._default_definition_json), self._master_secret_id)
     _, _, revoc_reg_delta_json = await anoncreds.issuer_create_credential(
         self._wallet_handle, self._cred_offer_json, cred_req_json, self._default_cred_values_json,
         self._default_revoc_reg_def_id, self._blob_storage_reader_cfg_handle)
     try:
         req = await ledger.build_revoc_reg_entry_request(submit_did, self._default_revoc_reg_def_id,
                                                          "CL_ACCUM", revoc_reg_delta_json)
     except Exception:
         self._old_reqs_cnt = 0
         await self._upd_revoc_reg()
         raise NoReqDataAvailableException()
     return req
Пример #6
0
    async def _gen_req(self, submit_did, req_data):
        _, schema_json = await anoncreds.issuer_create_schema(
            submit_did, req_data, "1.0",
            json.dumps(["name", "age", "sex", "height"]))
        schema_request = await ledger.build_schema_request(
            submit_did, schema_json)

        for ap in self._sources_amounts:
            if self._sources_amounts[ap]:
                (source, amount) = self._sources_amounts[ap].pop()
                address = ap
                inputs = [source]
                outputs = [{"recipient": address, "amount": amount - 1}]
                req_fees = await payment.add_request_fees(
                    self._wallet_handle, submit_did, schema_request,
                    json.dumps(inputs), json.dumps(outputs), None)
                return req_fees[0]
        raise NoReqDataAvailableException()
Пример #7
0
 def _gen_req_data(self):
     if not self._receipts:
         raise NoReqDataAvailableException()
     return random.choice(self._receipts)