Ejemplo n.º 1
0
def build_mint_transaction(wallet_handle: int, payment_address: str, amount: int):
    outputs = [{
        'recipient':
            payment_address if payment_address.startswith(PAYMENT_PREFIX) else PAYMENT_PREFIX + payment_address,
        'amount': amount
    }]

    try:
        return run_coroutine(payment.build_mint_req(wallet_handle, None, json.dumps(outputs), None))
    except IndyError as err:
        if err.error_code == ErrorCode.CommonInvalidStructure:
            raise Exception('Invalid payment address has been provided')
        raise Exception(err.message)
Ejemplo n.º 2
0
    def mint(self, outputs, text=None, mechanism=None, version=None, number_signers=3):
        """ Builds a mint request. """
        outputs_ready = self._prepare_outputs(outputs)

        mint_request_future = build_mint_req(self._client_wallet_handle, self._wallet._trustees[0], json.dumps(outputs_ready), None)
        mint_request = self._looper.loop.run_until_complete(mint_request_future)[0]
        if text and mechanism and version:
            mint_request = self.add_transaction_author_agreement_to_request(mint_request, text, mechanism, version)
        mint_request = self._wallet.sign_request_trustees(mint_request, number_signers=number_signers)
        mint_request = json.loads(mint_request)
        signatures = mint_request["signatures"]
        mint_request = self._sdk.sdk_json_to_request_object(mint_request)
        setattr(mint_request, "signatures", signatures)
        return mint_request
Ejemplo n.º 3
0
def mint_request(libsovtoken, payment_address, wallet, trustees, looper):
    mint_future = build_mint_req(wallet,
                                 trustees[0],
                                 json.dumps([{"recipient": payment_address, "amount": 10}]),
                                 None)
    mint_request, _ = looper.loop.run_until_complete(mint_future)
    for trustee in trustees:
        mint_future = multi_sign_request(wallet, trustee, mint_request)
        mint_request = looper.loop.run_until_complete(mint_future)
    mint_request = json.loads(mint_request)
    sigs = mint_request["signatures"]
    mint_request = sdk_json_to_request_object(mint_request)
    setattr(mint_request, "signatures", sigs)
    return mint_request